?? index.php
字號(hào):
<?php
//########################################################################
//Web版進(jìn)銷存安裝程序
//程序開發(fā):馬鬼團(tuán)隊(duì)
//聯(lián)系QQ:12612019
//#########################################################################
/*------------------------
初始化系統(tǒng)環(huán)境
------------------------*/
$step=$_GET['step'];
define('VIOOMAROOT',substr(dirname(__FILE__),0,-8));
require_once(VIOOMAROOT."/include/config_rglobals.php");
if(empty($step)) $step = 1;
require_once("./inc_install.php");
/*------------------------
顯示協(xié)議文件
------------------------*/
if($step==1){
if(file_exists('install.finish')) {
echo '你已經(jīng)安裝過(guò)該系統(tǒng),如果想重新安裝,請(qǐng)先刪除install目錄的 install.finish 文件,然后再次運(yùn)行該程序';
exit;
}
include_once("./templets/step1.html");
exit();
}
/*------------------------
測(cè)試環(huán)境要求
------------------------*/
else if($step==2)
{
$phpv = @phpversion();
$sp_os = $_ENV["OS"];
$sp_gd = @gdversion();
$sp_server = $_SERVER["SERVER_SOFTWARE"];
$sp_host = (empty($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_HOST"] : $_SERVER["REMOTE_ADDR"]);
$sp_name = $_SERVER["SERVER_NAME"];
$sp_max_execution_time = ini_get('max_execution_time');
$sp_allow_reference = (ini_get('allow_call_time_pass_reference') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
$sp_allow_url_fopen = (ini_get('allow_url_fopen') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
$sp_safe_mode = (ini_get('safe_mode') ? '<font color=red>[×]On</font>' : '<font color=green>[√]Off</font>');
$sp_gd = ($sp_gd>0 ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
$sp_mysql = (function_exists('mysql_connect') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
if($sp_mysql=='<font color=red>[×]Off</font>') $sp_mysql_err = true;
else $sp_mysql_err = false;
$sp_testdirs = array(
'/',
'/include',
'/data/sessions'
);
include_once("./templets/step2.html");
exit();
}
/*------------------------
填寫設(shè)置
------------------------*/
else if($step==3)
{
if(!empty($_SERVER["REQUEST_URI"])){$scriptName = $_SERVER["REQUEST_URI"]; }
else{ $scriptName = $_SERVER["PHP_SELF"]; }
$path = ereg_replace("/install/index\.php(.*)$","",$scriptName);
if(empty($_SERVER['HTTP_HOST'])) $baseurl = "http://".$_SERVER['HTTP_HOST'];
else $baseurl = "http://".$_SERVER['SERVER_NAME'];
$rnd_cookieEncode = chr(mt_rand(ord('A'),ord('Z'))).chr(mt_rand(ord('a'),ord('z'))).chr(mt_rand(ord('A'),ord('Z'))).chr(mt_rand(ord('A'),ord('Z'))).chr(mt_rand(ord('a'),ord('z'))).mt_rand(1000,9999).chr(mt_rand(ord('A'),ord('Z')));
include_once("./templets/step3.html");
exit();
}
/*------------------------
開始安裝進(jìn)程
------------------------*/
else if($step==5)
{
if(empty($setupsta)) $setupsta = 0;
//初始化基本安裝數(shù)據(jù)、創(chuàng)建表
//----------------------------------
if($setupsta==0)
{
$setupinfo = '';
$gotourl = '';
$gototime = 2000;
if(eregi("[^\.0-9a-z@!_-]",$adminuser) || eregi("[^\.0-9a-z@!_-]",$adminpwd)){
echo GetBackAlert("管理員用戶名或密碼含有非法字符!");
exit();
}
//檢測(cè)數(shù)據(jù)庫(kù)權(quán)限
$conn = @mysql_connect($dbhost,$dbuser,$dbpwd);
if(!$conn){
echo GetBackAlert("數(shù)據(jù)庫(kù)服務(wù)器或登錄密碼無(wú)效,\\n\\n無(wú)法連接數(shù)據(jù)庫(kù),請(qǐng)重新設(shè)定!");
exit();
}
$rs = mysql_select_db($dbname,$conn);
if(!$rs){
$rs = mysql_query(" CREATE DATABASE `$dbname`; ",$conn);
if(!$rs){
$errstr = GetBackAlert("數(shù)據(jù)庫(kù) {$dbname} 不存在,也沒(méi)權(quán)限創(chuàng)建新的數(shù)據(jù)庫(kù)!");
echo $errstr;
exit();
}else{
$rs = mysql_select_db($dbname,$conn);
if(!$rs){
$errstr = GetBackAlert("你對(duì)數(shù)據(jù)庫(kù) {$dbname} 沒(méi)權(quán)限!");
echo $errstr;
exit();
}
}
}
//讀取配置模板,并替換真實(shí)配置
$errstr = GetBackAlert("讀取配置 config_base.php 失敗,請(qǐng)檢查install/config_base.php是否可讀取!");
$fp = fopen(VIOOMAROOT."/install/config_base.php","r") or die($errstr);
$configstr1 = fread($fp,filesize(VIOOMAROOT."/install/config_base.php"));
fclose($fp);
$errstr = GetBackAlert("讀取配置 config_hand.php 失敗,請(qǐng)檢查install/config_hand.php是否可讀取!");
$fp = fopen(VIOOMAROOT."/install/config_hand.php","r") or die($errstr);
$configstr2 = fread($fp,filesize(VIOOMAROOT."/install/config_hand.php"));
fclose($fp);
$configstr1 = str_replace('~dbhost~',$dbhost,$configstr1);
$configstr1 = str_replace('~dbname~',$dbname,$configstr1);
$configstr1 = str_replace('~dbuser~',$dbuser,$configstr1);
$configstr1 = str_replace('~dbpwd~',$dbpwd,$configstr1);
$configstr1 = str_replace('~dbprefix~',$dbprefix,$configstr1);
$configstr1 = str_replace('~db_language~',$db_language,$configstr1);
$errstr = GetBackAlert("寫入配置 include/config_base.php 失敗,請(qǐng)檢查 include文件夾 是否可讀寫!");
$fp = fopen(VIOOMAROOT."/include/config_base.php","w") or die($errstr);
fwrite($fp,$configstr1);
fclose($fp);
$indexurl = (empty($cmspath) ? '/' : $cmspath);
$configstr2 = str_replace('~cmspath~',$cmspath,$configstr2);
$configstr2 = str_replace('~cookiepwd~',$cookiepwd,$configstr2);
$configstr2 = str_replace('~webname~',$webname,$configstr2);
$configstr2 = str_replace('~weburl~',$weburl,$configstr2);
$configstr2 = str_replace('~indexurl~',$indexurl,$configstr2);
$configstr2 = str_replace('~adminmail~',$adminmail,$configstr2);
$fp = fopen(VIOOMAROOT."/include/config_hand.php","w") or die($errstr);
fwrite($fp,$configstr2);
fclose($fp);
$fp = fopen(VIOOMAROOT."/include/config_hand_bak.php","w");
fwrite($fp,$configstr2);
fclose($fp);
//檢測(cè)數(shù)據(jù)庫(kù)信息并創(chuàng)建基本數(shù)據(jù)表
mysql_query("SET NAMES '{$db_language}';",$conn);
$rs = mysql_query("SELECT VERSION();",$conn);
$row = mysql_fetch_array($rs);
$mysql_version = $row[0];
$mysql_versions = explode(".",trim($mysql_version));
$mysql_version = $mysql_versions[0].".".$mysql_versions[1];
$adminpwd=md5($adminpwd);
$admindatas = "
INSERT INTO `#@__boss` VALUES (10, '{$adminuser}', '{$adminpwd}', '2008-08-18 20:35:28', '127.0.0.1','0','1');
INSERT INTO `#@__config` VALUES (1, 'cfg_webname', '公司名稱', '{$webname}', 'string', 8);
INSERT INTO `#@__config` VALUES (2, 'cfg_basehost', '站點(diǎn)根網(wǎng)址', '{$weburl}', 'string', 8);
INSERT INTO `#@__config` VALUES (3, 'cfg_cmspath', '安裝目錄', '{$path}', 'string', 8);
INSERT INTO `#@__config` VALUES (5, 'cfg_cookie_encode', 'cookie加密碼', '{$cookiepwd}', 'string', 8);
INSERT INTO `#@__config` VALUES (4, 'cfg_indexurl', '網(wǎng)頁(yè)主頁(yè)鏈接', '{$indexurl}', 'string',8);
INSERT INTO `#@__config` VALUES (6, 'cfg_adminemail', '站長(zhǎng)EMAIL', '{$adminmail}', 'string', 8);
INSERT INTO `#@__config` VALUES (7, 'cfg_backup_dir', '數(shù)據(jù)備份目錄', 'backup_data', 'string', 30);
INSERT INTO `#@__config` VALUES (8, 'cfg_keeptime', 'Cookie保持時(shí)間', '2', 'smallint', 6);
INSERT INTO `#@__config` VALUES (9, 'cfg_address', '公司地址', '', 'string', 200);
INSERT INTO `#@__config` VALUES (10, 'cfg_conact', '聯(lián)系人', '', 'string', 10);
INSERT INTO `#@__config` VALUES (11, 'cfg_phone', '聯(lián)系電話', '', 'string', 15);
INSERT INTO `#@__config` VALUES (12, 'cfg_islevel', '是否啟用會(huì)員等級(jí)', '0', 'smallint', 6);
INSERT INTO `#@__config` VALUES (13, 'cfg_isdiscount', '是否按等級(jí)打折', '0', 'smallint', 6);
INSERT INTO `#@__config` VALUES (14, 'cfg_isalarm', '庫(kù)存報(bào)警', '1', 'smallint', 6);
INSERT INTO `#@__config` VALUES (15, 'cfg_isshow', '報(bào)表里是否顯示詳細(xì)信息', '1', 'smallint', 6);
INSERT INTO `#@__config` VALUES (16, 'cfg_record', '顯示記錄數(shù)', '10', 'smallint', 6);
INSERT INTO `#@__config` VALUES (17, 'cfg_way', '員工業(yè)務(wù)提成', '1', 'smallint', 6);
INSERT INTO #@__usertype VALUES (1,'超級(jí)管理員','1','admin_AllowAll');
INSERT INTO #@__usertype VALUES (5,'倉(cāng)庫(kù)管理員','1','c_ACClab');
INSERT INTO #@__usertype VALUES (10,'銷售管理員','1','s_ACCsale');
INSERT INTO #@__usertype VALUES (20,'財(cái)務(wù)管理員','1','s_ACCmon');
";
if($mysql_version < 4.1) $fp = fopen(VIOOMAROOT."/install/setup40.sql","r");
else $fp = fopen(VIOOMAROOT."/install/setup41.sql","r");
//創(chuàng)建數(shù)據(jù)表和寫入數(shù)據(jù)
$query = "";
while(!feof($fp))
{
$line = trim(fgets($fp,1024));
if(ereg(";$",$line)){
$query .= $line;
$query = str_replace('#@__',$dbprefix,$query);
if($mysql_version < 4.1) mysql_query($query,$conn);
else mysql_query(str_replace('#~lang~#',$db_language,$query),$conn);
$query='';
}else if(!ereg("^(//|--)",$line)){
$query .= $line;
}
}
fclose($fp);
$sysquerys = explode(';',$admindatas);
foreach($sysquerys as $query){
if(trim($query)!='') mysql_query(str_replace('#@__',$dbprefix,$query),$conn);
}
mysql_close($conn);
$gotourl = 'index.php?step=5&setupsta=1';
$setupinfo = "
成功安裝系統(tǒng)基本數(shù)據(jù),現(xiàn)在開始安裝必要的基本數(shù)據(jù)<br />
請(qǐng)稍等...<br />
如果系統(tǒng)太長(zhǎng)時(shí)間沒(méi)反應(yīng),請(qǐng)點(diǎn)擊此<a href='{$gotourl}'>鏈接>></a>
";
include_once("./templets/step4.html");
exit();
}
//安裝基本數(shù)據(jù)
else if($setupsta==1)
{
$gototime = 2000;
$gotourl = '../login.php';
$setupinfo = "
已完成所有項(xiàng)目的安裝<br />
現(xiàn)在轉(zhuǎn)入管理員登錄頁(yè)面,請(qǐng)稍等...<br />
如果系統(tǒng)太長(zhǎng)時(shí)間沒(méi)反應(yīng),請(qǐng)點(diǎn)擊此<a href='{$gotourl}'>鏈接>></a>
";
include_once(VIOOMAROOT."/include/config_base.php");
$dsql = new DedeSql(false);
$fp = fopen(VIOOMAROOT."/install/setup_data1.sql","r");
//創(chuàng)建數(shù)據(jù)表和寫入數(shù)據(jù)
$query = "";
while(!feof($fp))
{
$line = trim(fgets($fp,1024));
if(ereg(";$",$line)){
$query .= $line;
//if(trim($query)!='') mysql_query(str_replace('#@__',$dbprefix,$query),$conn);
$dsql->ExecuteNoneQuery($query);
$query='';
}else if(!ereg("^(//|--)",$line)){
$query .= $line;
}
}
fclose($fp);
$dsql->Close();
include_once("./templets/step4.html");
exit();
}
}
/*------------------------
檢測(cè)數(shù)據(jù)庫(kù)是否有效
function _10_TestDbPwd()
------------------------*/
else if($step==10)
{
header("Pragma:no-cache\r\n");
header("Cache-Control:no-cache\r\n");
header("Expires:0\r\n");
header("Content-Type: text/html; charset=gb2312");
$conn = @mysql_connect($dbhost,$dbuser,$dbpwd);
if($conn)
{
$rs = mysql_select_db($dbname,$conn);
if(!$rs)
{
$rs = mysql_query(" CREATE DATABASE `$dbname`; ",$conn);
if($rs){
mysql_query(" DROP DATABASE `$dbname`; ",$conn);
echo "<font color='green'>信息正確</font>";
}else{
echo "<font color='red'>數(shù)據(jù)庫(kù)不存在,也沒(méi)權(quán)限創(chuàng)建新的數(shù)據(jù)庫(kù)!</font>";
}
}else{
echo "<font color='green'>信息正確</font>";
}
}else{
echo "<font color='red'>數(shù)據(jù)庫(kù)連接失敗!</font>";
}
@mysql_close($conn);
exit();
}
?>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -