jwarnier
2010-09-23 458767fb1b65a15ddae3846df6aacdc9610342ad
- replace double-quotes with single-quotes whenever appropriate
- reword some output
- fix typos


7 files modified
332 ■■■■ changed files
server/lib/classes/db_mysql.inc.php 128 ●●●● patch | view | raw | blame | history
server/lib/classes/file.inc.php 52 ●●●● patch | view | raw | blame | history
server/lib/classes/getconf.inc.php 10 ●●●● patch | view | raw | blame | history
server/lib/classes/modules.inc.php 72 ●●●● patch | view | raw | blame | history
server/lib/classes/plugins.inc.php 24 ●●●● patch | view | raw | blame | history
server/lib/classes/services.inc.php 12 ●●●● patch | view | raw | blame | history
server/lib/classes/system.inc.php 34 ●●●● patch | view | raw | blame | history
server/lib/classes/db_mysql.inc.php
@@ -29,18 +29,18 @@
    class db
    {
        var $dbHost = "";        // hostname of the MySQL server
        var $dbName = "";        // logical database name on that server
        var $dbUser = "";        // database authorized user
        var $dbPass = "";        // user's password
        var $dbHost = '';        // hostname of the MySQL server
        var $dbName = '';        // logical database name on that server
        var $dbUser = '';        // database authorized user
        var $dbPass = '';        // user's password
        var $linkId = 0;        // last result of mysql_connect()
        var $queryId = 0;        // last result of mysql_query()
        var $record    = array();    // last record fetched
        var $autoCommit = 1;    // Autocommit Transactions
        var $currentRow;        // current row number
        var $errorNumber = 0;    // last error number
        var $errorMessage = "";    // last error message
        var $errorLocation = "";// last error location
        var $errorMessage = '';    // last error message
        var $errorLocation = '';// last error location
        var $show_error_messages = true;
        // constructor
@@ -48,10 +48,10 @@
        {
            
            global $conf;
            $this->dbHost = $conf["db_host"];
            $this->dbName = $conf["db_database"];
            $this->dbUser = $conf["db_user"];
            $this->dbPass = $conf["db_password"];
            $this->dbHost = $conf['db_host'];
            $this->dbName = $conf['db_database'];
            $this->dbUser = $conf['db_user'];
            $this->dbPass = $conf['db_password'];
            $this->dbCharset = $conf['db_charset'];
            //$this->connect();
        }
@@ -66,7 +66,7 @@
            if($this->errorNumber && $this->show_error_messages && method_exists($app,'log'))
            {
                // echo('<br /><b>'.$this->errorLocation.'</b><br />'.$this->errorMessage);
                $app->log($this->errorLocation." ".$this->errorMessage,LOGLEVEL_WARN);
                $app->log($this->errorLocation.' '.$this->errorMessage,LOGLEVEL_WARN);
                //flush();
            }
        }
@@ -282,16 +282,16 @@
        unset($tmp);
        
        // Insert the server_id, if the record has a server_id
        $server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0;
        if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
        $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0;
        if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
        
        if($diff_num > 0) {
            //print_r($diff_num);
            //print_r($diffrec_full);
            $diffstr = $app->db->quote(serialize($diffrec_full));
            $username = $app->db->quote($_SESSION["s"]["user"]["username"]);
            $dbidx = $primary_field.":".$primary_id;
            $username = $app->db->quote($_SESSION['s']['user']['username']);
            $dbidx = $primary_field.':'.$primary_id;
                        
            if($action == 'INSERT') $action = 'i';
            if($action == 'UPDATE') $action = 'u';
@@ -383,27 +383,27 @@
       */
       
       function createTable($table_name,$columns) {
       $index = "";
       $index = '';
       $sql = "CREATE TABLE $table_name (";
       foreach($columns as $col){
            $sql .= $col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." ";
            $sql .= $col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
       
            if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' ";
            if($col["notNull"] == true) {
                $sql .= "NOT NULL ";
            if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
            if($col['notNull'] == true) {
                $sql .= 'NOT NULL ';
            } else {
                $sql .= "NULL ";
                $sql .= 'NULL ';
            }
            if($col["autoInc"] == true) $sql .= "auto_increment ";
            $sql.= ",";
            if($col['autoInc'] == true) $sql .= 'auto_increment ';
            $sql.= ',';
            // key Definitionen
            if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),";
            if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),";
            if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),";
            if($col['option'] == 'primary') $index .= "PRIMARY KEY (".$col['name']."),";
            if($col['option'] == 'index') $index .= "INDEX (".$col['name']."),";
            if($col['option'] == 'unique') $index .= "UNIQUE (".$col['name']."),";
       }
       $sql .= $index;
       $sql = substr($sql,0,-1);
       $sql .= ")";
       $sql .= ')';
       
       $this->query($sql);
       return true;
@@ -423,29 +423,29 @@
       
       */
       function alterTable($table_name,$columns) {
       $index = "";
       $index = '';
       $sql = "ALTER TABLE $table_name ";
       foreach($columns as $col){
            if($col["action"] == 'add') {
                $sql .= "ADD ".$col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." ";
            } elseif ($col["action"] == 'alter') {
                $sql .= "CHANGE ".$col["name"]." ".$col["name_new"]." ".$this->mapType($col["type"],$col["typeValue"])." ";
            } elseif ($col["action"] == 'drop') {
                $sql .= "DROP ".$col["name"]." ";
            if($col['action'] == 'add') {
                $sql .= "ADD ".$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
            } elseif ($col['action'] == 'alter') {
                $sql .= "CHANGE ".$col['name']." ".$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
            } elseif ($col['action'] == 'drop') {
                $sql .= "DROP ".$col['name'].' ';
            }
            if($col["action"] != 'drop') {
            if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' ";
            if($col["notNull"] == true) {
                $sql .= "NOT NULL ";
            if($col['action'] != 'drop') {
            if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
            if($col['notNull'] == true) {
                $sql .= 'NOT NULL ';
            } else {
                $sql .= "NULL ";
                $sql .= 'NULL ';
            }
            if($col["autoInc"] == true) $sql .= "auto_increment ";
            $sql.= ",";
            if($col['autoInc'] == true) $sql .= 'auto_increment ';
            $sql.= ',';
            // key Definitionen
            if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),";
            if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),";
            if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),";
            if($col['option'] == 'primary') $index .= "PRIMARY KEY (".$col['name']."),";
            if($col['option'] == 'index') $index .= "INDEX (".$col['name']."),";
            if($col['option'] == 'unique') $index .= "UNIQUE (".$col['name']."),";
            }
       }
       $sql .= $index;
@@ -505,38 +505,38 @@
            
            $column = array();
        
            $column["name"] = $name;
            //$column["type"] = $type;
            $column["defaultValue"] = $default;
            if(stristr($key,"PRI")) $column["option"] = "primary";
            if(stristr($isnull,"YES")) {
                $column["notNull"] = false;
            $column['name'] = $name;
            //$column['type'] = $type;
            $column['defaultValue'] = $default;
            if(stristr($key,'PRI')) $column['option'] = 'primary';
            if(stristr($isnull,'YES')) {
                $column['notNull'] = false;
            } else {
               $column["notNull"] = true;
               $column['notNull'] = true;
            }
            if($extra == 'auto_increment') $column["autoInc"] = true;
            if($extra == 'auto_increment') $column['autoInc'] = true;
            
            
            // Type in Metatype umsetzen
            
            if(stristr($type,"int(")) $metaType = 'int32';
            if(stristr($type,"bigint")) $metaType = 'int64';
            if(stristr($type,"char")) {
            if(stristr($type,'int(')) $metaType = 'int32';
            if(stristr($type,'bigint')) $metaType = 'int64';
            if(stristr($type,'char')) {
                $metaType = 'char';
                $tmp_typeValue = explode('(',$type);
                $column["typeValue"] = substr($tmp_typeValue[1],0,-1);
                $column['typeValue'] = substr($tmp_typeValue[1],0,-1);
            }
            if(stristr($type,"varchar")) {
            if(stristr($type,'varchar')) {
                $metaType = 'varchar';
                $tmp_typeValue = explode('(',$type);
                $column["typeValue"] = substr($tmp_typeValue[1],0,-1);
                $column['typeValue'] = substr($tmp_typeValue[1],0,-1);
            }
            if(stristr($type,"text")) $metaType = 'text';
            if(stristr($type,"double")) $metaType = 'double';
            if(stristr($type,"blob")) $metaType = 'blob';
            if(stristr($type,'text')) $metaType = 'text';
            if(stristr($type,'double')) $metaType = 'double';
            if(stristr($type,'blob')) $metaType = 'blob';
            
            
            $column["type"] = $metaType;
            $column['type'] = $metaType;
            
        $columns[] = $column;
        }
@@ -595,7 +595,7 @@
            return 'char';
       break;
       case 'varchar':
            if($typeValue < 1) die("Datenbank Fehler: Für diesen Datentyp ist eine Längenangabe notwendig.");
            if($typeValue < 1) die('Database failure: Lenght required for these data types.');
            return 'varchar('.$typeValue.')';
       break;
       case 'text':
@@ -609,4 +609,4 @@
        
    }
?>
?>
server/lib/classes/file.inc.php
@@ -33,14 +33,14 @@
    function rf($file){
      global $app;
      clearstatcache();
      if(!$fp = fopen ($file, "rb")){
        $app->log("WARNING: could not open file ".$file, 2);
      if(!$fp = fopen ($file, 'rb')){
        $app->log('WARNING: Could not open file '.$file, 2);
        return false;
      } else {
        if(filesize($file) > 0){
          $content = fread($fp, filesize($file));
        } else {
          $content = "";
          $content = '';
        }
        fclose($fp);
        return $content;
@@ -50,8 +50,8 @@
    function wf($file, $content){
      global $app;
      $this->mkdirs(dirname($file));
      if(!$fp = fopen ($file, "wb")){
        $app->log("WARNING: could not open file ".$file, 2);
      if(!$fp = fopen ($file, 'wb')){
        $app->log('WARNING: Could not open file '.$file, 2);
        return false;
      } else {
        fwrite($fp,$content);
@@ -63,8 +63,8 @@
    function af($file, $content){
      global $app;
      $this->mkdirs(dirname($file));
      if(!$fp = fopen ($file, "ab")){
        $app->log("WARNING: could not open file ".$file, 2);
      if(!$fp = fopen ($file, 'ab')){
        $app->log('WARNING: Could not open file '.$file, 2);
        return false;
      } else {
        fwrite($fp,$content);
@@ -83,7 +83,7 @@
            if($pos != 0){
              $new_lines[] = substr($line,0,$pos);
            } else {
              $new_lines[] = "";
              $new_lines[] = '';
            }
          } else {
            $new_lines[] = $line;
@@ -95,7 +95,7 @@
        $new_lines = NULL;
        return $content_without_comments;
      } else {
        return "";
        return '';
      }
    }
    
@@ -106,7 +106,7 @@
        $manual = "\n".trim($parts[1]);
        return $manual;
      } else {
        return "";
        return '';
      }
    }
    
@@ -120,13 +120,13 @@
      $lines = explode("\n", $content);
      if(!empty($lines)){
        foreach($lines as $line){
          if(trim($line) != "") $new_lines[] = $line;
          if(trim($line) != '') $new_lines[] = $line;
        }
      }
      if(is_array($new_lines)){
        $content = implode("\n", $new_lines);
      } else {
        $content = "";
        $content = '';
      }
      if($file){
        $this->wf($input, $content);
@@ -160,17 +160,17 @@
    
    function edit_dist($var, $val){
      global $$var;
      $files = array("/root/ispconfig/dist.inc.php");
      $files = array('/root/ispconfig/dist.inc.php');
      foreach($files as $file){
        if(is_file($file)){
          $file_content = $this->unix_nl($this->rf($file));
          $lines = explode("\n", $file_content);
          for($i=0;$i<sizeof($lines);$i++){
            $parts = explode("=", $lines[$i]);
            $parts = explode('=', $lines[$i]);
            if($parts[0] == $var || $parts[0] == '$'.$var.' '){
              $parts[1] = str_replace($$var, $val, $parts[1]);
            }
            $lines[$i] = implode("=", $parts);
            $lines[$i] = implode('=', $parts);
          }
          $file_content = implode("\n", $lines);
          $this->wf($file, $file_content);
@@ -178,7 +178,7 @@
      }
    }
    
    function getDirectoryListing($dirname, $sortorder = "a", $show_subdirs = 0, $show_subdirfiles = 0, $exts = "", $ext_save = 1){
    function getDirectoryListing($dirname, $sortorder = 'a', $show_subdirs = 0, $show_subdirfiles = 0, $exts = '', $ext_save = 1){
    // This function will return an array with filenames based on the criteria you can set in the variables
    // @sortorder : a for ascending (the standard) or d for descending (you can use the "r" for reverse as well, works the same)
    // @show_subdirs : 0 for NO, 1 for YES - meaning it will show the names of subdirectories if there are any
@@ -190,33 +190,33 @@
    // @ext_save : 1 for YES, 0 for NO - meaning it will filter out system files or not (such as .htaccess)
    
       $dirname = realpath($dirname);
       if (!$exts || empty($exts) || $exts == "") {
           $exts = array("jpg", "gif", "jpeg", "png");
       if (!$exts || empty($exts) || $exts == '') {
           $exts = array('jpg', 'gif', 'jpeg', 'png');
       }
       if ($handle = opendir($dirname)) {
           $filelist = array();
           while (false !== ($file = readdir($handle))) {
    
               // Filter out higher directory references
               if ($file != "." && $file != "..") {
               if ($file != '.' && $file != '..') {
                   // Only look at directories or files, filter out symbolic links
                   if ( filetype ($dirname."/".$file) != "link") {
                   if ( filetype ($dirname.'/'.$file) != 'link') {
                       // If it's a file, check against valid extentions and add to the list
                       if ( filetype ($dirname."/".$file) == "file" ) {
                       if ( filetype ($dirname.'/'.$file) == 'file' ) {
                           if ($this->checkFileExtension($file, $exts, $ext_save)) {
                                           $filelist[] = $file;
                           }
                       }
                       // If it's a directory and either subdirs should be listed or files from subdirs add relevant names to the list
                       else if ( filetype ($dirname."/".$file) == "dir" && ($show_subdirs == 1 || $show_subdirfiles == 1)) {
                       else if ( filetype ($dirname.'/'.$file) == 'dir' && ($show_subdirs == 1 || $show_subdirfiles == 1)) {
                           if ($show_subdirs == 1) {
                               $filelist[] = $file;
                           }
                           if ($show_subdirfiles == 1) {
                               $subdirname = $file;
                               $subdirfilelist = $this->getDirectoryListing($dirname."/".$subdirname."/", $sortorder, $show_subdirs, $show_subdirfiles, $exts, $ext_save);
                               $subdirfilelist = $this->getDirectoryListing($dirname.'/'.$subdirname.'/', $sortorder, $show_subdirs, $show_subdirfiles, $exts, $ext_save);
                               for ($i = 0 ; $i < count($subdirfilelist) ; $i++) {
                                   $subdirfilelist[$i] = $subdirname."/".$subdirfilelist[$i];
                                   $subdirfilelist[$i] = $subdirname.'/'.$subdirfilelist[$i];
                               }
                               $filelist = array_merge($filelist, $subdirfilelist);
                           }
@@ -231,7 +231,7 @@
           // Sort the results
           if (count($filelist) > 1) {
               natcasesort($filelist);
               if ($sortorder == "d" || $sortorder == "r" ) {
               if ($sortorder == 'd' || $sortorder == 'r' ) {
                   $filelist = array_reverse($filelist, TRUE);
               }
           }
@@ -249,7 +249,7 @@
               return $passed;
           }
       }
       if ($exts == "all") {
       if ($exts == 'all') {
                       $passed = TRUE;
           return $passed;
       }
server/lib/classes/getconf.inc.php
@@ -38,8 +38,8 @@
        if(!is_array($this->config[$server_id])) {
            $app->uses('ini_parser');
            $server_id = intval($server_id);
            $server = $app->db->queryOneRecord("SELECT config FROM server WHERE server_id = $server_id");
            $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server["config"]));
            $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id);
            $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
        }
        
        if($section == '') {
@@ -54,12 +54,12 @@
        
        if(!is_array($this->config['global'])) {
            $app->uses('ini_parser');
            $tmp = $app->db->queryOneRecord("SELECT config FROM sys_ini WHERE sysini_id = 1");
            $this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp["config"]));
            $tmp = $app->db->queryOneRecord('SELECT config FROM sys_ini WHERE sysini_id = 1');
            $this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp['config']));
        }
        return ($section == '') ? $this->config['global'] : $this->config['global'][$section];
    }
    
}
?>
?>
server/lib/classes/modules.inc.php
@@ -43,21 +43,21 @@
        $subPath = 'mods-enabled';
        if ($type == 'core') $subPath = 'mods-core';
        $modules_dir = $conf["rootpath"].$conf["fs_div"].$subPath.$conf["fs_div"];
        $modules_dir = $conf['rootpath'].$conf['fs_div'].$subPath.$conf['fs_div'];
        if (is_dir($modules_dir)) {
            if ($dh = opendir($modules_dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        $module_name = substr($file,0,-8);
                        include_once($modules_dir.$file);
                        if($this->debug) $app->log("Loading Module: $module_name",LOGLEVEL_DEBUG);
                        if($this->debug) $app->log('Loading Module: '.$module_name,LOGLEVEL_DEBUG);
                        $app->loaded_modules[$module_name] = new $module_name;
                        $app->loaded_modules[$module_name]->onLoad();
                    }
                }
            }
        } else {
            $app->log("Modules directory missing: $modules_dir",LOGLEVEL_ERROR);
            $app->log('Modules directory missing: '.$modules_dir,LOGLEVEL_ERROR);
        }
        
    }
@@ -84,18 +84,18 @@
        
        //* If its a multiserver setup
        if($app->db->dbHost != $app->dbmaster->dbHost) {
            if($conf["mirror_server_id"] > 0) {
                $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = ".$conf["mirror_server_id"]." OR server_id = 0) ORDER BY datalog_id";
            if($conf['mirror_server_id'] > 0) {
                $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf['server_id']." OR server_id = ".$conf['mirror_server_id']." OR server_id = 0) ORDER BY datalog_id";
            } else {
                $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
                $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf['server_id']." OR server_id = 0) ORDER BY datalog_id";
            }
            
            $records = $app->dbmaster->queryAllRecords($sql);
            foreach($records as $d) {
                
                //** encode data to utf-8 and unserialize it
                if(!$data = unserialize(stripslashes($d["data"]))) {
                    $data = unserialize($d["data"]);
                if(!$data = unserialize(stripslashes($d['data']))) {
                    $data = unserialize($d['data']);
                }
                //** Decode data back to locale
                foreach($data['old'] as $key => $val) {
@@ -107,20 +107,20 @@
                
                $replication_error = false;
                
                $this->current_datalog_id = $d["datalog_id"];
                $this->current_datalog_id = $d['datalog_id'];
                
                /*
                * If we are in a mirror setup, rewrite the server_id of records that originally 
                * belonged to the mirrored server to the local server_id
                */
                if($conf["mirror_server_id"] > 0 && $d['dbtable'] != 'server') {
                    if(isset($data['new']['server_id']) && $data['new']['server_id'] == $conf["mirror_server_id"]) $data['new']['server_id'] = $conf["server_id"];
                    if(isset($data['old']['server_id']) && $data['old']['server_id'] == $conf["mirror_server_id"]) $data['old']['server_id'] = $conf["server_id"];
                if($conf['mirror_server_id'] > 0 && $d['dbtable'] != 'server') {
                    if(isset($data['new']['server_id']) && $data['new']['server_id'] == $conf['mirror_server_id']) $data['new']['server_id'] = $conf['server_id'];
                    if(isset($data['old']['server_id']) && $data['old']['server_id'] == $conf['mirror_server_id']) $data['old']['server_id'] = $conf['server_id'];
                }
                
                if(count($data['new']) > 0) {
                    if($d["action"] == 'i' || $d["action"] == 'u') {
                        $idx = explode(":",$d["dbidx"]);
                    if($d['action'] == 'i' || $d['action'] == 'u') {
                        $idx = explode(':',$d['dbidx']);
                        $tmp_sql1 = '';
                        $tmp_sql2 = '';
                        foreach($data['new'] as $fieldname => $val) {
@@ -137,9 +137,9 @@
                        $app->db->query($sql);
                        if($app->db->errorNumber > 0) {
                            $replication_error = true;
                            $app->log("Replication failed. Error: (" . $d[dbtable] . ") in mysql server: (".$app->db->dbHost.") " . $app->db->errorMessage . " # SQL: " . $sql,LOGLEVEL_ERROR);
                            $app->log("Replication failed. Error: (" . $d[dbtable] . ") in MySQL server: (".$app->db->dbHost.") " . $app->db->errorMessage . " # SQL: " . $sql,LOGLEVEL_ERROR);
                        }
                        $app->log("Replicated from master: ".$sql,LOGLEVEL_DEBUG);
                        $app->log('Replicated from master: '.$sql,LOGLEVEL_DEBUG);
                    }
                    /*
                    if($d["action"] == 'u') {
@@ -158,8 +158,8 @@
                        $app->log("Replicated from master: ".$sql,LOGLEVEL_DEBUG);
                    }
                    */
                    if($d["action"] == 'd') {
                        $idx = explode(":",$d["dbidx"]);
                    if($d['action'] == 'd') {
                        $idx = explode(':',$d['dbidx']);
                        $sql = "DELETE FROM $d[dbtable] ";
                        $sql .= " WHERE $idx[0] = $idx[1]";
                        $app->db->query($sql);
@@ -167,23 +167,23 @@
                            $replication_error = true;
                            $app->log("Replication failed. Error: (" . $d[dbtable] . ") " . $app->db->errorMessage . " # SQL: " . $sql,LOGLEVEL_ERROR);
                        }
                        $app->log("Replicated from master: ".$sql,LOGLEVEL_DEBUG);
                        $app->log('Replicated from master: '.$sql,LOGLEVEL_DEBUG);
                    }
                
                
                    if($replication_error == false) {
                        if(is_array($data['old']) || is_array($data['new'])) {
                            $this->raiseTableHook($d["dbtable"],$d["action"],$data);
                            $this->raiseTableHook($d['dbtable'],$d['action'],$data);
                        } else {
                            $app->log("Data array was empty for datalog_id ".$d["datalog_id"],LOGLEVEL_WARN);
                            $app->log('Data array was empty for datalog_id '.$d['datalog_id'],LOGLEVEL_WARN);
                        }
                        //$this->raiseTableHook($d["dbtable"],$d["action"],$data);
                        //$app->dbmaster->query("DELETE FROM sys_datalog WHERE datalog_id = ".$d["datalog_id"]);
                        //$app->log("Deleting sys_datalog ID ".$d["datalog_id"],LOGLEVEL_DEBUG);
                        $app->dbmaster->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf["server_id"]);
                        $app->log("Processed datalog_id ".$d["datalog_id"],LOGLEVEL_DEBUG);
                        $app->dbmaster->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf['server_id']);
                        $app->log('Processed datalog_id '.$d['datalog_id'],LOGLEVEL_DEBUG);
                    } else {
                        $app->log("Error in Replication, changes were not processed.",LOGLEVEL_ERROR);
                        $app->log('Error in Replication, changes were not processed.',LOGLEVEL_ERROR);
                        /*
                         * If there is any error in processing the datalog we can't continue, because
                         * we do not know if the newer actions require this (old) one.
@@ -191,19 +191,19 @@
                        return;
                    }
                } else {
                    $app->log("Datalog does not contain any changes for this record ".$d["datalog_id"],LOGLEVEL_DEBUG);
                    $app->log('Datalog does not contain any changes for this record '.$d['datalog_id'],LOGLEVEL_DEBUG);
                }
            }
            
        //* if we have a single server setup
        } else {
            $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
            $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf['server_id']." OR server_id = 0) ORDER BY datalog_id";
            $records = $app->db->queryAllRecords($sql);
            foreach($records as $d) {
                
                //** encode data to utf-8 to be able to unserialize it and then unserialize it
                if(!$data = unserialize(stripslashes($d["data"]))) {
                    $data = unserialize($d["data"]);
                if(!$data = unserialize(stripslashes($d['data']))) {
                    $data = unserialize($d['data']);
                }
                //** decode data back to current locale
                foreach($data['old'] as $key => $val) {
@@ -213,16 +213,16 @@
                    $data['new'][$key] = utf8_decode($val);
                }
                
                $this->current_datalog_id = $d["datalog_id"];
                $this->current_datalog_id = $d['datalog_id'];
                if(is_array($data['old']) || is_array($data['new'])) {
                    $this->raiseTableHook($d["dbtable"],$d["action"],$data);
                    $this->raiseTableHook($d['dbtable'],$d['action'],$data);
                } else {
                    $app->log("Data array was empty for datalog_id ".$d["datalog_id"],LOGLEVEL_WARN);
                    $app->log('Data array was empty for datalog_id '.$d['datalog_id'],LOGLEVEL_WARN);
                }
                //$app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]);
                //$app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG);
                $app->db->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf["server_id"]);
                $app->log("Processed datalog_id ".$d["datalog_id"],LOGLEVEL_DEBUG);
                $app->db->query("UPDATE server SET updated = ".$d['datalog_id']." WHERE server_id = ".$conf['server_id']);
                $app->log('Processed datalog_id '.$d['datalog_id'],LOGLEVEL_DEBUG);
            }
        }
        
@@ -241,8 +241,8 @@
        
        if(is_array($hooks)) {
            foreach($hooks as $hook) {
                $module_name = $hook["module"];
                $function_name = $hook["function"];
                $module_name = $hook['module'];
                $function_name = $hook['function'];
                // Claa the processing function of the module
                if($this->debug) $app->log("Call function '$function_name' in module '$module_name' raised by TableHook '$table_name'.",LOGLEVEL_DEBUG);
                call_user_method($function_name,$app->loaded_modules[$module_name],$table_name,$action,$data);
@@ -256,4 +256,4 @@
    
}
?>
?>
server/lib/classes/plugins.inc.php
@@ -44,7 +44,7 @@
        $subPath = 'plugins-enabled';
        if ($type == 'core') $subPath = 'plugins-core';
        
        $plugins_dir = $conf["rootpath"].$conf["fs_div"].$subPath.$conf["fs_div"];
        $plugins_dir = $conf['rootpath'].$conf['fs_div'].$subPath.$conf['fs_div'];
        $tmp_plugins = array();
        
        if (is_dir($plugins_dir)) {
@@ -62,15 +62,15 @@
                //** load the plugins
                foreach($tmp_plugins as $plugin_name => $file) {
                    include_once($plugins_dir.$file);
                    if($this->debug) $app->log("Loading Plugin: $plugin_name",LOGLEVEL_DEBUG);
                    if($this->debug) $app->log('Loading plugin: '.$plugin_name,LOGLEVEL_DEBUG);
                    $app->loaded_plugins[$plugin_name] = new $plugin_name;
                    $app->loaded_plugins[$plugin_name]->onLoad();
                }
            } else {
                $app->log("Unable to open the plugin directory: $plugins_dir",LOGLEVEL_ERROR);
                $app->log('Unable to open the plugins directory: '.$plugins_dir,LOGLEVEL_ERROR);
            }
        } else {
            $app->log("Plugin directory missing: $plugins_dir",LOGLEVEL_ERROR);
            $app->log('Plugins directory missing: '.$plugins_dir,LOGLEVEL_ERROR);
        }
        
    }
@@ -83,7 +83,7 @@
        global $app;
        foreach($events as $event_name) {
            $this->available_events[$event_name] = $module_name;
            if($this->debug) $app->log("Announced event: $event_name",LOGLEVEL_DEBUG);
            if($this->debug) $app->log('Announced event: '.$event_name,LOGLEVEL_DEBUG);
        }
    }
    
@@ -95,10 +95,10 @@
    function registerEvent($event_name,$plugin_name,$function_name) {
        global $app;
        if(!isset($this->available_events[$event_name])) {
            $app->log("Unable to register the function '$function_name' in the plugin '$plugin_name' for event '$event_name'",LOGLEVEL_DEBUG);
            $app->log("Unable to register function '$function_name' from plugin '$plugin_name' for event '$event_name'",LOGLEVEL_DEBUG);
        } else {
            $this->subscribed_events[$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name);
            if($this->debug)  $app->log("Registered the function '$function_name' in the plugin '$plugin_name' for event '$event_name'.",LOGLEVEL_DEBUG);
            if($this->debug)  $app->log("Registered function '$function_name' from plugin '$plugin_name' for event '$event_name'.",LOGLEVEL_DEBUG);
        }
    }
    
@@ -108,14 +108,14 @@
        
        // Get the subscriptions for this event
        $events = (isset($this->subscribed_events[$event_name]))?$this->subscribed_events[$event_name]:'';
        if($this->debug) $app->log("Raised event: '$event_name'",LOGLEVEL_DEBUG);
        if($this->debug) $app->log('Raised event: '.$event_name,LOGLEVEL_DEBUG);
        
        if(is_array($events)) {
            foreach($events as $event) {
                $plugin_name = $event["plugin"];
                $function_name = $event["function"];
                $plugin_name = $event['plugin'];
                $function_name = $event['function'];
                // Call the processing function of the plugin
                $app->log("Call function '$function_name' in plugin '$plugin_name' raised by event '$event_name'.",LOGLEVEL_DEBUG);
                $app->log("Calling function '$function_name' from plugin '$plugin_name' raised by event '$event_name'.",LOGLEVEL_DEBUG);
                call_user_method($function_name,$app->loaded_plugins[$plugin_name],$event_name,$data);
                unset($plugin_name);
                unset($function_name);
@@ -127,4 +127,4 @@
    
}
?>
?>
server/lib/classes/services.inc.php
@@ -41,7 +41,7 @@
        if(is_array($this->registered_services[$service_name])) {
            $this->delayed_restarts[$service_name] = $action;
        } else {
            $app->log("Unable to add a delayed restart for  '$service_name'. Service '$service_name' is not registered.",LOGLEVEL_WARNING);
            $app->log("Unable to add a delayed restart for '$service_name'. Service not registered.",LOGLEVEL_WARNING);
        }
        
    }
@@ -51,12 +51,12 @@
        global $app;
        
        if(is_array($this->registered_services[$service_name])) {
            $module_name = $this->registered_services[$service_name]["module"];
            $function_name = $this->registered_services[$service_name]["function"];
            $app->log("Call function '$function_name' in module '$module_name'.",LOGLEVEL_DEBUG);
            $module_name = $this->registered_services[$service_name]['module'];
            $function_name = $this->registered_services[$service_name]['function'];
            $app->log("Calling function '$function_name' from module '$module_name'.",LOGLEVEL_DEBUG);
            call_user_method($function_name,$app->loaded_modules[$module_name],$action);
        } else {
            $app->log("Unable to restart $service_name. Service $service_name is not registered.",LOGLEVEL_WARNING);
            $app->log("Unable to restart $service_name. Service not registered.",LOGLEVEL_WARNING);
        }
        
    }
@@ -77,4 +77,4 @@
    }
}
?>
?>
server/lib/classes/system.inc.php
@@ -926,7 +926,7 @@
     *
     */
    function network_info(){
        $dist = $this->server_conf["dist"];
        $dist = $this->server_conf['dist'];
          ob_start();
          passthru('ifconfig');
          $output = ob_get_contents();
@@ -950,9 +950,9 @@
                  }
                  $output = trim(ob_get_contents());
                  ob_end_clean();
                  if($output != ""){
                    $ifconfig["INTERFACE"][$interface] = $output;
                    $ifconfig["IP"][$output] = $interface;
                  if($output != ''){
                    $ifconfig['INTERFACE'][$interface] = $output;
                    $ifconfig['IP'][$output] = $interface;
                  }
            }
            if(!empty($ifconfig)){
@@ -1087,23 +1087,23 @@
      if ($urlHandle){
        socket_set_timeout($urlHandle, $timeout);
    
        $urlString = 'GET '.$path." HTTP/1.0\r\nHost: ".$url_parts["host"]."\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
        $urlString = 'GET '.$path." HTTP/1.0\r\nHost: ".$url_parts['host']."\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
        if ($user) $urlString .= 'Authorization: Basic '.base64_encode($user.':'.$pass)."\r\n";
        $urlString .= "\r\n";
        fputs($urlHandle, $urlString);
    
        $month["Jan"] = '01';
        $month["Feb"] = '02';
        $month["Mar"] = '03';
        $month["Apr"] = '04';
        $month["May"] = '05';
        $month["Jun"] = '06';
        $month["Jul"] = '07';
        $month["Aug"] = '08';
        $month["Sep"] = '09';
        $month["Oct"] = '10';
        $month["Nov"] = '11';
        $month["Dec"] = '12';
        $month['Jan'] = '01';
        $month['Feb'] = '02';
        $month['Mar'] = '03';
        $month['Apr'] = '04';
        $month['May'] = '05';
        $month['Jun'] = '06';
        $month['Jul'] = '07';
        $month['Aug'] = '08';
        $month['Sep'] = '09';
        $month['Oct'] = '10';
        $month['Nov'] = '11';
        $month['Dec'] = '12';
        $c = 0;
        $l = 0;
        $startzeit = time();