Guest User

Untitled

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