Commit 62f407f89ff99e497f24e3f800a0c5d2437726f9
1 parent
a25e0a4a
KTS-2571
"Upgrade wizard is not calling ini upgrade function" Fixed. Added backup before writing config.ini Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7511 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
79 additions
and
38 deletions
lib/config/config.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -150,6 +150,25 @@ class KTConfig { |
| 150 | 150 | return $oDefault; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | + /** | |
| 154 | + * Return the location of the config.ini | |
| 155 | + * | |
| 156 | + * @return string | |
| 157 | + */ | |
| 158 | + static function getConfigFilename() | |
| 159 | + { | |
| 160 | + $configPath = file_get_contents(KT_DIR . '/config/config-path'); | |
| 161 | + | |
| 162 | + if (is_file($configPath)) | |
| 163 | + { | |
| 164 | + return $configPath; | |
| 165 | + } | |
| 166 | + else | |
| 167 | + { | |
| 168 | + return KT_DIR . '/' . $configPath; | |
| 169 | + } | |
| 170 | + } | |
| 171 | + | |
| 153 | 172 | static function &getSingleton() { |
| 154 | 173 | static $singleton = null; |
| 155 | 174 | ... | ... |
lib/upgrades/Ini.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -48,7 +48,27 @@ class Ini { |
| 48 | 48 | |
| 49 | 49 | function Ini($iniFile = '../../config.ini') { |
| 50 | 50 | $this->iniFile = $iniFile; |
| 51 | - $this->read($iniFile); | |
| 51 | + $this->backupIni($iniFile); | |
| 52 | + $this->read($iniFile); | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Create a backup with the date as an extension in the same location as the original config.ini | |
| 57 | + * | |
| 58 | + * @param string $iniFile | |
| 59 | + * @return boolean | |
| 60 | + */ | |
| 61 | + function backupIni($iniFile) | |
| 62 | + { | |
| 63 | + $content = file_get_contents($iniFile); | |
| 64 | + if ($content === false) | |
| 65 | + { | |
| 66 | + return false; | |
| 67 | + } | |
| 68 | + $date = date('YmdHis'); | |
| 69 | + | |
| 70 | + $backupFile = $iniFile . '.' .$date; | |
| 71 | + return file_put_contents($backupFile, $content) !== false; | |
| 52 | 72 | } |
| 53 | 73 | |
| 54 | 74 | function read($iniFile) { |
| ... | ... | @@ -85,7 +105,7 @@ class Ini { |
| 85 | 105 | $key = trim(substr($iniLine, 0, $equalsPos)); |
| 86 | 106 | $value = trim(substr($iniLine, $equalsPos+1)); |
| 87 | 107 | if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { |
| 88 | - $value = substr($value, 1, -1); | |
| 108 | + $value = substr($value, 1, -1); | |
| 89 | 109 | } |
| 90 | 110 | $this->cleanArray[$section][$key] = stripcslashes($value); |
| 91 | 111 | } else { |
| ... | ... | @@ -104,21 +124,21 @@ class Ini { |
| 104 | 124 | $fileHandle = fopen($iniFile, 'wb'); |
| 105 | 125 | foreach ($this->cleanArray as $section => $items) { |
| 106 | 126 | if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { |
| 107 | - fwrite ($fileHandle, "\r\n"); | |
| 127 | + fwrite ($fileHandle, "\r\n"); | |
| 108 | 128 | continue; |
| 109 | 129 | } |
| 110 | 130 | if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { |
| 111 | - fwrite ($fileHandle, "$items\r\n"); | |
| 131 | + fwrite ($fileHandle, "$items\r\n"); | |
| 112 | 132 | continue; |
| 113 | 133 | } |
| 114 | 134 | fwrite ($fileHandle, "[".$section."]\r\n"); |
| 115 | 135 | foreach ($items as $key => $value) { |
| 116 | 136 | if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { |
| 117 | - fwrite ($fileHandle, "\r\n"); | |
| 137 | + fwrite ($fileHandle, "\r\n"); | |
| 118 | 138 | continue; |
| 119 | 139 | } |
| 120 | 140 | if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { |
| 121 | - fwrite ($fileHandle, "$value\r\n"); | |
| 141 | + fwrite ($fileHandle, "$value\r\n"); | |
| 122 | 142 | continue; |
| 123 | 143 | } |
| 124 | 144 | |
| ... | ... | @@ -145,7 +165,7 @@ class Ini { |
| 145 | 165 | } |
| 146 | 166 | return false; |
| 147 | 167 | } |
| 148 | - | |
| 168 | + | |
| 149 | 169 | function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { |
| 150 | 170 | |
| 151 | 171 | if($this->itemExists($addSection, $addItem)) return false; | ... | ... |
lib/upgrades/UpgradeFunctions.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -916,9 +916,12 @@ class UpgradeFunctions { |
| 916 | 916 | // {{{ updateConfigFile35 |
| 917 | 917 | function updateConfigFile35() |
| 918 | 918 | { |
| 919 | - if(file_exists('../../config.ini')) { | |
| 919 | + $configPath = KTConfig::getConfigFilename(); | |
| 920 | + $configPath = str_replace(array("\n","\r"), array('',''), $configPath); | |
| 921 | + | |
| 922 | + if(file_exists($configPath)) { | |
| 920 | 923 | |
| 921 | - $ini = new Ini(); | |
| 924 | + $ini = new Ini($configPath); | |
| 922 | 925 | |
| 923 | 926 | // Webservices Section |
| 924 | 927 | $ini->addItem('webservice', 'uploadDirectory', '${varDirectory}/uploads'); |
| ... | ... | @@ -1008,7 +1011,6 @@ class UpgradeFunctions { |
| 1008 | 1011 | $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"); |
| 1009 | 1012 | |
| 1010 | 1013 | $ini->write(); |
| 1011 | - | |
| 1012 | 1014 | } |
| 1013 | 1015 | } |
| 1014 | 1016 | // }}} |
| ... | ... | @@ -1031,7 +1033,7 @@ class UpgradeFunctions { |
| 1031 | 1033 | |
| 1032 | 1034 | $oScheduler = new Scheduler('Indexing'); |
| 1033 | 1035 | $oScheduler->setScriptPath(KT_DIR . '/bin/indexingTask.' . $ext); |
| 1034 | - $oScheduler->setFrequency('5mins'); | |
| 1036 | + $oScheduler->setFrequency('1min'); | |
| 1035 | 1037 | $oScheduler->setFirstRunTime(date('Y-m-d H:i',mktime($hour, $min, 0, $mon, $day, $year))); |
| 1036 | 1038 | $oScheduler->registerTask(); |
| 1037 | 1039 | ... | ... |