function sfInitInstall() { // インストール済みが定義されていない。 if (!defined('ECCUBE_INSTALL')) { $phpself = $_SERVER['SCRIPT_NAME']; if (strpos('/install/', $phpself) === false) { $path = substr($phpself, 0, strpos($phpself, basename($phpself))); $install_url = SC_Utils_Ex::searchInstallerPath($path); header('Location: ' . $install_url); exit; } } $path = HTML_REALDIR . 'install/' . DIR_INDEX_FILE; if (file_exists($path)) { SC_Utils_Ex::sfErrorHeader('>> /install/' . DIR_INDEX_FILE . ' は、インストール完了後にファイルを削除してください。削除するには<a href="' . ROOT_URLPATH . 'deleteInstaller.php">こちら</a>をクリックしてください。'); } }
/** * インストーラのパスを検索し, URL を返す. * * $path と同階層に install/index.php があるか検索する. * 存在しない場合は上位階層を再帰的に検索する. * インストーラのパスが見つかった場合は, その URL を返す. * DocumentRoot まで検索しても見つからない場合は /install/index.php を返す. * * @param string $path 検索対象のパス * @return string インストーラの URL */ function searchInstallerPath($path) { $installer = 'install/' . DIR_INDEX_PATH; if (SC_Utils_Ex::sfIsHTTPS()) { $proto = 'https://'; } else { $proto = 'http://'; } $host = $proto . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']; if ($path == '/') { return $host . $path . $installer; } if (substr($path, -1, 1) != '/') { $path .= $path . '/'; } $installer_url = $host . $path . $installer; $resources = fopen(SC_Utils_Ex::getRealURL($installer_url), 'r'); if ($resources === false) { $installer_url = SC_Utils_Ex::searchInstallerPath($path . '../'); } return $installer_url; }