install的作用
顾名思义,install的作用就是安装, 那如果有人已经安装过了呢?并不是所有人都会直接输入域名让服务器自动跳转到index.php(之所以看不到后缀,只看见域名是因为伪静态),如果有人可以输入域名/install.php
是不是会再次安装呢?当然不是!
第一件事:确认
未安装时,入口文件index.php检查完未安装后,将页面跳转到install.php。
为了防止安装后通过域名/install.php
重复安装,install.php会进行一次安装前确认,这一段代码在install.php的开头。
<?php if (!file_exists(dirname(__FILE__) . '/config.inc.php')): ?>
<?php
...
/*省略安装准备代码*/
...
else:
require_once dirname(__FILE__) . '/config.inc.php';
//判断是否已经安装
$db = Typecho_Db::get();
try {
$installed = $db->fetchRow($db->select()->from('table.options')->where('name = ?', 'installed'));
if (empty($installed) || $installed['value'] == 1) {
Typecho_Response::setStatus(404);