diff --git a/build.php b/build.php index 12803b9..b00baab 100644 --- a/build.php +++ b/build.php @@ -6,10 +6,6 @@ $version=$argv[1]; -$dirs = array( - ".", -); - echo << @@ -64,94 +60,187 @@ function vMiddle(inner){
MiniCMS安装程序
v{$version}
- +
- - -
- -
- -
- -
-
- -
检测到MiniCMS配置文件,将使用升级模式安装。
-
- + + +
+ +
+ +
+ +
+
+ +
检测到MiniCMS配置文件,将使用升级模式安装。
+
+ - + +失败]'; + } + } else { + \$install_failed = true; + echo '[无法创建目录]'; + } + echo '
'; + } + + if (isset(\$_POST["start_install"])) { + ?> + +
+\n"; -echo "\n"; -echo "
"; -echo "\''.$version.'\', \'site_link\'=>\'\',\'site_name\'=>\'{$_POST[\'sitename\']}\',\'site_desc\'=>\'又一个MiniCMS网站\',\'user_name\'=>\'{$_POST[\'username\']}\',\'user_pass\'=>\'{$_POST[\'password\']}\',\'user_nick\'=>\'{$_POST[\'nickname\']}\',\'comment_code\'=>\'\');?>");'; -echo " }\n"; -echo " if (!is_dir('mc-files/pages/index')) {\n"; -echo " mkdir('mc-files/pages/index', 0744, true);\n"; -echo ' file_put_contents(\'mc-files/pages/index/delete.php\', \'\');'."\n"; -echo ' file_put_contents(\'mc-files/pages/index/publish.php\', \'\');'."\n"; -echo ' file_put_contents(\'mc-files/pages/index/draft.php\', \'\');'."\n"; -echo " }\n"; -echo " if (!is_dir('mc-files/posts/index')) {\n"; -echo " mkdir('mc-files/posts/index', 0744, true);\n"; -echo ' file_put_contents(\'mc-files/posts/index/delete.php\', \'\');'."\n"; -echo ' file_put_contents(\'mc-files/posts/index/publish.php\', \'\');'."\n"; -echo ' file_put_contents(\'mc-files/posts/index/draft.php\', \'\');'."\n"; -echo " }\n"; -echo "?>"; -echo "
"; - -echo '
升级安装完毕
'."\n"; -echo "
安装文件无法删除,请手工删除。
\n"; -echo '
'."\n"; - -echo "\n"; echo <<
+ \$is_upgrade=true; + + if (!\$install_failed) { + if (!is_file('mc-files/mc-conf.php')) { + \$is_upgrade = false; + echo '
'; + echo "创建配置文件"; + if (!file_put_contents('mc-files/mc-conf.php', + " '\$version',". + "'site_link' => '',". + "'site_name' => '{\$_POST['sitename']}',". + "'site_desc' => '又一个MiniCMS网站',". + "'user_name' => '{\$_POST['username']}',". + "'user_pass' => '{\$_POST['password']}',". + "'user_nick' => '{\$_POST['nickname']}',". + "'comment_code' => '');?>" + )) { + \$install_failed = true; + echo '[失败]'; + } + echo '
'; + } + + if (!is_dir('mc-files/posts/index')) { + echo '
'; + echo "创建文章索引目录"; + if (mkdir('mc-files/posts/index', 0744, true)) { + echo '
'; + echo "创建页面索引文件"; + if ( + !file_put_contents('mc-files/posts/index/delete.php', '') || + !file_put_contents('mc-files/posts/index/publish.php', '') || + !file_put_contents('mc-files/posts/index/draft.php', '') + ) { + \$install_failed = true; + echo '[失败]'; + rmdir('mc-files/posts/index'); + } + echo '
'; + } else { + \$install_failed = true; + echo '[失败]'; + echo '
'; + } + } + + if (!is_dir('mc-files/pages/index')) { + echo '
'; + echo "创建页面索引目录"; + if (mkdir('mc-files/pages/index', 0744, true)) { + echo '
'; + echo "创建页面索引文件"; + if ( + !file_put_contents('mc-files/pages/index/delete.php', '') || + !file_put_contents('mc-files/pages/index/publish.php', '') || + !file_put_contents('mc-files/pages/index/draft.php', '') + ) { + \$install_failed = true; + echo '[失败]'; + rmdir('mc-files/pages/index'); + } + echo '
'; + } else { + \$install_failed = true; + echo '[失败]'; + echo '
'; + } + } + } +?> +
+ +
升级安装失败
+ +
升级安装完毕
+ +
安装文件无法删除,请手工删除。
+ +
+
+ +
+
+ + + + HTML; function build($dirs) { + global $ignores; + foreach ($dirs as $dir) { if (!is_dir($dir)) { - echo "$dir not exists"; + echo "目录\"$dir\"不存在"; exit; } if ($dh = opendir($dir)) { $sub_dirs = array(); while (($item = readdir($dh)) !== false) { - if ($item[0] == '.' || ($dir == "." && $item == "build.php")) + if ($item[0] == '.') continue; - $file = $dir."/".$item; + if ($dir == '.') + $file = $item; + else + $file = $dir."/".$item; + + if (in_array($file, $ignores)) + continue; if (is_dir($file)) { $sub_dirs[] = $file; } else { - echo " echo \"解压 $file
\";\n"; - echo " install('$file', <<