[ Index ] |
|
Code source de Seagull 0.6.1 |
1 <?php 2 /* Reminder: always indent with 4 spaces (no tabs). */ 3 // +---------------------------------------------------------------------------+ 4 // | Copyright (c) 2006, Demian Turner | 5 // | All rights reserved. | 6 // | | 7 // | Redistribution and use in source and binary forms, with or without | 8 // | modification, are permitted provided that the following conditions | 9 // | are met: | 10 // | | 11 // | o Redistributions of source code must retain the above copyright | 12 // | notice, this list of conditions and the following disclaimer. | 13 // | o Redistributions in binary form must reproduce the above copyright | 14 // | notice, this list of conditions and the following disclaimer in the | 15 // | documentation and/or other materials provided with the distribution. | 16 // | o The names of the authors may not be used to endorse or promote | 17 // | products derived from this software without specific prior written | 18 // | permission. | 19 // | | 20 // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 21 // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 22 // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 23 // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 24 // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 25 // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 26 // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 30 // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 // | | 32 // +---------------------------------------------------------------------------+ 33 // | Seagull 0.6 | 34 // +---------------------------------------------------------------------------+ 35 // | setup.php | 36 // +---------------------------------------------------------------------------+ 37 // | Authors: | 38 // | Demian Turner <demian@phpkitchen.com> | 39 // | Gerry Lachac <glachac@tethermedia.com> | 40 // | Andy Crain <apcrain@fuse.net> | 41 // +---------------------------------------------------------------------------+ 42 // $Id: setup.php,v 1.5 2005/02/03 11:29:01 demian Exp $ 43 44 /* 45 sgl setup 46 ========= 47 - ability to upload and unzip/tar a packaged module 48 - file permission handling ideas from FUDforum installer 49 - more user-friendly error messages from Gallery2 50 - if no DB detected, prompt to create, otherwise offer to create tables 51 52 53 php ini 54 ======= 55 - deal with register_globals and set session.use_trans_sid = 0 56 - allow_url_fopen = Off 57 - detect and deal with safe_mode 58 - magic_quotes must be off 59 - file_uploads ideally enabled 60 61 module setup 62 ============ 63 - choose modules and permissions must be created and set at install time 64 - attempt to 65 - uncompress 66 - move to correct location 67 - apply user perms 68 - apply prefs 69 - add module's db tables to Config 70 - load module's schema + data 71 - add 'section' or 'screen' navigation links 72 - register module in registry 73 */ 74 75 // This adds default values for the installer form, based on a 76 // ini-file. 77 function overrideDefaultInstallSettings() 78 { 79 if (file_exists(SGL_PATH.'/etc/customInstallDefaults.ini')) { 80 $customInstallDefaults = parse_ini_file(SGL_PATH.'/etc/customInstallDefaults.ini', false); 81 $ret = $customInstallDefaults; 82 } else { 83 $ret = array(); 84 } 85 return $ret; 86 } 87 88 // initialise 89 90 // set initial paths according to install type 91 $pearTest = '@PHP-DIR@'; 92 if ($pearTest != '@' . 'PHP-DIR'. '@') { 93 define('SGL_PEAR_INSTALLED', true); 94 $rootDir = '@PHP-DIR@/Seagull'; 95 $varDir = '@DATA-DIR@/Seagull/var'; 96 } else { 97 $rootDir = dirname(__FILE__) . '/..'; 98 $varDir = dirname(__FILE__) . '/../var'; 99 } 100 101 // check for lib cache 102 define('SGL_CACHE_LIBS', (is_file($varDir . '/ENABLE_LIBCACHE.txt')) 103 ? true 104 : false); 105 106 // are we doing a minimal install? 107 define('SGL_MINIMAL_INSTALL', (is_file($rootDir . '/MINIMAL_INSTALL.txt')) 108 ? true 109 : false); 110 111 require_once $rootDir . '/lib/SGL/FrontController.php'; 112 require_once $rootDir . '/lib/SGL/Install/Common.php'; 113 SGL_FrontController::init(); 114 session_start(); 115 $_SESSION['ERRORS'] = array(); 116 117 // check if requesting auth.txt download 118 if (isset($_GET['download']) && $_GET['download'] == 1) { 119 if (isset($_SESSION['authString'])) { 120 header("Content-Type: text/plain"); 121 header("Content-Length: " . strlen($_SESSION['authString'])); 122 header("Content-Description: Download AUTH.txt to your computer."); 123 header("Content-Disposition: attachment; filename=AUTH.txt"); 124 print $_SESSION['authString']; 125 exit; 126 } 127 } 128 129 // reroute to front controller 130 if (isset($_GET['start'])) { 131 132 // remove installer info 133 @session_destroy(); 134 $_SESSION = array(); 135 136 // clear session cookie 137 $c = &SGL_Config::singleton(); 138 $conf = $c->getAll(); 139 setcookie( $conf['cookie']['name'], null, 0, $conf['cookie']['path'], 140 $conf['cookie']['domain'], $conf['cookie']['secure']); 141 142 $aUrl = array( 143 'managerName' => 'default', 144 'moduleName' => 'default', 145 'welcome' => 1 146 ); 147 SGL_HTTP::redirect($aUrl); 148 } 149 150 // check authorization 151 if (is_file(SGL_PATH . '/var/INSTALL_COMPLETE.php') 152 && empty($_SESSION['valid'])) { 153 154 if (!empty($_POST['frmPassword'])) { 155 $aLines = file(SGL_PATH . '/var/INSTALL_COMPLETE.php'); 156 $secret = trim(substr($aLines[1], 1)); 157 if ($_POST['frmPassword'] != $secret) { 158 $_SESSION['message'] = 'incorrect password'; 159 header('Location: setup.php'); 160 exit; 161 } else { 162 $_SESSION['valid'] = true; 163 header('Location: setup.php'); 164 } 165 } else { 166 SGL_Install_Common::printHeader(); 167 SGL_Install_Common::printLoginForm(); 168 SGL_Install_Common::printFooter(); 169 exit; 170 } 171 } 172 173 // load QuickFormController libs 174 require_once 'HTML/QuickForm/Controller.php'; 175 require_once 'HTML/QuickForm/Action/Next.php'; 176 require_once 'HTML/QuickForm/Action/Back.php'; 177 require_once 'HTML/QuickForm/Action/Display.php'; 178 179 // load wizard screens and qf overrides 180 require_once SGL_PATH . '/lib/SGL/Install/WizardLicenseAgreement.php'; 181 require_once SGL_PATH . '/lib/SGL/Install/WizardSetupAuth.php'; 182 require_once SGL_PATH . '/lib/SGL/Install/WizardDetectEnv.php'; 183 require_once SGL_PATH . '/lib/SGL/Install/WizardTestDbConnection.php'; 184 require_once SGL_PATH . '/lib/SGL/Install/WizardCreateDb.php'; 185 require_once SGL_PATH . '/lib/SGL/Install/WizardCreateAdminUser.php'; 186 require_once SGL_PATH . '/lib/SGL/Install/QuickFormOverride.php'; 187 188 // load tasks 189 require_once SGL_PATH . '/lib/SGL/Task/DetectEnv.php'; 190 require_once SGL_PATH . '/lib/SGL/Task/Install.php'; 191 192 class ActionProcess extends HTML_QuickForm_Action 193 { 194 function perform(&$page, $actionName) 195 { 196 $data = $page->controller->exportValues(); 197 198 // is this a rebuild? 199 $dbh = & SGL_DB::singleton(); 200 $res = false; 201 if (!PEAR::isError($dbh)) { 202 require_once SGL_CORE_DIR . '/Sql.php'; 203 $table = SGL_Sql::addTablePrefix('module'); 204 $query = 'SELECT COUNT(*) FROM ' . $table; 205 $res = $dbh->getOne($query); 206 } 207 208 if (!PEAR::isError($res) && $res > 1) { // it's a re-install 209 $data['aModuleList'] = SGL_Install_Common::getModuleList(); 210 if (count($data['aModuleList'])) { 211 foreach ($data['aModuleList'] as $key => $moduleName) { 212 if (!SGL::moduleIsEnabled($moduleName)) { 213 unset($data['aModuleList'][$key]); 214 } 215 } 216 } 217 } elseif (PEAR::isError($dbh)) { // a new install 218 $data['aModuleList'] = SGL_Install_Common::getMinimumModuleList(); 219 SGL_Error::pop(); // two errors produced 220 SGL_Error::pop(); 221 } else { 222 $data['aModuleList'] = SGL_Install_Common::getMinimumModuleList(); 223 SGL_Error::pop(); 224 } 225 226 $runner = new SGL_TaskRunner(); 227 $runner->addData($data); 228 $runner->addTask(new SGL_Task_SetTimeout()); 229 $runner->addTask(new SGL_Task_CreateConfig()); 230 $runner->addTask(new SGL_Task_DefineTableAliases()); 231 $runner->addTask(new SGL_Task_DisableForeignKeyChecks()); 232 $runner->addTask(new SGL_Task_PrepareInstallationProgressTable()); 233 $runner->addTask(new SGL_Task_DropTables()); 234 $runner->addTask(new SGL_Task_CreateTables()); 235 $runner->addTask(new SGL_Task_LoadTranslations()); 236 $runner->addTask(new SGL_Task_LoadDefaultData()); 237 $runner->addTask(new SGL_Task_SyncSequences()); 238 $runner->addTask(new SGL_Task_BuildNavigation()); 239 $runner->addTask(new SGL_Task_LoadBlockData()); 240 $runner->addTask(new SGL_Task_LoadSampleData()); 241 $runner->addTask(new SGL_Task_CreateConstraints()); 242 $runner->addTask(new SGL_Task_SyncSequences()); 243 $runner->addTask(new SGL_Task_EnableForeignKeyChecks()); 244 $runner->addTask(new SGL_Task_VerifyDbSetup()); 245 $runner->addTask(new SGL_Task_CreateFileSystem()); 246 $runner->addTask(new SGL_Task_CreateDataObjectEntities()); 247 $runner->addTask(new SGL_Task_CreateDataObjectLinkFile()); 248 $runner->addTask(new SGL_Task_UnLinkWwwData()); 249 $runner->addTask(new SGL_Task_SymLinkWwwData()); 250 $runner->addTask(new SGL_Task_CreateAdminUser()); 251 $runner->addTask(new SGL_Task_InstallerCleanup()); 252 253 $ok = $runner->main(); 254 } 255 } 256 257 // start wizard 258 $wizard =& new HTML_QuickForm_Controller('installationWizard'); 259 $wizard->addPage(new WizardLicenseAgreement('page1')); 260 $wizard->addPage(new WizardSetupAuth('page2')); 261 $wizard->addPage(new WizardDetectEnv('page3')); 262 $wizard->addPage(new WizardTestDbConnection('page4')); 263 $wizard->addPage(new WizardCreateDb('page5')); 264 $wizard->addPage(new WizardCreateAdminUser('page6')); 265 266 // We actually add these handlers here for the sake of example 267 // They can be automatically loaded and added by the controller 268 $wizard->addAction('display', new ActionDisplay()); 269 $wizard->addAction('next', new HTML_QuickForm_Action_Next()); 270 $wizard->addAction('back', new HTML_QuickForm_Action_Back()); 271 272 // This is the action we should always define ourselves 273 $wizard->addAction('process', new ActionProcess()); 274 275 $wizard->run(); 276 277 if (SGL_Install_Common::errorsExist()) { 278 SGL_Install_Common::errorPrint(); 279 } 280 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 01:27:52 2007 | par Balluche grâce à PHPXref 0.7 |