Exemplo n.º 1
0
function check_username_password($username, $password, &$ret_token)
{
    $ret = null;
    $mysqli = mysqli_new();
    $sql = "select * from manager where name='root' and password='******'";
    $sql = "select * from users where username='******'and password='******'";
    $result = mysqli_obj_query($mysqli, $sql);
    if (is_null($result) || 1 != $result->num_rows) {
        $ret = "username or password was not right";
    } else {
        require_once "./session.php";
        update_session($username);
        while ($row = mysqli_fetch_assoc($result)) {
            //echo json_encode($row);
            $token = md5(uniqid(rand()));
            $ret_token = $token;
            $sql = "INSERT INTO `loginStatus`(`username`, `token`) VALUES ('{$username}', '{$token}')";
            $result = mysqli_obj_query($mysqli, $sql);
            $ret = "ok";
            break;
        }
    }
    /* free result set */
    //$result->free();
    $mysqli->close();
    return $ret;
}
Exemplo n.º 2
0
function mysqli_obj()
{
    $obj = new stdClass();
    $obj->status = "connecting";
    $mysqli = mysqli_new();
    /* check connection */
    if ($mysqli->connect_errno) {
        $obj->reason = "Failed to connect to MySQL: " . $mysqli->connect_errno . $mysqli->connect_error;
        $obj->status = "error";
    } else {
        $obj->status = "ok";
        $obj->host_info = $mysqli->host_info;
    }
    $obj->version = array('master' => 1, 'subversion' => 2, 'patch' => 3);
    $obj->body = 'another post';
    $obj->Token = md5(uniqid(rand()));
    //echo (json_encode($obj));
    return $obj;
}
Exemplo n.º 3
0
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<?php 
require_once "../db/conn.php";
if (isset($_POST["submit"]) && $_POST["submit"] == "Signup") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    if ($username == "" || $password == "" || $email == "") {
        echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>";
    } else {
        #mysql_query("set names 'gdk'");
        $sql = "select * from users where username='******'";
        $result = mysqli_obj_query(mysqli_new(), $sql);
        $num = $result->num_rows;
        if ($num) {
            echo "<script>alert('用户名已存在'); history.go(-1);</script>";
        } else {
            $sql = "INSERT INTO users(username, password, email) VALUES ('{$username}', '{$password}', '{$email}')";
            $result = mysqli_obj_query(mysqli_new(), $sql);
            if ($result) {
                echo "<script>alert('注册成功!'); history.go(-1);</script>";
            } else {
                echo "<script>alert(''注册失败!'); history.go(-1);</script>";
            }
        }
    }
} else {
    echo "<script>alert('提交未成功!'); history.go(-1);</script>";
}
Exemplo n.º 4
0
<?php

require_once "../db/conn.php";
$mysqli = mysqli_new();
$sql = "SELECT * FROM `uploadStatus` WHERE time = (SELECT max( time ) FROM `uploadStatus` )";
$result = mysqli_obj_query($mysqli, $sql);
if (is_null($result) || 1 != $result->num_rows) {
    $ret = "query failed";
} else {
    while ($row = mysqli_fetch_assoc($result)) {
        echo json_encode($row);
    }
}
echo $ret;