コード例 #1
0
ファイル: httpjson.inc.php プロジェクト: smdern/IRRemote
function hj_return($status, $message = null)
{
    global $_hj_response;
    $_hj_response['status'] = $status;
    if (!empty($message)) {
        $_hj_response['message'] = $message;
    }
    // Log
    global $_hj_log;
    hj_log('resp', $_hj_response);
    hj_log($_hj_log);
    die(json_encode($_hj_response));
}
コード例 #2
0
ファイル: auth.inc.php プロジェクト: smdern/IRRemote
function auth_username_password($db, $username, $password)
{
    $st = $db->prepare("SELECT access_token, password FROM users WHERE username=? LIMIT 1");
    $st->bind_param("s", $username);
    $st->execute();
    $st->bind_result($token, $hash);
    $st->fetch();
    $st->close();
    hj_log("auth_token_db", $token);
    require_once __DIR__ . '/crypto.inc.php';
    if (validate_password($password, $hash)) {
        hj_log("auth_token_db", $token);
        return $token;
    }
    return NULL;
}
コード例 #3
0
ファイル: upload.php プロジェクト: smdern/IRRemote
$req = hj_request();
hj_log('req', $req);
$acc = $req->userinfo;
auth_request($req);
$remote = $req->remote;
$det = $req->remote->details;
$user_id = get_id($acc->username);
$db = get_db();
$st = $db->prepare('INSERT INTO remotes' . '(user_id, manufacturer, model, device_type) VALUES(?,?,?,?)');
$type_string = get_type_string($req->remote);
$st->bind_param("isss", $user_id, $det->manufacturer, $det->model, $type_string);
$st->execute();
$remote_id = $st->insert_id;
$st->close();
$st = $db->prepare('INSERT INTO buttons' . '(remote_id, function, frequency, pattern) VALUES(?,?,?,?)');
$b_func = $b_freq = $b_patt = '';
$st->bind_param("isis", $remote_id, $b_func, $b_freq, $b_patt);
$i = 0;
foreach ($remote->buttons as $ignored => $b_json) {
    hj_log("b" . $i, $b_json);
    $i++;
    $b = new Button($b_json);
    $b_func = $b->func_string();
    $b_freq = $b->signal->frequency;
    $b_patt = $b->signal->serialize_pattern();
    $st->execute();
}
$st->close();
$db->close();
hj_resp("remote_id", $remote_id);
hj_return(0);