| @@ -9,19 +9,14 @@ | |||||
| * @license https://www.dedebiz.com/license | * @license https://www.dedebiz.com/license | ||||
| * @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
| */ | */ | ||||
| define('DEDE_ENVIRONMENT', 'production'); | define('DEDE_ENVIRONMENT', 'production'); | ||||
| define('DEBUG_LEVEL', FALSE); //如果设置为TRUE则会打印执行SQL的时间和标签加载时间方便调试 | define('DEBUG_LEVEL', FALSE); //如果设置为TRUE则会打印执行SQL的时间和标签加载时间方便调试 | ||||
| //切换工作目录到./public | |||||
| //切换工作目录到/src | |||||
| $workDir = dirname(__FILE__) . "/src"; | $workDir = dirname(__FILE__) . "/src"; | ||||
| chdir($workDir); | chdir($workDir); | ||||
| if (substr(php_sapi_name(), 0, 3) === 'cgi') { | if (substr(php_sapi_name(), 0, 3) === 'cgi') { | ||||
| die("DedeBIZ:needs php-cli to run\n\n"); | die("DedeBIZ:needs php-cli to run\n\n"); | ||||
| } | } | ||||
| $helpStr = " | $helpStr = " | ||||
| NAME: | NAME: | ||||
| DedeBIZ Cli Tools | DedeBIZ Cli Tools | ||||
| @@ -36,7 +31,6 @@ COMMANDS: | |||||
| WEBSITE: | WEBSITE: | ||||
| https://www.dedebiz.com/help/ | https://www.dedebiz.com/help/ | ||||
| "; | "; | ||||
| //将选项转化为SQL IN参数 | //将选项转化为SQL IN参数 | ||||
| function Option2SQLin($str = "") | function Option2SQLin($str = "") | ||||
| { | { | ||||
| @@ -63,7 +57,6 @@ function Option2SQLin($str = "") | |||||
| } | } | ||||
| return implode(",", $strs); | return implode(",", $strs); | ||||
| } | } | ||||
| function RandEncode($length=26) | function RandEncode($length=26) | ||||
| { | { | ||||
| $chars='abcdefghigklmnopqrstuvwxwyABCDEFGHIGKLMNOPQRSTUVWXWY0123456789'; | $chars='abcdefghigklmnopqrstuvwxwyABCDEFGHIGKLMNOPQRSTUVWXWY0123456789'; | ||||
| @@ -75,7 +68,6 @@ function RandEncode($length=26) | |||||
| } | } | ||||
| return $rnd_cookieEncode; | return $rnd_cookieEncode; | ||||
| } | } | ||||
| if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | ||||
| //PHP5.4以下不支持内建服务器 | //PHP5.4以下不支持内建服务器 | ||||
| //用于开发调试 | //用于开发调试 | ||||
| @@ -90,10 +82,8 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| DedeCli::error("Check your root path is right"); | DedeCli::error("Check your root path is right"); | ||||
| exit; | exit; | ||||
| } | } | ||||
| require_once($workDir . "/system/common.inc.php"); | require_once($workDir . "/system/common.inc.php"); | ||||
| require_once(DEDEINC . "/libraries/cli.class.php"); | require_once(DEDEINC . "/libraries/cli.class.php"); | ||||
| //一个命令行的生成工具 | //一个命令行的生成工具 | ||||
| if (count($argv) > 2 && ($argv[2] == "arc" || $argv[2] == "a")) { | if (count($argv) > 2 && ($argv[2] == "arc" || $argv[2] == "a")) { | ||||
| //生成文档 | //生成文档 | ||||
| @@ -188,7 +178,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| DedeCli::error("start is empty"); | DedeCli::error("start is empty"); | ||||
| exit; | exit; | ||||
| } | } | ||||
| //1.生成首页 | //1.生成首页 | ||||
| $pv = new PartView(); | $pv = new PartView(); | ||||
| $row = $pv->dsql->GetOne("SELECT * FROM `#@__homepageset` "); | $row = $pv->dsql->GetOne("SELECT * FROM `#@__homepageset` "); | ||||
| @@ -238,7 +227,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| } | } | ||||
| DedeCli::write("Make list html successfull"); | DedeCli::write("Make list html successfull"); | ||||
| } | } | ||||
| //生成文档 | //生成文档 | ||||
| $tt = $dsql->GetOne("SELECT COUNT(id) as dd FROM `#@__arctiny` WHERE senddate >=" . $start . " AND arcrank>-1"); | $tt = $dsql->GetOne("SELECT COUNT(id) as dd FROM `#@__arctiny` WHERE senddate >=" . $start . " AND arcrank>-1"); | ||||
| $total = intval($tt['dd']); | $total = intval($tt['dd']); | ||||
| @@ -252,7 +240,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| $i++; | $i++; | ||||
| } | } | ||||
| DedeCli::write("Make archives html successfull"); | DedeCli::write("Make archives html successfull"); | ||||
| //优化数据 | //优化数据 | ||||
| OptimizeData($dsql); | OptimizeData($dsql); | ||||
| DedeCli::write("Optimize data successfull"); | DedeCli::write("Optimize data successfull"); | ||||
| @@ -291,7 +278,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| DedeCli::error("latest version,don't need to update"); | DedeCli::error("latest version,don't need to update"); | ||||
| exit; | exit; | ||||
| } | } | ||||
| $fileHashURL = "https://cdn.dedebiz.com/release/{$cfg_version_detail}.json"; | $fileHashURL = "https://cdn.dedebiz.com/release/{$cfg_version_detail}.json"; | ||||
| $del = new DedeHttpDown(); | $del = new DedeHttpDown(); | ||||
| $del->OpenUrl($fileHashURL); | $del->OpenUrl($fileHashURL); | ||||
| @@ -322,9 +308,7 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| $dbpwd = ""; | $dbpwd = ""; | ||||
| $dbprefix = "dede_"; | $dbprefix = "dede_"; | ||||
| $dblang = "utf8"; | $dblang = "utf8"; | ||||
| mkdir($workDir.'/data/tplcache', 0777); | mkdir($workDir.'/data/tplcache', 0777); | ||||
| //common.inc.php | //common.inc.php | ||||
| $configStr1 = str_replace("~dbtype~",$dbtype,$configStr1); | $configStr1 = str_replace("~dbtype~",$dbtype,$configStr1); | ||||
| $configStr1 = str_replace("~dbhost~",$dbhost,$configStr1); | $configStr1 = str_replace("~dbhost~",$dbhost,$configStr1); | ||||
| @@ -336,14 +320,12 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| $fp = fopen($workDir."/data/common.inc.php","w") or die("error,check /data writeable"); | $fp = fopen($workDir."/data/common.inc.php","w") or die("error,check /data writeable"); | ||||
| fwrite($fp,$configStr1); | fwrite($fp,$configStr1); | ||||
| fclose($fp); | fclose($fp); | ||||
| $cookieencode = RandEncode(26); | $cookieencode = RandEncode(26); | ||||
| $baseurl = "http://127.0.0.1:8088"; | $baseurl = "http://127.0.0.1:8088"; | ||||
| $indexUrl = "/"; | $indexUrl = "/"; | ||||
| $cmspath = ""; | $cmspath = ""; | ||||
| $webname = "DedeBIZ本地测试开发站点"; | $webname = "DedeBIZ本地测试开发站点"; | ||||
| $adminmail = "admin@dedebiz.com"; | $adminmail = "admin@dedebiz.com"; | ||||
| $fp = fopen($workDir."/install/config.cache.inc.php","r"); | $fp = fopen($workDir."/install/config.cache.inc.php","r"); | ||||
| $configStr2 = fread($fp,filesize($workDir."/install/config.cache.inc.php")); | $configStr2 = fread($fp,filesize($workDir."/install/config.cache.inc.php")); | ||||
| fclose($fp); | fclose($fp); | ||||
| @@ -353,15 +335,12 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| $configStr2 = str_replace("~cookieEncode~",$cookieencode,$configStr2); | $configStr2 = str_replace("~cookieEncode~",$cookieencode,$configStr2); | ||||
| $configStr2 = str_replace("~webname~",$webname,$configStr2); | $configStr2 = str_replace("~webname~",$webname,$configStr2); | ||||
| $configStr2 = str_replace("~adminmail~",$adminmail,$configStr2); | $configStr2 = str_replace("~adminmail~",$adminmail,$configStr2); | ||||
| $fp = fopen($workDir.'/data/config.cache.inc.php','w'); | $fp = fopen($workDir.'/data/config.cache.inc.php','w'); | ||||
| fwrite($fp,$configStr2); | fwrite($fp,$configStr2); | ||||
| fclose($fp); | fclose($fp); | ||||
| $fp = fopen($workDir.'/data/config.cache.bak.php','w'); | $fp = fopen($workDir.'/data/config.cache.bak.php','w'); | ||||
| fwrite($fp,$configStr2); | fwrite($fp,$configStr2); | ||||
| fclose($fp); | fclose($fp); | ||||
| $query = ''; | $query = ''; | ||||
| $fp = fopen($workDir.'/install/sql-dftables.txt','r'); | $fp = fopen($workDir.'/install/sql-dftables.txt','r'); | ||||
| while(!feof($fp)) | while(!feof($fp)) | ||||
| @@ -374,7 +353,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| $query = preg_replace('/character set (.*?) /i','',$query); | $query = preg_replace('/character set (.*?) /i','',$query); | ||||
| $query = str_replace('unsigned','',$query); | $query = str_replace('unsigned','',$query); | ||||
| $query = str_replace('TYPE=MyISAM','',$query); | $query = str_replace('TYPE=MyISAM','',$query); | ||||
| $query = preg_replace ('/TINYINT\(([\d]+)\)/i','INTEGER',$query); | $query = preg_replace ('/TINYINT\(([\d]+)\)/i','INTEGER',$query); | ||||
| $query = preg_replace ('/mediumint\(([\d]+)\)/i','INTEGER',$query); | $query = preg_replace ('/mediumint\(([\d]+)\)/i','INTEGER',$query); | ||||
| $query = preg_replace ('/smallint\(([\d]+)\)/i','INTEGER',$query); | $query = preg_replace ('/smallint\(([\d]+)\)/i','INTEGER',$query); | ||||
| @@ -399,7 +377,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| } | } | ||||
| } | } | ||||
| fclose($fp); | fclose($fp); | ||||
| //导入默认数据 | //导入默认数据 | ||||
| $query = ''; | $query = ''; | ||||
| $fp = fopen($workDir.'/install/sql-dfdata.txt','r'); | $fp = fopen($workDir.'/install/sql-dfdata.txt','r'); | ||||
| @@ -422,7 +399,6 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| } | } | ||||
| } | } | ||||
| fclose($fp); | fclose($fp); | ||||
| //更新配置 | //更新配置 | ||||
| $cquery = "UPDATE `{$dbprefix}sysconfig` SET value='{$baseurl}' WHERE varname='cfg_basehost';"; | $cquery = "UPDATE `{$dbprefix}sysconfig` SET value='{$baseurl}' WHERE varname='cfg_basehost';"; | ||||
| $db->exec($cquery); | $db->exec($cquery); | ||||
| @@ -436,46 +412,35 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) { | |||||
| $db->exec($cquery); | $db->exec($cquery); | ||||
| $cquery = "UPDATE `{$dbprefix}sysconfig` SET value='{$adminmail}' WHERE varname='cfg_adminemail';"; | $cquery = "UPDATE `{$dbprefix}sysconfig` SET value='{$adminmail}' WHERE varname='cfg_adminemail';"; | ||||
| $db->exec($cquery); | $db->exec($cquery); | ||||
| $adminuser = "admin"; | $adminuser = "admin"; | ||||
| $adminpwd = "admin"; | $adminpwd = "admin"; | ||||
| //增加管理员帐号 | //增加管理员帐号 | ||||
| $adminquery = "INSERT INTO `{$dbprefix}admin` VALUES (1, 10, '$adminuser', '".substr(md5($adminpwd),5,20)."', 'admin', '', '', 0, '".time()."', '127.0.0.1');"; | $adminquery = "INSERT INTO `{$dbprefix}admin` VALUES (1, 10, '$adminuser', '".substr(md5($adminpwd),5,20)."', 'admin', '', '', 0, '".time()."', '127.0.0.1');"; | ||||
| $db->exec($adminquery); | $db->exec($adminquery); | ||||
| DedeCli::write("admin user:admin"); | DedeCli::write("admin user:admin"); | ||||
| DedeCli::write("admin password:admin"); | DedeCli::write("admin password:admin"); | ||||
| //关连前台会员帐号 | //关连前台会员帐号 | ||||
| $adminquery = "INSERT INTO `{$dbprefix}member` (`mid`,`mtype`,`userid`,`pwd`,`uname`,`sex`,`rank`,`money`,`email`, | |||||
| `scores` ,`matt` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip` ) | |||||
| VALUES ('1','个人','$adminuser','".md5($adminpwd)."','$adminuser','男','100','0','','10000','10','','0','','".time()."','','0',''); "; | |||||
| $adminquery = "INSERT INTO `{$dbprefix}member` (`mid`,`mtype`,`userid`,`pwd`,`uname`,`sex`,`rank`,`money`,`email`,`scores` ,`matt` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip` ) | |||||
| VALUES ('1','个人','$adminuser','".md5($adminpwd)."','$adminuser','男','100','0','','10000','10','','0','','".time()."','','0',''); "; | |||||
| $db->exec($adminquery); | $db->exec($adminquery); | ||||
| $adminquery = "INSERT INTO `{$dbprefix}member_person` (`mid`,`onlynet`,`sex`,`uname`,`qq`,`msn`,`tel`,`mobile`,`place`,`oldplace`,`birthday`,`star`, | |||||
| `income` , `education` , `height` , `bodytype` , `blood` , `vocation` , `smoke` , `marital` , `house` ,`drink` , `datingtype` , `language` , `nature` , `lovemsg` , `address`,`uptime`) | |||||
| VALUES ('1', '1', '男', '{$adminuser}', '', '', '', '', '0', '0','1980-01-01', '1', '0', '0', '160', '0', '0', '0', '0', '0', '0','0', '0', '', '', '', '','0'); "; | |||||
| $adminquery = "INSERT INTO `{$dbprefix}member_person` (`mid`,`onlynet`,`sex`,`uname`,`qq`,`msn`,`tel`,`mobile`,`place`,`oldplace`,`birthday`,`star`,`income`,`education`,`height`,`bodytype`,`blood`,`vocation`,`smoke`,`marital`,`house` ,`drink`,`datingtype`,`language`,`nature`,`lovemsg`,`address`,`uptime`) | |||||
| VALUES ('1', '1', '男', '{$adminuser}', '', '', '', '', '0', '0','1980-01-01', '1', '0', '0', '160', '0', '0', '0', '0', '0', '0','0', '0', '', '', '', '','0'); "; | |||||
| $db->exec($adminquery); | $db->exec($adminquery); | ||||
| $adminquery = "INSERT INTO `{$dbprefix}member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`) | $adminquery = "INSERT INTO `{$dbprefix}member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`) | ||||
| VALUES ('1','0','0','0','0','0','0','0','0'); "; | |||||
| VALUES ('1','0','0','0','0','0','0','0','0'); "; | |||||
| $db->exec($adminquery); | $db->exec($adminquery); | ||||
| $adminquery = "Insert Into `{$dbprefix}member_space`(`mid` ,`pagesize` ,`matt` ,`spacename` ,`spacelogo` ,`spacestyle`, `sign` ,`spacenews`) | $adminquery = "Insert Into `{$dbprefix}member_space`(`mid` ,`pagesize` ,`matt` ,`spacename` ,`spacelogo` ,`spacestyle`, `sign` ,`spacenews`) | ||||
| Values('1','10','0','{$adminuser}的空间','','person','',''); "; | |||||
| Values('1','10','0','{$adminuser}的空间','','person','',''); "; | |||||
| $db->exec($adminquery); | $db->exec($adminquery); | ||||
| if (phpversion() < "5.4") { | if (phpversion() < "5.4") { | ||||
| die("DedeBIZ:command web server not support\n\n"); | die("DedeBIZ:command web server not support\n\n"); | ||||
| } | } | ||||
| // 写入程序安装锁 | // 写入程序安装锁 | ||||
| file_put_contents($workDir.'/install/install_lock.txt', 'ok'); | file_put_contents($workDir.'/install/install_lock.txt', 'ok'); | ||||
| echo "Start Dev Server For DedeBIZ\n\r"; | echo "Start Dev Server For DedeBIZ\n\r"; | ||||
| echo "Open http://localhost:8088\n\r"; | echo "Open http://localhost:8088\n\r"; | ||||
| passthru(PHP_BINARY . ' -S localhost:8088 -t' . escapeshellarg('./')); | passthru(PHP_BINARY . ' -S localhost:8088 -t' . escapeshellarg('./')); | ||||
| exit; | exit; | ||||
| } else { | } else { | ||||
| echo $helpStr; | echo $helpStr; | ||||
| } | |||||
| } | |||||