Example #1
0
function check_user($username_user, $password_user, $device)
{
    include 'sql.php';
    $id = get_profile_id($username_user, $password_user);
    $SQL = "SELECT * FROM user WHERE profile_id={$id}";
    $result = $conn->query($SQL);
    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        if ($row['username'] == $username_user && $row['password'] == $password_user) {
            get_oauth($username_user, $password_user, $device);
            $conn->close();
        } else {
            header($_SERVER["SERVER_PROTOCOL"] . " " . $GLOBALS['status_notfound']);
            $result_array = array('status' => 'error', 'message' => 'User not found');
            print_r(json_encode($result_array));
        }
    }
}
Example #2
0
<?php

include '../libs/helper.php';
include '../libs/accesscontrol.php';
include '../libs/configer.php';
$json = file_get_contents('php://input');
$obj = json_decode($json);
if (isset($obj->{"username"}) && isset($obj->{"password"}) && $obj->{"isAdmin"} == 'true') {
    $decode_password = base64_decode($obj->{"password"});
    $username_user = $obj->{"username"};
    $password_user = md5($decode_password);
    $device = $obj->{"user_data"};
    get_admin_oauth($username_user, $password_user, $device);
} else {
    if (isset($obj->{"username"}) && isset($obj->{"password"})) {
        $decode_password = base64_decode($obj->{"password"});
        $username_user = $obj->{"username"};
        $password_user = md5($decode_password);
        $device = $obj->{"user_data"};
        get_oauth($username_user, $password_user, $device);
    } else {
        header($_SERVER["SERVER_PROTOCOL"] . " " . $GLOBALS['bad_request']);
        $result_array = array('status' => 'Error', 'message' => 'Method not allowed');
        print_r(json_encode($result_array));
    }
}