Guest User

Untitled

a guest
Oct 1st, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. <?php
  2.  
  3. if (!empty($_POST)) {
  4.  
  5. $clientId = isset($_POST['clientId']) ? $_POST['clientId'] : 0;
  6.  
  7. $gcm_regId = isset($_POST['gcm_regId']) ? $_POST['gcm_regId'] : '';
  8.  
  9. $ios_fcm_regId = isset($_POST['ios_fcm_regId']) ? $_POST['ios_fcm_regId'] : '';
  10.  
  11. $android_msg_fcm_regid = isset($_POST['android_msg_fcm_regid']) ? $_POST['android_msg_fcm_regid'] : '';
  12. $ios_msg_fcm_regid = isset($_POST['ios_msg_fcm_regid']) ? $_POST['ios_msg_fcm_regid'] : '';
  13.  
  14. $username = isset($_POST['username']) ? $_POST['username'] : '';
  15. $password = isset($_POST['password']) ? $_POST['password'] : '';
  16.  
  17. $clientId = helper::clearInt ($clientId);
  18.  
  19. $android_msg_fcm_regid = helper::clearText ($android_msg_fcm_regid);
  20. $android_msg_fcm_regid = helper::escapeText ($android_msg_fcm_regid);
  21.  
  22. $ios_msg_fcm_regid = helper::clearText ($ios_msg_fcm_regid);
  23. $ios_msg_fcm_regid = helper::escapeText ($ios_msg_fcm_regid);
  24.  
  25. $gcm_regId = helper::clearText ($gcm_regId);
  26. $ios_fcm_regId = helper::clearText ($ios_fcm_regId);
  27. $username = helper::clearText ($username);
  28. $password = helper::clearText ($password);
  29.  
  30. $gcm_regId = helper::escapeText ($gcm_regId);
  31. $ios_fcm_regId = helper::escapeText ($ios_fcm_regId);
  32. $username = helper::escapeText ($username);
  33. $password = helper::escapeText ($password);
  34.  
  35. if ($clientId != CLIENT_ID) {
  36.  
  37. api::printError (ERROR_UNKNOWN, "Error client Id.");
  38. }
  39.  
  40. $access_data = array();
  41.  
  42. $account = new account($dbo);
  43. $access_data = $account -> signin($username, $password);
  44.  
  45. unset($account);
  46.  
  47. if ($access_data["error"] == = false) {
  48.  
  49. $account = new account($dbo, $access_data['accountId']);
  50.  
  51. switch ($account -> getState()) {
  52.  
  53. case ACCOUNT_STATE_BLOCKED: {
  54.  
  55. break;
  56. }
  57.  
  58. default: {
  59.  
  60. $auth = new auth($dbo);
  61. $access_data = $auth -> create($access_data['accountId'], $clientId);
  62.  
  63. if ($access_data['error'] == = false) {
  64.  
  65. $account -> setState(ACCOUNT_STATE_ENABLED);
  66. $account -> setLastActive();
  67. $access_data['account'] = array();
  68.  
  69. array_push($access_data['account'], $account -> get());
  70.  
  71. if (strlen($gcm_regId) != 0) {
  72.  
  73. $account -> setGCM_regId($gcm_regId);
  74. }
  75.  
  76. if (strlen($ios_fcm_regId) != 0) {
  77.  
  78. $account -> set_ios_fcm_regId($ios_fcm_regId);
  79. }
  80.  
  81. if (strlen($ios_msg_fcm_regid) != 0) {
  82.  
  83. $account -> set_ios_msg_fcm_regId($ios_msg_fcm_regid);
  84. }
  85.  
  86. if (strlen($android_msg_fcm_regid) != 0) {
  87.  
  88. $account -> set_android_msg_fcm_regId($android_msg_fcm_regid);
  89. }
  90. }
  91.  
  92. break;
  93. }
  94. }
  95. }
  96.  
  97. echo json_encode ($access_data);
  98. exit;
  99. }
Add Comment
Please, Sign In to add comment