function check_step() { global $err; if (check_write(SETUPTEMP_FILE, 2)) { $r = fs_mkdir(CACHE_DIR); $r &= fs_mkdir(INDEX_DIR); $r &= fs_copy(CONFIG_DEFAULT, CONFIG_FILE); $r &= fs_copy(FP_DEFAULTS . 'plugins.conf.php', CONFIG_DIR . 'plugins.conf.php'); $r &= fs_copy(FP_DEFAULTS . 'widgets.conf.php', CONFIG_DIR . 'widgets.conf.php'); //$r &= create_content(); return true; } $err[] = 'Write error'; return false; }
<blockquote> <?php echo check_write("../data"); ?> data 网站配置信息及缓存目录<br /> <?php echo check_write("../data/admin_tplc"); ?> data/admin_tplc 后台管理模板缓存目录 <br /> <?php echo check_write("../data/tpl_c"); ?> data/tpl_c 前台模板缓存目录<br /> <?php echo check_write("../upfiles"); ?> upfiles 附件上传目录<br /> <?php echo check_write("../app/database.config.php"); ?> app/database.config.php 数据库环境配置目录 </blockquote> </div> </div></div> <div class="space"></div> <div align="right"><button onclick="window.location.href='index.php?act=setconfig'" type="button" class="btn"><span><span>下一步,配置数据库环境</span></span></button></div> </div> <div class="clear"></div> </div> <?php $APP->tpl->p("foot", "", "0");
echo "\r\n</head>\r\n<body>\r\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\r\n\t<tr>\r\n\t\t<td colspan=\"3\" background=\"../../images/index03.gif\"><img src=\"../../images/index03.gif\" alt=\"\" width=\"100%\" height=\"40\"></td>\r\n\t</tr><tr>\r\n\t\t<td align=\"center\">\r\n\t\t<br><br>\r\n\r\n<table width=\"55%\" border=\"0\" cellpadding=\"20\" cellspacing=\"0\">\r\n\t<tr>\r\n\t\t<td class=\"olotd\" align=\"center\">\r\n\t\t\t\r\n\t\t\t<!-- Begin Page -->\r\n\t\t\t<table width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\" >\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"menuhead2\" width=\"100%\"> MyIT CRM Upgrader from versions 0.2.9.x</td>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr><tr>\r\n\t\t\t\t\t<td class=\"menutd2\" colspan=\"2\">\r\n\r\n\t\t\t\t\t\t<table width=\"100%\" class=\"olotable\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\" >\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td width=\"100%\" valign=\"top\" >\r\n\r\n\t\t\t\t\t\t\t\t\t<form action=\"index.php\" method=\"POST\" name=\"install\" id=\"install\" onsubmit=\"try { var myValidator = validate_install; } catch(e) { return true; } return myValidator(this);\">\r\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"mode\" value=\"install\">\r\n\r\n\t\t\t\t\t\t\t\t\t\t<table width=\"100%\" class=\"menutd\" cellspacing=\"0\" border=\"0\" cellpadding=\"5\">\r\n\t\t\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<table >\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Initial File Checks</b><br>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<table class=\"olotable\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\" >\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tYou need to set the config file conf.php to be writable by your webserver for the install after that you must make them read only by your webserver.\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tThe file log/access.log needs to be writable by the web server. The cache directory needs to be writable by the server.\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr><tr>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\">Main Config Writable "; if (!check_write('../../conf.php')) { echo "<font color=\"red\">../../conf.php is not writable stopping</font>"; $errors[] = array('../../conf.php' => 'Not Writable'); } else { echo "<font color=\"green\"><b>OK</b>"; } echo "</td>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr><tr>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\">Cache Folder "; if (!check_write('../../cache')) { echo "<font color=\"red\">../../cache is not writable stopping.</font>"; $errors[] = array('../../cache' => 'Not Writable'); } else { echo "<font color=\"green\"><b>OK</b>"; } echo "</td>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr><tr>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td align=\"left\">Access Log "; if (!check_write('../../log/access.log')) { echo "<font color=\"red\">../../log/access.log is not writable stopping.</font>"; $errors[] = array('../../log/access.log' => 'Not Writable'); } else { echo "<font color=\"green\"><b>OK</b>"; } echo "</td>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- End of File Checks -->\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</table>"; if (is_array($errors)) { echo "Set up can not continue until the following errors are fixed:<br>"; foreach ($errors as $key => $val) { echo "<font color=\"red\">Error {$key}: "; foreach ($val as $k => $v) { echo "{$k} {$v}"; } echo "</font><br>"; }
function check_write($path, $path_type = 1, $check_type = 1) { if ($path_type == 1) { if (is_dir($path)) { if ($check_type == 1) { $testfile = $path . '/test.tmp'; } else { check_write($path); $testfile = $path . 'default' . '/test.tmp'; } @chmod($testfile, 0777); $fp = @fopen($testfile, 'ab'); @unlink($testfile); if ($fp === false) { return false; } } else { return false; } } elseif ($path_type == 2) { @chmod($path, 0777); $fp = @fopen($path, 'ab'); if ($fp === false) { return false; } } return true; }
install_head(); echo_start(); echo_msg("欢迎您安装PHPOK3.0精简版企业网站系统" . HR); echo_msg("检查属性是否可写:", check_write("./") . " 根目录"); echo_msg("", check_write("data") . " data 文本数据目录"); echo_msg("", check_write("data/admin_tplc") . " data/admin_tplc 后台模板编译目录"); echo_msg("", check_write("data/cache") . " data/cache 目录"); echo_msg("", check_write("data/yui_tplc") . " data/yui_tplc 前台模板编译目录"); echo_msg("", check_write("upfiles") . " upfiles 上传附件目录"); echo_msg("", check_write("upfiles/xu_temp") . " data/xu_temp XUploadFile控件上传临时目录"); echo_msg("", check_write("upfiles/xu_temp_") . " data/xu_temp_ XUploadFile控件上传缓存目录"); if (file_exists("config.php")) { echo_msg("", check_write("config.php") . " config.php 配置文件"); } if (file_exists(".htaccess")) { echo_msg("", check_write(".htaccess") . " .htaccess 伪静态页文件"); } echo_msg(HR . "<span style='color:red;'>友情提示:</span>程序检查可能不全面,建议手动检查"); echo_msg(HR . button("setconfig")); echo_end(); install_foot(); } elseif ($sysact == "setconfig") { install_head("配置config.php文件"); echo_start(); echo_msg("配置config.php文件信息" . HR); form_start("install.php?act=setconfig_ok"); echo_msg("服务器地址:", "<input type='text' name='db_host' value='localhost'>", true); echo_msg("数据库端口:", "<input type='text' name='db_port' value='3306' style='width:45px;'>", true); echo_msg("数据库账号:", "<input type='text' name='db_user' value='root'>", true); echo_msg("数据库密码:", "<input type='text' name='db_pass'>", true); echo_msg("数据库名称:", "<input type='text' name='db_data'> [请确保存在数据库]", true);