本文整理汇总了PHP中Installer::createIndexFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Installer::createIndexFile方法的具体用法?PHP Installer::createIndexFile怎么用?PHP Installer::createIndexFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Installer
的用法示例。
在下文中一共展示了Installer::createIndexFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init($configfile, $mode = "running", $entryScript = "")
{
require_once "Installer.php";
date_default_timezone_set("Asia/Jakarta");
$bp = Setting::setupBasePath($configfile);
$ap = Setting::$rootPath . DIRECTORY_SEPARATOR . "app";
Setting::$path = $ap . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "settings.json";
if (!is_file(Setting::$path)) {
$configdir = dirname(Setting::$path);
if (!is_dir($configdir)) {
mkdir($configdir, 777, true);
}
$oldConfig = $bp . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "settings.json";
if (is_file($oldConfig)) {
rename($oldConfig, Setting::$path);
header("Location: " . $_SERVER['DOCUMENT_URI']);
die;
}
$json = Setting::$default;
$json = json_encode($json, JSON_PRETTY_PRINT);
$result = @file_put_contents(Setting::$path, $json);
require_once "Installer.php";
Installer::createIndexFile("install");
Setting::$mode = "install";
}
$file = @file_get_contents(Setting::$path);
## set entry script
Setting::$entryScript = realpath($entryScript == "" ? $_SERVER["SCRIPT_FILENAME"] : $entryScript);
## set default data value
if (!$file || isset($result) && !$result) {
Setting::$data = Setting::$default;
$path = isset($result) && !$result ? $result : $file;
if (!$path) {
$path = Setting::$path;
}
$_GET['errorBeforeInstall'] = true;
Setting::redirError("Failed to write in '{path}'", ["{path}" => $path]);
return false;
} else {
$setting = json_decode($file, true);
Setting::$data = Setting::arrayMergeRecursiveReplace(Setting::$default, $setting);
}
## set host
if (!Setting::get('app.host')) {
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$port = $_SERVER['SERVER_PORT'] == 443 || $_SERVER['SERVER_PORT'] == 80 ? "" : ":" . $_SERVER['SERVER_PORT'];
Setting::set('app.host', $protocol . $_SERVER['HTTP_HOST'] . $port);
}
## set debug
if (Setting::$mode == null) {
Setting::$mode = $mode;
}
if ($mode == 'testing') {
Setting::$mode = 'testing';
}
if (Setting::get('app.mode') != 'production') {
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
}
}
示例2: init
public static function init($config)
{
## we hare to make sure the error page is shown
## so we need to strip yii unneeded config to make sure it is running
$config['defaultController'] = "install";
$config['components']['errorHandler'] = ['errorAction' => 'install/default/index'];
Installer::checkInstall();
if (Setting::$mode == "init") {
$url = preg_replace('/\\/?plansys\\/?$/', '', Setting::fullPath());
if (is_file(Setting::getRootPath() . DIRECTORY_SEPARATOR . "index.php")) {
header("Location: " . $url . "/index.php");
die;
}
if (!Installer::createIndexFile()) {
Setting::redirError("Failed to write in \"{path}\" <br/> Permission denied", ['{path}' => Setting::getRootPath() . DIRECTORY_SEPARATOR . "index.php"]);
return $config;
} else {
header("Location: " . $url . "/index.php?r=install/default/index");
die;
}
}
return $config;
}
示例3: actionDb
public function actionDb()
{
$model = new InstallDbForm();
$model->host = Setting::get('db.host');
$model->username = Setting::get('db.username');
$model->password = Setting::get('db.password');
$model->dbname = Setting::get('db.dbname');
$error = false;
$mode = "init";
if (isset($_POST['InstallDbForm'])) {
$model->attributes = $_POST['InstallDbForm'];
if ($model->validate()) {
$error = false;
try {
$dbh = new pdo("mysql:host={$model->host};dbname={$model->dbname}", $model->username, $model->password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch (PDOException $ex) {
$error = $ex->getMessage();
}
if (!$error) {
Setting::set('db.host', $model->host, false);
Setting::set('db.username', $model->username, false);
Setting::set('db.password', $model->password, false);
Setting::set('db.dbname', $model->dbname, false);
Setting::write();
if ($model->resetdb == "yes") {
Installer::createIndexFile("install");
$this->redirect(['/install/default/resetdb']);
} else {
Installer::createIndexFile("running");
$this->redirect(['/install/default/finish']);
}
}
}
}
$this->renderForm('InstallDbForm', $model, ['error' => $error, 'mode' => $mode]);
}