Exemplo n.º 1
0
 function write($varname, $value)
 {
     if (!$this->valid_session()) {
         return false;
     }
     $sql = "SELECT id FROM " . $this->session_vars_table . " WHERE name='" . $varname . "' AND session='" . $this->getSessionID() . "'";
     $rez = Mysql::query_array($sql);
     if (!isset($rez[0])) {
         $rez = Mysql::query("INSERT INTO " . $this->session_vars_table . "  \r\n\t\t  \t\t\t(name,session,value) VALUES\r\n\t\t  \t\t\t('" . $varname . "', '" . $this->getSessionID() . "', '" . $value . "')");
     } else {
         $mas["value"] = $value;
         //		  	$ids["session"] = $this->session;
         $ids["name"] = $varname;
         $sql = "UPDATE " . $this->session_vars_table . " SET `value` = '" . $value . "' WHERE name='" . $varname . "' AND session='" . $this->getSessionID() . "'";
         Mysql::query($sql);
     }
     $GLOBALS[$varname] = $value;
     $this->variables[$varname] = $value;
     $this->s_touch();
 }
Exemplo n.º 2
0
 * Time: 下午5:17
 */
include '../Visitor.php';
$userId = getUserId();
$mysql = new Mysql();
if (isset($_POST['from'])) {
    $from = $_POST['from'];
} else {
    $from = 0;
}
if (isset($_POST['size'])) {
    $size = $_POST['size'];
} else {
    $size = 30;
}
$waiting = "";
if (isset($_POST['waiting']) && $_POST['waiting']) {
    $sendTime = time() - 10 * 60;
    $waiting = " and timestamp>{$sendTime} ";
}
$sql = "SELECT *,ft.id as footprintId FROM footprint ft inner join foot f WHERE ft.footId=f.id and ft.userId={$userId} order by timestamp desc limit {$from},{$size}";
if (isset($sendTime)) {
    $sql = "SELECT *,ft.id as footprintId FROM footprint ft inner join foot f WHERE ft.footId=f.id and ft.userId={$userId} {$waiting}order by timestamp desc limit {$from},{$size}";
}
$foot_array = $mysql->query_array($sql);
foreach ($foot_array as $v) {
    $footprint = new FootPrint($v);
    $footPrints[] = $footprint;
}
$res = [ok => 1, data => $footPrints];
echo json_encode($res);
Exemplo n.º 3
0
<?php

/**
 * Created by PhpStorm.
 * User: shaoting
 * Date: 15/7/26
 * Time: 下午9:57
 */
include "../Visitor.php";
$userId = getUserId();
$mysql = new Mysql();
$result = $mysql->select("*", "`user_regular`", "`user_id`", "{$userId}");
if ($result) {
    //echo "SELECT * FROM user_regular u inner join regular r WHERE r.id=u.regular_id and u.user_id={$userId}";
    $regular_array = $mysql->query_array("select * from (SELECT u.*,r.host,r.threshold FROM user_regular u inner join regular r WHERE r.id=u.regular_id and u.user_id={$userId} order by time desc ) a group by host");
} else {
    //echo "select * from (SELECT *,count(r.id) count FROM user_regular u inner join regular r WHERE r.id=u.regular_id group by r.id)a limit 10";
    //无规则时返回大家用的最多的规则
    $regular_array = $mysql->query_array("select * from (SELECT u.*,r.host,r.threshold,count(r.id) count FROM user_regular u inner join regular r WHERE r.id=u.regular_id group by r.id)a group by host order by time desc limit 10");
}
foreach ($regular_array as $v) {
    $regular = new Regular($v);
    $regulars[] = $regular;
}
$res = [ok => 1, data => $regulars];
echo json_encode($res);