示例#1
0
function LoadZipOrDir($dbi, $zip_or_dir)
{
    global $LANG, $genericpages;
    $type = filetype($zip_or_dir);
    if ($type == 'file') {
        $zip = new ZipReader($zip_or_dir);
        while (list($fn, $data, $attrib) = $zip->readFile()) {
            LoadFile($dbi, $fn, $data, $attrib['mtime']);
        }
    } else {
        if ($type == 'dir') {
            $handle = opendir($dir = $zip_or_dir);
            // load default pages
            while ($fn = readdir($handle)) {
                if ($fn[0] == '.' || filetype("{$dir}/{$fn}") != 'file') {
                    continue;
                }
                $stat = stat("{$dir}/{$fn}");
                $mtime = $stat[9];
                LoadFile($dbi, $fn, implode("", file("{$dir}/{$fn}")), $mtime);
            }
            closedir($handle);
            if ($LANG != "C") {
                // if language is not default, then insert
                // generic pages from the English ./pgsrc
                reset($genericpages);
                $dir = DEFAULT_WIKI_PGSRC;
                while (list(, $fn) = each($genericpages)) {
                    LoadFile($dbi, $fn, implode("", file("{$dir}/{$fn}")), $mtime);
                }
            }
        }
    }
}
function ParseSmileyFile($strFileName)
{
    // Chargement du fichier des smileys
    $strContent = LoadFile($strFileName);
    // Les smileys sont traités au niveau HTML, il faut donc convertir
    // les caractères spéciaux éventuels
    $strContent = htmlspecialchars($strContent);
    // On va parser les lignes une par une
    $astrLines = explode("\n", $strContent);
    $aVars = array();
    foreach ($astrLines as $strLine) {
        // Commentaires
        if (substr($strLine, 0, 1) == ';') {
            continue;
        }
        $nMiddle = strpos($strLine, '=');
        if ($nMiddle) {
            $strName = trim(substr($strLine, 0, $nMiddle));
            $strValue = trim(substr($strLine, $nMiddle + 1));
            if ($strValue == 'true') {
                $strValue = true;
            }
            if ($strValue == 'false') {
                $strValue = false;
            }
            $aVars[$strValue] = $strName;
        }
    }
    return $aVars;
}
function LoadView($name, $company_id)
{
    global $view_base_path;
    $view_data = array();
    $view_data['company_id'] = $company_id;
    $view_info = array();
    ArrayAppend($view_info, 'css', LoadFile(VIEW_BASE_PATH . "{$name}_view.css", $view_data));
    ArrayAppend($view_info, 'js', LoadFile(VIEW_BASE_PATH . "{$name}_view.js", $view_data));
    ArrayAppend($view_info, 'html', LoadFile(VIEW_BASE_PATH . "{$name}_view.html", $view_data));
    return $view_info;
}
 /**
 * 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['API_URL'] = $this->config['API_URL'];
     if (!$out['API_URL']) {
         $out['API_URL'] = 'localhost';
     }
     $out['API_PORT'] = $this->config['API_PORT'];
     if (!$out['API_PORT']) {
         $out['API_PORT'] = '6720';
     }
     $out['API_ENABLE'] = (int) $this->config['API_ENABLE'];
     if ($this->view_mode == 'bus_monitor') {
         global $ajax;
         if ($ajax) {
             echo nl2br(LoadFile(ROOT . 'cached/knx_monitor.txt'));
             exit;
         }
     }
     if ($this->view_mode == 'update_settings') {
         global $api_url;
         global $api_port;
         global $api_enable;
         $this->config['API_URL'] = $api_url;
         $this->config['API_PORT'] = $api_port;
         $old_status = $this->config['API_ENABLE'];
         $this->config['API_ENABLE'] = (int) $api_enable;
         if ($this->config['API_ENABLE'] != $old_status) {
             SaveFile(ROOT . 'reboot');
         }
         $this->saveConfig();
         $this->redirect("?");
     }
     if ($this->data_source == 'knxdevices' || $this->data_source == '') {
         if ($this->view_mode == '' || $this->view_mode == 'search_knxdevices') {
             $this->search_knxdevices($out);
             $out['API_STATUS'] = $this->connect();
         }
         if ($this->view_mode == 'edit_knxdevices') {
             $this->edit_knxdevices($out, $this->id);
         }
         if ($this->view_mode == 'delete_knxdevices') {
             $this->delete_knxdevices($this->id);
             $this->redirect("?data_source=knxdevices");
         }
     }
     if (isset($this->data_source) && !$_GET['data_source'] && !$_POST['data_source']) {
         $out['SET_DATASOURCE'] = 1;
     }
     if ($this->data_source == 'knxproperties') {
         if ($this->view_mode == '' || $this->view_mode == 'search_knxproperties') {
             $this->search_knxproperties($out);
         }
     }
 }
示例#5
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function removeFromList($id)
 {
     $product = SQLSelectOne("SELECT * FROM products WHERE ID='" . (int) $id . "'");
     if ($product['ID']) {
         SQLExec("DELETE FROM shopping_list_items WHERE PRODUCT_ID='" . (int) $id . "'");
         if (defined('DROPBOX_SHOPPING_LIST')) {
             $data = LoadFile(DROPBOX_SHOPPING_LIST);
             $data = str_replace("\r", '', $data);
             $lines = explode("\n", $data);
             $total = count($lines);
             $found = 0;
             $res_lines = array();
             for ($i = 0; $i < $total; $i++) {
                 if (is_integer(strpos($lines[$i], $product['TITLE']))) {
                     $found = 1;
                 } else {
                     $res_lines[] = $lines[$i];
                 }
             }
             if ($found) {
                 $data = implode("\n", $res_lines);
                 SaveFile(DROPBOX_SHOPPING_LIST, $data);
             }
         }
     }
 }
示例#6
0
 function cached($content) {
  $h=md5($content);
  $filename=ROOT.'cached/'.$this->name.'_'.$h.'.txt';
  $cache_expire=15*60; // 15 minutes cache expiration time

  if (file_exists($filename)) {
   if ((time()-filemtime($filename))<=$cache_expire) {
    $cached_result=LoadFile($filename);
   } else {
    unlink($filename);
   }
  }

  if ($cached_result=='') {
   $p=new jTemplate(DIR_TEMPLATES.'null.html', $this->data, $this);
   $cached_result=$p->parse($content, $this->data, DIR_TEMPLATES);
   SaveFile($filename, $cached_result);
  }

  return $cached_result;

 }
示例#7
0
function LoadPostFile(&$request)
{
    $upload = $request->getUploadedFile('file');
    if (!$upload) {
        $request->finish(_("No uploaded file to upload?"));
    }
    // FIXME: more concise message
    // Dump http headers.
    StartLoadDump($request, sprintf(_("Uploading %s"), $upload->getName()));
    echo "<dl>\n";
    $fd = $upload->open();
    if (IsZipFile($fd)) {
        LoadZip($request, $fd, false, array(_("RecentChanges")));
    } else {
        LoadFile($request, $upload->getName(), $upload->getContents());
    }
    echo "</dl>\n";
    EndLoadDump($request);
}
示例#8
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function import_classes(&$out)
 {
     global $file;
     global $overwrite;
     global $only_classes;
     $data = LoadFile($file);
     $records = unserialize($data);
     if (is_array($records)) {
         $total = count($records);
         for ($i = 0; $i < $total; $i++) {
             $old_class = SQLSelectOne("SELECT ID FROM classes WHERE TITLE LIKE '" . DBSafe($records[$i]['TITLE']) . "'");
             $total_o = 0;
             if ($old_class['ID']) {
                 $old_objects = SQLSelect("SELECT * FROM objects WHERE CLASS_ID='" . $old_class['ID'] . "'");
                 $total_o = count($old_objects);
                 for ($io = 0; $io < $total_o; $io++) {
                     $old_objects[$io]['CLASS_ID'] = 0;
                     SQLUpdate('objects', $old_objects[$io]);
                 }
                 if ($overwrite) {
                     $this->delete_classes($old_class['ID']);
                     $records[$i]['ID'] = $old_class['ID'];
                 } else {
                     $records[$i]['TITLE'] = $records[$i]['TITLE'] . rand(0, 500);
                 }
             }
             $objects = $records[$i]['OBJECTS'];
             unset($records[$i]['OBJECTS']);
             $methods = $records[$i]['METHODS'];
             unset($records[$i]['METHODS']);
             $properties = $records[$i]['PROPERTIES'];
             unset($records[$i]['PROPERTIES']);
             $records[$i]['ID'] = SQLInsert('classes', $records[$i]);
             if ($total_o) {
                 for ($io = 0; $io < $total_o; $io++) {
                     $old_objects[$io]['CLASS_ID'] = $records[$i]['ID'];
                     SQLUpdate('objects', $old_objects[$io]);
                 }
             }
             if (is_array($properties)) {
                 $total_p = count($properties);
                 for ($p = 0; $p < $total_p; $p++) {
                     $properties[$p]['CLASS_ID'] = $records[$i]['ID'];
                     $properties[$p]['ID'] = SQLInsert('properties', $properties[$p]);
                 }
             }
             if (is_array($methods)) {
                 $total_m = count($methods);
                 for ($m = 0; $m < $total_m; $m++) {
                     $methods[$m]['CLASS_ID'] = $records[$i]['ID'];
                     $methods[$m]['ID'] = SQLInsert('methods', $methods[$m]);
                 }
             }
             if (is_array($objects) && !$only_classes) {
                 $total_o = count($objects);
                 for ($o = 0; $o < $total_o; $o++) {
                     $objects[$o]['CLASS_ID'] = $records[$i]['ID'];
                     $methods = $objects[$o]['METHODS'];
                     unset($objects[$o]['METHODS']);
                     $properties = $objects[$o]['PROPERTIES'];
                     unset($objects[$o]['PROPERTIES']);
                     $objects[$o]['ID'] = SQLInsert('objects', $objects[$o]);
                     if (is_array($properties)) {
                         $total_p = count($properties);
                         for ($p = 0; $p < $total_p; $p++) {
                             $properties[$p]['OBJECT_ID'] = $objects[$o]['ID'];
                             $properties[$p]['ID'] = SQLInsert('properties', $properties[$p]);
                         }
                     }
                     if (is_array($methods)) {
                         $total_m = count($methods);
                         for ($m = 0; $m < $total_m; $m++) {
                             $methods[$m]['OBJECT_ID'] = $objects[$o]['ID'];
                             $methods[$m]['ID'] = SQLInsert('methods', $methods[$m]);
                         }
                     }
                 }
             }
         }
         //print_r($records);
     }
     $this->updateTree_classes();
     $this->redirect("?");
 }
示例#9
0
    $ED = $arEditions[LANG][$_REQUEST['edition']];
    if (is_array($ED['LIST'])) {
        $url = $_REQUEST['url'];
    } else {
        $url = $ED['LIST'];
    }
    if ($_REQUEST['LICENSE_KEY'] && false !== ($p = strpos($url, '/'))) {
        $url = substr($url, $p + 1);
    }
    $strRequestedUrl = $site . $path . $url . $suffix;
    $iTimeOut = TIMEOUT;
    $strUserAgent = "BitrixSiteLoader";
    $strFilename = $_SERVER["DOCUMENT_ROOT"] . "/" . basename($strRequestedUrl);
    $strLog = '';
    $status = '';
    $res = LoadFile($strRequestedUrl . ($_REQUEST["LICENSE_KEY"] != '' ? "?lp=" . md5($_REQUEST["LICENSE_KEY"]) : ''), $strFilename, $iTimeOut);
    if (!$res) {
        $txt = nl2br($strLog);
    } elseif ($res == 2) {
        $txt = $status;
        $script = "<script>GoToPage(\"" . $this_script_name . "?action=LOAD&edition=" . urlencode($_REQUEST['edition']) . "&url=" . urlencode($url) . "&lang=" . urlencode(LANG) . "&LICENSE_KEY=" . urlencode($_REQUEST["LICENSE_KEY"]) . "&action_next=" . urlencode($_REQUEST["action_next"]) . "&xz=" . rand(0, 32000) . "\");</script>\n";
    } else {
        $txt = $status;
        $script = "<script>GoToPage(\"" . $this_script_name . "?action=UNPACK&by_step=Y&filename=" . urlencode(basename($strRequestedUrl)) . "&lang=" . urlencode(LANG) . "&xz=" . rand(0, 32000) . "\");</script>\n";
    }
    $ar = array('FORM' => $form, 'TITLE' => LoaderGetMessage("LOADER_MENU_LOAD"), 'HEAD' => LoaderGetMessage("LOADER_MENU_LOAD"), 'TEXT' => $txt, 'BOTTOM' => '<input type="button" value="&nbsp;&nbsp;&nbsp;' . LoaderGetMessage("LOADER_BACK") . '&nbsp;&nbsp;&nbsp;" onclick="document.location=\'' . $this_script_name . '?action=LIST&lang=' . LANG . '\'">');
    /*********************************************************************/
} elseif ($strAction == "UNPACK") {
    /*********************************************************************/
    //	$iNumDistrFiles = 8000;
    SetCurrentStatus(LoaderGetMessage("LOADER_UNPACK_ACTION"));
示例#10
0
  if (!$this->name_id) {
   $tmp=SQLSelectOne("SELECT ID, NAME FROM tdwiki");
   $this->name_id=$tmp['NAME'];
  }

  $rec=SQLSelectOne("SELECT * FROM $table_name WHERE NAME='".$this->name_id."'");

  if (!$rec['ID']) {
   $rec['NAME']=$this->name_id;
   $rec['CONTENT']=LoadFile(DIR_TEMPLATES.$this->name.'/default.html');
   $rec['ID']=SQLInsert($table_name, $rec);
  }


  if ($this->mode=='reset') {
   $rec['CONTENT']=LoadFile(DIR_TEMPLATES.$this->name.'/default.html');
   SQLUpdate($table_name, $rec);
   $this->redirect("?");
  }

  global $mode;

  if ($mode=='update') {
   global $content;
   //DebMes($content);
   $rec['CONTENT']=$content;
   SQLUpdate($table_name, $rec);
   echo "OK";
   exit;
  }
示例#11
0
         header("Cache-Control: private");
         header("Pragma: no-cache");
         header("Content-type: multipart/x-mixed-replace; boundary={$boundary}");
         print "--{$boundary}\n";
         set_time_limit(0);
         @apache_setenv('no-gzip', 1);
         @ini_set('zlib.output_compression', 0);
         @ini_set('implicit_flush', 1);
         for ($i = 0; $i < ob_get_level(); $i++) {
             ob_end_flush();
         }
         ob_implicit_flush(1);
         while (true) {
             print "Content-type: image/jpeg\n\n";
             system(PATH_TO_FFMPEG . ' -rtsp_transport tcp -y -i "' . $url . '"' . $resize . ' -r 10 -f image2 -ss 00:00:01.500 -vframes 1 ' . $img);
             print LoadFile($img);
             print "--{$boundary}\n";
             sleep(1);
         }
     } else {
         system(PATH_TO_FFMPEG . ' -rtsp_transport tcp -y -i "' . $url . '"' . $resize . ' -r 10 -f image2 -ss 00:00:01.500 -vframes 1 ' . $img);
     }
     $dc = 1;
 } else {
     //echo $url.' - '.$username.' - '.$password;exit;
     $result = getURL($url, 0, $username, $password);
     if ($result) {
         if ($live) {
             $boundary = "my_mjpeg";
             header("Cache-Control: no-cache");
             header("Cache-Control: private");
 function import_event(&$out)
 {
     global $file;
     global $overwrite;
     $data = LoadFile($file);
     $event = json_decode($this->removeBOM($data), true);
     if (is_array($event)) {
         $rec = SQLSelectOne("SELECT * FROM tlg_event WHERE TITLE='" . DBSafe($event["TITLE"]) . "'");
         if ($rec['ID']) {
             if ($overwrite) {
                 $event['ID'] = $rec['ID'];
                 SQLUpdate("tlg_event", $event);
                 // update
             } else {
                 $event["TITLE"] .= "_copy";
                 SQLInsert("tlg_event", $event);
                 // adding new record
             }
         } else {
             SQLInsert("tlg_event", $event);
         }
         // adding new record
     }
     $this->redirect("?tab=events");
 }
示例#13
0
try {
    $conn = new MongoClient(CONNECT);
    $db = $conn->kladr;
    $db->drop();
    foreach ($file_list as $key => $file) {
        $info = pathinfo($file);
        if ($info['filename'] == 'SOCRBASE') {
            LoadFile($db, $arLoaders, $file);
            unset($file_list[$key]);
            break;
        }
    }
    foreach ($file_list as $key => $file) {
        $info = pathinfo($file);
        if ($info['filename'] == 'ALTNAMES') {
            LoadFile($db, $arLoaders, $file);
            unset($file_list[$key]);
            break;
        }
    }
    foreach ($file_list as $file) {
        LoadFile($db, $arLoaders, $file);
    }
    //$db->altnames->drop();
    //$db->socrbase->drop();
    $conn->close();
} catch (MongoConnectionException $e) {
    die('Error connecting to MongoDB server');
} catch (MongoException $e) {
    die('Error: ' . $e->getMessage());
}
示例#14
0
<?php

require_once 'configuration.php';
require_once 'view_helper.php';
require_once 'authenticate.php';
if (!isset($_GET['name'])) {
    exit;
} else {
    $view_name = $_GET['name'];
}
//var_dump($_POST);
//var_dump($_COOKIE);
$view_data = array();
if (count($_POST) > 0) {
    require_once VIEW_BASE_PATH . "{$view_name}_view_save.php";
}
if (($user_info = IsLoggedIn()) === false) {
    $view_data['is_logged_in'] = false;
} else {
    $view_data['is_logged_in'] = true;
    $view_data['user_id'] = $user_info['user_id'];
    $view_data['user_info'] = $user_info;
}
if (($html = LoadFile(VIEW_BASE_PATH . "{$view_name}_view.html", $view_data)) !== false) {
    echo $html;
}
示例#15
0
 /**
 * BackEnd
 *
 * Module backend
 *
 * @access public
 */
 function admin(&$out)
 {
     global $file;
     if ($this->view_mode == '') {
         $files = array();
         $dir = ROOT . 'texts';
         $handle = opendir($dir);
         while (false !== ($thing = readdir($handle))) {
             if ($thing == '.' || $thing == '..') {
                 continue;
             }
             if (preg_match('/(.+?)\\.txt$/', $thing, $m)) {
                 $files[] = array('FILENAME' => $m[1], 'FILENAME_URL' => urlencode($m[1]));
             }
         }
         closedir($handle);
         $out['FILES'] = $files;
     } elseif ($this->view_mode == 'delete_file' && $file != '') {
         @unlink(ROOT . 'texts/' . $file . ".txt");
         $this->redirect("?");
     } elseif ($this->view_mode == 'edit_file') {
         if ($this->mode == 'update' && $file != '') {
             global $data;
             SaveFile(ROOT . 'texts/' . $file . ".txt", trim($data));
             $out['OK'] = 1;
         }
         if ($file != '') {
             $data = LoadFile(ROOT . 'texts/' . $file . ".txt");
             $out['DATA'] = htmlspecialchars($data);
         }
         $out['FILE'] = $file;
         $out['FILE_URL'] = urlencode($out['FILE']);
     }
 }
示例#16
0
 /**
 * Block tag parsing
 *
 * Used to include template blocks with params [#block name param="value"#]..[#endblock name#]
 *
 * @access private
 * @param string $res template strings
 * @return string parsed template strings
 */
 function parseBlocks(&$res, &$hash)
 {
     if (preg_match_all('/\\[#block (.*?)#\\]/', $res, $matches, PREG_PATTERN_ORDER)) {
         $count_matches_0 = count($matches[0]);
         for ($i = 0; $i < $count_matches_0; $i++) {
             $raw = $matches[1][$i];
             if (Is_Integer(strpos($raw, '="'))) {
                 // inc file parameters
                 $new_hash = $hash;
                 preg_match_all('/(\\w+?)="(.*?)"/', $raw, $matches1, PREG_PATTERN_ORDER);
                 $count_matches1_0 = count($matches1[0]);
                 for ($k = 0; $k < $count_matches1_0; $k++) {
                     $new_hash[$matches1[1][$k]] = $matches1[2][$k];
                     $raw = str_replace($matches1[0][$k], '', $raw);
                 }
             }
             $block_name = $dir . trim($raw);
             $file_name = $block_name . ".html";
             if (!file_exists(ROOT . "templates/blocks/" . $file_name)) {
                 $res = str_replace($matches[0][$i], "<!-- Cannot find file {$file_name} -->", $res);
             } else {
                 $tmp = explode("[#...#]", LoadFile(ROOT . "templates/blocks/" . $file_name));
                 if (isset($new_hash) && (Is_Integer(strpos($tmp[0], '[#')) || Is_Integer(strpos($tmp[0], '<#')))) {
                     // CONDITIONS
                     $this->parseGlobals($tmp[0], $new_hash);
                     $this->parseIf($tmp[0], $new_hash);
                     // [#VARIABLE#] - general variables
                     if (preg_match_all('/\\[#(\\w+?)#\\]/', $tmp[0], $matches1, PREG_PATTERN_ORDER)) {
                         for ($l = 0; $l < count($matches1[1]); $l++) {
                             $tmp[0] = str_replace($matches1[0][$l], $new_hash[$matches1[1][$l]], $tmp[0]);
                         }
                     }
                 }
                 if (isset($new_hash) && (Is_Integer(strpos($tmp[1], '[#')) || Is_Integer(strpos($tmp[1], '<#')))) {
                     // CONDITIONS
                     $this->parseGlobals($tmp[1], $new_hash);
                     $this->parseIf($tmp[1], $new_hash);
                     // [#VARIABLE#] - general variables
                     if (preg_match_all('/\\[#(\\w+?)#\\]/', $tmp[1], $matches1, PREG_PATTERN_ORDER)) {
                         for ($l = 0; $l < count($matches1[1]); $l++) {
                             $tmp[1] = str_replace($matches1[0][$l], $new_hash[$matches1[1][$l]], $tmp[1]);
                         }
                     }
                 }
                 $res = str_replace($matches[0][$i], $tmp[0], $res);
                 $res = str_replace("[#endblock {$block_name}#]", $tmp[1], $res);
                 unset($new_hash);
             }
         }
     }
     return $res;
 }
示例#17
0
/**
* Title
*
* Description
*
* @access public
*/
function getURL($url, $cache = 600, $username = '', $password = '')
{
    $cache_file = ROOT . 'cached/urls/' . preg_replace('/\\W/is', '_', str_replace('http://', '', $url)) . '.html';
    if (!$cache || !is_file($cache_file) || time() - filemtime($cache_file) > $cache) {
        //download
        try {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            // bad style, I know...
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_TIMEOUT, 15);
            if ($username != '' || $password != '') {
                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
            }
            $tmpfname = ROOT . 'cached/cookie.txt';
            curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfname);
            curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfname);
            $result = curl_exec($ch);
        } catch (Exception $e) {
            registerError('geturl', $url . ' ' . get_class($e) . ', ' . $e->getMessage());
        }
        if ($cache > 0) {
            if (!is_dir(ROOT . 'cached/urls')) {
                @mkdir(ROOT . 'cached/urls', 0777);
            }
            SaveFile($cache_file, $result);
        }
    } else {
        $result = LoadFile($cache_file);
    }
    return $result;
}
 /**
 * BackEnd
 *
 * Module backend
 *
 * @access public
 */
 function admin(&$out)
 {
     global $ajax;
     global $filter;
     global $atype;
     if ($ajax) {
         header("HTTP/1.0: 200 OK\n");
         header('Content-Type: text/html; charset=utf-8');
         if ($atype == "incmode") {
             $this->getConfig();
             echo $this->config['MS_INCLUSION_MODE'];
             exit;
         }
         $limit = 50;
         // Find last midifed
         $filename = ROOT . 'debmes/log_*-cycle_mysensor.php.txt';
         foreach (glob($filename) as $file) {
             $LastModified[] = filemtime($file);
             $FileName[] = $file;
         }
         $files = array_multisort($LastModified, SORT_NUMERIC, SORT_ASC, $FileName);
         $lastIndex = count($LastModified) - 1;
         // Open file
         $data = LoadFile($FileName[$lastIndex]);
         $lines = explode("\n", $data);
         $lines = array_reverse($lines);
         $res_lines = array();
         $total = count($lines);
         $added = 0;
         for ($i = 0; $i < $total; $i++) {
             if (trim($lines[$i]) == '') {
                 continue;
             }
             if ($filter && preg_match('/' . preg_quote($filter) . '/is', $lines[$i])) {
                 $res_lines[] = $lines[$i];
                 $added++;
             } elseif (!$filter) {
                 $res_lines[] = $lines[$i];
                 $added++;
             }
             if ($added >= $limit) {
                 break;
             }
         }
         echo implode("<br/>", $res_lines);
         exit;
     }
     if (isset($this->data_source) && !$_GET['data_source'] && !$_POST['data_source']) {
         $out['SET_DATASOURCE'] = 1;
     }
     $this->getConfig();
     $out['MS_CONTYPE'] = $this->config['MS_CONTYPE'];
     $out['MS_HOST'] = $this->config['MS_HOST'];
     $out['MS_PORT'] = $this->config['MS_PORT'];
     $out['MS_SERIAL'] = $this->config['MS_SERIAL'];
     $out['MS_MEASURE'] = $this->config['MS_MEASURE'];
     $out['MS_AUTOID'] = $this->config['MS_AUTOID'];
     $out['MS_NEXTID'] = $this->config['MS_NEXTID'];
     $out['MS_INCLUSION_MODE'] = $this->config['MS_INCLUSION_MODE'];
     if ($out['MS_CONTYPE'] == "") {
         $out['MS_CONTYPE'] = 0;
         $this->config['MS_CONTYPE'] = $out['MS_CONTYPE'];
         $this->saveConfig();
     }
     if ($out['MS_HOST'] == "") {
         $out['MS_HOST'] = '10.9.0.253';
         $this->config['MS_HOST'] = $out['MS_HOST'];
         $this->saveConfig();
     }
     if ($out['MS_PORT'] == "") {
         $out['MS_PORT'] = '5003';
         $this->config['MS_PORT'] = $out['MS_PORT'];
         $this->saveConfig();
     }
     if ($out['MS_SERIAL'] == "") {
         $out['MS_SERIAL'] = '/dev/ttyMySensorsGateway';
         $this->config['MS_SERIAL'] = $out['MS_SERIAL'];
         $this->saveConfig();
     }
     if ($out['MS_MEASURE'] == "") {
         $out['MS_MEASURE'] = 'M';
         $this->config['MS_MEASURE'] = $out['MS_MEASURE'];
         $this->saveConfig();
     }
     if ($out['MS_AUTOID'] == "") {
         $out['MS_AUTOID'] = 1;
         $this->config['MS_AUTOID'] = $out['MS_AUTOID'];
         $this->saveConfig();
     }
     if ($out['MS_NEXTID'] == "") {
         $out['MS_NEXTID'] = 10;
         $this->config['MS_NEXTID'] = $out['MS_NEXTID'];
         $this->saveConfig();
     }
     if ($this->data_source == 'mysensors' || $this->data_source == '') {
         if ($this->view_mode == 'update_settings') {
             global $ms_contype;
             global $ms_host;
             global $ms_port;
             global $ms_serial;
             global $ms_measure;
             global $ms_autoid;
             global $ms_nextid;
             $this->config['MS_CONTYPE'] = $ms_contype;
             $this->config['MS_HOST'] = $ms_host;
             $this->config['MS_PORT'] = (int) $ms_port;
             $this->config['MS_SERIAL'] = $ms_serial;
             $this->config['MS_MEASURE'] = $ms_measure;
             $this->config['MS_AUTOID'] = $ms_autoid;
             $this->config['MS_NEXTID'] = $ms_nextid;
             $this->saveConfig();
             $this->redirect("?");
         }
         if ($this->view_mode == '' || $this->view_mode == 'search_ms') {
             if ($this->tab == 'mesh') {
                 $this->search_mesh($out);
             } else {
                 if ($this->tab == 'log') {
                     $this->search_log($out);
                 } else {
                     $this->search_ms($out);
                 }
             }
         }
         if ($this->view_mode == 'node_edit') {
             $this->edit_ms($out, $this->id);
         }
         if ($this->view_mode == 'inc_mode') {
             $NId = 0;
             $SId = 0;
             $mType = 3;
             $ack = 0;
             $SubType = 5;
             if ($this->config['MS_INCLUSION_MODE'] == 0) {
                 $val = 1;
             } else {
                 $val = 0;
             }
             $this->config['MS_INCLUSION_MODE'] = $val;
             $this->saveConfig();
             $this->cmd("{$NId};{$SId};{$mType};{$ack};{$SubType};" . $val);
             $this->redirect("?");
         }
         if ($this->view_mode == 'node_delete') {
             $this->delete_ms($this->id);
             $this->redirect("?");
         }
         if ($this->view_mode == 'sensor_add') {
             $this->add_sensor($out, $this->id);
         }
         if ($this->view_mode == 'sensor_delete') {
             $this->delete_sensor($this->id);
             global $pid;
             $this->redirect("?data_source={$this->data_source}&view_mode=node_edit&id={$pid}&tab=sensors");
         }
         if ($this->view_mode == 'presentation_clean') {
             $this->clean_presentation($this->id);
             $this->redirect("?data_source={$this->data_source}&view_mode=node_edit&id={$this->id}&tab=presentation");
         }
     }
 }
示例#19
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function import_scene()
 {
     global $file;
     global $overwrite;
     $data = unserialize(LoadFile($file));
     if ($data['SCENE_DATA']) {
         $rec = $data['SCENE_DATA'];
         if (!$rec['WALLPAPER']) {
             unset($rec['WALLPAPER']);
         }
         $rec['TITLE'] .= ' (imported)';
         $elements = $rec['ELEMENTS'];
         unset($rec['ID']);
         unset($rec['ELEMENTS']);
         $rec['ID'] = SQLInsert('scenes', $rec);
         $total = count($elements);
         for ($i = 0; $i < $total; $i++) {
             $states = $elements[$i]['STATES'];
             unset($elements[$i]['STATES']);
             unset($elements[$i]['ID']);
             $elements[$i]['SCENE_ID'] = $rec['ID'];
             $elements[$i]['ID'] = SQLInsert('elements', $elements[$i]);
             $totalE = count($states);
             for ($iE = 0; $iE < $totalE; $iE++) {
                 unset($states[$iE]['ID']);
                 $states[$iE]['ELEMENT_ID'] = $elements[$i]['ID'];
                 SQLInsert('elm_states', $states[$iE]);
             }
         }
         if ($data['BACKGROUND_IMAGE']) {
             $filename = ROOT . $rec['BACKGROUND'];
             SaveFile($filename, base64_decode($data['BACKGROUND_IMAGE']));
         }
         if ($data['WALLPAPER_IMAGE']) {
             $filename = ROOT . $rec['WALLPAPER'];
             SaveFile($filename, base64_decode($data['WALLPAPER_IMAGE']));
         }
         $this->redirect("?view_mode=edit_scenes&id=" . $rec['ID']);
     }
     $this->redirect("?");
 }
示例#20
0
			html($ar);
			die();
		}
		elseif ($res==2) // частичная закачка
		{
			$text = getMsg('ARC_DOWN_PROCESS').' <b>'.htmlspecialchars($arc_name).'</b>' . $status .
			'<input type=hidden name=Step value=2>'.
			'<input type=hidden name=source value=download>'.
			'<input type=hidden name=continue value=Y>'.
			'<input type=hidden name=arc_down_url value="'.htmlspecialchars($url).'">';
		}
		else
		{
			$next_arc_name = CTar::getNextName($arc_name);
			$next_url = str_replace($arc_name, $next_arc_name, $url);
			$res = LoadFile($next_url, $next_arc_name, $strNextRealUrl);
			if ($res != false && $strRealUrl != $strNextRealUrl)
			{
				$text = getMsg('ARC_DOWN_PROCESS').' <b>'.htmlspecialchars($next_arc_name).'</b>' . $status .
				'<input type=hidden name=Step value=2>'.
				'<input type=hidden name=source value=download>'.
				'<input type=hidden name=continue value=Y>'.
				'<input type=hidden name=arc_down_url value="'.htmlspecialchars($next_url).'">';
			}
			else
			{
				$text = $status .
				'<input type=hidden name=Step value=2>'.
				'<input type=hidden name=arc_name value="'.htmlspecialchars(preg_replace('#\.[0-9]+$#','',$arc_name)).'">';
			}
		}
示例#21
0
 $titles = array();
 foreach ($menu_items as $k => $v) {
     $titles[$v['ID']] = $v['TITLE'];
 }
 $total = count($menu_items);
 for ($i = 0; $i < $total; $i++) {
     if ($titles[$menu_items[$i]['PARENT_ID']]) {
         $menu_items[$i]['TITLE'] = $titles[$menu_items[$i]['PARENT_ID']] . ' &gt; ' . $menu_items[$i]['TITLE'];
     }
 }
 $out['MENU_ITEMS'] = $menu_items;
 $out['STATES'] = SQLSelect("SELECT * FROM elm_states WHERE ELEMENT_ID='" . $element['ID'] . "' ORDER BY elm_states.PRIORITY DESC");
 $out['STATE_ID'] = $state_id;
 if ($element['TYPE'] == 's3d') {
     if (file_exists(ROOT . $element['S3D_SCENE'])) {
         $scene_text = LoadFile(ROOT . $element['S3D_SCENE']);
         $scene_data = json_decode($scene_text, true);
         if (is_array($scene_data['object']['children'])) {
             function processObjectsTree($objects, &$result)
             {
                 $total = count($objects);
                 for ($i = 0; $i < $total; $i++) {
                     if ($objects[$i]['name']) {
                         $result[] = array('TITLE' => $objects[$i]['name'], 'TYPE' => $objects[$i]['type']);
                     } else {
                         $result[] = array('TITLE' => $objects[$i]['uuid'], 'TYPE' => $objects[$i]['type']);
                     }
                     if (is_array($objects[$i]['children'])) {
                         processObjectsTree($objects[$i]['children'], $result);
                     }
                 }
示例#22
0
/**
* Title
*
* Description
*
* @access public
*/
 function getURL($url, $cache=600, $username='', $password='') {
  $cache_file=ROOT.'cached/urls/'.preg_replace('/\W/is', '_', str_replace('http://', '', $url)).'.html';
  if (!$cache || !is_file($cache_file) || ((time()-filemtime($cache_file))>$cache)) {
   //download
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
   if ($username!='') {
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
    curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password); 
   }
   $result = curl_exec($ch);
   if ($cache>0) {
    if (!is_dir(ROOT.'cached/urls')) {
     @mkdir(ROOT.'cached/urls', 0777);
    }
    SaveFile($cache_file, $result);
   }
  } else {
   $result=LoadFile($cache_file);
  }
  return $result;
 }
 function getDescriptions($dir) {
  $descr=array();
  if (file_exists($dir."Descript.ion")) {
   $data=LoadFile($dir."Descript.ion");
   $strings=explode("\n", $data);
   for($i=0;$i<count($strings);$i++) {
    $fields=explode("\t", $strings[$i]);
    $filename=$fields[0];
    $filename=str_replace("\"", "", $filename);
    $description=$fields[1];
    $descr[$filename]=$description;
   }
  }
  return $descr;
 }
示例#24
0
//linux command
$bts_cmd = 'hcitool scan | grep ":"';
$first_run = 1;
$skip_counter = 0;
echo "Running bluetooth scanner\n";
while (1) {
    $skip_counter++;
    if ($skip_counter >= 30) {
        $skip_counter = 0;
        $data = '';
        if (IsWindowsOS()) {
            // windows scanner
            $isDelete = unlink($devices_file);
            exec(SERVER_ROOT . '/apps/bluetoothview/bluetoothview.exe /stab ' . $devices_file);
            if (file_exists($devices_file)) {
                $data = LoadFile($devices_file);
                sleep(5);
            }
        } else {
            //linux scanner
            ob_start();
            passthru($bts_cmd);
            $bt_scan_arr = explode("\n", ob_get_contents());
            ob_end_clean();
            $lines = array();
            $btScanArrayLength = count($bt_scan_arr) - 1;
            for ($i = 0; $i < $btScanArrayLength; $i++) {
                $btstr = explode("\t", $bt_scan_arr[$i]);
                $btaddr[$i] = $btstr[1];
                $btname[$i] = rtrim($btstr[2]);
                $lines[] = $i . "\t" . $btname[$i] . "\t" . $btaddr[$i];
示例#25
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function restoredatabase($filename)
 {
     $data = LoadFile($filename);
     $data = str_replace("\r", "", $data);
     $data .= "\n";
     $query = explode(";\n", $data);
     for ($i = 0; $i < count($query) - 1; $i++) {
         if ($query[$i][0] != "#") {
             SQLExec($query[$i]);
         }
     }
 }
示例#26
0
function BuildStandardReplacements()
{
    global $k_aConfig, $k_aLangConfig, $k_strVersion, $k_strWikiURI;
    $astrReplacements = array('Vars' => array(), 'Values' => array());
    // Ajout des variables du fichier configuration.ini
    foreach ($k_aConfig as $strVar => $strValue) {
        AddReplacement($astrReplacements, 'Config.' . $strVar, $strValue);
    }
    // Ajout des variables de configurations supplémentaires
    AddReplacement($astrReplacements, 'Config.URI', $k_strWikiURI);
    AddReplacement($astrReplacements, 'Config.Version', $k_strVersion);
    AddReplacement($astrReplacements, 'Config.PageSeparator', GetPageSeparator());
    AddReplacement($astrReplacements, 'Config.WikiURI', GetScriptURI('Wiki'));
    AddReplacement($astrReplacements, 'Config.EditURI', GetScriptURI('Edit'));
    AddReplacement($astrReplacements, 'Config.HistoryURI', GetScriptURI('History'));
    // Ajout des variables da la langue
    foreach ($k_aLangConfig as $strVar => $strValue) {
        AddReplacement($astrReplacements, 'Lang.' . $strVar, $strValue);
    }
    // Ajout des variables de langue supplémentaires
    AddReplacement($astrReplacements, 'Lang.Rules', LoadFile($k_aConfig['LanguagePath'] . '/rules.html'));
    return $astrReplacements;
}
示例#27
0
    $use_caching = 0;
} else {
    $use_caching = 0;
}
// 60 minutes cache expiration time
$cache_expire = 60 * 60;
$cached_result = '';
$req_url = $_SERVER['REQUEST_URI'];
if ($req_url == '/') {
    $req_url = '/index.html';
}
if ($use_caching && preg_match('/^\\/([\\/\\w_-]+)\\.html$/', $req_url, $matches) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    $cache_filename = preg_replace('/\\W/', '_', $matches[1]) . '.html';
    if (file_exists(ROOT . 'cached/' . $cache_filename)) {
        if (time() - filemtime(ROOT . 'cached/' . $cache_filename) <= $cache_expire) {
            $cached_result = LoadFile(ROOT . 'cached/' . $cache_filename);
        } else {
            unlink(ROOT . 'cached/' . $cache_filename);
        }
    }
}
if ($cached_result == '') {
    if (!file_exists(DIR_MODULES . 'control_modules/installed')) {
        include_once DIR_MODULES . "control_modules/control_modules.class.php";
        $ctl = new control_modules();
    }
    $app = new application();
    if ($md != $app->name) {
        $app->restoreParams();
    } else {
        $app->getParams();
示例#28
0
 /**
 * BackEnd
 *
 * Module backend
 *
 * @access public
 */
 function admin(&$out)
 {
     global $ajax;
     if ($ajax) {
         global $op;
         global $filter;
         if ($op == 'getcontent') {
             header("HTTP/1.0: 200 OK\n");
             header('Content-Type: text/html; charset=utf-8');
             if ($this->view_mode == '') {
                 $qry = "1";
                 if ($filter) {
                     $qry .= " AND (objects.TITLE LIKE '%" . DBSafe($filter) . "%' OR properties.TITLE LIKE '%" . DBSafe($filter) . "%' OR objects.DESCRIPTION LIKE '%" . DBSafe($filter) . "%')";
                 }
                 $res = SQLSelect("SELECT pvalues.*, objects.TITLE as OBJECT, objects.DESCRIPTION as OBJECT_DESCRIPTION, properties.TITLE as PROPERTY, properties.DESCRIPTION FROM pvalues LEFT JOIN objects ON pvalues.OBJECT_ID=objects.ID LEFT JOIN properties ON pvalues.PROPERTY_ID=properties.ID WHERE {$qry} ORDER BY pvalues.UPDATED DESC");
                 $total = count($res);
                 echo '<table border=1 cellspacing=4 cellpadding=4 width=100%>';
                 echo '<tr>';
                 echo '<td><b>PROPERTY</b></td>';
                 echo '<td><b>VALUE</b></td>';
                 echo '<td><b>UPDATED</b></td>';
                 echo '</tr>';
                 for ($i = 0; $i < $total; $i++) {
                     echo '<tr>';
                     echo '<td>';
                     echo $res[$i]['OBJECT'] . '.' . $res[$i]['PROPERTY'];
                     if ($res[$i]['OBJECT_DESCRIPTION'] != '') {
                         echo "<br><small style='font-size:9px'>" . $res[$i]['OBJECT_DESCRIPTION'] . "</small>";
                     }
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['VALUE'] . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['UPDATED'] . '&nbsp;';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
             } elseif ($this->view_mode == 'debmes') {
                 $limit = 50;
                 $filename = ROOT . 'debmes/' . date('Y-m-d') . '.log';
                 $data = LoadFile($filename);
                 $lines = explode("\n", $data);
                 $lines = array_reverse($lines);
                 $res_lines = array();
                 $total = count($lines);
                 $added = 0;
                 for ($i = 0; $i < $total; $i++) {
                     if (trim($lines[$i]) == '') {
                         continue;
                     }
                     if ($filter && preg_match('/' . preg_quote($filter) . '/is', $lines[$i])) {
                         $res_lines[] = $lines[$i];
                         $added++;
                     } elseif (!$filter) {
                         $res_lines[] = $lines[$i];
                         $added++;
                     }
                     if ($added >= $limit) {
                         break;
                     }
                 }
                 echo implode("<br/>", $res_lines);
             } elseif ($this->view_mode == 'performance') {
                 $qry = "1";
                 if ($filter) {
                     $qry .= " AND (OPERATION LIKE '%" . DBSafe($filter) . "%')";
                 }
                 $time_start = date('Y-m-d H:i:s', time() - 10);
                 $res = SQLSelect("SELECT OPERATION, SUM(COUNTER) as TOTAL, SUM(TIMEUSED) as TIME_TOTAL FROM performance_log WHERE ADDED>='" . $time_start . "' AND {$qry} GROUP BY OPERATION ORDER BY TIME_TOTAL DESC ");
                 //methods.OBJECT_ID<>0
                 $total = count($res);
                 echo '<table border=1 cellspacing=4 cellpadding=4 width=100%>';
                 echo '<tr>';
                 echo '<td><b>OPERATION</b></td>';
                 echo '<td><b>COUNTER</b></td>';
                 echo '<td><b>TIME</b></td>';
                 echo '<td><b>AV. TIME</b></td>';
                 echo '</tr>';
                 for ($i = 0; $i < $total; $i++) {
                     echo '<tr>';
                     echo '<td>';
                     echo htmlspecialchars($res[$i]['OPERATION']) . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['TOTAL'] . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo number_format($res[$i]['TIME_TOTAL'], 2) . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo number_format($res[$i]['TIME_TOTAL'] / $res[$i]['TOTAL'], 2) . '&nbsp;';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
                 SQLExec("DELETE FROM performance_log WHERE ADDED<'" . date('Y-m-d H:i:s', time() - 60 * 60) . "'");
             } elseif ($this->view_mode == 'methods') {
                 $qry = "1";
                 if ($filter) {
                     $qry .= " AND (objects.TITLE LIKE '%" . DBSafe($filter) . "%' OR methods.TITLE LIKE '%" . DBSafe($filter) . "%' OR methods.DESCRIPTION LIKE '%" . DBSafe($filter) . "%')";
                 }
                 $res = SQLSelect("SELECT methods.*, objects.TITLE as OBJECT, objects.DESCRIPTION as OBJECT_DESCRIPTION, methods.DESCRIPTION FROM methods LEFT JOIN objects ON methods.OBJECT_ID=objects.ID WHERE {$qry} ORDER BY methods.EXECUTED DESC");
                 //methods.OBJECT_ID<>0
                 $total = count($res);
                 echo '<table border=1 cellspacing=4 cellpadding=4 width=100%>';
                 echo '<tr>';
                 echo '<td><b>METHOD</b></td>';
                 echo '<td><b>PARAMS</b></td>';
                 echo '<td><b>EXECUTED</b></td>';
                 echo '</tr>';
                 for ($i = 0; $i < $total; $i++) {
                     echo '<tr>';
                     echo '<td>';
                     @($tmp = unserialize($res[$i]['EXECUTED_PARAMS']));
                     if ($tmp['ORIGINAL_OBJECT_TITLE'] && !$res[$i]['OBJECT']) {
                         $res[$i]['OBJECT'] = $tmp['ORIGINAL_OBJECT_TITLE'];
                         //unset($tmp['ORIGINAL_OBJECT_TITLE']);
                         $res[$i]['EXECUTED_PARAMS'] = serialize($tmp);
                     }
                     echo $res[$i]['OBJECT'] . '.' . $res[$i]['TITLE'];
                     if ($res[$i]['DESCRIPTION']) {
                         echo "<br><small style='font-size:9px'>";
                         echo $res[$i]['DESCRIPTION'];
                         echo "</small>";
                     }
                     echo '</td>';
                     echo '<td>';
                     echo str_replace(';', '; ', $res[$i]['EXECUTED_PARAMS']) . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['EXECUTED'] . '&nbsp;';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
             } elseif ($this->view_mode == 'scripts') {
                 $qry = "1";
                 if ($filter) {
                     $qry .= " AND (scripts.TITLE LIKE '%" . DBSafe($filter) . "%' OR scripts.DESCRIPTION LIKE '%" . DBSafe($filter) . "%')";
                 }
                 $res = SQLSelect("SELECT scripts.* FROM scripts WHERE {$qry} ORDER BY scripts.EXECUTED DESC");
                 $total = count($res);
                 echo '<table border=1 cellspacing=4 cellpadding=4 width=100%>';
                 echo '<tr>';
                 echo '<td><b>SCRIPT</b></td>';
                 echo '<td><b>PARAMS</b></td>';
                 echo '<td><b>EXECUTED</b></td>';
                 echo '</tr>';
                 for ($i = 0; $i < $total; $i++) {
                     echo '<tr>';
                     echo '<td>';
                     echo $res[$i]['TITLE'];
                     if ($res[$i]['DESCRIPTION'] != '') {
                         echo "<br><small style='font-size:9px'>" . $res[$i]['DESCRIPTION'] . "</small>";
                     }
                     echo '</td>';
                     echo '<td>';
                     echo str_replace(';', '; ', $res[$i]['EXECUTED_PARAMS']) . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['EXECUTED'] . '&nbsp;';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
             } elseif ($this->view_mode == 'timers') {
                 $qry = "1";
                 if ($filter) {
                     $qry .= " AND (jobs.TITLE LIKE '%" . DBSafe($filter) . "%')";
                 }
                 $res = SQLSelect("SELECT jobs.* FROM jobs WHERE EXPIRED!=1 AND PROCESSED!=1 AND {$qry} ORDER BY jobs.RUNTIME");
                 $total = count($res);
                 echo '<table border=1 cellspacing=4 cellpadding=4 width=100%>';
                 echo '<tr>';
                 echo '<td><b>TIMER</b></td>';
                 echo '<td><b>COMMAND</b></td>';
                 echo '<td><b>SCHEDULED</b></td>';
                 echo '</tr>';
                 for ($i = 0; $i < $total; $i++) {
                     echo '<tr>';
                     echo '<td>';
                     echo $res[$i]['TITLE'];
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['COMMANDS'];
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['RUNTIME'] . '&nbsp;';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
             } elseif ($this->view_mode == 'events') {
                 $qry = "1";
                 if ($filter) {
                     $qry .= " AND (events.EVENT_NAME LIKE '%" . DBSafe($filter) . "%')";
                 }
                 $res = SQLSelect("SELECT events.* FROM events WHERE {$qry} ORDER BY events.ADDED DESC LIMIT 30");
                 $total = count($res);
                 echo '<table border=1 cellspacing=4 cellpadding=4 width=100%>';
                 echo '<tr>';
                 echo '<td><b>EVENT</b></td>';
                 echo '<td><b>DETAILS</b></td>';
                 echo '<td><b>ADDED</b></td>';
                 echo '</tr>';
                 for ($i = 0; $i < $total; $i++) {
                     echo '<tr>';
                     echo '<td>';
                     echo $res[$i]['EVENT_NAME'] . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['DETAILS'] . '&nbsp;';
                     echo '</td>';
                     echo '<td>';
                     echo $res[$i]['ADDED'] . '&nbsp;';
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</table>';
             }
             exit;
         }
     }
 }
示例#29
0
<?php

/*
* @version 0.1 (wizard)
*/
if ($this->owner->name == 'panel') {
    $out['CONTROLPANEL'] = 1;
}
$table_name = 'app_quotes';
if ($this->mode == 'update') {
    global $file;
    if (file_exists($file)) {
        $tmp = LoadFile($file);
        $ok = 1;
        //$tmp=str_replace("\r", '', $tmp);
        $lines = mb_split("\n", $tmp);
        $total_lines = count($lines);
        for ($i = 0; $i < $total_lines; $i++) {
            //$values=explode("\t", $lines[$i]);
            $rec = array();
            $rec_ok = 1;
            $rec['BODY'] = $lines[$i];
            if ($rec['BODY'] == '') {
                $rec_ok = 0;
            }
            if ($rec_ok) {
                $old = SQLSelectOne("SELECT ID FROM " . $table_name . " WHERE BODY LIKE '" . DBSafe($rec['BODY']) . "'");
                if ($old['ID']) {
                    $rec['ID'] = $old['ID'];
                    SQLUpdate($table_name, $rec);
                } else {
示例#30
0
	}

	if ($source == 'download')
	{
		$strUrl = $_REQUEST['arc_down_url'];

		if (!preg_match('#http://#',$strUrl))
			$strUrl = 'http://'.$strUrl;
		$arc_name = trim(basename($strUrl));

		$strLog = '';
		$status = '';

		if ($_REQUEST['continue'])
		{
			$res = LoadFile($strUrl, $_SERVER['DOCUMENT_ROOT'].'/'.$arc_name, $arHeaders);
			if (file_exists($file = $_SERVER['DOCUMENT_ROOT'].'/'.$arc_name))
			{
				$size = filesize($file);
				if ($res == 1 && $size < 1024 * 1024 && $_REQUEST['last_piece'])
				{
					unlink($file);
					$res = false; // html page
				}
			}
		}
		else // начало закачки
		{
			$res = 2;
			SetCurrentProgress(0);
		}