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


PHP SQLUpdate函数代码示例

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


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

示例1: context_activate_ext

function context_activate_ext($id, $timeout = 0, $timeout_code = '', $timeout_context_id = 0)
{
    $user_id = context_getuser();
    $user = SQLSelectOne("SELECT * FROM users WHERE ID='" . (int) $user_id . "'");
    $user['ACTIVE_CONTEXT_ID'] = $id;
    if ($id) {
        $user['ACTIVE_CONTEXT_EXTERNAL'] = 1;
    } else {
        $user['ACTIVE_CONTEXT_EXTERNAL'] = 0;
    }
    $user['ACTIVE_CONTEXT_UPDATED'] = date('Y-m-d H:i:s');
    DebMes("setting external context: " . $id);
    SQLUpdate('users', $user);
    if ($id) {
        //execute pattern
        if (!$timeout) {
            $timeout = 60;
        }
        $ev = '';
        if ($timeout_code) {
            $ev .= $timeout_code;
        }
        if ($timeout_context_id) {
            $ev .= "context_activate_ext(" . (int) $timeout_context_id . ");";
        } else {
            $ev .= "context_clear();";
        }
        setTimeOut('user_' . $user_id . '_contexttimeout', $ev, $timeout);
    } else {
        context_clear();
        clearTimeOut('user_' . $user_id . '_contexttimeout');
    }
}
开发者ID:vasvlad,项目名称:majordomo,代码行数:33,代码来源:context.inc.php

示例2: removeMissingSubscribers

function removeMissingSubscribers()
{
    $settings = SQLSelect("SELECT * FROM settings WHERE NAME LIKE 'HOOK_EVENT_%' AND TYPE='json'");
    $total = count($settings);
    for ($i = 0; $i < $total; $i++) {
        $data = json_decode($settings[$i]['VALUE'], true);
        $changed = 0;
        if (is_array($data)) {
            foreach ($data as $k => $v) {
                $module_name = $k;
                if (!file_exists(DIR_MODULES . 'modules/' . $module_name . '/' . $module_name . '.class.php')) {
                    unset($data[$module_name]);
                    $changed = 1;
                }
            }
            if ($changed) {
                $settings[$i]['VALUE'] = json_encode($data);
                SQLUpdate('settings', $settings[$i]);
            }
        }
    }
}
开发者ID:AirKing555,项目名称:majordomo,代码行数:22,代码来源:hooks.inc.php

示例3: updateTree_product_categories

 /**
 * product_categories update tree
 *
 * @access private
 */
 function updateTree_product_categories($parent_id = 0, $parent_list = '')
 {
     $table = 'product_categories';
     if (!is_array($parent_list)) {
         $parent_list = array();
     }
     $sub_list = array();
     $res = SQLSelect("SELECT * FROM {$table} WHERE PARENT_ID='{$parent_id}'");
     $total = count($res);
     for ($i = 0; $i < $total; $i++) {
         if ($parent_list[0]) {
             $res[$i]['PARENT_LIST'] = implode(',', $parent_list);
         } else {
             $res[$i]['PARENT_LIST'] = '0';
         }
         $sub_list[] = $res[$i]['ID'];
         $tmp_parent = $parent_list;
         $tmp_parent[] = $res[$i]['ID'];
         $sub_this = $this->updateTree_product_categories($res[$i]['ID'], $tmp_parent);
         if ($sub_this[0]) {
             $res[$i]['SUB_LIST'] = implode(',', $sub_this);
         } else {
             $res[$i]['SUB_LIST'] = $res[$i]['ID'];
         }
         SQLUpdate($table, $res[$i]);
         $sub_list = array_merge($sub_list, $sub_this);
     }
     return $sub_list;
 }
开发者ID:cdkisa,项目名称:majordomo,代码行数:34,代码来源:app_products.class.php

示例4: propertySetHandle

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function propertySetHandle($object, $property, $value)
 {
     $commands = SQLSelect("SELECT * FROM commands WHERE LINKED_OBJECT LIKE '" . DBSafe($object) . "' AND LINKED_PROPERTY LIKE '" . DBSafe($property) . "'");
     $total = count($commands);
     for ($i = 0; $i < $total; $i++) {
         $commands[$i]['CUR_VALUE'] = $value;
         SQLUpdate('commands', $commands[$i]);
     }
 }
开发者ID:NioFBI,项目名称:majordomo,代码行数:16,代码来源:commands.class.php

示例5: usual

 /**
 * FrontEnd
 *
 * Module frontend
 *
 * @access public
 */
 function usual(&$out)
 {
     global $session;
     if ($this->action == 'addevent') {
         global $mode;
         $this->mode = $mode;
         if ($this->mode == 'update') {
             global $type;
             global $window;
             global $details;
             global $terminal_to;
             global $user_to;
             $event = array();
             $event['EVENT_TYPE'] = $type;
             $event['WINDOW'] = $window;
             $event['DETAILS'] = $details;
             $event['TERMINAL_TO'] = $terminal_to;
             $event['TERMINAL_FROM'] = $session->data['TERMINAL'];
             $event['USER_TO'] = $user_to;
             $event['USER_FROM'] = $session->data['USERNAME'];
             $event['ADDED'] = date('Y-m-d H:i:s');
             $event['EXPIRE'] = date('Y-m-d H:i:s', time() + 5 * 60);
             //5 minutes expire
             SQLInsert('events', $event);
         }
         $terminals = SQLSelect("SELECT * FROM terminals ORDER BY TITLE");
         $total = count($terminals);
         for ($i = 0; $i < $total; $i++) {
             if ($terminals[$i]['NAME'] == $session->data['TERMINAL']) {
                 $terminals[$i]['SELECTED'] = 1;
                 $out['TERMINAL_TITLE'] = $terminals[$i]['TITLE'];
             }
         }
         $out['TERMINALS'] = $terminals;
         $users = SQLSelect("SELECT * FROM users ORDER BY NAME");
         $total = count($users);
         for ($i = 0; $i < $total; $i++) {
             if ($users[$i]['USERNAME'] == $session->data['USERNAME']) {
                 $users[$i]['SELECTED'] = 1;
                 $out['USER_TITLE'] = $users[$i]['NAME'];
             }
         }
         $out['USERS'] = $users;
     }
     if ($this->action == 'getnextevent') {
         if (!$session->data['TERMINAL']) {
             $session->data['TERMINAL'] = 'temp' . date('YmdHis');
         }
         //echo "next event for ".$session->data['USERNAME']." on ".$session->data['TERMINAL'];//.date('H:i:s')
         SQLExec("DELETE FROM events WHERE EXPIRE<NOW() AND EVENT_TYPE!='system'");
         $qry = "1";
         //$qry.=" AND TERMINAL_FROM!='".DBSafe($session->data['TERMINAL'])."'";
         $qry .= " AND EVENT_TYPE!='system'";
         $qry .= " AND PROCESSED=0";
         $qry .= " AND (TERMINAL_TO='*' OR TERMINAL_TO='" . DBSafe($session->data['TERMINAL']) . "')";
         $qry .= " AND (USER_TO='*' OR USER_TO='" . DBSafe($session->data['USERNAME']) . "')";
         $event = SQLSelectOne("SELECT * FROM events WHERE {$qry} ORDER BY ADDED");
         if ($event['ID']) {
             $res = $event['ID'] . '|' . $event['EVENT_TYPE'] . '|' . $event['WINDOW'] . '|' . str_replace("\n", '\\n', $event['DETAILS']);
             echo $res;
             $event['PROCESSED'] = 1;
             SQLUpdate('events', $event);
         }
         exit;
     }
 }
开发者ID:NioFBI,项目名称:majordomo,代码行数:73,代码来源:events.class.php

示例6: SQLUpdate

             $state_rec['CONDITION_ADVANCED'] = '';
         }
     }
     $state_rec['SWITCH_SCENE'] = (int) $switch_scene_new;
     if ($state_rec['ID']) {
         SQLUpdate('elm_states', $state_rec);
     } else {
         $state_rec['ID'] = SQLInsert('elm_states', $state_rec);
         $state_id = $state_rec['ID'];
     }
 } elseif ($element['TYPE'] == 'container') {
     $state_rec['TITLE'] = 'default';
     $state_rec['ELEMENT_ID'] = $element['ID'];
     $state_rec['TITLE'] = $state_title_new;
     if ($state_rec['ID']) {
         SQLUpdate('elm_states', $state_rec);
     } else {
         $state_rec['ID'] = SQLInsert('elm_states', $state_rec);
         $state_id = $state_rec['ID'];
     }
 } elseif (($element['TYPE'] == 'nav' || $element['TYPE'] == 'navgo') && !$state_rec['ID']) {
     $state_rec = array();
     $state_rec['TITLE'] = 'default';
     $state_rec['ELEMENT_ID'] = $element['ID'];
     $state_rec['HTML'] = $element['TITLE'];
     $state_rec['ID'] = SQLInsert('elm_states', $state_rec);
     $state_id = $state_rec['ID'];
 } elseif ($element['TYPE'] == 'button' && !$state_rec['ID']) {
     global $linked_object;
     global $linked_method;
     $state_rec = array();
开发者ID:NioFBI,项目名称:majordomo,代码行数:31,代码来源:scenes_edit.inc.php

示例7: edit_btdevices

 /**
 * btdevices edit/add
 *
 * @access public
 */
 function edit_btdevices(&$out, $id)
 {
     $rec = SQLSelectOne("SELECT * FROM btdevices WHERE ID='" . (int) $id . "'");
     if ($this->mode == 'update') {
         global $title;
         global $user_id;
         $rec['TITLE'] = $title;
         $rec['USER_ID'] = $user_id;
         SQLUpdate('btdevices', $rec);
         $this->redirect("?");
     }
     $rec['LOG'] = nl2br($rec['LOG']);
     outHash($rec, $out);
     $out['USERS'] = SQLSelect("SELECT * FROM users ORDER BY NAME");
 }
开发者ID:vasvlad,项目名称:majordomo,代码行数:20,代码来源:btdevices.class.php

示例8: saveConfig

/**
* Saving module configuration
*
* Used for saving $this->config variable in project module repository database for future
*
* @access public
*/
 function saveConfig() {
  $rec=SQLSelectOne("SELECT * FROM project_modules WHERE NAME='".$this->name."'");
  $rec["DATA"]=serialize($this->config);
  SQLUpdate("project_modules", $rec);
 }
开发者ID:novozhenets,项目名称:majordomo,代码行数:12,代码来源:module.class.php

示例9: removeLinkedProperty

function removeLinkedProperty($object, $property, $module)
{
    $value = SQLSelectOne("SELECT * FROM pvalues WHERE ID='" . getValueIdByName($object, $property) . "'");
    if ($value['ID']) {
        if (!$value['LINKED_MODULES']) {
            $tmp = array();
        } else {
            $tmp = explode(',', $value['LINKED_MODULES']);
        }
        if (in_array($module, $tmp)) {
            $total = count($tmp);
            $res = array();
            for ($i = 0; $i < $total; $i++) {
                if ($tmp[$i] != $module) {
                    $res[] = $tmp[$i];
                }
            }
            $tmp = $res;
            $value['LINKED_MODULES'] = implode(',', $tmp);
            SQLUpdate('pvalues', $value);
        }
    } else {
        return 0;
    }
}
开发者ID:AirKing555,项目名称:majordomo,代码行数:25,代码来源:objects.class.php

示例10: str_replace

 */
if ($action == 'testdata') {
    if ($step < 2) {
        $content = str_replace(array("\r", "\n\n", ";\n"), array('', "\n", ";<wind>\n"), trim(readover(R_P . 'lang/example.sql'), " \n"));
        //$content = preg_replace("/{#(.+?)}/eis",'$lang[\\1]',$content).'<wind>';
        $content = explode("\n", $content);
        $writearray = SQLCreate($content);
    }
    @set_time_limit(200);
    if (!file_exists(D_P . 'data/sql_config.php')) {
        Promptmsg('config_noexists', 'database');
    } else {
        $db = pwNewDBForInstall();
    }
    $sqlcache = readover(D_P . 'data/install_sys.sql');
    $update = SQLUpdate($sqlcache, 500);
    if ($update) {
        $step = $step ? $step + 1 : 2;
        $stepstring = str_pad('..', $step);
        $input = "<input type=\"hidden\" name=\"step\" value=\"{$step}\">";
        Promptmsg('install_initdata', $action, true);
    } else {
        require_once R_P . 'admin/cache.php';
        $pwChannel = L::loadClass('channelservice', 'area');
        $pwChannel->updateAreaChannels();
        require R_P . 'lang/step/nav_tiyan.php';
        //设置门户首页为默认首页
        $update = array('area_default_alias', 'string', 'finance', '');
        $db->update("REPLACE INTO pw_hack VALUES (" . pwImplode($update) . ')');
        //更新关联版块信息
        updatecache_cnc();
开发者ID:sherlockhouse,项目名称:aliyun,代码行数:31,代码来源:install.php

示例11: checkAllVars

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkAllVars($force = 0)
 {
     // ping hosts
     if ($force) {
         $pings = SQLSelect("SELECT * FROM webvars WHERE 1");
     } else {
         $pings = SQLSelect("SELECT * FROM webvars WHERE CHECK_NEXT<=NOW()");
     }
     $total = count($pings);
     for ($i = 0; $i < $total; $i++) {
         $host = $pings[$i];
         if (!$force) {
             echo date('H:i:s') . " Checking webvar: " . processTitle($host['HOSTNAME']) . "\n";
         }
         if (!$host['HOSTNAME']) {
             continue;
         }
         $online_interval = $host['ONLINE_INTERVAL'];
         if (!$online_interval) {
             $online_interval = 60;
         }
         $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $online_interval);
         SQLUpdate('webvars', $host);
         // checking
         //web host
         $old_status = $host['LATEST_VALUE'];
         if ($host['AUTH'] && $host['USERNAME']) {
             $content = getURL(processTitle($host['HOSTNAME']), $host['ONLINE_INTERVAL'], $host['USERNAME'], $host['PASSWORD']);
         } else {
             $content = getURL(processTitle($host['HOSTNAME']), $host['ONLINE_INTERVAL']);
         }
         if ($host['ENCODING'] != '') {
             $content = iconv($host['ENCODING'], "UTF-8", $content);
         }
         $ok = 1;
         $new_status = '';
         if ($host['SEARCH_PATTERN']) {
             if (preg_match('/' . $host['SEARCH_PATTERN'] . '/is', $content, $m)) {
                 //$new_status=$m[1];
                 $total1 = count($m);
                 for ($i1 = 1; $i1 < $total1; $i1++) {
                     $new_status .= $m[$i1];
                 }
             } else {
                 $ok = 0;
                 // result did not matched
             }
         } else {
             $new_status = $content;
         }
         if ($host['CHECK_PATTERN'] && !preg_match('/' . $host['CHECK_PATTERN'] . '/is', $new_status)) {
             $ok = 0;
             // result did not pass the check
         }
         if (strlen($new_status) > 50 * 1024) {
             $new_status = substr($new_status, 0, 50 * 1024);
         }
         if (!$ok) {
             $host['LOG'] = date('Y-m-d H:i:s') . ' incorrect value:' . $new_status . "\n" . $host['LOG'];
             $tmp = explode("\n", $host['LOG']);
             $total = count($tmp);
             if ($total > 50) {
                 $tmp = array_slice($tmp, 0, 50);
                 $host['LOG'] = implode("\n", $tmp);
             }
             SQLUpdate('webvars', $host);
             continue;
         }
         $host['CHECK_LATEST'] = date('Y-m-d H:i:s');
         $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $online_interval);
         if ($old_status != $new_status) {
             $host['LOG'] = date('Y-m-d H:i:s') . ' new value:' . $new_status . "\n" . $host['LOG'];
             $tmp = explode("\n", $host['LOG']);
             $total = count($tmp);
             if ($total > 50) {
                 $tmp = array_slice($tmp, 0, 50);
                 $host['LOG'] = implode("\n", $tmp);
             }
         }
         $host['LATEST_VALUE'] = $new_status;
         SQLUpdate('webvars', $host);
         if ($host['LINKED_OBJECT'] != '' && $host['LINKED_PROPERTY'] != '') {
             getObject($host['LINKED_OBJECT'])->setProperty($host['LINKED_PROPERTY'], $new_status);
         }
         if ($old_status != $new_status && $old_status != '') {
             $params = array('VALUE' => $new_status);
             // do some status change actions
             $run_script_id = 0;
             $run_code = '';
             // got online
             if ($host['SCRIPT_ID']) {
                 $run_script_id = $host['SCRIPT_ID'];
             } elseif ($host['CODE']) {
//.........这里部分代码省略.........
开发者ID:cdkisa,项目名称:majordomo,代码行数:101,代码来源:webvars.class.php

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

示例13: addLinkedProperty

            // adding new record
        }
        if ($rec['LINKED_OBJECT'] && $rec['LINKED_PROPERTY']) {
            addLinkedProperty($rec['LINKED_OBJECT'], $rec['LINKED_PROPERTY'], $this->name);
        }
        if ($old_linked_object && $old_linked_object != $rec['LINKED_OBJECT'] && $old_linked_property && $old_linked_property != $rec['LINKED_PROPERTY']) {
            removeLinkedProperty($old_linked_object, $old_linked_property, $this->name);
        }
        $out['OK'] = 1;
    } else {
        $out['ERR'] = 1;
    }
    global $new_value;
    if ($new_value) {
        $rec['VALUE'] = $new_value;
        SQLUpdate('mqtt', $rec);
        $this->setProperty($rec['ID'], $new_value, 1);
    }
}
//options for 'LOCATION_ID' (select)
$tmp = SQLSelect("SELECT ID, TITLE FROM locations ORDER BY TITLE");
$locations_total = count($tmp);
for ($locations_i = 0; $locations_i < $locations_total; $locations_i++) {
    $location_id_opt[$tmp[$locations_i]['ID']] = $tmp[$locations_i]['TITLE'];
}
for ($i = 0; $i < count($tmp); $i++) {
    if ($rec['LOCATION_ID'] == $tmp[$i]['ID']) {
        $tmp[$i]['SELECTED'] = 1;
    }
}
$out['LOCATION_ID_OPTIONS'] = $tmp;
开发者ID:sergejey,项目名称:majordomo-mqtt,代码行数:31,代码来源:mqtt_edit.inc.php

示例14: checkAllHosts

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkAllHosts($limit = 1000)
 {
     // ping hosts
     $pings = SQLSelect("SELECT * FROM pinghosts WHERE CHECK_NEXT<=NOW() ORDER BY CHECK_NEXT LIMIT " . $limit);
     $total = count($pings);
     for ($i = 0; $i < $total; $i++) {
         $host = $pings[$i];
         echo "Checking " . $host['HOSTNAME'] . "\n";
         $online_interval = $host['ONLINE_INTERVAL'];
         if (!$online_interval) {
             $online_interval = 60;
         }
         $offline_interval = $host['OFFLINE_INTERVAL'];
         if (!$offline_interval) {
             $offline_interval = $online_interval;
         }
         if ($host['STATUS'] == '1') {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $online_interval);
         } else {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $offline_interval);
         }
         SQLUpdate('pinghosts', $host);
         $online = 0;
         // checking
         if (!$host['TYPE']) {
             //ping host
             $online = ping(processTitle($host['HOSTNAME']));
         } else {
             //web host
             $online = getURL(processTitle($host['HOSTNAME']), 0);
             SaveFile("./cached/host_" . $host['ID'] . '.html', $online);
             if ($host['SEARCH_WORD'] != '' && !is_integer(strpos($online, $host['SEARCH_WORD']))) {
                 $online = 0;
             }
             if ($online) {
                 $online = 1;
             }
         }
         if ($online) {
             $new_status = 1;
         } else {
             $new_status = 2;
         }
         $old_status = $host['STATUS'];
         if ($host['COUNTER_REQUIRED']) {
             $old_status_expected = $host['STATUS_EXPECTED'];
             $host['STATUS_EXPECTED'] = $new_status;
             if ($old_status_expected != $host['STATUS_EXPECTED']) {
                 $host['COUNTER_CURRENT'] = 0;
                 $host['LOG'] = date('Y-m-d H:i:s') . ' tries counter reset (status: ' . $host['STATUS_EXPECTED'] . ')' . "\n" . $host['LOG'];
             } elseif ($host['STATUS'] != $host['STATUS_EXPECTED']) {
                 $host['COUNTER_CURRENT']++;
                 $host['LOG'] = date('Y-m-d H:i:s') . ' tries counter increased to ' . $host['COUNTER_CURRENT'] . ' (status: ' . $host['STATUS_EXPECTED'] . ')' . "\n" . $host['LOG'];
             }
             if ($host['COUNTER_CURRENT'] >= $host['COUNTER_REQUIRED']) {
                 $host['STATUS'] = $host['STATUS_EXPECTED'];
                 $host['COUNTER_CURRENT'] = 0;
             } else {
                 $interval = min($online_interval, $offline_interval, 20);
                 $online_interval = $interval;
                 $offline_interval = $interval;
             }
         } else {
             $host['STATUS'] = $new_status;
             $host['STATUS_EXPECTED'] = $host['STATUS'];
             $host['COUNTER_CURRENT'] = 0;
         }
         $host['CHECK_LATEST'] = date('Y-m-d H:i:s');
         if ($host['LINKED_OBJECT'] != '' && $host['LINKED_PROPERTY'] != '') {
             setGlobal($host['LINKED_OBJECT'] . '.' . $host['LINKED_PROPERTY'], $host['STATUS']);
         }
         if ($host['STATUS'] == '1') {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $online_interval);
         } else {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $offline_interval);
         }
         if ($old_status != $host['STATUS']) {
             if ($host['STATUS'] == 2) {
                 $host['LOG'] .= date('Y-m-d H:i:s') . ' Host is offline' . "\n";
             } elseif ($host['STATUS'] == 1) {
                 $host['LOG'] .= date('Y-m-d H:i:s') . ' Host is online' . "\n";
             }
             $tmp = explode("\n", $host['LOG']);
             $total = count($tmp);
             if ($total > 50) {
                 $tmp = array_slice($tmp, 0, 50);
                 $host['LOG'] = implode("\n", $tmp);
             }
         }
         SQLUpdate('pinghosts', $host);
         if ($old_status != $host['STATUS'] && $old_status != 0) {
             // do some status change actions
             $run_script_id = 0;
//.........这里部分代码省略.........
开发者ID:cdkisa,项目名称:majordomo,代码行数:101,代码来源:pinghosts.class.php

示例15: checkWatchFolder

 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkWatchFolder($id, $no_script = 0)
 {
     $rec = SQLSelectOne("SELECT * FROM watchfolders WHERE ID=" . (int) $id);
     if (!$rec['ID']) {
         return 0;
     }
     $res = $this->getTree($rec['FOLDER'], $rec['CHECK_SUB'], $rec['CHECK_MASK']);
     $rec['CHECK_LATEST'] = date('Y-m-d H:i:s');
     if (!$rec['CHECK_INTERVAL']) {
         $rec['CHECK_INTERVAL'] = 60;
     }
     $rec['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $rec['CHECK_INTERVAL'] * 60);
     if ($rec['CHECK_RESULTS'] != serialize($res)) {
         $files_updated = 1;
     } else {
         $files_updated = 0;
     }
     if ($rec['CHECK_RESULTS']) {
         $last_check_results = unserialize($rec['CHECK_RESULTS']);
     } else {
         $last_check_results = array();
     }
     $rec['CHECK_RESULTS'] = serialize($res);
     SQLUpdate('watchfolders', $rec);
     if ($files_updated && !$no_script && $rec['SCRIPT_ID'] && $rec['SCRIPT_TYPE']) {
         //checking for updated files
         $new_files = array();
         foreach ($res as $k => $v) {
             if (!$last_check_results[$k] || $last_check_results[$k]['SIZE'] != $res[$k]['SIZE']) {
                 $new_files[$k] = $v;
             }
         }
         //run script if set
         if ($rec['SCRIPT_TYPE'] == 2) {
             // run script for all files
             $params = array();
             $params['FOLDER'] = $rec['FOLDER'];
             $params['FILES_UPDATED'] = $new_files;
             runScript($rec['SCRIPT_ID'], $params);
         } elseif ($rec['SCRIPT_TYPE'] == 1) {
             // run script for every new file
             foreach ($new_files as $k => $v) {
                 $params = array();
                 $params['FOLDER'] = $rec['FOLDER'];
                 $params['FILENAME'] = $k;
                 runScript($rec['SCRIPT_ID'], $params);
             }
         }
     }
 }
开发者ID:vasvlad,项目名称:majordomo,代码行数:57,代码来源:watchfolders.class.php


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