本文整理汇总了PHP中Process::set_timezone_offset方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::set_timezone_offset方法的具体用法?PHP Process::set_timezone_offset怎么用?PHP Process::set_timezone_offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::set_timezone_offset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: input_controller
function input_controller()
{
//return array('content'=>"ok");
global $mysqli, $redis, $user, $session, $route, $max_node_id_limit, $feed_settings;
// There are no actions in the input module that can be performed with less than write privileges
if (!$session['write']) {
return array('content' => false);
}
global $feed, $timestore_adminkey;
$result = false;
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);
$process->set_timezone_offset($user->get_timezone($session['userid']));
if ($route->format == 'html') {
if ($route->action == 'api') {
$result = view("Modules/input/Views/input_api.php", array());
}
if ($route->action == 'view') {
$result = view("Modules/input/Views/input_view.php", array());
}
}
if ($route->format == 'json') {
/*
input/bulk.json?data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]]
The first number of each node is the time offset (see below).
The second number is the node id, this is the unique identifer for the wireless node.
All the numbers after the first two are data values. The first node here (node 16) has only one data value: 1137.
Optional offset and time parameters allow the sender to set the time
reference for the packets.
If none is specified, it is assumed that the last packet just arrived.
The time for the other packets is then calculated accordingly.
offset=-10 means the time of each packet is relative to [now -10 s].
time=1387730127 means the time of each packet is relative to 1387730127
(number of seconds since 1970-01-01 00:00:00 UTC)
Examples:
// legacy mode: 4 is 0, 2 is -2 and 0 is -4 seconds to now.
input/bulk.json?data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]]
// offset mode: -6 is -16 seconds to now.
input/bulk.json?data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&offset=-10
// time mode: -6 is 1387730121
input/bulk.json?data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&time=1387730127
// sentat (sent at) mode:
input/bulk.json?data=[[520,16,1137],[530,17,1437,3164],[535,19,1412,3077]]&offset=543
See pull request for full discussion:
https://github.com/emoncms/emoncms/pull/118
*/
if ($route->action == 'bulk') {
$valid = true;
if (!isset($_GET['data']) && isset($_POST['data'])) {
$data = json_decode(post('data'));
} else {
$data = json_decode(get('data'));
}
$userid = $session['userid'];
$dbinputs = $input->get_inputs($userid);
$len = count($data);
if ($len > 0) {
if (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;
$nodeid = $item[1];
$inputs = array();
$name = 1;
for ($i = 2; $i < count($item); $i++) {
$value = (double) $item[$i];
$inputs[$name] = $value;
//.........这里部分代码省略.........
示例2: node_controller
function node_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);
$process->set_timezone_offset($user->get_timezone($session['userid']));
include "Modules/node/node_model.php";
$node = new Node($mysqli, $redis, $process);
if ($route->format == 'html') {
if ($route->action == "list" && $session['write']) {
$result = view("Modules/node/node_view.php", array());
}
if ($route->action == "api" && $session['write']) {
$result = view("Modules/node/node_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 = $node->set($session['userid'], get('nodeid'), 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;
$nodeid = $item[1];
$bytevalues = array();
for ($i = 2; $i < count($item); $i++) {
$bytevalues[] = (int) $item[$i];
}
$result = $node->set($session['userid'], $nodeid, $time, $bytevalues);
}
}
}
}
if ($route->action == 'setdecoder' && $session['write']) {
$result = $node->set_decoder($session['userid'], get('nodeid'), get('decoder'));
}
if ($route->action == 'getall' && $session['write']) {
$result = $node->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);
}