diff --git a/lib/config/config.inc.php b/lib/config/config.inc.php index d63f2cb..a5d7894 100644 --- a/lib/config/config.inc.php +++ b/lib/config/config.inc.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -150,6 +150,25 @@ class KTConfig { return $oDefault; } + /** + * Return the location of the config.ini + * + * @return string + */ + static function getConfigFilename() + { + $configPath = file_get_contents(KT_DIR . '/config/config-path'); + + if (is_file($configPath)) + { + return $configPath; + } + else + { + return KT_DIR . '/' . $configPath; + } + } + static function &getSingleton() { static $singleton = null; diff --git a/lib/upgrades/Ini.inc.php b/lib/upgrades/Ini.inc.php index e5be4a4..e900ba8 100644 --- a/lib/upgrades/Ini.inc.php +++ b/lib/upgrades/Ini.inc.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -48,7 +48,27 @@ class Ini { function Ini($iniFile = '../../config.ini') { $this->iniFile = $iniFile; - $this->read($iniFile); + $this->backupIni($iniFile); + $this->read($iniFile); + } + + /** + * Create a backup with the date as an extension in the same location as the original config.ini + * + * @param string $iniFile + * @return boolean + */ + function backupIni($iniFile) + { + $content = file_get_contents($iniFile); + if ($content === false) + { + return false; + } + $date = date('YmdHis'); + + $backupFile = $iniFile . '.' .$date; + return file_put_contents($backupFile, $content) !== false; } function read($iniFile) { @@ -85,7 +105,7 @@ class Ini { $key = trim(substr($iniLine, 0, $equalsPos)); $value = trim(substr($iniLine, $equalsPos+1)); if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { - $value = substr($value, 1, -1); + $value = substr($value, 1, -1); } $this->cleanArray[$section][$key] = stripcslashes($value); } else { @@ -104,21 +124,21 @@ class Ini { $fileHandle = fopen($iniFile, 'wb'); foreach ($this->cleanArray as $section => $items) { if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { - fwrite ($fileHandle, "\r\n"); + fwrite ($fileHandle, "\r\n"); continue; } if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { - fwrite ($fileHandle, "$items\r\n"); + fwrite ($fileHandle, "$items\r\n"); continue; } fwrite ($fileHandle, "[".$section."]\r\n"); foreach ($items as $key => $value) { if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { - fwrite ($fileHandle, "\r\n"); + fwrite ($fileHandle, "\r\n"); continue; } if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { - fwrite ($fileHandle, "$value\r\n"); + fwrite ($fileHandle, "$value\r\n"); continue; } @@ -145,7 +165,7 @@ class Ini { } return false; } - + function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { if($this->itemExists($addSection, $addItem)) return false; diff --git a/lib/upgrades/UpgradeFunctions.inc.php b/lib/upgrades/UpgradeFunctions.inc.php index 12ebac6..724cbce 100644 --- a/lib/upgrades/UpgradeFunctions.inc.php +++ b/lib/upgrades/UpgradeFunctions.inc.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -916,9 +916,12 @@ class UpgradeFunctions { // {{{ updateConfigFile35 function updateConfigFile35() { - if(file_exists('../../config.ini')) { + $configPath = KTConfig::getConfigFilename(); + $configPath = str_replace(array("\n","\r"), array('',''), $configPath); + + if(file_exists($configPath)) { - $ini = new Ini(); + $ini = new Ini($configPath); // Webservices Section $ini->addItem('webservice', 'uploadDirectory', '${varDirectory}/uploads'); @@ -1008,7 +1011,6 @@ class UpgradeFunctions { $ini->addItem('DiskUsage', 'urgentThreshold', '5', "When free space in a mount point is less than this percentage,\r\n; the disk usage dashlet will highlight the mount in RED"); $ini->write(); - } } // }}} @@ -1031,7 +1033,7 @@ class UpgradeFunctions { $oScheduler = new Scheduler('Indexing'); $oScheduler->setScriptPath(KT_DIR . '/bin/indexingTask.' . $ext); - $oScheduler->setFrequency('5mins'); + $oScheduler->setFrequency('1min'); $oScheduler->setFirstRunTime(date('Y-m-d H:i',mktime($hour, $min, 0, $mon, $day, $year))); $oScheduler->registerTask();