本文整理汇总了PHP中setGlobal函数的典型用法代码示例。如果您正苦于以下问题:PHP setGlobal函数的具体用法?PHP setGlobal怎么用?PHP setGlobal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setGlobal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: poll_device
//.........这里部分代码省略.........
$dataTypes[] = "DINT";
$data_set[$k] = (int) $v;
$swapregs = false;
} elseif ($rec['RESPONSE_CONVERT'] == 'd2is' || $rec['RESPONSE_CONVERT'] == 'dw2is') {
$dataTypes[] = "DINT";
$data_set[$k] = (int) $v;
$swapregs = true;
} else {
$data_set[$k] = (int) $v;
$dataTypes[] = "INT";
$swapregs = false;
}
}
$recData = $modbus->writeMultipleRegister($rec['DEVICE_ID'], $rec['REQUEST_START'], $data_set, $dataTypes, $swapregs);
} catch (Exception $e) {
// Print error information if any
$rec['LOG'] = date('Y-m-d H:i:s') . " FC16 Error: {$modbus} {$e}\n" . $rec['LOG'];
}
} elseif ($rec['REQUEST_TYPE'] == 'FC23') {
//FC23 Read/Write multiple registers
//TO-DO
}
//echo $rec['LOG'];exit;
if ($rec['REQUEST_TYPE'] == 'FC1' || $rec['REQUEST_TYPE'] == 'FC2' || $rec['REQUEST_TYPE'] == 'FC3' || $rec['REQUEST_TYPE'] == 'FC4' && is_array($recData)) {
// PROCESS RESPONSE
if ($rec['RESPONSE_CONVERT'] == 'r2f') {
//REAL to Float
$values = array_chunk($recData, 4);
$recData = array();
foreach ($values as $bytes) {
echo $recData[] = PhpType::bytes2float($bytes, false);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'r2fs') {
//REAL to Float (swap regs)
$values = array_chunk($recData, 4);
$recData = array();
foreach ($values as $bytes) {
echo $recData[] = PhpType::bytes2float($bytes, true);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'd2i') {
//DINT to integer
$values = array_chunk($recData, 4);
$recData = array();
foreach ($values as $bytes) {
echo $recData[] = PhpType::bytes2signedInt($bytes, false);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'd2is') {
//DINT to integer (swap regs)
$values = array_chunk($recData, 4);
$recData = array();
foreach ($values as $bytes) {
echo $recData[] = PhpType::bytes2signedInt($bytes, true);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'dw2i') {
//DWORD to integer
$values = array_chunk($recData, 4);
$recData = array();
foreach ($values as $bytes) {
$recData[] = PhpType::bytes2unsignedInt($bytes, false);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'dw2is') {
//DWORD to integer (swap regs)
$values = array_chunk($recData, 4);
$recData = array();
foreach ($values as $bytes) {
$recData[] = PhpType::bytes2unsignedInt($bytes, true);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'i2i') {
//INT to integer
$values = array_chunk($recData, 2);
$recData = array();
foreach ($values as $bytes) {
$recData[] = PhpType::bytes2signedInt($bytes, false);
}
} elseif ($rec['RESPONSE_CONVERT'] == 'w2i') {
//WORD to integer
$values = array_chunk($recData, 2);
$recData = array();
foreach ($values as $bytes) {
$recData[] = PhpType::bytes2unsignedInt($bytes, false);
}
} elseif ($rec['RESPONSE_CONVERT'] == 's') {
//String
$recData = array(PhpType::bytes2string($recData));
} else {
//
}
$result = implode(',', $recData);
if ($result && $result != $rec['DATA']) {
$rec['LOG'] = date('Y-m-d H:i:s') . " " . $result . "\n" . $rec['LOG'];
}
$rec['DATA'] = $result;
SQLUpdate('modbusdevices', $rec);
if ($rec['LINKED_OBJECT'] && $rec['LINKED_PROPERTY']) {
setGlobal($rec['LINKED_OBJECT'] . '.' . $rec['LINKED_PROPERTY'], $rec['DATA'], array($this->name => '0'));
}
} else {
SQLUpdate('modbusdevices', $rec);
}
}
开发者ID:sergejey,项目名称:majordomo-modbus,代码行数:101,代码来源:modbus.class.php
示例2: cycleAlive
private function cycleAlive()
{
if ($this->_latestAlive == time()) {
return;
}
$this->_latestAlive = time();
global $cycleName;
global $websockets_script_started;
if ($cycleName) {
setGlobal($cycleName, time(), 1);
}
global $websockets_script_started;
if ($websockets_script_started > 0 && time() - $websockets_script_started > 12 * 60 * 60) {
exit;
// restart every 12 hours
}
}
开发者ID:szolenko,项目名称:majordomo,代码行数:17,代码来源:MajordomoApplication.php
示例3: tick
public function tick()
{
global $config;
if (time() - $this->last_check > 3) {
$queue_data = getGlobal('IRCBot1.pushMessage');
$this->last_check = time();
if ($queue_data != '') {
setGlobal('IRCBot1.pushMessage', '');
$messages = explode("\n", $queue_data);
$total = count($messages);
for ($i = 0; $i < $total; $i++) {
if ($messages[$i]) {
sendMessage($this->socket, $this->config['channel'], iconv('UTF-8', $config['encoding'], $messages[$i]));
}
}
}
setGlobal('cycle_app_ircbotRun', time(), 1);
if (file_exists('./reboot')) {
global $db;
$db->Disconnect();
exit;
}
}
}
开发者ID:sergejey,项目名称:majordomo-app_ircbot,代码行数:24,代码来源:majordomoPlugin.php
示例4: upload
/**
* Title
*
* Description
*
* @access public
*/
function upload(&$out)
{
set_time_limit(0);
global $restore;
global $file;
global $file_name;
global $folder;
if (!$folder) {
$folder = IsWindowsOS() ? '/.' : '/';
} else {
$folder = '/' . $folder;
}
if ($restore != '') {
//$file=ROOT.'saverestore/'.$restore;
$file = $restore;
} elseif ($file != '') {
copy($file, ROOT . 'saverestore/' . $file_name);
//$file=ROOT.'saverestore/'.$file_name;
$file = $file_name;
}
umask(0);
@mkdir(ROOT . 'saverestore/temp', 0777);
if ($file != '') {
// && mkdir(ROOT.'saverestore/temp', 0777)
chdir(ROOT . 'saverestore/temp');
if (IsWindowsOS()) {
// for windows only
exec(DOC_ROOT . '/gunzip ../' . $file, $output, $res);
exec(DOC_ROOT . '/tar xvf ../' . str_replace('.tgz', '.tar', $file), $output, $res);
//@unlink('../'.str_replace('.tgz', '.tar', $file));
} else {
exec('tar xzvf ../' . $file, $output, $res);
}
@unlink(ROOT . 'saverestore/temp' . $folder . '/config.php');
//print_r($output);exit;
chdir('../../');
$ignores = SQLSelect("SELECT * FROM ignore_updates ORDER BY NAME");
$total = count($ignores);
for ($i = 0; $i < $total; $i++) {
$name = $ignores[$i]['NAME'];
if (is_dir(ROOT . 'saverestore/temp/modules/' . $name)) {
$this->removeTree(ROOT . 'saverestore/temp/modules/' . $name);
}
if (is_dir(ROOT . 'saverestore/temp/templates/' . $name)) {
$this->removeTree(ROOT . 'saverestore/temp/templates/' . $name);
}
}
// UPDATING FILES DIRECTLY
$this->copyTree(ROOT . 'saverestore/temp' . $folder, ROOT, 1);
// restore all files
//if (is_dir(ROOT.'saverestore/temp/'.$folder.'modules')) {
// code restore
$source = ROOT . 'modules';
if ($dir = @opendir($source)) {
while (($file = readdir($dir)) !== false) {
if (Is_Dir($source . "/" . $file) && $file != '.' && $file != '..') {
// && !file_exists($source."/".$file."/installed")
@unlink(ROOT . "modules/" . $file . "/installed");
}
}
}
@unlink(ROOT . "modules/control_modules/installed");
@SaveFile(ROOT . 'reboot', 'updated');
//}
if (file_exists(ROOT . 'saverestore/temp' . $folder . '/dump.sql')) {
// data restore
$this->restoredatabase(ROOT . 'saverestore/temp' . $folder . '/dump.sql');
}
$this->config['LATEST_UPDATED_ID'] = $out['LATEST_ID'];
setGlobal('UpdateVersion', $this->config['LATEST_UPDATED_ID']);
$this->saveConfig();
global $with_extensions;
$this->redirect("?mode=clear&ok_msg=" . urlencode("Updates Installed!") . "&with_extensions=" . $with_extensions);
}
/*
require 'Tar.php';
$tar_object = new Archive_Tar($file);
if ($tar_object->extract(ROOT.'skins/'.$basename)) {
$out['OK_EXT']=1;
} else {
$out['ERR_FORMAT']=1;
}
*/
}
开发者ID:cdkisa,项目名称:majordomo,代码行数:91,代码来源:saverestore.class.php
示例5: processMessage
/**
* Title
*
* Description
*
* @access public
*/
function processMessage($path, $value)
{
if (preg_match('/\\#$/', $path)) {
return 0;
}
$rec = SQLSelectOne("SELECT * FROM mqtt WHERE PATH LIKE '" . DBSafe($path) . "'");
if (!$rec['ID']) {
$rec['PATH'] = $path;
$rec['TITLE'] = $path;
$rec['ID'] = SQLInsert('mqtt', $rec);
}
$rec['VALUE'] = $value;
$rec['UPDATED'] = date('Y-m-d H:i:s');
SQLUpdate('mqtt', $rec);
if ($rec['LINKED_OBJECT'] && $rec['LINKED_PROPERTY']) {
setGlobal($rec['LINKED_OBJECT'] . '.' . $rec['LINKED_PROPERTY'], $rec['VALUE'], array('mqtt' => '0'));
}
}
开发者ID:Andrew-Shtein,项目名称:majordomo,代码行数:25,代码来源:mqtt.class.php
示例6: pollDevice
/**
* Title
*
* Description
*
* @access public
*/
function pollDevice($device_id, $data = 0)
{
$rec = SQLSelectOne("SELECT * FROM zwave_devices WHERE ID='" . $device_id . "'");
$properties = array();
if (!$data) {
$data = $this->apiCall('/ZWaveAPI/Run/devices[' . $rec['NODE_ID'] . '].instances[' . $rec['INSTANCE_ID'] . ']');
}
if (!$data) {
return 0;
}
if ($rec['CLASS_BASIC']) {
$value = $data->commandClasses->{"32"}->data->value;
if ($value !== $rec['BASIC']) {
$rec['BASIC'] = $value;
SQLUpdate('zwave_devices', $rec);
}
$properties['Basic'] = $rec['BASIC'];
}
if ($rec['CLASS_SENSOR_BINARY']) {
// ...
$value = (int) $data->commandClasses->{"48"}->data->level->value;
if ($value !== $rec['LEVEL']) {
$rec['LEVEL'] = $value;
SQLUpdate('zwave_devices', $rec);
}
$properties['Level'] = $rec['LEVEL'];
}
if ($rec['CLASS_SENSOR_MULTILEVEL']) {
// multiple sensor support required!
//SENSOR_VALUE
$values = array();
for ($i = 0; $i < 255; $i++) {
if (isset($data->commandClasses->{"49"}->data->{"{$i}"})) {
$sensor = $data->commandClasses->{"49"}->data->{"{$i}"};
$values[] = $sensor->sensorTypeString->value . ': ' . $sensor->val->value . $sensor->scaleString->value;
$properties[$sensor->sensorTypeString->value . ', ' . $sensor->scaleString->value] = $sensor->val->value;
}
}
$value = implode('; ', $values);
if ($value != $rec['SENSOR_VALUE']) {
$rec['SENSOR_VALUE'] = $value;
SQLUpdate('zwave_devices', $rec);
}
}
if ($rec['CLASS_THERMOSTAT']) {
$value = $data->commandClasses->{"64"}->data->{$data->commandClasses->{"64"}->data->mode->value}->modeName->value;
if ($value != $rec['MODE_VALUE']) {
$rec['MODE_VALUE'] = $value;
SQLUpdate('zwave_devices', $rec);
}
$properties['Thermostat mode'] = $rec['MODE_VALUE'];
}
if ($rec['CLASS_SWITCH_BINARY']) {
$value = (int) $data->commandClasses->{"37"}->data->level->value;
if ($value !== $rec['LEVEL']) {
$rec['LEVEL'] = $value;
SQLUpdate('zwave_devices', $rec);
}
$properties['Level'] = $rec['LEVEL'];
}
if ($rec['CLASS_SWITCH_MULTILEVEL']) {
$value = (int) $data->commandClasses->{"38"}->data->level->value;
if ($value !== $rec['LEVEL']) {
$rec['LEVEL'] = $value;
SQLUpdate('zwave_devices', $rec);
}
$properties['Level'] = $rec['LEVEL'];
}
if ($rec['CLASS_BATTERY']) {
$value = (int) $data->commandClasses->{"128"}->data->last->value;
if ($value != $rec['BATTERY_LEVEL']) {
$rec['BATTERY_LEVEL'] = $value;
SQLUpdate('zwave_devices', $rec);
}
$properties['Battery'] = $rec['BATTERY_LEVEL'];
}
if ($rec['CLASS_METER']) {
// ...
}
foreach ($properties as $k => $v) {
$prop = SQLSelectOne("SELECT * FROM zwave_properties WHERE DEVICE_ID='" . $rec['ID'] . "' AND UNIQ_ID LIKE '" . DBSafe($k) . "'");
$prop['DEVICE_ID'] = $rec['ID'];
$prop['UNIQ_ID'] = $k;
$prop['TITLE'] = $k;
$prop['VALUE'] = $v;
$prop['UPDATED'] = date('Y-m-d H:i:s');
if ($prop['ID']) {
SQLUpdate('zwave_properties', $prop);
if ($prop['LINKED_OBJECT'] && $prop['LINKED_PROPERTY']) {
setGlobal($prop['LINKED_OBJECT'] . '.' . $prop['LINKED_PROPERTY'], $prop['VALUE'], array('zwave_properties' => '0'));
}
} else {
$prop['ID'] = SQLInsert('zwave_properties', $prop);
//.........这里部分代码省略.........
开发者ID:vasvlad,项目名称:majordomo,代码行数:101,代码来源:zwave.class.php
示例7: jzMediaTrack
}
if ($_GET['mode'] == "random") {
$pl = $pl->getSmartPlaylist();
}
$pl->play();
} else {
if (isset($_GET['type']) && $_GET['type'] == "track") {
// send file directly if method == direct.
// otherwise send a playlist.
// TODO: if method = direct, do things like update playcount.
// and also validate user (pass username / md5(password) in URL)
$el =& new jzMediaTrack($_GET['jz_path']);
$pl =& new jzPlaylist();
$pl->add($el);
if (isset($_GET['clip'])) {
setGlobal("CLIP_MODE", true);
}
$pl->play();
} else {
// Ok, was this a radio playlist or standard
if (isset($_GET['mode']) && $_GET['mode'] == "radio") {
// Let's set the limit
$lim = isset($_GET['limit']) ? $_GET['limit'] : false;
// Now let's get the tracks from the primary artist
$el =& new jzMediaNode($_GET['jz_path']);
$pl = new jzPlaylist();
$pl->add($el);
$pl = $pl->getSmartPlaylist($lim, "radio");
$pl->play();
} else {
$el =& new jzMediaNode($_GET['jz_path']);
开发者ID:seanfbrown,项目名称:jinzora,代码行数:31,代码来源:index.php
示例8: chdir
<?php
chdir(dirname(__FILE__) . '/../');
include_once "./config.php";
include_once "./lib/loader.php";
include_once "./lib/threads.php";
set_time_limit(0);
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once "./load_settings.php";
include_once DIR_MODULES . "control_modules/control_modules.class.php";
$ctl = new control_modules();
if (defined('ONEWIRE_SERVER')) {
include_once DIR_MODULES . 'onewire/onewire.class.php';
$onw = new onewire();
} else {
exit;
}
while (1) {
echo date("H:i:s") . " running " . basename(__FILE__) . "\n";
setGlobal(str_replace('.php', '', basename(__FILE__)) . 'Run', time());
// check all 1wire devices
$onw->updateDevices();
$onw->updateDisplays();
if (file_exists('./reboot') || $_GET['onetime']) {
$db->Disconnect();
exit;
}
sleep(1);
}
DebMes("Unexpected close of cycle: " . basename(__FILE__));
开发者ID:vasvlad,项目名称:majordomo,代码行数:31,代码来源:cycle_onewire.php
示例9: SQLUpdate
$object_rec['CLASS_ID'] = $class_rec['ID'];
SQLUpdate('objects', $object_rec);
}
foreach ($known_fields as $k => $v) {
$prop_rec = SQLSelectOne("SELECT * FROM properties WHERE TITLE LIKE '" . DBSafe($k) . "' AND CLASS_ID = '" . $object_rec['CLASS_ID'] . "'");
if (!$prop_rec['ID']) {
$prop_rec['CLASS_ID'] = $object_rec['CLASS_ID'];
$prop_rec['TITLE'] = $k;
$prop_rec['KEEP_HISTORY'] = 7;
$prop_rec['ID'] = SQLInsert('properties', $prop_rec);
}
}
$res = '';
$updated = array();
foreach ($known_fields as $k => $v) {
if ($v < 0) {
continue;
}
$res .= $k . ' = ' . $data[(int) $v] . "\n";
$old_value = getGlobal('ws.' . $k);
if ($old_value != $data[(int) $v]) {
$updated[$k] = 1;
setGlobal('ws.' . $k, $data[(int) $v]);
}
}
if ($updated['pressure']) {
setGlobal('ws.pressureRt', round((double) getGlobal('ws.pressure') / 1.33), 1);
}
echo "OK";
$db->Disconnect();
// closing database connection
开发者ID:vasvlad,项目名称:majordomo,代码行数:31,代码来源:cumulus.php
示例10: updateDevice
function updateDevice($id)
{
if (!defined('ONEWIRE_SERVER')) {
return 0;
}
$rec = SQLSelectOne("SELECT * FROM owdevices WHERE ID='" . $id . "'");
if (!$rec['ID']) {
return 0;
}
$ow = new OWNet(ONEWIRE_SERVER);
$device = '/' . $rec['UDID'];
$rec['CHECK_LATEST'] = date('Y-m-d H:i:s');
$rec['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + (int) $rec['ONLINE_INTERVAL']);
$old_status = $rec['STATUS'];
$tmp = $ow->get($device, OWNET_MSG_DIR, false);
if (!$tmp) {
$rec['STATUS'] = 0;
} else {
$rec['STATUS'] = 1;
}
SQLUpdate('owdevices', $rec);
if ($rec['STATUS'] != $old_status && ($rec['SCRIPT_ID'] || $rec['CODE'])) {
$params = array();
$params['DEVICE'] = $device;
$params['STATUS'] = $rec['STATUS'];
$params['STATUS_CHANGED'] = 1;
if ($rec['SCRIPT_ID']) {
runScript($rec['SCRIPT_ID'], $params);
} elseif ($rec['CODE']) {
try {
$code = $rec['CODE'];
$success = eval($code);
if ($success === false) {
DebMes("Error in 1-wire action code: " . $code);
}
} catch (Exception $e) {
DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
}
}
}
if (!$rec['STATUS']) {
return 0;
}
$changed_values = array();
$changed = 0;
$properties = explode(',', $tmp);
$totalp = count($properties);
for ($ip = 0; $ip < $totalp; $ip++) {
$sysname = str_replace($device . '/', '', $properties[$ip]);
//echo $properties[$ip]." (".$sysname."): ";
$prec = SQLSelectOne("SELECT * FROM owproperties WHERE DEVICE_ID='" . $rec['ID'] . "' AND SYSNAME='" . DBSafe($sysname) . "'");
if (!$prec['ID']) {
$prec['DEVICE_ID'] = $rec['ID'];
$prec['SYSNAME'] = $sysname;
$prec['PATH'] = $properties[$ip];
$prec['ID'] = SQLInsert('owproperties', $prec);
}
$old_value = $prec['VALUE'];
$value = $ow->get($properties[$ip], OWNET_MSG_READ, false);
if (is_null($value)) {
$ow->get("/", OWNET_MSG_DIR, false);
// hack. for some reason it didn't work correct without it on some devices
$value = $ow->get($properties[$ip], OWNET_MSG_READ, false);
}
if (!is_null($value)) {
$value = iconv("CP1251", "UTF-8", $value);
// value updated
$prec['VALUE'] = $value;
$prec['UPDATED'] = date('Y-m-d H:i:s');
$prec['CHECK_LATEST'] = $prec['UPDATED'];
SQLUpdate('owproperties', $prec);
//$rec['LOG']=date('Y-m-d H:i:s')." ".$prec['SYSNAME'].": ".$prec['VALUE']."\n".$rec['LOG'];
//SQLUpdate('owdevices', $rec);
if ($prec['LINKED_OBJECT'] && $prec['LINKED_PROPERTY']) {
setGlobal($prec['LINKED_OBJECT'] . '.' . $prec['LINKED_PROPERTY'], $prec['VALUE'], array($this->name => '0'));
}
if ($old_value != $value) {
$changed = 1;
$changed_values[$prec['SYSNAME']] = array('OLD_VALUE' => $old_value, 'VALUE' => $prec['VALUE']);
}
}
}
if ($changed) {
$params = $changed_values;
$params['DEVICE'] = $device;
if ($rec['SCRIPT_ID']) {
runScript($rec['SCRIPT_ID'], $params);
} elseif ($rec['CODE']) {
try {
$code = $rec['CODE'];
$success = eval($code);
if ($success === false) {
DebMes("Error in code: " . $code);
}
} catch (Exception $e) {
DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
}
}
}
}
开发者ID:sergejey,项目名称:majordomo-onewire,代码行数:100,代码来源:onewire.class.php
示例11: usual
//.........这里部分代码省略.........
}
$out['VOLUMES'][] = $rec;
}
global $ajax;
if ($ajax != '') {
global $command;
if ($command != '') {
if (!$this->intCall) {
echo $command . ' ';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($terminal['PLAYER_USERNAME'] || $terminal['PLAYER_PASSWORD']) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $terminal['PLAYER_USERNAME'] . ':' . $terminal['PLAYER_PASSWORD']);
}
if (!$terminal['PLAYER_PORT'] && $terminal['PLAYER_TYPE'] == 'foobar') {
$terminal['PLAYER_PORT'] = '8888';
} elseif (!$terminal['PLAYER_PORT'] && $terminal['PLAYER_TYPE'] == 'xbmc') {
$terminal['PLAYER_PORT'] = '8080';
} elseif (!$terminal['PLAYER_PORT']) {
$terminal['PLAYER_PORT'] = '80';
}
if ($terminal['PLAYER_TYPE'] == 'vlc' || $terminal['PLAYER_TYPE'] == '') {
$terminal['PLAYER_PORT'] = '80';
if ($command == 'refresh') {
$out['PLAY'] = preg_replace('/\\\\$/is', '', $out['PLAY']);
$out['PLAY'] = preg_replace('/\\/$/is', '', $out['PLAY']);
if (preg_match('/^http/', $out['PLAY'])) {
$path = urlencode($out['PLAY']);
} else {
$path = urlencode('' . str_replace('/', "\\", $out['PLAY']));
}
curl_setopt($ch, CURLOPT_URL, "http://" . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT'] . "/rc/?command=vlc_play¶m=" . $path);
//echo $path;exit;
$res = curl_exec($ch);
}
if ($command == 'fullscreen') {
curl_setopt($ch, CURLOPT_URL, "http://" . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT'] . "/rc/?command=vlc_fullscreen");
$res = curl_exec($ch);
}
if ($command == 'pause') {
curl_setopt($ch, CURLOPT_URL, "http://" . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT'] . "/rc/?command=vlc_pause");
$res = curl_exec($ch);
}
if ($command == 'next') {
curl_setopt($ch, CURLOPT_URL, "http://" . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT'] . "/rc/?command=vlc_next");
$res = curl_exec($ch);
}
if ($command == 'prev') {
curl_setopt($ch, CURLOPT_URL, "http://" . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT'] . "/rc/?command=vlc_prev");
$res = curl_exec($ch);
}
if ($command == 'close') {
curl_setopt($ch, CURLOPT_URL, "http://" . $terminal['HOST'] . ":" . $terminal['PLAYER_PORT'] . "/rc/?command=vlc_close");
$res = curl_exec($ch);
}
if ($command == 'volume') {
global $volume;
setGlobal('ThisComputer.volumeLevel', $volume);
callMethod('ThisComputer.VolumeLevelChanged', array('VALUE' => $volume, 'HOST' => $terminal['HOST']));
}
} elseif ($terminal['PLAYER_TYPE'] == 'xbmc') {
include DIR_MODULES . 'app_player/xbmc.php';
} elseif ($terminal['PLAYER_TYPE'] == 'foobar') {
include DIR_MODULES . 'app_player/foobar.php';
} elseif ($terminal['PLAYER_TYPE'] == 'vlcweb') {
include DIR_MODULES . 'app_player/vlcweb.php';
} elseif ($terminal['PLAYER_TYPE'] == 'mpd') {
include DIR_MODULES . 'app_player/mpd.php';
}
// close cURL resource, and free up system resources
curl_close($ch);
}
if (!$this->intCall) {
if ($session->data['PLAY_TERMINAL'] != '') {
echo " on " . $session->data['PLAY_TERMINAL'] . ' ';
}
echo "OK";
if ($res) {
echo " (" . $res . ")";
}
$session->save();
exit;
}
}
$terminals = SQLSelect("SELECT * FROM terminals WHERE CANPLAY=1 ORDER BY TITLE");
$total = count($terminals);
for ($i = 0; $i < $total; $i++) {
if ($terminals[$i]['NAME'] == $session->data['PLAY_TERMINAL']) {
$terminals[$i]['SELECTED'] = 1;
$out['TERMINAL_TITLE'] = $terminals[$i]['TITLE'];
}
}
$out['TERMINALS_TOTAL'] = count($terminals);
if ($out['TERMINALS_TOTAL'] == 1 || !$session->data['PLAY_TERMINAL']) {
$terminals[0]['SELECTED'] = 1;
}
$out['TERMINALS'] = $terminals;
}
开发者ID:vasvlad,项目名称:majordomo,代码行数:101,代码来源:app_player.class.php
示例12: processResponse
/**
* Summary of processResponse
* @param mixed $out Out param
* @return void
*/
function processResponse($out)
{
global $socket;
echo date('Y-m-d H:i:s') . ' Incoming: ' . trim($out) . "\n";
if (preg_match('/REQUEST:(.+)/is', $out, $m)) {
$url = $m[1];
if (!preg_match('/^http:/', $url)) {
$url = 'http://localhost' . $url;
}
echo date('Y-m-d H:i:s') . ' Sending request to ' . $url . "\n";
DebMes('Connect command: ' . $url);
$content = getURL($url, 0);
}
if (preg_match('/PING/is', $out, $m)) {
$in = "PONG!\n";
echo date('Y-m-d H:i:s') . ' Sending: ' . $in;
socket_write($socket, $in, strlen($in));
echo "OK.\n";
setGlobal(str_replace('.php', '', basename(__FILE__)) . 'Run', time(), 1);
}
}
开发者ID:cdkisa,项目名称:majordomo,代码行数:26,代码来源:cycle_connect.php
示例13: processMessage
function processMessage()
{
$skip = false;
$data = $this->telegramBot->getData();
$this->debug($data);
$bot_name = $this->config['TLG_BOTNAME'];
$text = $this->telegramBot->Text();
$callback = $this->telegramBot->Callback_Data();
if ($callback) {
$chat_id = $data["callback_query"]["from"]["id"];
$username = $data["callback_query"]["message"]["chat"]["username"];
$fullname = $data["callback_query"]["from"]["first_name"] . ' ' . $data["callback_query"]["from"]["last_name"];
} else {
$chat_id = $this->telegramBot->ChatID();
$username = $this->telegramBot->Username();
$fullname = $this->telegramBot->FirstName() . ' ' . $this->telegramBot->LastName();
}
// поиск в базе пользователя
$user = SQLSelectOne("SELECT * FROM tlg_user WHERE USER_ID LIKE '" . DBSafe($chat_id) . "';");
if ($chat_id < 0 && substr($text, 0, strlen('@' . $bot_name)) === '@' . $bot_name) {
$this->debug("Direct message to bot: " . $bot_name . " ({$text})");
$text = str_replace('@' . $bot_name, '', $text);
$source_user = SQLSelectOne("SELECT * FROM tlg_user WHERE TRIM(NAME) LIKE '" . DBSafe(trim($username)) . "'");
if ($source_user['ID']) {
$user = $source_user;
$this->debug("New user check: " . serialize($user));
} else {
$this->debug("Cannot find user: " . $username);
}
} else {
$this->debug("Chatid: " . $chat_id . "; Bot-name: " . $bot_name . "; Message: " . $text);
}
if ($text == "/start" || $text == "/start@" . $bot_name) {
// если нет добавляем
if (!$user['ID']) {
$user['USER_ID'] = $chat_id;
$user['CREATED'] = date('Y/m/d H:i:s');
$user['ID'] = SQLInsert('tlg_user', $user);
$this->log("Added new user: " . $username . " - " . $chat_id);
}
$reply = "Вы зарегистрированы! Обратитесь к администратору для получения доступа к функциям.";
$content = array('chat_id' => $chat_id, 'text' => $reply);
$this->sendContent($content);
$this->updateInfo($user);
return;
}
// пользователь не найден
if (!$user['ID']) {
$this->debug("Unknow user: " . $chat_id . "; Message: " . $text);
return;
}
$document = $this->telegramBot->Document();
$audio = $this->telegramBot->Audio();
$video = $this->telegramBot->Video();
$voice = $this->telegramBot->Voice();
$sticker = $this->telegramBot->Sticker();
$photo_id = $this->telegramBot->PhotoIdBigSize();
$location = $this->telegramBot->Location();
if ($callback) {
$cbm = $this->telegramBot->Callback_Message();
$message_id = $cbm["message_id"];
// get events for callback
$events = SQLSelect("SELECT * FROM tlg_event WHERE TYPE_EVENT=9 and ENABLE=1;");
foreach ($events as $event) {
if ($event['CODE']) {
$this->log("Execute code event " . $event['TITLE']);
try {
eval($event['CODE']);
} catch (Exception $e) {
registerError('telegram', sprintf('Exception in "%s" method ' . $e->getMessage(), $text));
}
}
if ($skip) {
$this->log("Skip next processing events callback");
break;
}
}
return;
}
if ($location) {
$latitude = $location["latitude"];
$longitude = $location["longitude"];
$this->log("Get location from " . $chat_id . " - " . $latitude . "," . $longitude);
if ($user['MEMBER_ID']) {
$sqlQuery = "SELECT * FROM users WHERE ID = '" . $user['MEMBER_ID'] . "'";
$userObj = SQLSelectOne($sqlQuery);
if ($userObj['LINKED_OBJECT']) {
$this->log("Update location to user '" . $userObj['LINKED_OBJECT'] . "'");
setGlobal($userObj['LINKED_OBJECT'] . '.Coordinates', $latitude . ',' . $longitude);
setGlobal($userObj['LINKED_OBJECT'] . '.CoordinatesUpdated', date('H:i'));
setGlobal($userObj['LINKED_OBJECT'] . '.CoordinatesUpdatedTimestamp', time());
}
}
// get events for location
$events = SQLSelect("SELECT * FROM tlg_event WHERE TYPE_EVENT=8 and ENABLE=1;");
foreach ($events as $event) {
if ($event['CODE']) {
$this->log("Execute code event " . $event['TITLE']);
try {
eval($event['CODE']);
//.........这里部分代码省略.........
开发者ID:Anisan,项目名称:majordomo-telegram,代码行数:101,代码来源:telegram.class.php
示例14: admin
/**
* BackEnd
*
* Module backend
*
* @access public
*/
function admin(&$out)
{
if (isset($this->data_source) && !$_GET['data_source'] && !$_POST['data_source']) {
$out['SET_DATASOURCE'] = 1;
}
$this->getConfig();
$out['MQTT_CLIENT'] = $this->config['MQTT_CLIENT'];
$out['MQTT_HOST'] = $this->config['MQTT_HOST'];
$out['MQTT_PORT'] = $this->config['MQTT_PORT'];
$out['MQTT_QUERY'] = $this->config['MQTT_QUERY'];
if (!$out['MQTT_HOST']) {
$out['MQTT_HOST'] = 'localhost';
}
if (!$out['MQTT_PORT']) {
$out['MQTT_PORT'] = '1883';
}
if (!$out['MQTT_QUERY']) {
$out['MQTT_QUERY'] = '/var/now/#';
}
$out['MQTT_USERNAME'] = $this->config['MQTT_USERNAME'];
$out['MQTT_PASSWORD'] = $this->config['MQTT_PASSWORD'];
$out['MQTT_AUTH'] = $this->config['MQTT_AUTH'];
if ($this->view_mode == 'update_settings') {
global $mqtt_client;
global $mqtt_host;
global $mqtt_username;
global $mqtt_password;
global $mqtt_auth;
global $mqtt_port;
global $mqtt_query;
$this->config['MQTT_CLIENT'] = trim($mqtt_client);
$this->config['MQTT_HOST'] = trim($mqtt_host);
$this->config['MQTT_USERNAME'] = trim($mqtt_username);
$this->config['MQTT_PASSWORD'] = trim($mqtt_password);
$this->config['MQTT_AUTH'] = (int) $mqtt_auth;
$this->config['MQTT_PORT'] = (int) $mqtt_port;
$this->config['MQTT_QUERY'] = trim($mqtt_query);
$this->saveConfig();
setGlobal('cycle_mqttControl', 'restart');
$this->redirect("?");
}
if (!$this->config['MQTT_HOST']) {
$this->config['MQTT_HOST'] = 'localhost';
$this->saveConfig();
}
if (!$this->config['MQTT_PORT']) {
$this->config['MQTT_PORT'] = '1883';
$this->saveConfig();
}
if (!$this->config['MQTT_QUERY']) {
$this->config['MQTT_QUERY'] = '/var/now/#';
$this->saveConfig();
}
if ($this->data_source == 'mqtt' || $this->data_source == '') {
if ($this->view_mode == '' || $this->view_mode == 'search_mqtt') {
$this->search_mqtt($out);
}
if ($this->view_mode == 'edit_mqtt') {
$this->edit_mqtt($out, $this->id);
}
if ($this->view_mode == 'delete_mqtt') {
$this->delete_mqtt($this->id);
$this->redirect("?");
}
}
}
开发者ID:sergejey,项目名称:majordomo-mqtt,代码行数:73,代码来源:mqtt.class.php
示例15: date
$old_hour = date('h');
if ($_GET['onetime']) {
$old_minute = -1;
if (date('i') == '00') {
$old_hour = -1;
}
}
$old_date = date('Y-m-d');
$checked_time = 0;
$started_time = time();
echo date("H:i:s") . " running " . basename(__FILE__) . "\n";
while (1) {
if (time() - $checked_time > 5) {
$checked_time = time();
setGlobal(str_replace('.php', '', basename(__FILE__)) . 'Run', time(), 1);
setGlobal('ThisComputer.uptime', time() - getGlobal('ThisComputer.started_time'));
}
$m = date('i');
$h = date('h');
$dt = date('Y-m-d');
if ($m != $old_minute) {
//echo "new minute\n";
$sqlQuery = "SELECT ID, TITLE\n FROM objects\n WHERE {$o_qry}";
$objects = SQLSelect($sqlQuery);
$total = count($objects);
for ($i = 0; $i < $total; $i++) {
echo date('H:i:s') . ' ' . $objects[$i]['TITLE'] . "->onNewMinute\n";
getObject($objects[$i]['TITLE'])->setProperty("time", date('Y-m-d H:i:s'));
getObject($objects[$i]['TITLE'])->raiseEvent("onNewMinute");
}
$old_minute = $m;
开发者ID:szolenko,项目名称:majordomo,代码行数:31,代码来源:cycle_main.php
示例16: upload
//.........这里部分代码省略.........
chdir(ROOT . 'saverestore/temp');
if (IsWindowsOS()) {
// for windows only
exec(DOC_ROOT . '/gunzip ../' . $file, $output, $res);
exec(DOC_ROOT . '/tar xvf ../' . str_replace('.tgz', '.tar', $file), $output, $res);
//@unlink('../'.str_replace('.tgz', '.tar', $file));
} else {
exec('tar xzvf ../' . $file, $output, $res);
}
@unlink(ROOT . 'saverestore/temp' . $folder . '/config.php');
//print_r($output);exit;
if (1) {
chdir('../../');
if ($this->method == 'direct') {
$ignores = SQLSelect("SELECT * FROM ignore_updates ORDER BY NAME");
$total = count($ignores);
for ($i = 0; $i < $total; $i++) {
$name = $ignores[$i]['NAME'];
if (is_dir(ROOT . 'saverestore/temp/modules/' . $name)) {
$this->removeTree(ROOT . 'saverestore/temp/modules/' . $name);
}
if (is_dir(ROOT . 'saverestore/temp/templates/' . $name)) {
$this->removeTree(ROOT . 'saverestore/temp/templates/' . $name);
}
}
// UPDATING FILES DIRECTLY
//$this->copyTree(ROOT.'saverestore/temp'.$folder, ROOT, 1); // restore all files
} elseif ($this->method == 'ftp') {
// UPDATING FILES BY FTP
$conn_id = @ftp_connect($this->config['FTP_HOST']);
if ($conn_id) {
$login_result = @ftp_login($conn_id, $this->config['FTP_USERNAME'], $this->config['FTP_PASSWORD']);
if ($login_result) {
$systyp = ftp_systype($conn_id);
if (@ftp_chdir($conn_id, $this->config['FTP_FOLDER'] . 'saverestore')) {
@ftp_chdir($conn_id, $this->config['FTP_FOLDER']);
// ok, we're in. updating!
$log = '';
$files = $this->getLocalFilesTree(ROOT . 'saverestore/temp' . $folder, '.+', 'installed', $log, 0);
$total = count($files);
$modules_processed = array();
for ($i = 0; $i < $total; $i++) {
$file = $files[$i];
$file['REMOTE_FILENAME'] = preg_replace('/^' . preg_quote(ROOT . 'saverestore/temp/' . $folder, '/') . '/is', $this->config['FTP_FOLDER'], $file['FILENAME']);
$file['REMOTE_FILENAME'] = str_replace('//', '/', $file['REMOTE_FILENAME']);
$res_f = $this->ftpput($conn_id, $file['REMOTE_FILENAME'], $file['FILENAME'], FTP_BINARY);
if (preg_match('/\\.class\\.php$/', basename($file['FILENAME'])) && !$modules_processed[dirname($file['REMOTE_FILENAME'])]) {
// if this a module then we should update attributes for folder and remove 'installed' file
$modules_processed[dirname($file['REMOTE_FILENAME'])] = 1;
@ftp_site($conn_id, "CHMOD 0777 " . dirname($file['REMOTE_FILENAME']));
@ftp_delete($conn_id, dirname($file['REMOTE_FILENAME']) . '/installed');
}
}
} else {
$out['FTP_ERR'] = 'Incorrect folder (' . $ftp_folder . ')';
}
} else {
$out['FTP_ERR'] = 'Incorrect username/password';
}
ftp_close($conn_id);
} else {
$out['FTP_ERR'] = 'Cannot connect to host (' . $ftp_host . ')';
$this->redirect("?err_msg=" . urlencode($out['FTP_ERR']));
}
}
//if (is_dir(ROOT.'saverestore/temp/'.$folder.'modules')) {
// code restore
$source = ROOT . 'modules';
if ($dir = @opendir($source)) {
while (($file = readdir($dir)) !== false) {
if (Is_Dir($source . "/" . $file) && $file != '.' && $file != '..') {
|
请发表评论