コード例 #1
0
ファイル: 01_installer.php プロジェクト: swk/bluebox
 public function checkDBConnectivity()
 {
     // Are heading somewhere other then the installer? If so, check that we're OK to proceed.
     if (!Bluebox_Installer::is_installing()) {
         // Check DB connectivity
         $manager = Doctrine_Manager::getInstance();
         try {
             $manager->getCurrentConnection()->connect();
             Doctrine::getTable('Package')->findAll();
         } catch (Doctrine_Connection_Exception $e) {
             // We can't connect to the database - run the installer!
             // Get the guess the URL to work on
             Kohana::config_set('core.site_domain', Bluebox_Installer::guess_site_domain());
             url::redirect('/installer');
         }
     }
 }
コード例 #2
0
ファイル: installer.php プロジェクト: swk/bluebox
 /**
  * This attempts to uncomment the index_page in config.php if mod_rewrite is not
  * on or not allowed.
  *
  * @return void
  */
 public function fixModRewrite()
 {
     Kohana::config_set('core.site_domain', Bluebox_Installer::guess_site_domain());
     $indexPage = Kohana::config('core.index_page');
     if (!empty($indexPage)) {
         url::redirect('/installer');
     }
     Kohana::config_set('core.index_page', 'index.php');
     // Get the current config.php file
     if ($files = Kohana::find_file('config', 'config')) {
         $file = @file(end($files));
     }
     // Make sure we were sucessfull
     if (empty($file)) {
         // Use the preLog because we dont know if we have write permissions on logs/ yet!
         $preLog = $this->session->get('installer.pre_log');
         $preLog['error'][] = 'Could not locate or read config.php during mod_rewrite fix!';
         $this->session->set('installer.pre_log', $preLog);
         url::redirect('/index.php/installer?config_file=config');
     }
     foreach ($file as $num => $line) {
         preg_match('/.*[\'"`]([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)[\'"`].*$/imx', $line, $result);
         if (!empty($result[1]) && strstr($result[1], 'index_page')) {
             $file[$num] = ltrim($line, '/#;');
         }
     }
     $file = implode('', $file);
     // If we got the file then we must have made changes, attempt to save it back
     // but if there is an error doing so have the user do it
     if (@file_put_contents(end($files), $file) === FALSE) {
         // Use the preLog because we dont know if we have write permissions on logs/ yet!
         $_GET['config_file'] = 'config';
         $this->viewCache($file);
         $this->template->allowNext = TRUE;
         return FALSE;
     }
     url::redirect('/installer');
 }