Пример #1
0
             $main->getUsersForAdmins();
         } else {
             json_return(401, "Unauthorized Request", NULL);
         }
     } else {
         json_return(401, "Unauthorized Request", NULL);
     }
 } elseif ($task == "add_user") {
     $email = trim($_POST['email']);
     $pass = trim($_POST['pass']);
     $headers = apache_request_headers();
     if (isset($headers['Authorization'])) {
         $auth_array = split(":", $headers['Authorization']);
         if (trim($auth_array[0]) == session_id() && trim($auth_array[1]) == $_SESSION['api_key']) {
             $main = new Main();
             $main->addUser($email, $pass);
         } else {
             json_return(401, "Unauthorized Request", NULL);
         }
     } else {
         json_return(401, "Unauthorized Request", NULL);
     }
 } elseif ($task == "delete_user") {
     $user_id = trim($_POST['user_id']);
     if (strlen($user_id) <= 0) {
         json_return(400, "Bad Request", NULL);
     } else {
         $headers = apache_request_headers();
         if (isset($headers['Authorization'])) {
             $auth_array = split(":", $headers['Authorization']);
             if (trim($auth_array[0]) == session_id() && trim($auth_array[1]) == $_SESSION['api_key']) {
Пример #2
0
     } else {
         json_return(401, "Unauthorized Request", NULL);
     }
 } elseif ($task == "add_user") {
     $email = trim($_POST['email']);
     $pass = trim($_POST['pass']);
     $level = trim($_POST['level']);
     if (strlen($email) <= 0 || strlen($pass) <= 0 || strlen($level) <= 0) {
         json_return(400, "Bad Request", NULL);
     } else {
         //$headers = apache_request_headers();
         if (trim(getAuth()) != "") {
             $auth_array = split(":", getAuth());
             if (trim($auth_array[0]) == session_id() && trim($auth_array[1]) == $_SESSION['api_key']) {
                 $main = new Main();
                 $main->addUser($email, $pass, $level);
             } else {
                 json_return(401, "Unauthorized Request", NULL);
             }
         } else {
             json_return(401, "Unauthorized Request", NULL);
         }
     }
 } elseif ($task == "delete_user") {
     $user_id = trim($_POST['user_id']);
     if (strlen($user_id) <= 0) {
         json_return(400, "Bad Request", NULL);
     } else {
         //$headers = apache_request_headers();
         if (trim(getAuth()) != "") {
             $auth_array = split(":", getAuth());