install.php

来自「极限OA开源系统」· PHP 代码 · 共 916 行 · 第 1/2 页

PHP
916
字号
<?php/********************************************************************************//* 极限办公自动化系统 (极限OA)													*//* ========================      												*//* 欢迎使用 极限OA,在您开始使用之前,请务必完整阅读本软件附带的全部说明档				*//********************************************************************************//* Welcome to http://www.xsp.cn & http://oa.xsp.cn								*//* 技术支持论坛 http://www.1119.net												*//********************************************************************************//* 商业购买请联系 临海市极限网络有限公司											*//* 联系电话: (0576) 5131349	邮件: mkt@xsp.cn	QQ: 562873							*//********************************************************************************/error_reporting(7);set_magic_quotes_runtime(0);$action = ($HTTP_POST_VARS['action']) ? $HTTP_POST_VARS['action'] : $HTTP_GET_VARS['action'];$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'] ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];if (function_exists('set_time_limit') == 1 && @ini_get('safe_mode') == 0) {	@set_time_limit(1000);}@include './includes/config.php';echo echo_header();if(!$action) {	$jxoa_licence = <<<EOT版权所有 (c) 2004-2006,  极限网络有限公司 保留所有权力.1、极限OA 受著作权法及国际版权条约和其它知识产权法及条约的保护。只许可使用,而非出售。2、本授权协议仅适用于 极限OA 4.0 版本, 一旦您开始安装,则被视为完全同意本协议的全部内容, 若出现纠纷, 我们将根据相关法律和协议条款追究责任。3、被授权用户可查看代码或做适当更改, 但不可更改版权及链接,否则将视为违反授权协议,我们有权随时终止授权,责令停止损害,并追究民事和刑事责任的权力。4、被授权用户可在保留版权协议基础上自由散播本程序。5、遵守有关法律。您必须遵守与使用本“软件产品”有关的适用法律。EOT;	$jxoa_licence = str_replace('  ', '&nbsp; ', nl2br($jxoa_licence));	echo echo_action_1();} elseif($action == 'config') {	$exist_error = FALSE;	$write_error = FALSE;	if(file_exists('./includes/config.php')) {		$fileexists = result(1, 0);	} else {		$fileexists = result(0, 0);		$exist_error = TRUE;	}	if(is_writeable('./includes/config.php')) {		$filewriteable = result(1, 0);	} else {		$filewriteable = result(0, 0);		$write_error = TRUE;	}	if($exist_error) {		$config_info = '您的 config.php 不存在, 无法继续安装, 请用 FTP 将该文件上传后再试.';	} elseif(!$write_error) {		$config_info = '请在下面填写您的数据库账号信息, 通常情况下请不要修改红色选项内容.';	} elseif($write_error) {		$config_info = '安装向导无法写入配置文件, 请核对现有信息, 如需修改, 请通过 FTP 将改好的 config.php 上传.';	}	echo echo_action_2();	if(!$exist_error) {		if(!$write_error) {			$dbhost = 'localhost';			$dbuname = 'root';			$dbpass = '';			$dbname = 'oa';			$tablepre = 'oa_';			@include './includes/config.php';			echo echo_action_2_1();		} else {			@include './includes/config.php';			echo echo_action_2_2();		}	} else {		echo echo_action_2_3();	}} elseif($action == 'environment') {	if($HTTP_POST_VARS['saveconfig'] && is_writeable('./includes/config.php')) {		$dbhost = $HTTP_POST_VARS['dbhost'];		$dbuname = $HTTP_POST_VARS['dbuname'];		$dbpass = $HTTP_POST_VARS['dbpass'];		$dbname = $HTTP_POST_VARS['dbname'];		$tablepre = $HTTP_POST_VARS['tablepre'];		$fp = fopen('./includes/config.php', 'r');		$configfile = fread($fp, filesize('./includes/config.php'));		fclose($fp);		$configfile = preg_replace("/[$]dbhost\s*\=\s*[\"'].*?[\"']/is", "\$dbhost = '$dbhost'", $configfile);		$configfile = preg_replace("/[$]dbuname\s*\=\s*[\"'].*?[\"']/is", "\$dbuname = '$dbuname'", $configfile);		$configfile = preg_replace("/[$]dbpass\s*\=\s*[\"'].*?[\"']/is", "\$dbpass = '$dbpass'", $configfile);		$configfile = preg_replace("/[$]dbname\s*\=\s*[\"'].*?[\"']/is", "\$dbname = '$dbname'", $configfile);		$configfile = preg_replace("/[$]tablepre\s*\=\s*[\"'].*?[\"']/is", "\$tablepre = '$tablepre'", $configfile);		$fp = fopen('./includes/config.php', 'w');		fwrite($fp, trim($configfile));		fclose($fp);	}	include './includes/config.php';	$install_tmp = true;	include './includes/'.$database.'.php';	$db=new dbclass;	$db->connect($dbhost,$dbuname,$dbpass,$pconnect);		$msg = '';	$quit = FALSE;	$curr_os = PHP_OS;	$curr_php_version = PHP_VERSION;	if($curr_php_version < '4.0.0') {		$msg .= "<font color=\"red\">您的 PHP 版本小于 4.0.0, 无法使用 极限OA.</font>\t";		$quit = TRUE;	}	if(@ini_get(file_uploads)) {		$max_size = @ini_get(upload_max_filesize);		$curr_upload_status = "允许/最大 $max_size";		$msg .= "您可以上传尺寸在 $max_size 以下的文件.\t";	} else {		$curr_upload_status = '不允许上传文件';		$msg .= "<font color=\"red\">由于服务器屏蔽, 您无法使用文档管理功能.</font>\t";	}	$query = $db->query("SELECT VERSION()");	$curr_mysql_version = $db->result($query, 0);	if($curr_mysql_version < '3.23') {		$msg .= "<font color=\"red\">您的 MySQL 版本低于 3.23, 极限OA 的一些功能可能无法正常使用.</font>\t";	}	$curr_disk_space = intval(diskfreespace('.') / (1024 * 1024)).'M';	if(dir_writeable('./data/')) {		$curr_data_writeable = '可写';	} else {		$curr_data_writeable = '不可写';		$msg .= "<font color=\"red\">数据 ./data 目录属性非 777 或无法写入, 无法使用文件上传等功能.</font>\t";	}	$db->select_db($dbname);	if($db->error()) {		$db->query("CREATE DATABASE $dbname", 1);		if($db->error()) {			$msg .= "<font color=\"red\">指定的数据库 $dbname 不存在, 系统也无法自动建立, 无法安装 极限OA.</font>\t";			$quit = TRUE;		} else {			$db->select_db($dbname);			$msg .= "指定的数据库 $dbname 不存在, 但系统已成功建立, 可以继续安装.\t";		}	}	$query - $db->query("SELECT COUNT(*) FROM $tablepre"."settings", 1);	if(!$db->error()) {		$msg .= "<font color=\"red\">数据库中已经安装过 极限OA, 继续安装会清空原有数据.</font>\t";		$alert = " onSubmit=\"return confirm('继续安装会清空全部原有数据,您确定要继续吗?');\"";	} else {		$alert = '';	}	if($quit) {		$msg .= "<font color=\"red\">由于您目录属性或服务器配置原因, 无法继续安装 极限OA, 请仔细阅读安装说明.</font>";	} else {		$msg .= "您的服务器可以安装和使用 极限OA, 请进入下一步安装.";	}	$msgs = explode("\t", $msg);	unset($msg);	for($i = 0; $i < count($msgs); $i++) {		$action_3_outtmp .= "              <li>".$msgs[$i]."</li>\n";	}	if($quit) {$action_3_outtmp2 .= <<<DPT            <center>            <input class="button" type="button" name="refresh" value="重新检查设置" style="height: 25" onclick="javascript: window.location=('$PHP_SELF?action=environment');">&nbsp;            <input class="button" type="button" name="exit" value="退出安装向导" style="height: 25" onclick="javascript: window.close();">            </center>DPT;	} else {		$action_3_outtmp3 = 1;	}	echo echo_action_3();	} elseif($action == 'install') {	$username = $HTTP_POST_VARS['username'];	$email = $HTTP_POST_VARS['email'];	$password1 = $HTTP_POST_VARS['password1'];	$password2 = $HTTP_POST_VARS['password2'];	echo echo_action_4();	$msg = '';	if($username && $email && $password1 && $password2) {		if($password1 != $password2) {			$msg = "两次输入密码不一致.";		} elseif(strlen($username) > 15) {			$msg = "用户名超过 15 个字符限制.";		} elseif(preg_match("/^$|^c:\\con\\con$| |[,\"\s\t\<\>]|^游客|^Guest/is", $username)) {			$msg = "用户名空或包含非法字符.";		} elseif(!strstr($email, '@') || $email != stripslashes($email) || $email != htmlspecialchars($email)) {			$msg = "Email 地址无效";		}	} else {		$msg = '您的信息没有填写完整.';	}	if($msg) {		echo echo_action_4_1();		exit;	} else {		echo result(1, 0)."</td>\n";		echo"        </tr>\n";	}	echo echo_action_4_2();	include './includes/config.php';	include './includes/'.$database.'.php';		$action_4_outtmp2 = result(1, 0);		echo echo_action_4_3();	@$fp = fopen("data/oa.sql", "r");	$sqldump = @fread($fp, 99999999);	@fclose($fp);	$sqlquery = splitsql(str_replace(" oa_", " $tablepre", $sqldump));	unset($sqldump);	foreach($sqlquery as $sql) {		if(trim($sql) != '') {			if(substr($sql, 0, 12) == 'CREATE TABLE') {				$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);				echo '建立数据表 '.$name.' ... <font color="#0000EE">成功</font><br>';			}			$db->query($sql);		}	}	$db->query("INSERT INTO {$tablepre}members VALUES('2','4','ps2','$username','".md5($password1)."','1','$email','管理部门人员','1','0');");	//$db->query("DELETE FROM {$tablepre}members");	//$db->query("INSERT INTO {$tablepre}members (username, password, status, regip, regdate, lastvisit, email, dateformat, timeformat, showemail, newsletter, timeoffset)	//	VALUES ('$username', '".md5($password1)."', 'Admin', 'hidden', '".time()."', '".time()."', '$email', 'Y-n-j', 'h:i A', '1', '1', '8');");	echo echo_action_4_4();}	echo echo_action_4_5();function splitsql($sql){	$sql = str_replace("\r", "\n", $sql);	$ret = array();	$num = 0;	$queriesarray = explode(";\n", trim($sql));	unset($sql);	foreach($queriesarray as $query) {		$queries = explode("\n", trim($query));		foreach($queries as $query) {			$ret[$num] .= $query[0] == "#" ? NULL : $query;		}		$num++;	}	return($ret);}function result($result = 1, $output = 1) {	if($result) {		$text = '... <font color="#0000EE">成功</font><br>';		if(!$output) {			return $text;		}		echo $text;	} else {		$text = '... <font color="red">失败</font><br>';		if(!$output) {			return $text;		}		echo $text;	}}function dir_writeable($dir) {	if(!is_dir($dir)) {		@mkdir($dir, 0777);	}	if(is_dir($dir)) {		if($fp = @fopen("$dir/test.test", 'w')) {			@fclose($fp);			@unlink("$dir/test.test");			$writeable = 1;		} else {			$writeable = 0;		}	}	return $writeable;}function dir_clear($dir) {	echo '清空目录 '.$dir;	$directory = dir($dir);	while($entry = $directory->read()) {		$filename = $dir.'/'.$entry;		if(is_file($filename)) {			@unlink($filename);		}	}	$directory->close();	result();}function echo_header() {$s = <<<ODS<html><head><title>极限OA 安装向导</title><style>A:visited	{COLOR: #3A4273; TEXT-DECORATION: none}A:link		{COLOR: #3A4273; TEXT-DECORATION: none}A:hover		{COLOR: #3A4273; TEXT-DECORATION: underline}p		{TEXT-INDENT : 15px}body,table,td	{COLOR: #333333; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; LINE-HEIGHT: 20px; scrollbar-base-color: #E3E3EA; scrollbar-arrow-color: #5C5C8D}input		{COLOR: black; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; background-color: white; border: 1px gray solid;}.button		{COLOR: white; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; background-color: #0d78ee;border: 1px black solid;cursor: hand;height: 24}.install	{FONT-FAMILY: Arial, Verdana; FONT-SIZE: 20px; FONT-WEIGHT: bold; COLOR: #000000}</style></head><body bgcolor="#8080C0" text="#000000"><table width="95%" border="0" cellspacing="1" cellpadding="1" background="images/edging_bg.gif" align="center">  <tr>    <td>      <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">        <tr>           <td class="install" height="30" valign="bottom"><font color="red">> ></font>             极限OA 安装向导</td>        </tr>        <tr>          <td>             <hr noshade align="center" width="100%" size="1">          </td>        </tr>        <tr>          <td align="center" style="color:red">             <b>欢迎来到  极限OA 安装向导,安装前请仔细阅读 licence 档的每个细节,在您确定可以完全满足 极限OA 的授权协议之后才能开始安装。</b>          </td>        </tr>        <tr>          <td>            <hr noshade align="center" width="100%" size="1">          </td>        </tr>ODS;	return $s;}function echo_action_1() {	global $jxoa_licence,$PHP_SELF;$s = <<<ODS        <tr>           <td><b>第一步: </b><font color="#0000EE">阅读用户许可协议</font></td>        </tr>        <tr>           <td>            <hr noshade align="center" width="100%" size="1">          </td>        </tr>        <tr>          <td><b><font style="color:red;font-size:14.8px;font: 12px 宋体">·</font><font color="#000000"> 请您务必仔细阅读下面的许可协议</font></b></td>        </tr>        <tr>          <td><br>            <table width="90%" cellspacing="1" bgcolor="#333333" border="0" align="center">              <tr>                <td bgcolor="#f7f7f7">                  <table width="99%" cellspacing="1" border="0" align="center">                    <tr>                      <td>                        $jxoa_licence                    </td>                  </tr>                </table>              </td>            </tr>          </table>          </td>        </tr>        <tr>          <td align="center">            <br>            <form method="post" action="$PHP_SELF">              <input type="hidden" name="action" value="config">              <input class="button" type="submit" name="submit" value="我完全同意">&nbsp;              <input class="button" type="button" name="exit" value="我不能同意" onclick="javascript: window.close();">            </form>          </td>        </tr>ODS;	return $s;}function echo_action_2() {	global $fileexists,$filewriteable,$config_info;$s = <<<ODS        <tr>           <td><b>第二步: </b><font color="#0000EE">配置 config.php (位于 includes/ 下)</font></td>        </tr>        <tr>           <td>            <hr noshade align="center" width="100%" size="1">          </td>        </tr>        <tr>          <td><b><font style="color:red;font-size:14.8px;font: 12px 宋体">·</font><font color="#000000"> 检查配置文件状态</font></b></td>        </tr>        <tr>          <td>config.php 存在检查 $fileexists</td>        </tr>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?