コード例 #1
0
ファイル: context.inc.php プロジェクト: vasvlad/majordomo
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');
    }
}
コード例 #2
0
ファイル: gps.php プロジェクト: cdkisa/majordomo
         setGlobal($user['LINKED_OBJECT'] . '.Coordinates', $rec['LAT'] . ',' . $rec['LON']);
         setGlobal($user['LINKED_OBJECT'] . '.CoordinatesUpdated', date('H:i'));
         setGlobal($user['LINKED_OBJECT'] . '.CoordinatesUpdatedTimestamp', time());
         setGlobal($user['LINKED_OBJECT'] . '.BattLevel', $rec['BATTLEVEL']);
         setGlobal($user['LINKED_OBJECT'] . '.Charging', $rec['CHARGING']);
         $sqlQuery = "SELECT *\n                        FROM gpslog\n                       WHERE ID        != '" . $rec['ID'] . "'\n                         AND DEVICE_ID = '" . $device['ID'] . "'\n                       ORDER BY ID DESC\n                       LIMIT 1";
         $prev_log = SQLSelectOne($sqlQuery);
         if ($prev_log['ID']) {
             $distance = calculateTheDistance($rec['LAT'], $rec['LON'], $prev_log['LAT'], $prev_log['LON']);
             if ($distance > 100) {
                 //we're moving
                 $objectIsMoving = $user['LINKED_OBJECT'] . '.isMoving';
                 setGlobal($objectIsMoving, 1);
                 clearTimeOut($user['LINKED_OBJECT'] . '_moving');
                 // stopped after 15 minutes of inactivity
                 setTimeOut($user['LINKED_OBJECT'] . '_moving', "setGlobal('" . $objectIsMoving . "', 0);", 15 * 60);
             }
         }
     }
 }
 // checking locations
 $lat = (double) $_REQUEST['latitude'];
 $lon = (double) $_REQUEST['longitude'];
 $locations = SQLSelect("SELECT * FROM gpslocations");
 $total = count($locations);
 $location_found = 0;
 for ($i = 0; $i < $total; $i++) {
     if (!$locations[$i]['RANGE']) {
         $locations[$i]['RANGE'] = GPS_LOCATION_RANGE_DEFAULT;
     }
     $distance = calculateTheDistance($lat, $lon, $locations[$i]['LAT'], $locations[$i]['LON']);
コード例 #3
0
ファイル: jobs.class.php プロジェクト: vasvlad/majordomo
 /**
 * jobs search
 *
 * @access public
 */
 function search_jobs(&$out)
 {
     //require(DIR_MODULES.$this->name.'/jobs_search.inc.php');
     if ($this->mode == 'add') {
         global $commands;
         global $runin;
         global $runtype;
         global $title;
         if ($commands != '' && $title != '') {
             if ($runtype == 'm') {
                 $runin = $runin * 60;
             } elseif ($runtype == 'h') {
                 $runin = $runin * 60 * 60;
             }
             setTimeOut($title, $commands, $runin);
             $this->redirect("?");
         }
     }
     if ($this->mode == 'cancel') {
         global $id;
         deleteScheduledJob($id);
         $this->redirect("?");
     }
     $jobs = SQLSelect("SELECT * FROM jobs ORDER BY RUNTIME");
     if ($jobs[0]['ID']) {
         $out['JOBS'] = $jobs;
     }
 }
コード例 #4
0
ファイル: gps.php プロジェクト: vasvlad/majordomo
     $user = SQLSelectOne("SELECT * FROM users WHERE ID='" . $device['USER_ID'] . "'");
     if ($user['LINKED_OBJECT']) {
         setGlobal($user['LINKED_OBJECT'] . '.Coordinates', $rec['LAT'] . ',' . $rec['LON']);
         setGlobal($user['LINKED_OBJECT'] . '.CoordinatesUpdated', date('H:i'));
         setGlobal($user['LINKED_OBJECT'] . '.CoordinatesUpdatedTimestamp', time());
         setGlobal($user['LINKED_OBJECT'] . '.BattLevel', $rec['BATTLEVEL']);
         setGlobal($user['LINKED_OBJECT'] . '.Charging', $rec['CHARGING']);
         $prev_log = SQLSelectOne("SELECT * FROM gpslog WHERE ID!='" . $rec['ID'] . "' AND DEVICE_ID='" . $device['ID'] . "' ORDER BY ID DESC LIMIT 1");
         if ($prev_log['ID']) {
             $distance = calculateTheDistance($rec['LAT'], $rec['LON'], $prev_log['LAT'], $prev_log['LON']);
             if ($distance > 100) {
                 //we're moving
                 //DebMes("Distance: ".$distance. " (point A: ".$rec['LAT'].":".$rec['LON']." point B: ".$prev_log['LAT'].":".$prev_log['LON'].")");
                 setGlobal($user['LINKED_OBJECT'] . '.isMoving', 1);
                 clearTimeOut($user['LINKED_OBJECT'] . '_moving');
                 setTimeOut($user['LINKED_OBJECT'] . '_moving', "setGlobal('" . $user['LINKED_OBJECT'] . ".isMoving', 0);", 15 * 60);
                 // stopped after 15 minutes of inactivity
             }
         }
     }
 }
 // checking locations
 $lat = (double) $_REQUEST['latitude'];
 $lon = (double) $_REQUEST['longitude'];
 $locations = SQLSelect("SELECT * FROM gpslocations");
 $total = count($locations);
 $location_found = 0;
 for ($i = 0; $i < $total; $i++) {
     //echo "<br>".$locations[$i]['TITLE'];
     if (!$locations[$i]['RANGE']) {
         $locations[$i]['RANGE'] = 500;
コード例 #5
0
<?php

include '../init.php';
date_default_timezone_set("Asia/Manila");
$curr_time = date('h:m A', time());
if ($_GET['rid']) {
    $rid = $_GET['rid'];
    $timeout = $curr_time;
    setTimeOut($rid, $curr_time);
}