Esempio n. 1
0
function saveToCache($key, $value, $ttl = 60)
{
    if (isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST')) {
        global $memory_cache;
        $memory_cache[$key] = $value;
    }
    if (strlen($value) <= 255) {
        $rec = array('KEYWORD' => $key, 'DATAVALUE' => $value, 'EXPIRE' => date('Y-m-d H:i:s', time() + $ttl));
    } else {
        $rec = array('KEYWORD' => $key, 'DATAVALUE' => '(too big)', 'EXPIRE' => date('Y-m-d H:i:s', time() + $ttl));
    }
    SQLExec("REPLACE INTO cached_values (KEYWORD, DATAVALUE, EXPIRE) VALUES('" . DBSafe($rec['KEYWORD']) . "', '" . DBSafe($rec['DATAVALUE']) . "', '" . $rec['EXPIRE'] . "')");
}
Esempio n. 2
0
            */
            $value['VALUE'] = ${"value" . $props[$i]['ID']};
        }
        $props[$i]['VALUE'] = $value['VALUE'];
        $props[$i]['LINKED_MODULES'] = $value['LINKED_MODULES'];
    }
    $out['PROPERTIES'] = $props;
}
// step: methods
if ($this->tab == 'methods') {
    global $overwrite;
    global $delete_meth;
    if ($delete_meth) {
        $method = SQLSelectOne("SELECT * FROM methods WHERE ID='" . (int) $delete_meth . "'");
        $my_meth = SQLSelectOne("SELECT * FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($method['TITLE']) . "'");
        SQLExec("DELETE FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($method['TITLE']) . "'");
    }
    if ($overwrite) {
        global $method_id;
        $method = SQLSelectOne("SELECT * FROM methods WHERE ID='" . (int) $method_id . "'");
        $out['METHOD_CLASS_ID'] = $method['CLASS_ID'];
        $tmp = SQLSelectOne("SELECT * FROM classes WHERE ID='" . $method['CLASS_ID'] . "'");
        $out['METHOD_CLASS_TITLE'] = $tmp['TITLE'];
        $out['METHOD_TITLE'] = $method['TITLE'];
        $out['METHOD_TITLE_URL'] = urlencode($method['TITLE']);
        $out['OBJECT_TITLE'] = $rec['TITLE'];
        $out['OBJECT_TITLE_URL'] = urlencode($rec['TITLE']);
        $out['METHOD_ID'] = $method['ID'];
        $my_meth = SQLSelectOne("SELECT * FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($method['TITLE']) . "'");
        if ($this->mode == 'update') {
            $ok = 1;
Esempio n. 3
0
function recLocalTime($table, $id, $gmt, $field = "ADDED")
{
    // UPDATES TIMESTAMP FIELD USING GMT
    $rec = SQLSelectOne("SELECT ID, DATE_FORMAT({$field}, '%Y-%m-%d %H:%i') as DAT FROM {$table} WHERE ID='{$id}'");
    if (isset($rec["ID"])) {
        $new_dat = setLocalTime($rec['DAT'], $gmt);
        SQLExec("UPDATE {$table} SET {$field}='{$new_dat}' WHERE ID='{$id}'");
    }
}
Esempio n. 4
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS events');
     parent::uninstall();
 }
Esempio n. 5
0
 global $switch_scene_new;
 global $state_id;
 global $state_delete;
 global $state_clone;
 global $ext_url_new;
 global $homepage_id_new;
 global $open_scene_id_new;
 global $do_on_click_new;
 global $priority_new;
 global $code_new;
 if ($state_delete && $state_rec['ID']) {
     $state_rec = SQLSelectOne("SELECT * FROM elm_states WHERE ID='" . $state_id . "'");
     foreach ($state_rec as $k => $v) {
         $out['STATE_' . $k] = '';
     }
     SQLExec("DELETE FROM elm_states WHERE ID='" . $state_rec['ID'] . "'");
 } elseif ($state_title_new) {
     $state_rec['ELEMENT_ID'] = $element['ID'];
     $state_rec['TITLE'] = $state_title_new;
     $state_rec['IMAGE'] = $image_new;
     $state_rec['HTML'] = $html_new;
     $state_rec['IS_DYNAMIC'] = $is_dynamic_new;
     $state_rec['LINKED_OBJECT'] = $linked_object_new;
     $state_rec['LINKED_PROPERTY'] = $linked_property_new;
     $state_rec['CONDITION'] = $condition_new;
     $state_rec['CONDITION_VALUE'] = $condition_value_new;
     $state_rec['CONDITION_ADVANCED'] = $condition_advanced_new;
     $state_rec['PRIORITY'] = (int) $priority_new;
     if ($do_on_click_new != 'run_script') {
         $script_id_new = 0;
     }
Esempio n. 6
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS btdevices');
     parent::uninstall();
 }
Esempio n. 7
0
 function run()
 {
     // running current module
     global $session;
     if ($this->owner->name != 'panel' && $this->owner->name != 'master') {
         echo "Unauthorized Access";
         exit;
     }
     if ($this->id == '1') {
         $this->mode = 'edit';
         global $id;
         global $mode;
         $id = $this->id;
         $mode = 'edit';
         $out['MASTER'] = 1;
     }
     // LDAP inicial
     if (function_exists('ldap_connect') && is_file(ROOT . 'modules/ldap_users/installed')) {
         $out['LDAP_ON'] = 1;
     }
     if ($this->mode == 'logoff') {
         unset($session->data['AUTHORIZED']);
         unset($session->data['USER_NAME']);
         unset($session->data['USERNAME']);
         unset($session->data['SITE_USERNAME']);
         unset($session->data['SITE_USER_ID']);
         unset($session->data["cp_requested_url"]);
         $this->owner->redirect("/");
     }
     if ($this->action == "enter") {
         global $md;
         global $login;
         if (!$session->data["cp_requested_url"] && ($md != 'panel' || $action != '') && !$login) {
             $session->data["cp_requested_url"] = $_SERVER['REQUEST_URI'];
         }
         if ($this->mode == "check") {
             global $login;
             global $psw;
             //    $user=SQLSelectOne("SELECT * FROM admin_users WHERE LOGIN='******' AND PASSWORD='******'");
             $user = SQLSelectOne("SELECT * FROM admin_users WHERE LOGIN='******' AND PASSWORD='******'");
             //    $user=SQLSelectOne("SELECT * FROM admin_users WHERE 1");
             // LDAP logining
             if ($out['LDAP_ON'] != false && ($user == false || $psw == 'this_ldap_admin')) {
                 include_once ROOT . 'modules/ldap_users/ldap_users.class.php';
                 $ldap = new ldap_users();
                 $user = $ldap->ctrl_access();
             }
             // LDAP loginig
             if (!isset($user['ID'])) {
                 $out["ERRMESS"] = "Wrong username and/or password";
             } else {
                 $session->data['AUTHORIZED'] = 1;
                 $session->data['USER_NAME'] = $user['LOGIN'];
                 $session->data['USER_LEVEL'] = $user['PRIVATE'];
                 $session->data['USER_ID'] = $user['ID'];
                 if (!$session->data["cp_requested_url"]) {
                     if (file_exists(DIR_MODULES . 'dashboard/dashboard.class.php')) {
                         $this->owner->redirect("?action=dashboard");
                     }
                     $this->owner->redirect("?");
                 } else {
                     $this->owner->redirect($session->data["cp_requested_url"]);
                 }
             }
         }
     } elseif ($this->action == "logged") {
         $out["USER_NAME"] = $session->data["USER_NAME"];
         $tmp = SQLSelectOne("SELECT ID FROM admin_users WHERE LOGIN='******' AND PASSWORD='******'admin') . "'");
         if ($tmp['ID']) {
             $out['WARNING'] = 1;
         }
         $user = SQLSelectOne("SELECT * FROM admin_users WHERE LOGIN='******'");
         if (!$user['ID']) {
             unset($session->data['AUTHORIZED']);
             unset($session->data['USER_NAME']);
             $session->save();
             $this->owner->redirect("?");
         }
         $modules = SQLSelect("SELECT * FROM project_modules WHERE HIDDEN='0' ORDER BY CATEGORY, NAME");
         $modulesCnt = count($modules);
         for ($i = 0; $i < $modulesCnt; $i++) {
             if (preg_match("/," . $modules[$i]['NAME'] . ",/i", @$user["ACCESS"]) || preg_match("/," . $modules[$i]['NAME'] . "\$/i", @$user["ACCESS"]) || preg_match("/^" . $modules[$i]['NAME'] . ",/i", @$user["ACCESS"]) || preg_match("/^" . $modules[$i]['NAME'] . "\$/i", @$user["ACCESS"]) || 0) {
                 $new[] = $modules[$i];
             }
         }
         $on_row = 0;
         $newCnt = count($new);
         for ($i = 0; $i < $newCnt; $i++) {
             if ($new[$i]['CATEGORY'] != $new_category) {
                 $new[$i]['NEWCATEGORY'] = 1;
                 $new_category = $new[$i]['CATEGORY'];
                 $on_row = 0;
             }
             $on_row++;
             if ($on_row % 6 == 0 && $on_row >= 6) {
                 $new[$i]['NEWROW'] = 1;
             }
             if (file_exists(ROOT . 'img/admin/icons/ico_' . $new[$i]['NAME'] . '.gif')) {
                 $new[$i]['ICON'] = ROOTHTML . 'img/admin/icons/ico_' . $new[$i]['NAME'] . '.gif';
             } else {
                 $new[$i]['ICON'] = ROOTHTML . 'img/admin/icons/ico_default.gif';
             }
         }
         $out["MODULES"] = $new;
         if (file_exists(DIR_MODULES . 'saverestore/saverestore.class.php')) {
             $out['CHECK_UPDATES'] = 1;
             global $check;
             if ($check) {
                 include_once DIR_MODULES . 'saverestore/saverestore.class.php';
                 $sv = new saverestore();
                 $sv->checkUpdates($o);
                 if ($o['NO_UPDATES'] || $o['ERROR_CHECK']) {
                     echo "no";
                 } else {
                     echo "yes";
                 }
                 exit;
             }
         }
     } elseif ($this->action == "logoff") {
         unset($session->data['AUTHORIZED']);
         unset($session->data['USER_NAME']);
         unset($session->data['USERNAME']);
         $this->owner->redirect("?");
     } elseif ($this->action == "admin") {
         global $mode;
         global $mode2;
         global $id;
         if (!$session->data['AUTHORIZED']) {
             exit;
         }
         if ($mode == "delete") {
             SQLExec("DELETE FROM admin_users WHERE ID='" . $id . "'");
             $this->redirect("?");
         }
         if ($mode == "edit") {
             $user = SQLSelectOne("SELECT * FROM admin_users WHERE ID='" . $id . "'");
             if ($mode2 == "update") {
                 $ok = 1;
                 global $name;
                 global $login;
                 global $password;
                 global $email;
                 global $comments;
                 global $sel;
                 global $private;
                 global $EMAIL_ORDERS;
                 global $EMAIL_INVENTORY;
                 $user['NAME'] = $name;
                 if (!checkGeneral($user['NAME'])) {
                     $out["ERR_NAME"] = 1;
                     $ok = 0;
                 }
                 $user['LOGIN'] = $login;
                 if (!checkGeneral($user['LOGIN'])) {
                     $out["ERR_LOGIN"] = 1;
                     $ok = 0;
                 }
                 if ($password != '' || !$user['ID']) {
                     $user['PASSWORD'] = $password;
                     if (!checkGeneral($user['PASSWORD'])) {
                         $out["ERR_PASSWORD"] = 1;
                         $ok = 0;
                     } else {
                         $user['PASSWORD'] = md5($user['PASSWORD']);
                     }
                 }
                 $user['EMAIL'] = $email;
                 $user['COMMENTS'] = $comments;
                 $user['PRIVATE'] = (int) $private;
                 $user['EMAIL_ORDERS'] = $EMAIL_ORDERS;
                 $user['EMAIL_INVENTORY'] = $EMAIL_INVENTORY;
                 if (count($sel) > 0) {
                     $user['ACCESS'] = join(",", $sel);
                 } else {
                     $user['ACCESS'] = "";
                 }
                 if ($ok) {
                     SQLUpdateInsert("admin_users", $user);
                     $out["OK"] = 1;
                 }
             }
             $modules = SQLSelect("SELECT * FROM project_modules");
             $modulesCnt = count($modules);
             for ($i = 0; $i < $modulesCnt; $i++) {
                 if (preg_match("/," . $modules[$i]['NAME'] . ",/i", @$user["ACCESS"]) || preg_match("/," . $modules[$i]['NAME'] . "\$/i", @$user["ACCESS"]) || preg_match("/^" . $modules[$i]['NAME'] . ",/i", @$user["ACCESS"]) || preg_match("/^" . $modules[$i]['NAME'] . "\$/i", @$user["ACCESS"]) || 0) {
                     $modules[$i]["SELECTED"] = 1;
                 }
                 if (($i + 1) % 3 == 0) {
                     $modules[$i]['NEWR'] = 1;
                 }
             }
             $user["MODULES"] = $modules;
             outHash($user, $out);
         }
         $users = SQlSelect("SELECT * FROM admin_users ORDER BY ID DESC");
         $out["USERS"] = $users;
     }
     $out["MODE"] = $mode;
     $out["ACTION"] = $this->action;
     $this->data = $out;
     $p = new parser(DIR_TEMPLATES . $this->name . "/" . $this->name . ".html", $this->data, $this);
     $this->result = $p->result;
 }
Esempio n. 8
0
    $rec['KEEP_HISTORY'] = (int) $keep_history;
    global $onchange;
    $rec['ONCHANGE'] = trim($onchange);
    //updating 'Description' (text)
    global $description;
    $rec['DESCRIPTION'] = $description;
    //UPDATING RECORD
    if ($ok) {
        if ($rec['ID']) {
            SQLUpdate($table_name, $rec);
            // update
            if (!$rec['KEEP_HISTORY']) {
                $pvalues = SQLSelect("SELECT * FROM pvalues WHERE PROPERTY_ID='" . $rec['ID'] . "'");
                $total = count($pvalues);
                for ($i = 0; $i < $total; $i++) {
                    SQLExec("DELETE FROM phistory WHERE VALUE_ID='" . $pvalues[$i]['ID'] . "'");
                }
            }
        } else {
            $new_rec = 1;
            $rec['ID'] = SQLInsert($table_name, $rec);
            // adding new record
        }
        $out['OK'] = 1;
    } else {
        $out['ERR'] = 1;
    }
}
if (is_array($rec)) {
    foreach ($rec as $k => $v) {
        if (!is_array($v)) {
Esempio n. 9
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS rss_channels');
     SQLExec('DROP TABLE IF EXISTS rss_items');
     parent::uninstall();
 }
Esempio n. 10
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS history');
     parent::uninstall();
 }
Esempio n. 11
0
    //updating 'DEVICEID' (varchar)
    global $deviceid;
    $rec['DEVICEID'] = $deviceid;
    //UPDATING RECORD
    if ($ok) {
        if ($rec['ID']) {
            SQLUpdate($table_name, $rec);
            // update
        } else {
            $new_rec = 1;
            $rec['ID'] = SQLInsert($table_name, $rec);
            // adding new record
        }
        $out['OK'] = 1;
        if ($rec['DEVICEID']) {
            SQLExec("UPDATE gpslog SET DEVICE_ID='" . $rec['ID'] . "' WHERE DEVICE_ID=0 AND DEVICEID='" . DBSafe($rec['DEVICEID']) . "'");
        }
    } else {
        $out['ERR'] = 1;
    }
}
//options for 'USER_ID' (select)
$tmp = SQLSelect("SELECT ID, NAME FROM users ORDER BY NAME");
$users_total = count($tmp);
for ($users_i = 0; $users_i < $users_total; $users_i++) {
    $user_id_opt[$tmp[$users_i]['ID']] = $tmp[$users_i]['NAME'];
}
for ($i = 0; $i < $users_total; $i++) {
    if ($rec['USER_ID'] == $tmp[$i]['ID']) {
        $tmp[$i]['SELECTED'] = 1;
    }
Esempio n. 12
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS gpslog');
     SQLExec('DROP TABLE IF EXISTS gpslocations');
     SQLExec('DROP TABLE IF EXISTS gpsdevices');
     SQLExec('DROP TABLE IF EXISTS gpsactions');
     parent::uninstall();
 }
Esempio n. 13
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS watchfolders');
     parent::uninstall();
 }
Esempio n. 14
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS scenes');
     SQLExec('DROP TABLE IF EXISTS elements');
     SQLExec('DROP TABLE IF EXISTS elm_states');
     parent::uninstall();
 }
Esempio n. 15
0
 /**
 * Install
 *
 * Module installation routine
 *
 * @access private
 */
 function install($parent_name = "")
 {
     parent::install($parent_name);
     SQLExec("UPDATE project_modules SET HIDDEN=1 WHERE NAME LIKE '" . $this->name . "'");
 }
Esempio n. 16
0
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
 function uninstall() {
  SQLExec('DROP TABLE IF EXISTS terminals');
  parent::uninstall();
 }
Esempio n. 17
0
        }
        $out['OK'] = 1;
        if ($rec['CLASS_ID']) {
            $objects = getObjectsByClass($rec['CLASS_ID']);
            $total = count($objects);
            $replaces = array();
            for ($i = 0; $i < $total; $i++) {
                $property = SQLSelectOne("SELECT ID FROM properties WHERE TITLE LIKE '" . DBSafe($rec['TITLE']) . "' AND OBJECT_ID=" . (int) $objects[$i]['ID'] . " AND CLASS_ID!=" . (int) $rec['CLASS_ID']);
                if ($property['ID']) {
                    $replaces[] = $property['ID'];
                }
            }
            $total = count($replaces);
            for ($i = 0; $i < $total; $i++) {
                SQLExec("UPDATE pvalues SET PROPERTY_ID=" . (int) $rec['ID'] . " WHERE PROPERTY_ID=" . (int) $replaces[$i]);
                SQLExec("DELETE FROM properties WHERE ID=" . (int) $replaces[$i]);
            }
        }
    } else {
        $out['ERR'] = 1;
    }
}
if (is_array($rec)) {
    foreach ($rec as $k => $v) {
        if (!is_array($v)) {
            $rec[$k] = htmlspecialchars($v);
        }
    }
}
outHash($rec, $out);
global $overwrite;
Esempio n. 18
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS settings');
     parent::uninstall();
 }
Esempio n. 19
0
/**
* Module data installation
*
* Installing required module data structure into project.
* (Notes: file "initial.sql" will be executed if found in project directory)
*
* @param string $data required database tables and fields
* @access private
*/
 function dbInstall($data) {
  $sql="";
  $strings=explode("\n", $data);
  $table_defined=array();
  for($i=0;$i<count($strings);$i++) {

   $strings[$i]=preg_replace('/\/\/.+$/is', '', $strings[$i]);
   $fields=explode(":", $strings[$i]);
   $table=trim(array_shift($fields));
   $definition=trim(implode(':', $fields));
   $definition=str_replace("\r", "", trim($definition));


   if ($definition=="") continue;

   $tmp=explode(" ", $definition);
   $field=$tmp[0];
   $definition=str_replace($field.' ', '`'.$field.'` ', $definition);

   if (!IsSet($table_defined[$table])) {
   // new table
    if (strpos($definition, "auto_increment")) {
     $definition.=", PRIMARY KEY(".$field.")";
     //$definition.=", KEY(".$field.")";
    }
    $sql="CREATE TABLE IF NOT EXISTS $table ($definition);";
    $table_defined[$table]=1;
    SQLExec($sql);
    $result = SQLExec("SHOW FIELDS FROM $table");
    while($row = mysql_fetch_array($result)) {
     $tbl_fields[$table][$row[Field]]=1;
    }

   } elseif ((strtolower($field)=='key') || (strtolower($field)=='index')  || (strtolower($field)=='fulltext')) {

    if (!$indexes_retrieved[$table]) {
     $result = SQLExec("SHOW INDEX FROM $table");
     while($row = mysql_fetch_array($result)) {
      $tbl_indexes[$table][$row[Key_name]]=1;
     }
     $indexes_retrieved[$table]=1;
    }

    preg_match('/\((.+?)\)/', $definition, $matches);
    $key_name=trim($matches[1]);

    if (!IsSet($tbl_indexes[$table][$key_name])) {
     $sql="ALTER IGNORE TABLE $table ADD $definition;";     
     SQLExec($sql);
    }

   } elseif (!IsSet($tbl_fields[$table][$field])) {
   // new field
    $sql="ALTER IGNORE TABLE $table ADD $definition;";
    SQLExec($sql);
   }
  }

   // executing initial query and comments each line to prevent execution next time
    if (file_exists(DIR_MODULES.$this->name."/initial.sql")) {
     $data=LoadFile(DIR_MODULES.$this->name."/initial.sql");
     $data.="\n";
     $data=str_replace("\r", "", $data);
     $query=explode("\n",$data);
     for ($i=0;$i < count($query)-1;$i++) {
      if ($query[$i]{0}!="#") {
       SQLExec($query[$i]);
       $mdf[]="#".$query[$i];
      } else {
       $mdf[]=$query[$i];
      }
     }
     SaveFile(DIR_MODULES.$this->name."/initial.sql", join("\n", $mdf));
    }

 }
/**
* FrontEnd
*
* Module frontend
*
* @access public
*/
function usual(&$out) {


   $terminals=SQLSelect("SELECT * FROM terminals WHERE CANPLAY=1 ORDER BY TITLE");
   $total=count($terminals);
   for($i=0;$i<$total;$i++) {
    //if ($terminals[$i]['NAME']==$session->data['PLAY_TERMINAL']) {
    // $terminals[$i]['SELECTED']=1;
    // $out['TERMINAL_TITLE']=$terminals[$i]['TITLE'];
    //}
   }
   $out['TERMINALS']=$terminals;
   $out['TERMINALS_TOTAL']=count($terminals);


   if ($this->mode=='play') {
    //echo $this->owner->popup;
    global $showplayer;

    $this->showplayer=1;

    if ($this->showplayer) {
     $showplayer=1;
    }
    if ($showplayer) {
     $this->showplayer=1;
     $out['SHOWPLAYER']=1;
    }
    global $terminal_id;
    $out['TERMINAL_ID']=$terminal_id;
   }

 global $collection_id;

 if ($this->collection_id) {
  $collection_id=$this->collection_id;
 }
 $this->collection_id=$collection_id;

 $out['COLLECTIONS']=SQLSelect("SELECT * FROM collections ORDER BY TITLE");

 if (count($out['COLLECTIONS'])==1) {
  $collection_id=$out['COLLECTIONS'][0]['ID'];
  $this->collection_id=$collection_id;
  $out['COLLECTIONS_TOTAL']=1;
 }



 if ($collection_id) {
  $collection=SQLSelectOne("SELECT * FROM collections WHERE ID='".(int)$collection_id."'");
  $path=($collection['PATH']);//addslashes
  $out['COLLECTION_ID']=$collection['ID']; 
 } else {
  return;
 }

 //$this->getConfig();
 //$path=$this->config['PATH'];

// echo $path;
//
  global $folder;

  if ($this->folder) {
   $folder=base64_decode($this->folder);
  } else {
   $this->folder=base64_encode($folder);
  }
  

  $favorites=SQLSelect("SELECT * FROM media_favorites WHERE 1 ORDER BY ID DESC");
  if ($favorites) {
   $total=count($favorites);
   for($i=0;$i<$total;$i++) {
    $favorites[$i]['PATH']=urlencode(utf2win($favorites[$i]['PATH']));
   }
   $out['FAVORITES']=$favorites;
  }

  $folder=str_replace('././', './', $folder);
  $path=str_replace('././', './', $path);


  $act_dir=$path.$folder;



  $out['MEDIA_PATH']=win2utf($path);
  $out['CURRENT_DIR']=win2utf('./'.$folder);
  $out['CURRENT_DIR']=str_replace('././', './', $out['CURRENT_DIR']);
  $out['CURRENT_DIR_TITLE']=$folder;

  $tmp=explode('/', $out['CURRENT_DIR']);
  $total=count($tmp);
  if ($total>0) {
   $spath='.';
   for($i=0;$i<$total;$i++) {
    $tmp_rec=array();
    $tmp_rec['TITLE']=$tmp[$i];
    $spath.='/'.$tmp_rec['TITLE'];
    $spath=str_replace('././', './', $spath);
    $tmp_rec['PATH']=urlencode(utf2win($spath).'/');
    if ($tmp_rec['TITLE']=='.') {
     $tmp_rec['TITLE']='Home';
    }
    $out['HISTORY'][]=$tmp_rec;
    //echo $tmp_rec['PATH']."<br>";
   }
   $out['CURRENT_DIR_TITLE']=($out['HISTORY'][$total-3]['TITLE'].'/'.$out['HISTORY'][$total-2]['TITLE']);
  }


  $out['CURRENT_DIR_TITLE_HTML']=urlencode($out['CURRENT_DIR_TITLE']);
  $out['CURRENT_DIR_HTML']=urlencode('./'.($folder));

  $tmp=SQLSelectOne("SELECT ID FROM media_favorites WHERE LIST_ID='".(int)$list_id."' AND COLLECTION_ID='".$collection['ID']."' AND PATH LIKE '".DBSafe($out['CURRENT_DIR'])."'");
  if ($tmp['ID']) {
   $out['FAVORITE']=1;
  }

  global $file;
  if ($file) {
   $out['FILE']=win2utf($file);
   $out['BASEFILE']=win2utf(basename($file));
   $file=str_replace('/', '\\\\', $file);
   $out['FULLFILE']=win2utf(addslashes($path).$file);
   $out['FULLFILE_S']=str_replace('\\\\', '\\', $out['FULLFILE']);
  }

  if (preg_match('/foto/is', $act_dir) || preg_match('/photo/is', $act_dir)) {
   $out['LIST_MODE']='foto';
  }

  $descriptions=$this->getDescriptions($act_dir);

  global $media_ajax;
  if ($media_ajax) {
   global $op;
   global $list_id;
   global $title;
   global $dir;

   header ("HTTP/1.0: 200 OK\n");
   header ('Content-Type: text/html; charset=utf-8');

   $tmp_path=$dir;

   if ($op=='favorite_add') {
    $rec=array();
    $rec['TITLE']=$title;
    $rec['PATH']=$tmp_path;
    $rec['LIST_ID']=(int)$list_id;
    $rec['COLLECTION_ID']=$collection_id;
    SQLInsert('media_favorites', $rec);
    echo "OK";
   }
   if ($op=='favorite_remove') {
    SQLExec("DELETE FROM media_favorites WHERE LIST_ID='".(int)$list_id."' AND COLLECTION_ID='".$collection['ID']."' AND PATH LIKE '".DBSafe($tmp_path)."'");
    echo "OK";
   }
   exit;
  }


   function sort_files($a, $b) {
    return strcmp(strtoupper($a["TITLE"]), strtoupper($b["TITLE"])); 
   }

  $dirs=array();
  //$act_dir='\\\\home\\media\\';
  //echo $act_dir;
  $d=openDir($act_dir);
  //exit;

  if ($d) {
  while ($file=readDir($d)) {
   if (($file==".") || ($file=="..")) {
    continue;
   }
   if (Is_Dir($act_dir.$file)) {
    $rec=array();
    $rec['TITLE']=$file;
    $rec['TITLE_SHORT']=$rec['TITLE'];
    if (strlen($rec['TITLE_SHORT'])>50) {
     $rec['TITLE_SHORT']=substr($rec['TITLE_SHORT'], 0, 50).'...';
    }

    $rec['TITLE']=win2utf($rec['TITLE']);
    $rec['TITLE_SHORT']=win2utf($rec['TITLE_SHORT']);

    if (IsSet($descriptions[$file])) {
     $rec['DESCR']=$descriptions[$file];
    }
    $rec['PATH']=urlencode(($folder.$file)).'/';
    $rec['REAL_PATH']=$dir.$file;
    $rec['ID']=md5($rec['REAL_PATH']);
    $dirs[]=$rec;
   }
  }

  closeDir($d);
  }


  //$dirs=mysort_array($dirs, "TITLE");
  usort($dirs, 'sort_files');

  //print_r($dirs);

  if (count($dirs)>0) $out['DIRS']=$dirs;

  @$d=openDir($act_dir);
  if ($d) {

  $cover=$this->getCover($act_dir);
  if ($cover) {
   $out['COVER']=$cover;
   $out['COVER_PATH']=urlencode(str_replace('\\\\', '\\', $act_dir).$cover);
  }


  $files=array();
  while ($file=readDir($d)) {
   if (($file==".") || ($file=="..") || ($file=="Descript.ion")) {
    continue;
   }
   if (Is_File($act_dir.$file)) {
    $rec=array();
    $rec['TITLE']=$file;
    if (IsSet($descriptions[$file])) {
     $rec['DESCR']=$descriptions[$file];
    }
    if (strlen($rec['TITLE'])>50) {
     $rec['TITLE_SHORT']=substr($rec['TITLE'], 0, 50)."...";
    } else {
     $rec['TITLE_SHORT']=$rec['TITLE'];
    }
    $rec['TITLE']=win2utf($rec['TITLE']);
    $rec['TITLE_SHORT']=win2utf($rec['TITLE_SHORT']);
    $rec['REAL_PATH']=($folder.$file);
    $rec['PATH']=urlencode($folder.$file);
    $rec['FULL_PATH']=urlencode(str_replace('\\\\', '\\', $act_dir).$file);
    $size=filesize($act_dir.$file);
    $total_size+=$size;
    if ($size>1024) {
     if ($size>1024*1024) {
      $size=(((int)(($size/1024/1024)*10))/10)." Mb";
     } else {
      $size=(int)($size/1024)." Kb";
     }
    } else {
     $size.=" b";
    }
    $rec['SIZE']=$size;
    $rec['ID']=md5($rec['PATH']);
    $files[]=$rec;
   }
  }
  closeDir($d);
  }

  //$files=mysort_array($files, "TITLE");
  usort($files, 'sort_files');

  if (count($files)>0) {
   $total=count($files);
   $out['TOTAL_FILES']=$total;
   for($i=0;$i<$total;$i++) {
    if (preg_match('/\.jpg$/is', $files[$i]['PATH'])) {
     $files[$i]['IS_FOTO']=1;
    }
    if (($i+1)%4==0) {
     $files[$i]['NEWROW']=1;
    }
   }
   $out['FILES']=$files;
  }



  $out['TOTAL_DIRS']=count($dirs);

    if ($total_size>1024) {
     if ($total_size>1024*1024) {
      $total_size=(((int)(($total_size/1024/1024)*10))/10)." Mb";
     } else {
      $total_size=(int)($total_size/1024)." Kb";
     }
    } else {
     $total_size.=" b";
    }
    $out['TOTAL_SIZE']=$total_size;


}
 function install($parent_name = "")
 {
     parent::install($parent_name);
     $this->getModulesList();
     $lst = $this->modules;
     $lstCnt = count($lst);
     $code = "";
     for ($i = 0; $i < $lstCnt; $i++) {
         if (file_exists(DIR_MODULES . $lst[$i]['FILENAME'] . "/" . $lst[$i]['FILENAME'] . ".class.php")) {
             if ($lst[$i]['FILENAME'] == 'control_modules') {
                 continue;
             }
             $installedFile = DIR_MODULES . $lst[$i]['FILENAME'] . "/installed";
             if (file_exists($installedFile)) {
                 unlink($installedFile);
             }
             include_once DIR_MODULES . $lst[$i]['FILENAME'] . "/" . $lst[$i]['FILENAME'] . ".class.php";
             $obj = "\$object{$i}";
             $code .= "{$obj}=new " . $lst[$i]['FILENAME'] . ";\n";
         }
     }
     @eval("{$code}");
     SQLExec("UPDATE project_modules SET HIDDEN=0 WHERE NAME LIKE '" . $this->name . "'");
 }
Esempio n. 22
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS zwave_devices');
     SQLExec('DROP TABLE IF EXISTS zwave_properties');
     parent::uninstall();
 }
Esempio n. 23
0
 function run()
 {
     // running current module
     global $mode;
     global $name;
     $rep_ext = "";
     if (preg_match('/\\.dev/is', $_SERVER['HTTP_HOST'])) {
         $rep_ext = '.dev';
     }
     if (preg_match('/\\.jbk/is', $_SERVER['HTTP_HOST'])) {
         $rep_ext = '.jbk';
     }
     if (preg_match('/\\.bk/is', $_SERVER['HTTP_HOST'])) {
         $rep_ext = '.bk';
     }
     if ($rep_ext) {
         $out['LOCAL_PROJECT'] = 1;
         $out['REP_EXT'] = $rep_ext;
         $out['HOST'] = $_SERVER['HTTP_HOST'];
         $out['DOCUMENT_ROOT'] = dirname($_SERVER['SCRIPT_FILENAME']);
     }
     if ($mode == "edit") {
         global $mode2;
         $rec = SQLSelectOne("SELECT * FROM project_modules WHERE NAME='" . $name . "'");
         $rec['NAME'] = $name;
         if ($mode2 == "update") {
             global $title;
             global $category;
             $rec['TITLE'] = $title;
             $rec['CATEGORY'] = $category;
             SQLUpdate("project_modules", $rec);
             $this->redirect("?name={$name}&mode=edit");
         } elseif ($mode2 == "show") {
             if ($rec['HIDDEN']) {
                 $rec['HIDDEN'] = 0;
             } else {
                 $rec['HIDDEN'] = 1;
             }
             SQLUpdate('project_modules', $rec);
             $this->redirect("?");
         } elseif ($mode2 == "install") {
             $rec = SQLSelectOne("SELECT * FROM project_modules WHERE NAME='" . $name . "'");
             SQLExec("DELETE FROM project_modules WHERE NAME='" . $name . "'");
             @unlink(DIR_MODULES . $name . "/installed");
             include_once DIR_MODULES . $name . "/" . $name . ".class.php";
             $obj = "\$object{$i}";
             $code .= "{$obj}=new " . $name . ";\n";
             @eval($code);
             // add module to control access
             global $session;
             $user = SQLSelectOne("SELECT * FROM admin_users WHERE LOGIN='******'");
             if ($user['ID'] && !Is_Integer(strpos($user["ACCESS"], $name))) {
                 if ($user["ACCESS"] != '') {
                     $user["ACCESS"] .= ",{$name}";
                 } else {
                     $user["ACCESS"] = $name;
                 }
                 SQLUpdate('admin_users', $user);
             }
             SQLExec("UPDATE project_modules SET HIDDEN='" . (int) $rec['HIDDEN'] . "' WHERE NAME='" . $name . "'");
             // redirect to edit
             $this->redirect("?name={$name}&mode=edit");
         } elseif ($mode2 == 'uninstall') {
             SQLExec("DELETE FROM project_modules WHERE NAME='" . $name . "'");
             @unlink(DIR_MODULES . $name . "/installed");
             if (file_exists(DIR_MODULES . $name . "/" . $name . ".class.php")) {
                 include_once DIR_MODULES . $name . "/" . $name . ".class.php";
                 $obj = "\$object{$i}";
                 $code .= "{$obj}=new " . $name . ";\n";
                 $code .= "{$obj}" . "->uninstall();";
                 eval($code);
             }
             if ($out['LOCAL_PROJECT']) {
                 $this->redirect("?mode=repository_uninstall&module={$name}");
             } else {
                 $this->redirect("?");
             }
         }
         outHash($rec, $out);
     }
     if ($mode == 'repository_uninstall') {
         global $module;
         $out['MODULE'] = $module;
     }
     $out["MODE"] = $mode;
     $this->getModulesList();
     $lst = $this->modules;
     for ($i = 0; $i < count($lst); $i++) {
         $rec = SQLSelectOne("SELECT *, DATE_FORMAT(ADDED, '%M %d, %Y (%H:%i)') as DAT FROM project_modules WHERE NAME='" . $lst[$i]['FILENAME'] . "'");
         if (isset($rec['ID'])) {
             outHash($rec, $lst[$i]);
         }
     }
     $out["MODULES"] = $lst;
     $this->data = $out;
     $p = new parser(DIR_TEMPLATES . $this->name . "/" . $this->name . ".html", $this->data, $this);
     $this->result = $p->result;
 }
     $rec["MIB_FILE"] = '';
     SQLUpdate($table_name, $rec);
 }
 if ($rec['ID']) {
     $properties = SQLSelect("SELECT * FROM snmpproperties WHERE DEVICE_ID='" . $rec['ID'] . "'");
     $total = count($properties);
     for ($i = 0; $i < $total; $i++) {
         global ${'oid_' . $properties[$i]['ID']};
         global ${'type_' . $properties[$i]['ID']};
         global ${'ptitle_' . $properties[$i]['ID']};
         global ${'pvalue_' . $properties[$i]['ID']};
         global ${'pinterval_' . $properties[$i]['ID']};
         global ${'linked_object_' . $properties[$i]['ID']};
         global ${'linked_property_' . $properties[$i]['ID']};
         if (!${'oid_' . $properties[$i]['ID']}) {
             SQLExec("DELETE FROM snmpproperties WHERE ID='" . $properties[$i]['ID'] . "'");
             continue;
         }
         $prec = $properties[$i];
         $prec['OID'] = trim(${'oid_' . $properties[$i]['ID']});
         $prec['TYPE'] = ${'type_' . $properties[$i]['ID']};
         $prec['TITLE'] = trim(${'ptitle_' . $properties[$i]['ID']});
         if ($prec['ONLINE_INTERVAL'] != ${'pinterval_' . $properties[$i]['ID']}) {
             $prec['ONLINE_INTERVAL'] = (int) ${'pinterval_' . $properties[$i]['ID']};
             if ($prec['ONLINE_INTERVAL']) {
                 $prec['CHECK_NEXT'] = date('Y-m-d H:i:s');
             }
         }
         $old_linked_object = $prec['LINKED_OBJECT'];
         $old_linked_property = $prec['LINKED_PROPERTY'];
         $prec['LINKED_OBJECT'] = trim(${'linked_object_' . $properties[$i]['ID']});
Esempio n. 25
0
}
if (isset($_REQUEST['latitude'])) {
    //DebMes("GPS DATA RECEIVED: \n".serialize($_REQUEST));
    if ($_REQUEST['deviceid']) {
        $sqlQuery = "SELECT *\n                     FROM gpsdevices\n                    WHERE DEVICEID = '" . DBSafe($_REQUEST['deviceid']) . "'";
        $device = SQLSelectOne($sqlQuery);
        if (!$device['ID']) {
            $device = array();
            $device['DEVICEID'] = $_REQUEST['deviceid'];
            $device['TITLE'] = 'New GPS Device';
            if ($_REQUEST['token']) {
                $device['TOKEN'] = $_REQUEST['token'];
            }
            $device['ID'] = SQLInsert('gpsdevices', $device);
            $sqlQuery = "UPDATE gpslog\n                         SET DEVICE_ID = '" . $device['ID'] . "'\n                       WHERE DEVICEID = '" . DBSafe($_REQUEST['deviceid']) . "'";
            SQLExec($sqlQuery);
        }
        $device['LAT'] = $_REQUEST['latitude'];
        $device['LON'] = $_REQUEST['longitude'];
        $device['UPDATED'] = date('Y-m-d H:i:s');
        SQLUpdate('gpsdevices', $device);
    }
    $rec = array();
    //$rec['ADDED']     = ($time) ? $time : date('Y-m-d H:i:s');
    $rec['ADDED'] = date('Y-m-d H:i:s');
    $rec['LAT'] = $_REQUEST['latitude'];
    $rec['LON'] = $_REQUEST['longitude'];
    $rec['ALT'] = round($_REQUEST['altitude'], 2);
    $rec['PROVIDER'] = $_REQUEST['provider'];
    $rec['SPEED'] = round($_REQUEST['speed'], 2);
    $rec['BATTLEVEL'] = $_REQUEST['battlevel'];
Esempio n. 26
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]);
         }
     }
 }
Esempio n. 27
0
    /**
    * dbInstall
    *
    * Database installation routine
    *
    * @access private
    */
    function dbInstall($data)
    {
        /*
        commands - Commands
        */
        $data = <<<EOD
 commands: ID int(10) unsigned NOT NULL auto_increment
 commands: TITLE varchar(255) NOT NULL DEFAULT ''
 commands: SYSTEM varchar(255) NOT NULL DEFAULT ''
 commands: COMMAND varchar(255) NOT NULL DEFAULT ''
 commands: URL varchar(255) NOT NULL DEFAULT ''
 commands: TYPE char(50) NOT NULL DEFAULT ''
 commands: WINDOW varchar(255) NOT NULL DEFAULT ''
 commands: WIDTH int(10) NOT NULL DEFAULT '0'
 commands: HEIGHT int(10) NOT NULL DEFAULT '0'
 commands: PARENT_ID int(10) NOT NULL DEFAULT '0'
 commands: PRIORITY int(10) NOT NULL DEFAULT '0'
 commands: MIN_VALUE float(10) NOT NULL DEFAULT '0'
 commands: MAX_VALUE float(10) NOT NULL DEFAULT '0'
 commands: CUR_VALUE varchar(255) NOT NULL DEFAULT '0'
 commands: STEP_VALUE float(10) NOT NULL DEFAULT '1'
 commands: DATA text
 commands: LINKED_OBJECT varchar(255) NOT NULL DEFAULT ''
 commands: LINKED_PROPERTY varchar(255) NOT NULL DEFAULT ''
 commands: EXT_ID int(10) NOT NULL DEFAULT '0'
 commands: VISIBLE_DELAY int(10) NOT NULL DEFAULT '0'
 commands: INLINE int(3) NOT NULL DEFAULT '0'
 commands: SUB_PRELOAD int(3) NOT NULL DEFAULT '0'
 commands: RENDER_TITLE varchar(255) NOT NULL DEFAULT ''
 commands: RENDER_DATA text
 commands: RENDER_UPDATED datetime

 commands: ONCHANGE_OBJECT varchar(255) NOT NULL DEFAULT ''
 commands: ONCHANGE_METHOD varchar(255) NOT NULL DEFAULT ''
 commands: SCRIPT_ID int(10) NOT NULL DEFAULT '0'
 commands: ICON varchar(50) NOT NULL DEFAULT ''
 commands: CODE text


 commands: SUB_LIST text
 commands: PARENT_LIST text
 commands: AUTOSTART int(3) NOT NULL DEFAULT '0'
 commands: AUTO_UPDATE int(10) NOT NULL DEFAULT '0'
EOD;
        parent::dbInstall($data);
        SQLExec("ALTER TABLE `commands` CHANGE `MIN_VALUE` `MIN_VALUE` FLOAT( 10 ) NOT NULL DEFAULT '0'");
        SQLExec("ALTER TABLE `commands` CHANGE `MAX_VALUE` `MAX_VALUE` FLOAT( 10 ) NOT NULL DEFAULT '0'");
        SQLExec("ALTER TABLE `commands` CHANGE `STEP_VALUE` `STEP_VALUE` FLOAT( 10 ) NOT NULL DEFAULT '0'");
    }
Esempio n. 28
0
    }
}
if ($this->filter_name == 'logger' && !defined('SETTINGS_LOGGER_DESTINATION')) {
    $options = array('LOGGER_DESTINATION' => 'Write log to (file/database/both)');
    foreach ($options as $k => $v) {
        $tmp = SQLSelectOne("SELECT ID FROM settings WHERE NAME LIKE '" . $k . "'");
        if (!$tmp['ID']) {
            $tmp = array();
            $tmp['NAME'] = $k;
            $tmp['TITLE'] = $v;
            $tmp['TYPE'] = 'text';
            SQLInsert('settings', $tmp);
        }
    }
    $query = "CREATE TABLE IF NOT EXISTS `log4php_log` (`timestamp` DATETIME, `logger` VARCHAR(256), `level` VARCHAR(32), `message` VARCHAR(4000), `thread` INTEGER, `file` VARCHAR(255), `line` VARCHAR(10));";
    SQLExec($query);
}
if ($this->filter_name == 'scenes' && !defined('SETTINGS_SCENES_VERTICAL_NAV')) {
    $options = array('SCENES_VERTICAL_NAV' => 'Vertical navigation');
    foreach ($options as $k => $v) {
        $tmp = SQLSelectOne("SELECT ID FROM settings WHERE NAME LIKE '" . $k . "'");
        if (!$tmp['ID']) {
            $tmp = array();
            $tmp['NAME'] = $k;
            $tmp['TITLE'] = $v;
            $tmp['TYPE'] = 'onoff';
            $tmp['DEFAULTVALUE'] = '0';
            SQLInsert('settings', $tmp);
        }
    }
}
Esempio n. 29
0
 /**
 * Uninstall
 *
 * Module uninstall routine
 *
 * @access public
 */
 function uninstall()
 {
     SQLExec('DROP TABLE IF EXISTS products');
     SQLExec('DROP TABLE IF EXISTS product_categories');
     SQLExec('DROP TABLE IF EXISTS shopping_list_items');
     parent::uninstall();
 }
Esempio n. 30
0
            echo ".";
            echo str_repeat(' ', 1024);
            flush();
            flush();
        }
    }
    /*
    if ($to_delete[0]) {
     $total=count($to_delete);
     for($i=0;$i<$total;$i++) {
      SQLExec("DELETE FROM gpslog WHERE ID=".$to_delete[$i]);
     }
     $this->redirect("?");
    }
    */
    SQLExec("OPTIMIZE TABLE `gpslog`");
    echo " DONE";
    echo str_repeat(' ', 1024);
    flush();
    flush();
    exit;
}
global $session;
if ($this->owner->name == 'panel') {
    $out['CONTROLPANEL'] = 1;
}
$qry = "1";
// search filters
if (isset($this->device_id)) {
    $device_id = $this->device_id;
    $qry .= " AND DEVICE_ID='" . $this->device_id . "'";