diff --git a/include/staff/syslogs.inc.php b/include/staff/syslogs.inc.php index cb43e905e4ef0914b09067dd753f7bf67a39498b..5418518f71f498996aee68cd2a6f0b5a8f7b4034 100644 --- a/include/staff/syslogs.inc.php +++ b/include/staff/syslogs.inc.php @@ -45,9 +45,10 @@ if( ($startTime && $startTime>time()) or ($startTime>$endTime && $endTime>0)){ $qstr.='&endDate='.urlencode($_REQUEST['endDate']); } } -$sortOptions=array('title'=>'log.title','type'=>'log_type','ip'=>'log.ip_address','date'=>'log.created','created'=>'log.created','updated'=>'log.updated'); +$sortOptions=array('id'=>'log.log_id', 'title'=>'log.title','type'=>'log_type','ip'=>'log.ip_address' + ,'date'=>'log.created','created'=>'log.created','updated'=>'log.updated'); $orderWays=array('DESC'=>'DESC','ASC'=>'ASC'); -$sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'date'; +$sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'id'; //Sorting options... if($sort && $sortOptions[$sort]) { $order_column =$sortOptions[$sort]; diff --git a/main.inc.php b/main.inc.php index 1850eb31b462c05fc2c6f6064fc240a2f8ebed6e..f8586d1631f8ab92b1440e45ca0564bee9bf22d1 100644 --- a/main.inc.php +++ b/main.inc.php @@ -55,7 +55,7 @@ #Current version && schema signature (Changes from version to version) define('THIS_VERSION','1.7-DPR2'); //Shown on admin panel - define('SCHEMA_SIGNATURE','bbb021fbeb377ca66b6997b77e0167cc'); //MD5 signature of the db schema. (used to trigger upgrades) + define('SCHEMA_SIGNATURE','49478749dc680eef08b7954bd568cfd1'); //MD5 signature of the db schema. (used to trigger upgrades) #load config info $configfile=''; diff --git a/setup/inc/class.installer.php b/setup/inc/class.installer.php index 75ebdc7cdef148a89fd9016e1d1eb62e278f8e39..7b3dbe534eb0af30f13f27223f555849d30a6bb1 100644 --- a/setup/inc/class.installer.php +++ b/setup/inc/class.installer.php @@ -105,6 +105,8 @@ class Installer extends SetupWizard { //Last minute checks. if(!file_exists($schemaFile)) $this->errors['err']='Internal Error - please make sure your download is the latest (#1)'; + elseif(!($signature=trim(file_get_contents("$schemaFile.md5"))) || strcasecmp($signature, md5_file($schemaFile))) + $this->errors['err']='Unknown or invalid schema signature ('.$signature.' .. '.md5_file($schemaFile).')'; elseif(!file_exists($this->getConfigFile()) || !($configFile=file_get_contents($this->getConfigFile()))) $this->errors['err']='Unable to read config file. Permission denied! (#2)'; elseif(!($fp = @fopen($this->getConfigFile(),'r+'))) @@ -132,7 +134,7 @@ class Installer extends SetupWizard { .', default_email_id=1, alert_email_id=2, default_dept_id=1 ' .', default_sla_id=1, default_timezone_id=8, default_template_id=1 ' .', admin_email='.db_input($vars['admin_email']) - .', schema_signature='.db_input(md5_file($schemaFile)) + .', schema_signature='.db_input($signature) .', helpdesk_url='.db_input(URL) .', helpdesk_title='.db_input($vars['name']); if(!mysql_query($sql) || !($cid=mysql_insert_id())) diff --git a/setup/inc/class.setup.php b/setup/inc/class.setup.php index 34bc57486942bca10d9540459dfd8daf37a4f232..cd1ef81f4b7b149e232ca63f8adf7852ab20c55e 100644 --- a/setup/inc/class.setup.php +++ b/setup/inc/class.setup.php @@ -34,7 +34,7 @@ Class SetupWizard { function load_sql_file($file, $prefix, $abort=true, $debug=false) { if(!file_exists($file) || !($schema=file_get_contents($file))) - return $this->abort('Error accessing SQL file '.basename($file)); + return $this->abort('Error accessing SQL file '.basename($file), $debug); return $this->load_sql($schema, $prefix, $abort, $debug); } @@ -45,21 +45,20 @@ Class SetupWizard { function load_sql($schema, $prefix, $abort=true, $debug=false) { # Strip comments and remarks - $schema=preg_replace('%^\s*(#|--).*$%m','',$schema); + $schema=preg_replace('%^\s*(#|--).*$%m', '', $schema); # Replace table prefis - $schema = str_replace('%TABLE_PREFIX%',$prefix, $schema); + $schema = str_replace('%TABLE_PREFIX%', $prefix, $schema); # Split by semicolons - and cleanup if(!($statements = array_filter(array_map('trim', @explode(';', $schema))))) - return $this->abort('Error parsing SQL schema'); + return $this->abort('Error parsing SQL schema', $debug); @mysql_query('SET SESSION SQL_MODE =""'); foreach($statements as $k=>$sql) { - if(!mysql_query($sql)) { - if($debug) echo "[$sql]=>".mysql_error(); - if($abort) - return $this->abort("[$sql] - ".mysql_error()); - } + if(mysql_query($sql)) continue; + $error = "[$sql] ".mysql_error(); + if($abort) + return $this->abort($error, $debug); } return true; @@ -82,7 +81,7 @@ Class SetupWizard { } function check_php() { - return (version_compare(PHP_VERSION,$this->getPHPVersion())>=0); + return (version_compare(PHP_VERSION, $this->getPHPVersion())>=0); } function check_mysql() { @@ -96,8 +95,9 @@ Class SetupWizard { /* @error is a mixed var. */ - function abort($error) { + function abort($error, $debug=false) { + if($debug) echo $error; $this->onError($error); return false; // Always false... It's an abort. @@ -106,13 +106,12 @@ Class SetupWizard { function setError($error) { if($error && is_array($error)) - $this->errors = array_merge($this->errors,$error); + $this->errors = array_merge($this->errors, $error); elseif($error) $this->errors[] = $error; } function getErrors(){ - return $this->errors; } diff --git a/setup/inc/class.upgrader.php b/setup/inc/class.upgrader.php index 9e208426fcd9288c9108d847c598ca5112dc6d35..73af7e6066cddf41140d7bd6f2c2618431dfe83f 100644 --- a/setup/inc/class.upgrader.php +++ b/setup/inc/class.upgrader.php @@ -50,6 +50,8 @@ class Upgrader extends SetupWizard { } function onError($error) { + + Sys::log(LOG_ERR, 'Upgrader Error', $error); $this->setError($error); $this->setState('aborted'); } @@ -197,18 +199,23 @@ class Upgrader extends SetupWizard { if (!$this->load_sql_file($patch, $this->getTablePrefix())) return false; - //TODO: Log the upgrade - - //clear previous patch info - unset($_SESSION['ost_upgrader'][$this->getShash()]); - //Load up post-upgrade tasks.... if any. $phash = substr(basename($patch), 0, 17); + + //Log the patch info + $logMsg = "Patch $phash applied "; + if(($info = $this->readPatchInfo($patch)) && $info['version']) + $logMsg.= ' ('.$info['version'].') '; + + Sys::log(LOG_DEBUG, 'Upgrader - Patch applied', $logMsg); + + //Check if the said patch has scripted tasks if(!($tasks=$this->getTasksForPatch($phash))) continue; - //We have tasks to perform - set the tasks and break. + //We have work to do... set the tasks and break. $shash = substr($phash, 9, 8); $_SESSION['ost_upgrader'][$shash]['tasks'] = $tasks; $_SESSION['ost_upgrader'][$shash]['state'] = 'upgrade'; diff --git a/setup/inc/sql/bbb021fb-49478749.patch.sql b/setup/inc/sql/bbb021fb-49478749.patch.sql new file mode 100644 index 0000000000000000000000000000000000000000..8bd81f32016f936848f790ef325e1613317cc3fc --- /dev/null +++ b/setup/inc/sql/bbb021fb-49478749.patch.sql @@ -0,0 +1,9 @@ +/** + * Transitional patch - FIX on the INSTALLER schema + * + * @version 1.7-dpr3 installerfix + */ + +-- Finished with patch +UPDATE `%TABLE_PREFIX%config` + SET `schema_signature`='49478749dc680eef08b7954bd568cfd1'; diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql index 6c22f9919f812dcac571b4d846ca158b8b5421b8..33b034c763f8197e6d21d267abe50c58d2a37738 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql +++ b/setup/inc/sql/osticket-v1.7-mysql.sql @@ -615,7 +615,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_event` ( `topic_id` int(11) unsigned NOT NULL, `state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL, `staff` varchar(255) NOT NULL default 'SYSTEM', - `annulled` tinyint(1) unsigned NOT NULL defalt '0', + `annulled` tinyint(1) unsigned NOT NULL default '0', `timestamp` datetime NOT NULL, KEY `ticket_state` (`ticket_id`, `state`, `timestamp`), KEY `ticket_stats` (`timestamp`, `state`) diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 index e9497d0ebd591cb32c577721f38ddcc283fbf937..f27a74d5b65a34a55b6b03a5a5624c2adcf7fccf 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 +++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 @@ -1 +1 @@ -bbb021fbeb377ca66b6997b77e0167cc +49478749dc680eef08b7954bd568cfd1