$cacheEngine = Configure::read('BcCache.engine'); $cachePrefix = Configure::read('BcCache.prefix'); $cacheDuration = Configure::read('BcCache.duration'); // モデルスキーマ Cache::config('_cake_model_', array('engine' => $cacheEngine, 'prefix' => $cachePrefix . 'cake_model_', 'path' => CACHE . 'models' . DS, 'serialize' => $cacheEngine === 'File', 'duration' => $cacheDuration)); // コア環境 Cache::config('_cake_core_', array('engine' => $cacheEngine, 'prefix' => $cachePrefix . 'cake_core_', 'path' => CACHE . 'persistent' . DS, 'serialize' => $cacheEngine === 'File', 'duration' => $cacheDuration)); // DBデータキャッシュ Cache::config('_cake_data_', array('engine' => $cacheEngine, 'path' => CACHE . 'datas', 'probability' => 100, 'prefix' => $cachePrefix . 'cake_data_', 'lock' => true, 'serialize' => $cacheEngine === 'File', 'duration' => $cacheDuration)); // 環境情報キャッシュ Cache::config('_cake_env_', array('engine' => $cacheEngine, 'probability' => 100, 'path' => CACHE . 'environment', 'prefix' => $cachePrefix . 'cake_env_', 'lock' => false, 'serialize' => $cacheEngine === 'File', 'duration' => $cacheDuration)); /** * サイト基本設定を読み込む * bootstrapではモデルのロードは行わないようにする為ここで読み込む */ loadSiteConfig(); /** * メンテナンスチェック */ $isMaintenance = $parameter == 'maintenance/index'; Configure::write('BcRequest.isMaintenance', $isMaintenance); /** * アップデートチェック */ $isUpdater = false; $bcSite = Configure::read('BcSite'); $updateKey = preg_quote(Configure::read('BcApp.updateKey'), '/'); if (preg_match('/^' . $updateKey . '(|\\/index\\/)/', $parameter)) { $isUpdater = true; } elseif (BC_INSTALLED && !$isMaintenance && (!empty($bcSite['version']) && getVersion() > $bcSite['version'])) { header('Location: ' . topLevelUrl(false) . baseUrl() . 'maintenance/index');
/** * Step 5: 設定ファイルの生成 * データベース設定ファイル[database.php] * インストールファイル[install.php] * * @return void * @access public */ public function step5() { $this->pageTitle = 'baserCMSのインストール完了!'; Cache::config('default', array('engine' => 'File')); if (!BC_INSTALLED) { $installationData = $this->Session->read('Installation'); $installationData['lastStep'] = true; checkTmpFolders(); Configure::write('Cache.disable', false); // インストールファイルでセッションの保存方法を切り替える為、インストール情報をキャッシュに保存 Cache::write('Installation', $installationData, 'default'); // データベース設定を書き込む $this->BcManager->createDatabaseConfig($this->_readDbSetting()); // インストールファイルを生成する $secritySalt = $this->Session->read('Installation.salt'); $secrityCipherSeed = $this->Session->read('Installation.cipherSeed'); $this->BcManager->createInstallFile($secritySalt, $secrityCipherSeed); //================================================================== // BcManagerComponent::createPageTemplates() を実行する際、 // 固定ページでプラグインを利用している場合あり、プラグインがロードされていないとエラーになる為、 // リダイレクト前にコアプラグインの有効化とテーマ保有のプラグインのインストールを完了させておく // ================================================================= // データベースのデータを初期設定に更新 $this->BcManager->executeDefaultUpdates($this->_readDbSetting(Cache::read('Installation', 'default'))); // テーマを配置する $this->BcManager->deployTheme(); $dbDataPattern = $this->Session->read('Installation.dbDataPattern'); list($theme, $pattern) = explode('.', $dbDataPattern); loadSiteConfig(); App::build(array('Plugin' => array_merge(array(BASER_THEMES . Configure::read('BcSite.theme') . DS . 'Plugin' . DS), App::path('Plugin')))); $themesPlugins = BcUtil::getCurrentThemesPlugins(); if ($themesPlugins) { foreach ($themesPlugins as $plugin) { $this->BcManager->installPlugin($plugin); CakePlugin::load($plugin); $this->BcManager->resetTables('plugin', $dbConfig = null, $plugin); $this->BcManager->loadDefaultDataPattern('plugin', null, $pattern, $theme, $plugin); } } clearAllCache(); if (function_exists('opcache_reset')) { opcache_reset(); } $this->redirect('step5'); } else { $installationData = Cache::read('Installation', 'default'); if (empty($installationData['lastStep'])) { return; } } // ログイン $this->_login(); // テーマに管理画面のアセットへのシンボリックリンクを作成する $this->BcManager->deployAdminAssets(); // アップロード用初期フォルダを作成する $this->BcManager->createDefaultFiles(); // エディタテンプレート用の画像を配置 $this->BcManager->deployEditorTemplateImage(); // Pagesファイルを生成する $this->BcManager->createPageTemplates(); $this->Session->delete('InstallLastStep'); }
/** * baserCMSのインストール * * @param type $dbConfig * @param type $adminUser * @param type $adminPassword * @param type $adminEmail * @return boolean */ public function install($siteUrl, $dbConfig, $adminUser = array(), $baseUrl = '', $dbDataPattern = '') { if (!$dbDataPattern) { $dbDataPattern = Configure::read('BcApp.defaultTheme') . '.default'; } $result = true; // キャッシュ削除 clearAllCache(); // 一時フォルダ作成 checkTmpFolders(); if ($dbConfig['datasource'] == 'sqlite' || $dbConfig['datasource'] == 'csv') { switch ($dbConfig['datasource']) { case 'sqlite': $dbFolderPath = APP . 'db' . DS . 'sqlite'; break; case 'csv': $dbFolderPath = APP . 'db' . DS . 'csv'; break; } $Folder = new Folder(); if (!is_writable($dbFolderPath) && !$Folder->create($dbFolderPath, 0777)) { $this->log('データベースの保存フォルダの作成に失敗しました。db フォルダの書き込み権限を見なおしてください。'); $result = false; } } // SecritySaltの設定 $securitySalt = $this->setSecuritySalt(); $securityCipherSeed = $this->setSecurityCipherSeed(); // インストールファイル作成 if (!$this->createInstallFile($securitySalt, $securityCipherSeed, $siteUrl)) { $this->log('インストールファイル生成に失敗しました。設定フォルダの書き込み権限を見なおしてください。'); $result = false; } // データベース設定ファイル生成 if (!$this->createDatabaseConfig($dbConfig)) { $this->log('データベースの設定ファイル生成に失敗しました。設定フォルダの書き込み権限を見なおしてください。'); $result = false; } // データベース初期化 if (!$this->constructionDb($dbConfig, $dbDataPattern)) { $this->log('データベースの初期化に失敗しました。データベースの設定を見なおしてください。'); $result = false; } if ($adminUser) { // サイト基本設定登録 if (!$this->setAdminEmail($adminUser['email'])) { $this->log('サイト基本設定への管理者メールアドレスの設定処理が失敗しました。データベースの設定を見なおしてください。'); } // ユーザー登録 $adminUser['password_1'] = $adminUser['password']; $adminUser['password_2'] = $adminUser['password']; if (!$this->addDefaultUser($adminUser)) { $this->log('初期ユーザーの作成に失敗しました。データベースの設定を見なおしてください。'); $result = false; } } // データベースの初期更新 if (!$this->executeDefaultUpdates($dbConfig)) { $this->log('データベースのデータ更新に失敗しました。データベースの設定を見なおしてください。'); $result = false; } // コアプラグインのインストール if (!$this->installCorePlugin($dbConfig, $dbDataPattern)) { $this->log('コアプラグインのインストールに失敗しました。'); $result = false; } // テーマを配置 if (!$this->deployTheme()) { $this->log('テーマの配置に失敗しました。テーマフォルダの書き込み権限を確認してください。'); $result = false; } // テーマに管理画面のアセットへのシンボリックリンクを作成する if (!$this->deployAdminAssets()) { $this->log('管理システムのアセットファイルの配置に失敗しました。テーマフォルダの書き込み権限を確認してください。'); } // アップロード用初期フォルダを作成する if (!$this->createDefaultFiles()) { $this->log('アップロード用初期フォルダの作成に失敗しました。files フォルダの書き込み権限を確認してください。'); $result = false; } // エディタテンプレート用の画像を配置 if (!$this->deployEditorTemplateImage()) { $this->log('エディタテンプレートイメージの配置に失敗しました。files フォルダの書き込み権限を確認してください。'); $result = false; } //SiteConfigを再設定 loadSiteConfig(); // ページファイルを生成 $this->createPageTemplates(); return $result; }
/** * サイト基本設定をConfigureへ読み込む */ public function testLoadSiteConfig() { Configure::write('BcSite', null); loadSiteConfig(); $this->assertArrayHasKey('name', Configure::read('BcSite')); }
/** * コンストラクタ * * @param CakeRequest $request リクエストオブジェクト * @param CakeResponse $response レスポンスオブジェクト */ public function __construct($request = null, $response = null) { parent::__construct($request, $response); if (isConsole()) { unset($this->components['Session']); } // テンプレートの拡張子 $this->ext = Configure::read('BcApp.templateExt'); $isRequestView = $request->is('requestview'); $isInstall = $request->is('install'); // インストールされていない場合、トップページにリダイレクトする // コンソールベースのインストールの際のページテンプレート生成において、 // BC_INSTALLED、$isInstall ともに true でない為、コンソールの場合は無視する if (!(BC_INSTALLED || isConsole()) && !$isInstall) { $this->redirect('/'); } // コンソールベースのインストールの際のページテンプレート生成において、 // BC_INSTALLEDが true でない為、コンソールの場合も実行する if ((BC_INSTALLED || isConsole()) && $isRequestView) { // サイト基本設定の読み込み // DBに接続できない場合、CakePHPのエラーメッセージが表示されてしまう為、 try を利用 try { $SiteConfig = ClassRegistry::init('SiteConfig'); $this->siteConfigs = Configure::read('BcSite'); // asset ファイルの読み込みの際、bootstrap で、loadSiteConfig() を実行しない仕様となっているが、 // 存在しない asset ファイルを読み込んだ際に、上記理由により、Not Found ページで、テーマが適用されない為、 // 再度、loadSiteConfig() を実行 if (!$this->siteConfigs) { loadSiteConfig(); $this->siteConfigs = Configure::read('BcSite'); } if (empty($this->siteConfigs['version'])) { $this->siteConfigs['version'] = $this->getBaserVersion(); $SiteConfig->saveKeyValue($this->siteConfigs); } } catch (Exception $ex) { $this->siteConfigs = array(); } } // TODO beforeFilterでも定義しているので整理する if ($this->name == 'CakeError') { $this->uses = null; // サブサイト用のエラー try { $Site = ClassRegistry::init('Site'); $site = $Site->findByUrl($this->request->url); if (!empty($site['Site']['name'])) { $this->layoutPath = $site['Site']['name']; if ($site['Site']['name'] == 'mobile') { $this->helpers[] = 'BcMobile'; } elseif ($site['Site']['name'] == 'smartphone') { $this->helpers[] = 'BcSmartphone'; } } } catch (Exception $e) { } } /* 携帯用絵文字のモデルとコンポーネントを設定 */ // TODO 携帯をコンポーネントなどで判別し、携帯からのアクセスのみ実行させるようにする // ※ コンストラクト時点で、$this->request->params['prefix']を利用できない為。 // TODO 2008/10/08 egashira // beforeFilterに移動してみた。実際に携帯を使うサイトで使えるかどうか確認する //$this->uses[] = 'EmojiData'; //$this->components[] = 'Emoji'; }