当前位置: 首页>>代码示例>>PHP>>正文


PHP DebMes函数代码示例

本文整理汇总了PHP中DebMes函数的典型用法代码示例。如果您正苦于以下问题:PHP DebMes函数的具体用法?PHP DebMes怎么用?PHP DebMes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DebMes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: iteration

 public function iteration()
 {
     $result = '';
     if (!count($this->streams)) {
         return false;
     }
     $read = $this->streams;
     $write = null;
     $except = null;
     if (false === ($number_of_streams = stream_select($read, $write, $except, $this->timeout))) {
         DebMes("No active streams");
         return 0;
     }
     /* 
     $stream = next($read);
     if (!$stream) {
      reset($read);
      $stream=current($read);
     }
     */
     foreach ($read as $stream) {
         $id = array_search($stream, $this->streams);
         //stream_set_blocking($stream, FALSE);
         stream_set_timeout($stream, $this->timeout);
         //echo date('H:i:s')." Reading thread: ".$this->commandLines[$id]."\n";
         //$result = stream_get_contents($this->pipes[$id][1]);
         if (feof($stream) || ($contents = fread($stream, 255)) == false) {
             //)
             echo date('H:i:s') . " Closing thread: " . $this->commandLines[$id] . "\n";
             DebMes("Closing thread: " . $this->commandLines[$id]);
             $result .= "THREAD CLOSED: [" . $this->commandLines[$id] . "]\n";
             fclose($this->pipes[$id][0]);
             fclose($this->pipes[$id][1]);
             proc_close($this->handles[$id]);
             unset($this->handles[$id]);
             unset($this->streams[$id]);
             unset($this->pipes[$id]);
             unset($this->commandLines[$id]);
         } else {
             echo $contents;
             $result .= $contents;
         }
     }
     return $result;
 }
开发者ID:vasvlad,项目名称:majordomo,代码行数:45,代码来源:threads.php

示例2: error

/**
* Object constructor
*
* @access public
* @param string $description error description
* @param int $stop 0 - stop script execution, 1 - show warning and continue script execution
*/
  function error($description, $stop=0, $short=0) {
   $script='http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
   $dat=date("M d, Y H:i:s");
   $description=$dat." ".$script."\nError:\n".$description;
   DebMes($description);
   if (Defined("DEBUG_MODE")) {
    if (!$short) {
     $this->alert(nl2br($description));
    } else {
     echo (nl2br($description));
    }
   } else {
    if (!$short) {
     $this->alert("");
    } else {
     echo "Warning...<br>";
    }
   }
   sendmail("errors@".PROJECT_DOMAIN, PROJECT_BUGTRACK, "Error reporting: $script", $description);
   if ($stop) exit;
  }
开发者ID:novozhenets,项目名称:majordomo,代码行数:28,代码来源:errors.class.php

示例3: 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

示例4: SQLSelectOne

                $gpsaction = SQLSelectOne($sqlQuery);
                if ($gpsaction['ID']) {
                    $gpsaction['EXECUTED'] = date('Y-m-d H:i:s');
                    $gpsaction['LOG'] = $gpsaction['EXECUTED'] . " Executed\n" . $gpsaction['LOG'];
                    SQLUpdate('gpsactions', $gpsaction);
                    if ($gpsaction['SCRIPT_ID']) {
                        runScript($gpsaction['SCRIPT_ID']);
                    } elseif ($gpsaction['CODE']) {
                        try {
                            $code = $gpsaction['CODE'];
                            $success = eval($code);
                            if ($success === false) {
                                DebMes("Error in GPS action code: " . $code);
                            }
                        } catch (Exception $e) {
                            DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
                        }
                    }
                }
            }
        }
    }
}
if ($user['LINKED_OBJECT'] && !$location_found) {
    setGlobal($user['LINKED_OBJECT'] . '.seenAt', '');
}
$sqlQuery = "SELECT *, DATE_FORMAT(ADDED, '%H:%i') as DAT\n               FROM shouts\n              ORDER BY ADDED DESC\n              LIMIT 1";
$tmp = SQLSelectOne($sqlQuery);
if (!headers_sent()) {
    header("HTTP/1.0: 200 OK\n");
    header('Content-Type: text/html; charset=utf-8');
开发者ID:cdkisa,项目名称:majordomo,代码行数:31,代码来源:gps.php

示例5: chdir

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,代码行数:29,代码来源:cycle_onewire.php

示例6: include_once

<?
/**
* Write Error script
*
* @package MajorDoMo
* @author Serge Dzheigalo <jey@tut.by> http://smartliving.ru/
* @version 1.1
*/


 include_once("./config.php");
 include_once("./lib/loader.php");

 if ($error) {
  echo $error;
  DebMes("JAVASCRIPT Error: ".$error);
 }

?>
开发者ID:novozhenets,项目名称:majordomo,代码行数:19,代码来源:write_error.php

示例7: 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

示例8: checkState

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkState($id)
 {
     $rec = SQLSelectOne("SELECT * FROM elm_states WHERE ID='" . $id . "'");
     if (!checkAccess('scene_elements', $rec['ELEMENT_ID'])) {
         $status = 0;
         return $status;
     }
     startMeasure('state_dynamic' . $rec['IS_DYNAMIC']);
     if (!$rec['IS_DYNAMIC']) {
         $status = 1;
     } elseif ($rec['IS_DYNAMIC'] == 1) {
         if ($rec['LINKED_OBJECT'] != '' && $rec['LINKED_PROPERTY'] != '') {
             $value = gg(trim($rec['LINKED_OBJECT']) . '.' . trim($rec['LINKED_PROPERTY']));
         } elseif ($rec['LINKED_PROPERTY'] != '') {
             $value = gg($rec['LINKED_PROPERTY']);
         } else {
             $value = -1;
         }
         if (($rec['CONDITION'] == 2 || $rec['CONDITION'] == 3) && $rec['CONDITION_VALUE'] != '' && !is_numeric($rec['CONDITION_VALUE']) && !preg_match('/^%/', $rec['CONDITION_VALUE'])) {
             $rec['CONDITION_VALUE'] = '%' . $rec['CONDITION_VALUE'] . '%';
         }
         if (is_integer(strpos($rec['CONDITION_VALUE'], "%"))) {
             $rec['CONDITION_VALUE'] = processTitle($rec['CONDITION_VALUE']);
         }
         if ($rec['CONDITION'] == 1 && $value == $rec['CONDITION_VALUE']) {
             $status = 1;
         } elseif ($rec['CONDITION'] == 2 && (double) $value > (double) $rec['CONDITION_VALUE']) {
             $status = 1;
         } elseif ($rec['CONDITION'] == 3 && (double) $value < (double) $rec['CONDITION_VALUE']) {
             $status = 1;
         } elseif ($rec['CONDITION'] == 4 && $value != $rec['CONDITION_VALUE']) {
             $status = 1;
         } else {
             $status = 0;
         }
     } elseif ($rec['IS_DYNAMIC'] == 2) {
         $display = 0;
         if (is_integer(strpos($rec['CONDITION_ADVANCED'], "%"))) {
             $rec['CONDITION_ADVANCED'] = processTitle($rec['CONDITION_ADVANCED']);
         }
         try {
             $code = $rec['CONDITION_ADVANCED'];
             $success = eval($code);
             if ($success === false) {
                 DebMes("Error in scene code: " . $code);
                 registerError('scenes', "Error in scene code: " . $code);
             }
         } catch (Exception $e) {
             DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
             registerError('scenes', get_class($e) . ', ' . $e->getMessage());
         }
         $status = $display;
     }
     endMeasure('state_dynamic' . $rec['IS_DYNAMIC']);
     if ($rec['CURRENT_STATE'] != $status) {
         startMeasure('stateUpdate');
         $rec['CURRENT_STATE'] = $status;
         SQLExec('UPDATE elm_states SET CURRENT_STATE=' . $rec['CURRENT_STATE'] . ' WHERE ID=' . (int) $rec['ID']);
         endMeasure('stateUpdate');
     }
     return $status;
 }
开发者ID:NioFBI,项目名称:majordomo,代码行数:69,代码来源:scenes.class.php

示例9: while

    while (($lib_file = readdir($lib_dir)) !== false) {
        if (preg_match("/^cycle_.+?\\.php\$/", $lib_file)) {
            $cycles[] = './scripts/' . $lib_file;
        }
    }
    closedir($lib_dir);
}
$threads = new Threads();
if (substr(php_uname(), 0, 7) == "Windows") {
    $threads->phpPath = '..\\server\\php\\php.exe';
} else {
    $threads->phpPath = 'php';
}
foreach ($cycles as $path) {
    if (file_exists($path)) {
        DebMes("Starting " . $path . " ... ");
        echo "Starting " . $path . " ... ";
        if (preg_match("/_X/", $path)) {
            //для начала убедимся, что мы в Линуксе. Иначе удаленный запуск этих скриптов не делаем
            if (substr(php_uname(), 0, 5) == "Linux") {
                $display = '101';
                //Попробуем получить номер Дисплея из имени файла
                if (preg_match("/_X(.+)_/", $path, $displays)) {
                    if (count($displays) > 1) {
                        $display = $displays[1];
                    }
                }
                //запускаем Линуксовый поцесс на дисплее, номер которого в имени файла после _X
                $pipe_id = $threads->newXThread($path, $display);
            }
        } else {
开发者ID:vasvlad,项目名称:majordomo,代码行数:31,代码来源:cycle.php

示例10: usual

 /**
 * FrontEnd
 *
 * Module frontend
 *
 * @access public
 */
 function usual(&$out)
 {
     global $op;
     global $ajax;
     if ($ajax) {
         //  DebMes("101msg");
         if (!headers_sent()) {
             header("HTTP/1.0: 200 OK\n");
             header('Content-Type: text/html; charset=utf-8');
         }
         if ($op == 'playstation') {
             global $id;
             $rec = SQLSelectOne("SELECT * FROM ru101_stations WHERE (ID='" . (int) $id . "' OR TITLE LIKE '" . DBSafe($id) . "')");
             DebMes('Getting radio page from ' . $rec['PAGE_URL']);
             if ($rec['PAGE_URL']) {
                 $data = getURL($rec['PAGE_URL'], 5);
                 if (preg_match('/(\\/api\\/channel\\/getServers\\/.+?)\'/isu', $data, $matches)) {
                     $json_url = 'http://101.ru' . $matches[1];
                     $data = getURL($json_url);
                     $radio_data = json_decode($data, true);
                     //DebMes(serialize($radio_data));
                     //return 0;
                     $playlist_url = $radio_data['playlist'][0]['file'];
                     if ($playlist_url != '') {
                         $out['PLAY'] = $playlist_url;
                         $url = BASE_URL . ROOTHTML . 'popup/app_player.html?ajax=1';
                         $url .= "&command=refresh&play=" . urlencode($out['PLAY']);
                         getURL($url, 0);
                     } else {
                         DebMes("Cannot find playlist in " . $json_url);
                     }
                 } else {
                     DebMes("Cannot find playlist in " . $rec['PAGE_URL']);
                 }
             }
             echo "OK";
         }
         exit;
     }
     $categories = SQLSelect("SELECT * FROM ru101_categories ORDER BY TITLE");
     $total = count($categories);
     for ($i = 0; $i < $total; $i++) {
         $categories[$i]['STATIONS'] = SQLSelect("SELECT * FROM ru101_stations WHERE CATEGORY_ID='" . $categories[$i]['ID'] . "' ORDER BY TITLE");
     }
     if (!$categories[0]['ID']) {
         $rec = array('ID' => 0, 'TITLE' => 'All');
         $rec['STATIONS'] = SQLSelect("SELECT * FROM ru101_stations WHERE 1 ORDER BY TITLE");
         $categories = array($rec);
     } else {
     }
     $out['CATEGORIES'] = $categories;
 }
开发者ID:sergejey,项目名称:majordomo-app_101ru,代码行数:59,代码来源:app_101ru.class.php

示例11: upload

 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 = $restore;
     } elseif ($file != '') {
         copy($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);
             //echo DOC_ROOT.'/tar xvf ../'.str_replace('.tgz', '.tar', $file);exit;
             exec(DOC_ROOT . '/tar xvf ../' . str_replace('.tgz', '.tar', $file), $output, $res);
         } else {
             exec('tar xzvf ../' . $file, $output, $res);
         }
         $x = 0;
         $dir = opendir('./');
         while (($filec = readdir($dir)) !== false) {
             if ($filec == '.' || $filec == '..') {
                 continue;
             }
             if (is_Dir($filec)) {
                 $latest_dir = $filec;
             } elseif (is_File($filec)) {
                 $latest_file = $filec;
             }
             $x++;
         }
         if ($x == 1 && $latest_dir) {
             $folder = '/' . $latest_dir;
         }
         @unlink(ROOT . 'saverestore/temp' . $folder . '/config.php');
         @unlink(ROOT . 'saverestore/temp' . $folder . '/README.md');
         chdir('../../');
         // UPDATING FILES DIRECTLY
         $this->copyTree(ROOT . 'saverestore/temp' . $folder, ROOT, 1);
         // restore all files
         $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");
         global $name;
         global $version;
         DebMes("Installing/updating plugin {$name} ({$version})");
         $rec = SQLSelectOne("SELECT * FROM plugins WHERE MODULE_NAME LIKE '" . DBSafe($name) . "'");
         $rec['MODULE_NAME'] = $name;
         $rec['CURRENT_VERSION'] = $version;
         $rec['IS_INSTALLED'] = 1;
         $rec['LATEST_UPDATE'] = date('Y-m-d H:i:s');
         if ($rec['ID']) {
             SQLUpdate('plugins', $rec);
         } else {
             SQLInsert('plugins', $rec);
         }
         $this->redirect("?mode=clear&ok_msg=" . urlencode("Updates Installed!"));
     }
 }
开发者ID:cdkisa,项目名称:majordomo,代码行数:79,代码来源:market.class.php

示例12: SQLExec

  for($i=0;$i<$total;$i++) {
   $command=utf2win($safe_execs[$i]['COMMAND']);
   SQLExec("DELETE FROM safe_execs WHERE ID='".$safe_execs[$i]['ID']."'");
   echo "Executing (exclusive): ".$command."\n";
   DebMes("Executing (exclusive): ".$command);
   exec($command);
  }


  $safe_execs=SQLSelect("SELECT * FROM safe_execs WHERE EXCLUSIVE=0 ORDER BY PRIORITY DESC, ID");
  $total=count($safe_execs);
  for($i=0;$i<$total;$i++) {
   $command=utf2win($safe_execs[$i]['COMMAND']);
   SQLExec("DELETE FROM safe_execs WHERE ID='".$safe_execs[$i]['ID']."'");
   echo "Executing: ".$command."\n";
   DebMes("Executing: ".$command);
   execInBackground($command);
  }



  runScheduledJobs();

  $m=date('i');
  $h=date('h');
  $dt=date('Y-m-d');
  if ($m!=$old_minute) {
   echo "new minute\n";
   $objects=SQLSelect("SELECT ID, TITLE FROM objects WHERE $o_qry");
   $total=count($objects);
   for($i=0;$i<$total;$i++) {
开发者ID:novozhenets,项目名称:majordomo,代码行数:31,代码来源:cycle.php

示例13: admin

 /**
 * BackEnd
 *
 * Module backend
 *
 * @access public
 */
 function admin(&$out)
 {
     global $ajax;
     if ($ajax) {
         global $op;
         global $item_id;
         if ($op == 'get_label') {
             startMeasure('getLabel');
             $item = SQLSelectOne("SELECT * FROM commands WHERE ID='" . (int) $item_id . "'");
             startMeasure('getLabel ' . $item['TITLE'], 1);
             if ($item['ID']) {
                 $res = array();
                 if ($item['TYPE'] == 'custom') {
                     $item['DATA'] = processTitle($item['DATA'], $this);
                     $res['DATA'] = $item['DATA'];
                 } else {
                     $item['TITLE'] = processTitle($item['TITLE'], $this);
                     $res['DATA'] = $item['TITLE'];
                 }
                 if ($item['RENDER_DATA'] != $item['DATA'] || $item['RENDER_TITLE'] != $item['TITLE']) {
                     $tmp = SQLSelectOne("SELECT * FROM commands WHERE ID='" . $item['ID'] . "'");
                     $tmp['RENDER_TITLE'] = $item['TITLE'];
                     $tmp['RENDER_DATA'] = $item['DATA'];
                     $tmp['RENDER_UPDATED'] = date('Y-m-d H:i:s');
                     SQLUpdate('commands', $tmp);
                 }
                 echo json_encode($res);
             }
             endMeasure('getLabel ' . $item['TITLE'], 1);
             endMeasure('getLabel', 1);
             exit;
         }
         if ($op == 'get_value') {
             startMeasure('getValue');
             $item = SQLSelectOne("SELECT * FROM commands WHERE ID='" . (int) $item_id . "'");
             if ($item['ID']) {
                 $res = array();
                 $res['DATA'] = $item['CUR_VALUE'];
                 echo json_encode($res);
             }
             endMeasure('getValue', 1);
             exit;
         }
         if ($op == 'value_changed') {
             global $new_value;
             $item = SQLSelectOne("SELECT * FROM commands WHERE ID='" . (int) $item_id . "'");
             if ($item['ID']) {
                 $item['CUR_VALUE'] = $new_value;
                 SQLUpdate('commands', $item);
                 if ($item['LINKED_PROPERTY'] != '') {
                     $old_value = gg($item['LINKED_OBJECT'] . '.' . $item['LINKED_PROPERTY']);
                     sg($item['LINKED_OBJECT'] . '.' . $item['LINKED_PROPERTY'], $item['CUR_VALUE'], array('commands' => 'ID!=' . $item['ID']));
                     //DebMes("setting property ".$item['LINKED_OBJECT'].".".$item['LINKED_PROPERTY']." to ".$item['CUR_VALUE']);
                 }
                 $params = array('VALUE' => $item['CUR_VALUE']);
                 if (isset($old_value)) {
                     $params['OLD_VALUE'] = $old_value;
                 }
                 if ($item['ONCHANGE_METHOD'] != '') {
                     getObject($item['ONCHANGE_OBJECT'])->callMethod($item['ONCHANGE_METHOD'], $params);
                     //DebMes("calling method ".$item['ONCHANGE_OBJECT'].".".$item['ONCHANGE_METHOD']." with ".$item['CUR_VALUE']);
                 }
                 if ($item['SCRIPT_ID']) {
                     //DebMes('Running on_change script #'.$item['SCRIPT_ID']);
                     runScript($item['SCRIPT_ID'], $params);
                 }
                 if ($item['CODE']) {
                     //DebMes("Running on_change code");
                     try {
                         $code = $item['CODE'];
                         $success = eval($code);
                         if ($success === false) {
                             DebMes("Error menu item code: " . $code);
                         }
                     } catch (Exception $e) {
                         DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
                     }
                 }
             }
             echo "OK";
         }
         exit;
     }
     if (isset($this->data_source) && !$_GET['data_source'] && !$_POST['data_source']) {
         $out['SET_DATASOURCE'] = 1;
     }
     if ($this->data_source == 'commands' || $this->data_source == '') {
         if ($this->view_mode == '' || $this->view_mode == 'search_commands') {
             startMeasure('searchCommands');
             $this->search_commands($out);
             endMeasure('searchCommands', 1);
         }
         if ($this->view_mode == 'edit_commands') {
//.........这里部分代码省略.........
开发者ID:vasvlad,项目名称:majordomo,代码行数:101,代码来源:commands.class.php

示例14: checkState

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkState($id)
 {
     $rec = SQLSelectOne("SELECT * FROM elm_states WHERE ID='" . $id . "'");
     if (!$rec['IS_DYNAMIC']) {
         $status = 1;
     } elseif ($rec['IS_DYNAMIC'] == 1) {
         if ($rec['LINKED_OBJECT'] != '' && $rec['LINKED_PROPERTY'] != '') {
             $value = gg(trim($rec['LINKED_OBJECT']) . '.' . trim($rec['LINKED_PROPERTY']));
         } elseif ($rec['LINKED_PROPERTY'] != '') {
             $value = gg($rec['LINKED_PROPERTY']);
         } else {
             $value = -1;
         }
         if ($rec['CONDITION'] == 1 && $value == $rec['CONDITION_VALUE']) {
             $status = 1;
         } elseif ($rec['CONDITION'] == 2 && (double) $value > (double) $rec['CONDITION_VALUE']) {
             $status = 1;
         } elseif ($rec['CONDITION'] == 3 && (double) $value < (double) $rec['CONDITION_VALUE']) {
             $status = 1;
         } elseif ($rec['CONDITION'] == 4 && $value != $rec['CONDITION_VALUE']) {
             $status = 1;
         } else {
             $status = 0;
         }
     } elseif ($rec['IS_DYNAMIC'] == 2) {
         $display = 0;
         try {
             $code = $rec['CONDITION_ADVANCED'];
             $success = eval($code);
             if ($success === false) {
                 DebMes("Error in scene code: " . $code);
             }
         } catch (Exception $e) {
             DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
         }
         $status = $display;
     }
     if ($rec['CURRENT_STATE'] != $status) {
         $rec['CURRENT_STATE'] = $status;
         SQLExec('UPDATE elm_states SET CURRENT_STATE=' . $rec['CURRENT_STATE'] . ' WHERE ID=' . (int) $rec['ID']);
     }
     return $status;
 }
开发者ID:vasvlad,项目名称:majordomo,代码行数:50,代码来源:scenes.class.php

示例15: checkPattern

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkPattern($id)
 {
     global $session;
     global $pattern_matched;
     $rec = SQLSelectOne("SELECT * FROM patterns WHERE ID='" . (int) $id . "'");
     if (!$rec['PATTERN']) {
         $pattern = $rec['TITLE'];
     } else {
         $pattern = $rec['PATTERN'];
     }
     $pattern = str_replace("\r", '', $pattern);
     if ($pattern == '') {
         return 0;
     }
     if ($rec['EXECUTED'] > 0 && $rec['TIME_LIMIT'] && time() - $rec['EXECUTED'] <= $rec['TIME_LIMIT']) {
         return 0;
     }
     $lines_pattern = explode("\n", $pattern);
     $total_lines = count($lines_pattern);
     if (!$rec['TIME_LIMIT']) {
         $messages = SQLSelect("SELECT MESSAGE FROM shouts ORDER BY ID DESC LIMIT " . (int) $total_lines);
         $messages = array_reverse($messages);
     } else {
         $start_from = time() - $rec['TIME_LIMIT'];
         $messages = SQLSelect("SELECT MESSAGE FROM shouts WHERE ADDED>=('" . date('Y-m-d H:i:s', $start_from) . "') ORDER BY ADDED");
     }
     $total = count($messages);
     if (!$total) {
         return 0;
     }
     $lines = array();
     for ($i = 0; $i < $total; $i++) {
         $lines[] = $messages[$i]['MESSAGE'];
     }
     $history = implode('@@@@', $lines);
     $check = implode('@@@@', $lines_pattern);
     if (preg_match('/' . $check . '/is', $history, $matches)) {
         if (checkAccess('pattern', $rec['ID'])) {
             $is_common = 0;
             if ($rec['PARENT_ID']) {
                 $parent_rec = SQLSelectOne("SELECT IS_COMMON_CONTEXT FROM patterns WHERE ID='" . $rec['PARENT_ID'] . "'");
                 $is_common = (int) $parent_rec['IS_COMMON_CONTEXT'];
             }
             if ($rec['IS_CONTEXT']) {
                 context_activate($rec['ID']);
             } elseif ($rec['MATCHED_CONTEXT_ID']) {
                 context_activate($rec['MATCHED_CONTEXT_ID']);
             } elseif (!$is_common) {
                 context_activate(0);
             }
             $rec['LOG'] = date('Y-m-d H:i:s') . ' Pattern matched' . "\n" . $rec['LOG'];
             $rec['EXECUTED'] = time();
             SQLUpdate('patterns', $rec);
             global $noPatternMode;
             $noPatternMode = 1;
             $pattern_matched = 1;
             if ($rec['SCRIPT_ID']) {
                 runScript($rec['SCRIPT_ID'], $matches);
             } elseif ($rec['SCRIPT']) {
                 try {
                     $code = $rec['SCRIPT'];
                     $success = eval($code);
                     if ($success === false) {
                         DebMes("Error in pattern code: " . $code);
                     }
                 } catch (Exception $e) {
                     DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
                 }
             }
             $noPatternMode = 0;
         }
     }
     if ($pattern_matched) {
         return 1;
     } else {
         return 0;
     }
 }
开发者ID:vasvlad,项目名称:majordomo,代码行数:85,代码来源:patterns.class.php


注:本文中的DebMes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。