本文整理汇总了PHP中Monitor::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Monitor::set方法的具体用法?PHP Monitor::set怎么用?PHP Monitor::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monitor
的用法示例。
在下文中一共展示了Monitor::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: monitor_controller
function monitor_controller()
{
global $mysqli, $redis, $session, $route, $feed_settings, $user;
$result = false;
if (!isset($session['read'])) {
return array('content' => $result);
}
include "Modules/feed/feed_model.php";
$feed = new Feed($mysqli, $redis, $feed_settings);
require "Modules/input/input_model.php";
// 295
$input = new Input($mysqli, $redis, $feed);
require "Modules/input/process_model.php";
// 886
//$process = new Process($mysqli,$input,$feed,$user->get_timezone($session['userid']));
$process = new Process($mysqli, $input, $feed);
$process->set_timezone_offset($user->get_timezone($session['userid']));
include "Modules/monitor/monitor_model.php";
$monitor = new Monitor($mysqli, $redis, $process);
if ($route->format == 'html') {
if ($route->action == "list" && $session['write']) {
$result = view("Modules/monitor/monitor_view.php", array());
}
if ($route->action == "api" && $session['write']) {
$result = view("Modules/monitor/monitor_api.php", array());
}
}
if ($route->format == 'json') {
if ($route->action == 'set' && $session['write']) {
$data = explode(",", get('data'));
for ($i = 0; $i < count($data); $i++) {
$data[$i] = (int) $data[$i];
}
$result = $monitor->set($session['userid'], get('monitorid'), get('time'), $data);
}
if ($route->action == 'multiple' && $session['write']) {
$data = json_decode(prop('data'));
$len = count($data);
if ($len > 0 && isset($data[$len - 1][0])) {
// Sent at mode: input/bulk.json?data=[[45,16,1137],[50,17,1437,3164],[55,19,1412,3077]]&sentat=60
if (isset($_GET['sentat'])) {
$time_ref = time() - (int) $_GET['sentat'];
} elseif (isset($_POST['sentat'])) {
$time_ref = time() - (int) $_POST['sentat'];
} elseif (isset($_GET['offset'])) {
$time_ref = time() - (int) $_GET['offset'];
} elseif (isset($_POST['offset'])) {
$time_ref = time() - (int) $_POST['offset'];
} elseif (isset($_GET['time'])) {
$time_ref = (int) $_GET['time'];
} elseif (isset($_POST['time'])) {
$time_ref = (int) $_POST['time'];
} else {
$time_ref = time() - (int) $data[$len - 1][0];
}
foreach ($data as $item) {
if (count($item) > 2) {
// check for correct time format
$itemtime = (int) $item[0];
$time = $time_ref + (int) $itemtime;
$monitorid = $item[1];
$bytevalues = array();
for ($i = 2; $i < count($item); $i++) {
$bytevalues[] = (int) $item[$i];
}
$result = $monitor->set($session['userid'], $monitorid, $time, $bytevalues);
}
}
}
}
if ($route->action == 'setdecoder' && $session['write']) {
$result = $monitor->set_decoder($session['userid'], get('monitorid'), get('decoder'));
}
if ($route->action == 'getall' && $session['write']) {
$result = $monitor->get_all($session['userid']);
}
}
/*
// Sent at mode: data= [[45,16,1137]] &sentat=60
// Offset mode: data= [[-10,16,1137]] &offset=-10
// Time mode: data= [[-10,16,1137]] &time=1387729425
// Legacy mode: data= [[0,16,1137]]
// Sent at mode: data= [[45,16,1137],[50,17,1437,3164],[55,19,1412,3077]] &sentat=60
// Offset mode: data= [[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]] &offset=-10
// Time mode: data= [[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]] &time=1387729425
// Legacy mode: data= [[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]]
*/
return array('content' => $result);
}