install.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. <?php
  2. error_reporting(0);
  3. @set_time_limit(0);
  4. ob_start();
  5. header('content-type: text/html; charset=utf-8');
  6. define('PATH_ROOT', str_replace("\\",'/', dirname(dirname(__FILE__))));
  7. //print_r(PATH_ROOT);EXIT;
  8. $actions = array('license', 'env', 'db', 'finish');
  9. $action = $_COOKIE['action'];
  10. $action = in_array($action, $actions) ? $action : 'license';
  11. $ispost = strtolower($_SERVER['REQUEST_METHOD']) == 'post';
  12. if(file_exists(PATH_ROOT . '/install/install.lock') && $action != 'finish') {
  13. @header("Content-type: text/html; charset=UTF-8");
  14. echo "系统已经安装过了,如果要重新安装,那么请删除public/install目录下的install.lock文件";
  15. exit;
  16. }
  17. if($_GET['step']=='get_dblist'){
  18. $link = @mysqli_connect($_GET['db_host'], $_GET['db_user'], $_GET['db_pass']);
  19. if(mysqli_connect_errno()) {
  20. $error = mysqli_connect_errno();
  21. if (strpos($error, '1045') !== false) {
  22. $result = array('code'=> '100','msg'=>'您的数据库访问用户名或是密码错误');
  23. }
  24. }else {
  25. $sql = "SELECT `SCHEMA_NAME` FROM `information_schema`.`SCHEMATA`";
  26. $result = mysqli_query($link, $sql);
  27. while ($rs = mysqli_fetch_array($result)) {
  28. $databases[] = $rs[0];
  29. }
  30. $result = array('code' => '200', 'data' => implode(',', $databases));
  31. }
  32. echo json_encode($result);die;
  33. }
  34. /**
  35. * 安装第一步,许可协议
  36. */
  37. if ($action == 'license') {
  38. if($ispost) {
  39. setcookie('action', 'env');
  40. header('location: ?refresh');
  41. exit;
  42. }
  43. tpl_install_license();
  44. }
  45. /**
  46. *检测安装环境
  47. */
  48. if($action == 'env') {
  49. if($ispost) {
  50. setcookie('action', $_POST['do'] == 'continue' ? 'db' : 'license');
  51. header('location: ?refresh');
  52. exit;
  53. }
  54. $ret = array();
  55. $ret['server']['os']['value'] = php_uname();
  56. if(PHP_SHLIB_SUFFIX == 'dll') {
  57. $ret['server']['os']['remark'] = '建议使用 Linux 系统以提升程序性能';
  58. $ret['server']['os']['class'] = 'warning';
  59. }
  60. $ret['server']['sapi']['value'] = $_SERVER['SERVER_SOFTWARE'];
  61. if(PHP_SAPI == 'isapi') {
  62. $ret['server']['sapi']['remark'] = '建议使用 Apache 或 Nginx 以提升程序性能';
  63. $ret['server']['sapi']['class'] = 'warning';
  64. }
  65. $ret['server']['php']['value'] = PHP_VERSION;
  66. $ret['server']['dir']['value'] = PATH_ROOT;
  67. if(function_exists('disk_free_space')) {
  68. $ret['server']['disk']['value'] = floor(disk_free_space(PATH_ROOT) / (1024*1024)).'M';
  69. } else {
  70. $ret['server']['disk']['value'] = 'unknow';
  71. }
  72. $ret['server']['upload']['value'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
  73. $ret['php']['version']['value'] = PHP_VERSION;
  74. $ret['php']['version']['class'] = 'success';
  75. if(version_compare(PHP_VERSION, '7.1.0') == -1) {
  76. $ret['php']['version']['class'] = 'danger';
  77. $ret['php']['version']['failed'] = true;
  78. $ret['php']['version']['remark'] = 'PHP版本必须为 7.1.0 以上.';
  79. }
  80. $ret['php']['mysql']['ok'] = function_exists('mysqli_connect');
  81. if($ret['php']['mysql']['ok']) {
  82. $ret['php']['mysql']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  83. } else {
  84. $ret['php']['pdo']['failed'] = true;
  85. $ret['php']['mysql']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  86. }
  87. $ret['php']['pdo']['ok'] = extension_loaded('pdo') && extension_loaded('pdo_mysql');
  88. if($ret['php']['pdo']['ok']) {
  89. $ret['php']['pdo']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  90. $ret['php']['pdo']['class'] = 'success';
  91. if(!$ret['php']['mysql']['ok']) {
  92. $ret['php']['pdo']['remark'] = '您的PHP环境不支持 mysqli_connect,请开启此扩展. ';
  93. }
  94. } else {
  95. $ret['php']['pdo']['failed'] = true;
  96. if($ret['php']['mysql']['ok']) {
  97. $ret['php']['pdo']['value'] = '<span class="glyphicon glyphicon-remove text-warning"></span>';
  98. $ret['php']['pdo']['class'] = 'warning';
  99. $ret['php']['pdo']['remark'] = '您的PHP环境不支持PDO, 请开启此扩展. ';
  100. } else {
  101. $ret['php']['pdo']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  102. $ret['php']['pdo']['class'] = 'danger';
  103. $ret['php']['pdo']['remark'] = '您的PHP环境不支持PDO, 也不支持 mysqli_connect, 系统无法正常运行. ';
  104. }
  105. }
  106. $ret['php']['fopen']['ok'] = @ini_get('allow_url_fopen') && function_exists('fsockopen');
  107. if($ret['php']['fopen']['ok']) {
  108. $ret['php']['fopen']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  109. } else {
  110. $ret['php']['fopen']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  111. }
  112. $ret['php']['curl']['ok'] = extension_loaded('curl') && function_exists('curl_init');
  113. if($ret['php']['curl']['ok']) {
  114. $ret['php']['curl']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  115. $ret['php']['curl']['class'] = 'success';
  116. if(!$ret['php']['fopen']['ok']) {
  117. $ret['php']['curl']['remark'] = '您的PHP环境虽然不支持 allow_url_fopen, 但已经支持了cURL, 这样系统是可以正常高效运行的, 不需要额外处理. ';
  118. }
  119. } else {
  120. if($ret['php']['fopen']['ok']) {
  121. $ret['php']['curl']['value'] = '<span class="glyphicon glyphicon-remove text-warning"></span>';
  122. $ret['php']['curl']['class'] = 'warning';
  123. $ret['php']['curl']['remark'] = '您的PHP环境不支持cURL, 但支持 allow_url_fopen, 这样系统虽然可以运行, 但还是建议你开启cURL以提升程序性能和系统稳定性. ';
  124. } else {
  125. $ret['php']['curl']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  126. $ret['php']['curl']['class'] = 'danger';
  127. $ret['php']['curl']['remark'] = '您的PHP环境不支持cURL, 也不支持 allow_url_fopen, 系统无法正常运行. ';
  128. $ret['php']['curl']['failed'] = true;
  129. }
  130. }
  131. $ret['php']['gd']['ok'] = extension_loaded('gd');
  132. if($ret['php']['gd']['ok']) {
  133. $ret['php']['gd']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  134. $ret['php']['gd']['class'] = 'success';
  135. } else {
  136. $ret['php']['gd']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  137. $ret['php']['gd']['class'] = 'danger';
  138. $ret['php']['gd']['failed'] = true;
  139. $ret['php']['gd']['remark'] = '没有启用GD, 将无法正常上传和压缩图片, 系统无法正常运行. ';
  140. }
  141. $ret['php']['openssl']['ok'] = extension_loaded('openssl');
  142. if($ret['php']['openssl']['ok']) {
  143. $ret['php']['openssl']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  144. $ret['php']['openssl']['class'] = 'success';
  145. } else {
  146. $ret['php']['openssl']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  147. $ret['php']['openssl']['class'] = 'danger';
  148. $ret['php']['openssl']['failed'] = true;
  149. $ret['php']['openssl']['remark'] = '没有启用openssl扩展. ';
  150. }
  151. $ret['php']['bcmath']['ok'] = extension_loaded('bcmath');
  152. if($ret['php']['bcmath']['ok']) {
  153. $ret['php']['bcmath']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  154. $ret['php']['bcmath']['class'] = 'success';
  155. } else {
  156. $ret['php']['bcmath']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  157. $ret['php']['bcmath']['class'] = 'danger';
  158. $ret['php']['bcmath']['failed'] = true;
  159. $ret['php']['bcmath']['remark'] = '没有启用bcmath扩展. ';
  160. }
  161. $ret['php']['dom']['ok'] = class_exists('DOMDocument');
  162. if($ret['php']['dom']['ok']) {
  163. $ret['php']['dom']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  164. $ret['php']['dom']['class'] = 'success';
  165. } else {
  166. $ret['php']['dom']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  167. $ret['php']['dom']['class'] = 'danger';
  168. $ret['php']['dom']['failed'] = true;
  169. $ret['php']['dom']['remark'] = '没有启用DOMDocument, 将无法正常安装使用模块, 系统无法正常运行. ';
  170. }
  171. $ret['php']['session']['ok'] = ini_get('session.auto_start');
  172. if($ret['php']['session']['ok'] == 0 || strtolower($ret['php']['session']['ok']) == 'off') {
  173. $ret['php']['session']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  174. $ret['php']['session']['class'] = 'success';
  175. } else {
  176. $ret['php']['session']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  177. $ret['php']['session']['class'] = 'danger';
  178. $ret['php']['session']['failed'] = true;
  179. $ret['php']['session']['remark'] = '系统session.auto_start开启, 将无法正常注册会员, 系统无法正常运行. ';
  180. }
  181. $ret['php']['asp_tags']['ok'] = ini_get('asp_tags');
  182. if(empty($ret['php']['asp_tags']['ok']) || strtolower($ret['php']['asp_tags']['ok']) == 'off') {
  183. $ret['php']['asp_tags']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  184. $ret['php']['asp_tags']['class'] = 'success';
  185. } else {
  186. $ret['php']['asp_tags']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  187. $ret['php']['asp_tags']['class'] = 'danger';
  188. $ret['php']['asp_tags']['failed'] = true;
  189. $ret['php']['asp_tags']['remark'] = '请禁用可以使用ASP 风格的标志,配置php.ini中asp_tags = Off';
  190. }
  191. $ret['write']['root']['ok'] = local_writeable(PATH_ROOT . '/uploads');
  192. if($ret['write']['root']['ok']) {
  193. $ret['write']['root']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  194. $ret['write']['root']['class'] = 'success';
  195. } else {
  196. $ret['write']['root']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  197. $ret['write']['root']['class'] = 'danger';
  198. $ret['write']['root']['failed'] = true;
  199. $ret['write']['root']['remark'] = 'public/uploads无法写入, 将无法使用自动更新功能, 系统无法正常运行. ';
  200. }
  201. $ret['write']['data']['ok'] = local_writeable(PATH_ROOT . '/../runtime');
  202. if($ret['write']['data']['ok']) {
  203. $ret['write']['data']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  204. $ret['write']['data']['class'] = 'success';
  205. } else {
  206. $ret['write']['data']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  207. $ret['write']['data']['class'] = 'danger';
  208. $ret['write']['data']['failed'] = true;
  209. $ret['write']['data']['remark'] = 'runtime目录无法写入, 将无法写入配置文件, 系统无法正常安装. ';
  210. }
  211. $ret['write']['install']['ok'] = local_writeable(PATH_ROOT . '/install');
  212. if($ret['write']['install']['ok']) {
  213. $ret['write']['install']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  214. $ret['write']['install']['class'] = 'success';
  215. } else {
  216. $ret['write']['install']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  217. $ret['write']['install']['class'] = 'danger';
  218. $ret['write']['install']['failed'] = true;
  219. $ret['write']['install']['remark'] = 'public/install目录无法写入, 将无法写入安装文件, 系统无法正常安装. ';
  220. }
  221. $ret['write']['database']['ok'] = is_writable(PATH_ROOT . '/../config/database.php');
  222. if($ret['write']['database']['ok']) {
  223. $ret['write']['database']['value'] = '<span class="glyphicon glyphicon-ok text-success"></span>';
  224. $ret['write']['database']['class'] = 'success';
  225. } else {
  226. $ret['write']['database']['value'] = '<span class="glyphicon glyphicon-remove text-danger"></span>';
  227. $ret['write']['database']['class'] = 'danger';
  228. $ret['write']['database']['failed'] = true;
  229. $ret['write']['database']['remark'] = 'config/database.php文件无法写入, 将无法写入数据库配置文件, 系统无法正常安装. ';
  230. }
  231. $ret['continue'] = true;
  232. foreach($ret['php'] as $opt) {
  233. if($opt['failed']) {
  234. $ret['continue'] = false;
  235. break;
  236. }
  237. }
  238. foreach($ret['write'] as $opt) {
  239. if($opt['failed']) {
  240. $ret['continue'] = false;
  241. break;
  242. }
  243. }
  244. tpl_install_env($ret);
  245. }
  246. /**
  247. *配置数据库信息
  248. */
  249. if($action == 'db') {
  250. if($ispost) {
  251. if($_POST['do'] != 'continue') {
  252. setcookie('action', 'env');
  253. header('location: ?refresh');
  254. exit();
  255. }
  256. $db = $_POST['db'];
  257. $user = $_POST['user'];
  258. $store =$_POST['store'];
  259. $link = @mysqli_connect($db['server'], $db['username'], $db['password']);
  260. if(mysqli_connect_errno()) {
  261. $error =mysqli_connect_errno();
  262. if (strpos($error, '1045') !== false) {
  263. $error = '您的数据库访问用户名或是密码错误. <br />';
  264. }
  265. } else {
  266. mysqli_query($link,"SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
  267. mysqli_query($link,"SET sql_mode=''");
  268. if(mysqli_errno($link)) {
  269. $error = mysqli_error($link);
  270. } else {
  271. $query = mysqli_query($link,"SHOW DATABASES LIKE '{$db['name']}';");
  272. if (!mysqli_fetch_assoc($query)) {
  273. if(mysqli_get_server_info($link) > '4.1') {
  274. mysqli_query($link,"CREATE DATABASE IF NOT EXISTS `{$db['name']}` DEFAULT CHARACTER SET utf8");
  275. } else {
  276. mysqli_query($link,"CREATE DATABASE IF NOT EXISTS `{$db['name']}`");
  277. }
  278. }
  279. $query = mysqli_query($link,"SHOW DATABASES LIKE '{$db['name']}';");
  280. if (!mysqli_fetch_assoc($query)) {
  281. $error .= "数据库不存在且创建数据库失败. <br />";
  282. }
  283. if(mysqli_errno($link)) {
  284. $error .= mysqli_error($link);
  285. }
  286. }
  287. }
  288. if(empty($error)) {
  289. $pieces = explode(':', $db['server']);
  290. $db['port'] = !empty($pieces[1]) ? $pieces[1] : '3306';
  291. $config = db_config();
  292. $cookiepre = local_salt(4) . '_';
  293. $authkey = local_salt(8);
  294. $config = str_replace(array(
  295. '{db-server}', '{db-username}', '{db-password}', '{db-port}','{db-name}','{db-prefix}'
  296. ), array(
  297. $db['server'], $db['username'], $db['password'], $db['port'], $db['name'],$db['prefix']
  298. ), $config);
  299. mysqli_close($link);
  300. $link = mysqli_connect($db['server'], $db['username'], $db['password']);
  301. mysqli_select_db($link,$db['name']);
  302. mysqli_query($link,"SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
  303. mysqli_query($link,"SET sql_mode=''");
  304. //循环添加数据
  305. if(file_exists(PATH_ROOT . '/install/install_base.sql')){
  306. $sql = file_get_contents(PATH_ROOT . '/install/install_base.sql');
  307. //添加初始化数据
  308. if($_POST['initdata']){
  309. $sql.=file_get_contents(PATH_ROOT.'/install/initdata.sql');
  310. }
  311. $sql =str_replace('#__',$db['prefix'],$sql);
  312. $sql = str_replace("\r", "\n", $sql);
  313. $sql = explode(";\n", $sql);
  314. foreach ($sql as $item) {
  315. $item = trim($item);
  316. if(empty($item)) continue;
  317. preg_match('/CREATE TABLE `([^ ]*)`/', $item, $matches);
  318. if($matches) {
  319. $table_name = $matches[1];
  320. $result = mysqli_query($link,$item);
  321. } else {
  322. $result = mysqli_query($link,$item);
  323. }
  324. if(!$result){
  325. die('<script type="text/javascript">alert("安装数据库SQL语句错误");history.back();</script>');
  326. }
  327. }
  328. }else{
  329. die('<script type="text/javascript">alert("安装包不正确, 数据安装脚本缺失.");history.back();</script>');
  330. }
  331. //更新安装时间
  332. $setup_date = date("Y-m-d H:i:s",time());
  333. mysqli_query($link,"update {$db['prefix']}config set value = '{$setup_date}' where code = 'setup_date'");
  334. //添加用户管理员
  335. $password = md5($user['password']);
  336. $insert_error = mysqli_query($link,"INSERT INTO {$db['prefix']}admin (admin_name, admin_password, admin_is_super, admin_gid)
  337. VALUES('{$user['username']}', '{$password}', '1', '0')");
  338. if(!$insert_error){
  339. die('<script type="text/javascript">alert("管理员账户注册失败.");history.back();</script>');
  340. }
  341. $store_name = $store['store_name'];
  342. $member_name = $store['username'];
  343. $seller_name = $member_name;
  344. $member_password = $store['password'];
  345. // 创建店铺
  346. mysqli_query($link,"INSERT INTO {$db['prefix']}member (`member_id`,`member_name`,`member_password`,`member_nickname`,`member_email`,`member_addtime`,`member_logintime`,`member_old_logintime`) VALUES ('1', '{$member_name}','". md5($member_password) ."', '德尚网络_123456', '', '". time() ."', '". time() ."', '". time() ."')");
  347. mysqli_query($link,"INSERT INTO {$db['prefix']}membercommon (`member_id`) VALUES ('1')");
  348. mysqli_query($link,"INSERT INTO {$db['prefix']}store (`store_id`,`store_name`,`grade_id`,`member_id`,`member_name`,`seller_name`,`store_state`,`store_addtime`) VALUES ('1','{$store_name}','1','1','{$member_name}','{$seller_name}','1', '". time() ."')");
  349. mysqli_query($link,"INSERT INTO {$db['prefix']}storejoinin (`member_id`,`member_name`,`seller_name`,`store_name`,`joinin_state`) VALUES ('1', '{$member_name}', '{$seller_name}', '{$store_name}', '40')");
  350. mysqli_query($link,"INSERT INTO {$db['prefix']}seller (`seller_id`,`seller_name`,`member_id`,`sellergroup_id`,`store_id`,`is_admin`) VALUES ('1', '{$seller_name}', '1', '0', '1', '1')");
  351. mysqli_query($link,"INSERT INTO {$db['prefix']}storebindclass (`bid`, `store_id`, `commis_rate`, `class_1`, `class_2`, `class_3`, `state`) VALUES ('1', '1', '0', '0', '0', '0', '1')");
  352. mysqli_query($link,"update {$db['prefix']}goods set is_platform_store = 1 where store_id = 1");
  353. mysqli_query($link,"update {$db['prefix']}goodscommon set is_platform_store = 1 where store_id = 1");
  354. mysqli_query($link,"update {$db['prefix']}store set is_platform_store = 1 where store_id = 1");
  355. mysqli_query($link,"update {$db['prefix']}store set bind_all_gc = 1 where store_id = 1");
  356. if($_POST['initdata']){
  357. mysqli_query($link,"update {$db['prefix']}goods set store_name = '{$store_name}'");
  358. mysqli_query($link,"update {$db['prefix']}goodscommon set store_name = '{$store_name}'");
  359. }
  360. //配置数据库
  361. file_put_contents(PATH_ROOT . '/../config/database.php', $config);
  362. //生成辨识
  363. touch(PATH_ROOT . '/install/install.lock');
  364. setcookie('action', 'finish');
  365. header('location: ?refresh');
  366. exit();
  367. }
  368. }
  369. tpl_install_db($error);
  370. }
  371. /**
  372. * 安装完成
  373. */
  374. if($action == 'finish') {
  375. setcookie('action', '',time()-3600);
  376. $sitepath = strtolower(substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')));
  377. $sitepath = str_replace('/install',"",$sitepath);
  378. $url = strtolower('http://'.$_SERVER['HTTP_HOST'].$sitepath);
  379. tpl_install_finish($url);
  380. }
  381. function tpl_install_license() {
  382. echo <<<EOF
  383. <div class="panel panel-default">
  384. <div class="panel-heading">阅读许可协议</div>
  385. <div class="panel-body" style="overflow-y:scroll;max-height:400px;line-height:20px;">
  386. <h3>版权所有 (c)2017,DsMall开源商城团队保留所有权利。 </h3>
  387. <p>
  388. 感谢您选择DsMall开源商城(以下简称DsMall,DsMall基于 PHP + MySQL的技术开发,全部源码开放。 <br />
  389. 为了使你正确并合法的使用本软件,请你在使用前务必阅读清楚下面的协议条款:
  390. </p>
  391. <p>
  392. <strong>一、本授权协议适用且仅适用于DsMall开源商城系统(以下简称DsMall)任何版本,DsMall开源商城官方对本授权协议的最终解释权。</strong>
  393. </p>
  394. <p>
  395. <strong>二、协议许可的权利 </strong>
  396. <ol>
  397. <li>您可以在完全遵守本最终用户授权协议的基础上,将本软件应用于非商业用途,而不必支付软件版权授权费用。</li>
  398. <li>您可以在协议规定的约束和限制范围内修改DsMall开源商城源代码或界面风格以适应您的网站要求。</li>
  399. <li>您拥有使用本软件构建的网站全部内容所有权,并独立承担与这些内容的相关法律义务。</li>
  400. <li>获得商业授权之后,您可以将本软件应用于商业用途,同时依据所购买的授权类型中确定的技术支持内容,自购买时刻起,在技术支持期限内拥有通过指定的方式获得指定范围内的技术支持服务。商业授权用户享有反映和提出意见的权力,相关意见将被作为首要考虑,但没有一定被采纳的承诺或保证。</li>
  401. </ol>
  402. </p>
  403. <p>
  404. <strong>三、协议规定的约束和限制 </strong>
  405. <ol>
  406. <li>未获商业授权之前,不得将本软件用于商业用途(包括但不限于企业网站、经营性网站、以营利为目的或实现盈利的网站)。</li>
  407. <li>未经官方许可,不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。</li>
  408. <li>未经官方许可,禁止在DsMall开源商城的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。</li>
  409. <li>如果您未能遵守本协议的条款,您的授权将被终止,所被许可的权利将被收回,并承担相应法律责任。</li>
  410. </ol>
  411. </p>
  412. <p>
  413. <strong>四、有限担保和免责声明 </strong>
  414. <ol>
  415. <li>本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。</li>
  416. <li>用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺对免费用户提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。</li>
  417. <li>电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始确认本协议并安装 DsMall,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。</li>
  418. <li>如果本软件带有其它软件的整合API示范例子包,这些文件版权不属于本软件官方,并且这些文件是没经过授权发布的,请参考相关软件的使用许可合法的使用。</li>
  419. </ol>
  420. </p>
  421. </div>
  422. </div>
  423. <form class="form-inline" role="form" method="post">
  424. <ul class="pager">
  425. <li class="pull-left" style="display:block;padding:5px 10px 5px 0;">
  426. <div class="checkbox">
  427. <label>
  428. <input type="checkbox"> 我已经阅读并同意此协议
  429. </label>
  430. </div>
  431. </li>
  432. <li class="previous"><a href="javascript:;" onclick="if(jQuery(':checkbox:checked').length == 1){jQuery('form')[0].submit();}else{alert('您必须同意软件许可协议才能安装!')};">继续 <span class="glyphicon glyphicon-chevron-right"></span></a></li>
  433. </ul>
  434. </form>
  435. EOF;
  436. tpl_frame();
  437. }
  438. function tpl_frame() {
  439. global $action, $actions;
  440. $action = $_COOKIE['action'];
  441. $step = array_search($action, $actions);
  442. $steps = array();
  443. for($i = 0; $i <= $step; $i++) {
  444. if($i == $step) {
  445. $steps[$i] = ' step-info';
  446. } else {
  447. $steps[$i] = ' step-success';
  448. }
  449. }
  450. $progress = $step * 25 + 25;
  451. $curent_version = file_get_contents('../../app/version.php');
  452. $content = ob_get_contents();
  453. ob_clean();
  454. $tpl = <<<EOF
  455. <!DOCTYPE html>
  456. <html lang="zh-cn">
  457. <head>
  458. <meta charset="utf-8">
  459. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  460. <meta name="viewport" content="width=device-width, initial-scale=1">
  461. <title>安装系统 - DsMall开源商城</title>
  462. <script src="../static/plugins/jquery-2.1.4.min.js"></script>
  463. <link rel="stylesheet" href="../static/plugins/bootstrap/css/bootstrap.min.css">
  464. <script src="../static/plugins/bootstrap/js/bootstrap.min.js"></script>
  465. <style>
  466. html,body{font-size:13px;font-family:"Microsoft YaHei UI", "微软雅黑", "宋体";}
  467. .pager li.previous a{margin-right:10px;}
  468. .header a{color:#FFF;}
  469. .header a:hover{color:#428bca;}
  470. .footer{padding:10px;}
  471. .footer a,.footer{color:#eee;font-size:14px;line-height:25px;}
  472. .step{height: 60px;line-height:60px;font-weight: bold;}
  473. .step em{height:40px;width:40px;line-height:40px;margin:10px;display:block;float:left;text-align:center;border-radius: 50%;background:#e2e2e2;color:#fff;font-size:16px;font-style:normal;}
  474. .step .step-success em{background:#28b0e4;}
  475. .step .step-info em{background:#99CC33;}
  476. </style>
  477. </head>
  478. <body style="background-color:#28b0e4;">
  479. <div class="container">
  480. <div class="header" style="margin:20px auto;">
  481. <ul class="nav nav-pills pull-right" role="tablist">
  482. <li role="presentation" class="active"><a href="javascript:;">安装DsMall开源商城</a></li>
  483. <li role="presentation"><a target = "_blank" href="http://www.csdeshang.com/">DsMall开源商城官网</a></li>
  484. <li role="presentation"><a target = "_blank" href="http://bbs.csdeshang.com/">访问论坛</a></li>
  485. </ul>
  486. <img src="../uploads/home/common/site_logo.png" />
  487. </div>
  488. <div class="row well well-lg">
  489. <div class="col-xs-12">
  490. <div class="step">
  491. <div class="col-md-3 {$steps[0]}"><em>1</em>许可协议</div>
  492. <div class="col-md-3 {$steps[1]}"><em>2</em>环境监测</div>
  493. <div class="col-md-3 {$steps[2]}"><em>3</em>参数配置</div>
  494. <div class="col-md-3 {$steps[3]}"><em>4</em>安装成功</div>
  495. </div>
  496. <div class="progress" title="安装进度">
  497. <div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="{$progress}" aria-valuemin="0" aria-valuemax="100" style="width: {$progress}%;">
  498. {$progress}%
  499. </div>
  500. </div>
  501. </div>
  502. <div class="col-xs-12">
  503. {$content}
  504. </div>
  505. </div>
  506. <div class="footer" style="margin:15px auto;">
  507. <div class="text-center">
  508. <a target = "_blank" href="http://www.csdeshang.com">DsMall开源商城官网</a> &nbsp; &nbsp; <a target = "_blank" href="http://bbs.csdeshang.com/">DsMall开源商城论坛</a> &nbsp; &nbsp; <a target = "_blank" href="http://www.csdeshang.com">购买授权</a>
  509. </div>
  510. <div class="text-center">
  511. Powered by <a target = "_blank" href="http://www.csdeshang.com"><b>DsMall开源商城</b></a> {$curent_version} B2B2C &copy; 2012-2027 <a target = "_blank" href="http://www.csdeshang.com">www.csdeshang.com</a>
  512. </div>
  513. </div>
  514. </div>
  515. <script src="../static/plugins/jquery-2.1.4.min.js"></script>
  516. <script src="../static/plugins/bootstrap/js/bootstrap.min.js"></script>
  517. </body>
  518. </html>
  519. EOF;
  520. echo trim($tpl);
  521. }
  522. function local_writeable($dir) {
  523. $writeable = 0;
  524. if(!is_dir($dir)) {
  525. @mkdir($dir, 0777);
  526. }
  527. if(is_dir($dir)) {
  528. if($fp = fopen("$dir/test.txt", 'w')) {
  529. fclose($fp);
  530. unlink("$dir/test.txt");
  531. $writeable = 1;
  532. } else {
  533. $writeable = 0;
  534. }
  535. }
  536. return $writeable;
  537. }
  538. function tpl_install_env($ret = array()) {
  539. if(!$ret['continue']) {
  540. $continue = '<li class="previous disabled"><a href="javascript:;">请先解决环境问题后继续</a></li>';
  541. } else {
  542. $continue = '<li class="previous"><a href="javascript:;" onclick="$(\'#do\').val(\'continue\');$(\'form\')[0].submit();">继续 <span class="glyphicon glyphicon-chevron-right"></span></a></li>';
  543. }
  544. echo <<<EOF
  545. <div class="panel panel-default">
  546. <div class="panel-heading">服务器信息</div>
  547. <table class="table table-striped">
  548. <tr>
  549. <th style="width:150px;">参数</th>
  550. <th>值</th>
  551. <th></th>
  552. </tr>
  553. <tr class="{$ret['server']['os']['class']}">
  554. <td>服务器操作系统</td>
  555. <td>{$ret['server']['os']['value']}</td>
  556. <td>{$ret['server']['os']['remark']}</td>
  557. </tr>
  558. <tr class="{$ret['server']['sapi']['class']}">
  559. <td>Web服务器环境</td>
  560. <td>{$ret['server']['sapi']['value']}</td>
  561. <td>{$ret['server']['sapi']['remark']}</td>
  562. </tr>
  563. <tr class="{$ret['server']['php']['class']}">
  564. <td>PHP版本</td>
  565. <td>{$ret['server']['php']['value']}</td>
  566. <td>{$ret['server']['php']['remark']}</td>
  567. </tr>
  568. <tr class="{$ret['server']['dir']['class']}">
  569. <td>程序安装目录</td>
  570. <td>{$ret['server']['dir']['value']}</td>
  571. <td>{$ret['server']['dir']['remark']}</td>
  572. </tr>
  573. <tr class="{$ret['server']['disk']['class']}">
  574. <td>磁盘空间</td>
  575. <td>{$ret['server']['disk']['value']}</td>
  576. <td>{$ret['server']['disk']['remark']}</td>
  577. </tr>
  578. <tr class="{$ret['server']['upload']['class']}">
  579. <td>上传限制</td>
  580. <td>{$ret['server']['upload']['value']}</td>
  581. <td>{$ret['server']['upload']['remark']}</td>
  582. </tr>
  583. </table>
  584. </div>
  585. <div class="alert alert-info">PHP环境要求必须满足下列所有条件,否则系统或系统部份功能将无法使用。</div>
  586. <div class="panel panel-default">
  587. <div class="panel-heading">PHP环境要求</div>
  588. <table class="table table-striped">
  589. <tr>
  590. <th style="width:150px;">选项</th>
  591. <th style="width:250px;">要求</th>
  592. <th style="width:50px;">状态</th>
  593. <th>说明及帮助</th>
  594. </tr>
  595. <tr class="{$ret['php']['version']['class']}">
  596. <td>PHP版本</td>
  597. <td>7.1<= PHP <=7.2</td>
  598. <td>{$ret['php']['version']['value']}</td>
  599. <td>{$ret['php']['version']['remark']}</td>
  600. </tr>
  601. <tr class="{$ret['php']['pdo']['class']}">
  602. <td>MySQL</td>
  603. <td>支持(建议支持PDO)</br>版本 5.50<= MYSQL <=5.6</td>
  604. <td>{$ret['php']['mysql']['value']}</td>
  605. <td rowspan="2">{$ret['php']['pdo']['remark']}</td>
  606. </tr>
  607. <tr class="{$ret['php']['pdo']['class']}">
  608. <td>PDO_MYSQL</td>
  609. <td>支持(强烈建议支持)</td>
  610. <td>{$ret['php']['pdo']['value']}</td>
  611. </tr>
  612. <tr class="{$ret['php']['curl']['class']}">
  613. <td>allow_url_fopen</td>
  614. <td>支持(建议支持cURL)</td>
  615. <td>{$ret['php']['fopen']['value']}</td>
  616. <td rowspan="2">{$ret['php']['curl']['remark']}</td>
  617. </tr>
  618. <tr class="{$ret['php']['curl']['class']}">
  619. <td>cURL</td>
  620. <td>支持(强烈建议支持)</td>
  621. <td>{$ret['php']['curl']['value']}</td>
  622. </tr>
  623. <tr class="{$ret['php']['gd']['class']}">
  624. <td>GD2</td>
  625. <td>支持</td>
  626. <td>{$ret['php']['gd']['value']}</td>
  627. <td>{$ret['php']['gd']['remark']}</td>
  628. </tr>
  629. <tr class="{$ret['php']['openssl']['class']}">
  630. <td>openssl</td>
  631. <td>支持</td>
  632. <td>{$ret['php']['openssl']['value']}</td>
  633. <td>{$ret['php']['openssl']['remark']}</td>
  634. </tr>
  635. <tr class="{$ret['php']['bcmath']['class']}">
  636. <td>bcmath</td>
  637. <td>支持</td>
  638. <td>{$ret['php']['bcmath']['value']}</td>
  639. <td>{$ret['php']['bcmath']['remark']}</td>
  640. </tr>
  641. <tr class="{$ret['php']['dom']['class']}">
  642. <td>DOM</td>
  643. <td>支持</td>
  644. <td>{$ret['php']['dom']['value']}</td>
  645. <td>{$ret['php']['dom']['remark']}</td>
  646. </tr>
  647. <tr class="{$ret['php']['session']['class']}">
  648. <td>session.auto_start</td>
  649. <td>关闭</td>
  650. <td>{$ret['php']['session']['value']}</td>
  651. <td>{$ret['php']['session']['remark']}</td>
  652. </tr>
  653. <tr class="{$ret['php']['asp_tags']['class']}">
  654. <td>asp_tags</td>
  655. <td>关闭</td>
  656. <td>{$ret['php']['asp_tags']['value']}</td>
  657. <td>{$ret['php']['asp_tags']['remark']}</td>
  658. </tr>
  659. </table>
  660. </div>
  661. <div class="alert alert-info">系统要求DsMall开源商城安装目录下的runtime和uploads必须可写, 才能使用DsMall开源商城所有功能。</div>
  662. <div class="panel panel-default">
  663. <div class="panel-heading">目录权限监测</div>
  664. <table class="table table-striped">
  665. <tr>
  666. <th style="width:150px;">目录</th>
  667. <th style="width:250px;">要求</th>
  668. <th style="width:50px;">状态</th>
  669. <th>说明及帮助</th>
  670. </tr>
  671. <tr class="{$ret['write']['root']['class']}">
  672. <td>/</td>
  673. <td>public/uploads目录可写</td>
  674. <td>{$ret['write']['root']['value']}</td>
  675. <td>{$ret['write']['root']['remark']}</td>
  676. </tr>
  677. <tr class="{$ret['write']['data']['class']}">
  678. <td>/</td>
  679. <td>runtime目录可写</td>
  680. <td>{$ret['write']['data']['value']}</td>
  681. <td>{$ret['write']['data']['remark']}</td>
  682. </tr>
  683. <tr class="{$ret['write']['install']['class']}">
  684. <td>/</td>
  685. <td>public/install目录可写</td>
  686. <td>{$ret['write']['install']['value']}</td>
  687. <td>{$ret['write']['install']['remark']}</td>
  688. </tr>
  689. <tr class="{$ret['write']['database']['class']}">
  690. <td>/</td>
  691. <td>config/database.php文件可写</td>
  692. <td>{$ret['write']['database']['value']}</td>
  693. <td>{$ret['write']['database']['remark']}</td>
  694. </tr>
  695. </table>
  696. </div>
  697. <form class="form-inline" role="form" method="post">
  698. <input type="hidden" name="do" id="do" />
  699. <ul class="pager">
  700. <li class="previous"><a href="javascript:;" onclick="$('#do').val('back');$('form')[0].submit();"><span class="glyphicon glyphicon-chevron-left"></span> 返回</a></li>
  701. {$continue}
  702. </ul>
  703. </form>
  704. EOF;
  705. tpl_frame();
  706. }
  707. function tpl_install_db($error = '') {
  708. if(!empty($error)) {
  709. $message = '<div class="alert alert-danger">发生错误: ' . $error . '</div>';
  710. }
  711. $insTypes = array();
  712. if (!empty($_POST['type'])) {
  713. $insTypes = array();
  714. $insTypes[$_POST['type']] = ' checked="checked"';
  715. }
  716. $disabled = empty($insTypes['local']) ? ' disabled="disabled"' : '';
  717. echo <<<EOF
  718. {$message}
  719. <form class="form-horizontal" method="post" role="form">
  720. <div class="panel panel-default">
  721. <div class="panel-heading">安装选项</div>
  722. <div class="panel-body">
  723. <div class="form-group">
  724. <label class="col-sm-2 control-label">安装方式</label>
  725. <div class="col-sm-10">
  726. <label class="radio-inline">
  727. <input type="radio" name="type" value="local"{$insTypes['local']} checked> 离线安装
  728. </label>
  729. </div>
  730. </div>
  731. </div>
  732. </div>
  733. <div class="panel panel-default">
  734. <div class="panel-heading">数据库选项</div>
  735. <div class="panel-body">
  736. <div class="form-group">
  737. <label class="col-sm-2 control-label">数据库主机</label>
  738. <div class="col-sm-4">
  739. <input class="form-control" type="text" name="db[server]" value="127.0.0.1">
  740. </div>
  741. </div>
  742. <div class="form-group">
  743. <label class="col-sm-2 control-label">数据库用户</label>
  744. <div class="col-sm-4">
  745. <input class="form-control" type="text" name="db[username]" value="root">
  746. </div>
  747. </div>
  748. <div class="form-group">
  749. <label class="col-sm-2 control-label">数据库密码</label>
  750. <div class="col-sm-4">
  751. <input class="form-control" type="text" name="db[password]">
  752. </div>
  753. </div>
  754. <div class="form-group">
  755. <label class="col-sm-2 control-label">表前缀</label>
  756. <div class="col-sm-4">
  757. <input class="form-control" type="text" name="db[prefix]" value="ds_">
  758. </div>
  759. </div>
  760. <div class="form-group">
  761. <label class="col-sm-2 control-label">数据库名称</label>
  762. <div class="col-sm-4">
  763. <input class="form-control" type="text" name="db[name]" value="ds_mall" onblur="check_dblist()">
  764. </div>
  765. </div>
  766. <div class="form-group">
  767. <label class="col-sm-2 control-label">测试数据</label>
  768. <div class="col-sm-4">
  769. <input type="checkbox" name="initdata" checked="checked"/>
  770. </div>
  771. </div>
  772. </div>
  773. </div>
  774. <div class="panel panel-default">
  775. <div class="panel-heading">管理选项</div>
  776. <div class="panel-body">
  777. <div class="form-group">
  778. <label class="col-sm-2 control-label">管理员账号</label>
  779. <div class="col-sm-4">
  780. <input class="form-control" type="username" name="user[username]" value="admin">
  781. </div>
  782. </div>
  783. <div class="form-group">
  784. <label class="col-sm-2 control-label">管理员密码</label>
  785. <div class="col-sm-4">
  786. <input class="form-control user" type="password" name="user[password]" value="">
  787. </div>
  788. <p class="help-block">管理员密码不少于六个字符</p>
  789. </div>
  790. <div class="form-group">
  791. <label class="col-sm-2 control-label">确认密码</label>
  792. <div class="col-sm-4">
  793. <input class="form-control user" type="password" value="">
  794. </div>
  795. </div>
  796. </div>
  797. </div>
  798. <div class="panel panel-default">
  799. <div class="panel-heading">官方店铺信息</div>
  800. <div class="panel-body">
  801. <div class="form-group">
  802. <label class="col-sm-2 control-label">店铺名称</label>
  803. <div class="col-sm-4">
  804. <input class="form-control" type="text" name="store[store_name]" value="官方自营店铺">
  805. </div>
  806. </div>
  807. <div class="form-group">
  808. <label class="col-sm-2 control-label">会员用户名</label>
  809. <div class="col-sm-4">
  810. <input class="form-control" type="username" name="store[username]" value="buyer">
  811. </div>
  812. <p class="help-block">用户会员中心登录</p>
  813. </div>
  814. <div class="form-group">
  815. <label class="col-sm-2 control-label">登录密码</label>
  816. <div class="col-sm-4">
  817. <input class="form-control store" type="password" name="store[password]" value="">
  818. </div>
  819. <p class="help-block">商家和会员登录的密码一致</p>
  820. </div>
  821. <div class="form-group">
  822. <label class="col-sm-2 control-label">确认密码</label>
  823. <div class="col-sm-4">
  824. <input class="form-control store" type="password" value="">
  825. </div>
  826. </div>
  827. </div>
  828. </div>
  829. <input type="hidden" name="do" id="do" />
  830. <ul class="pager">
  831. <li class="previous"><a href="javascript:;" onclick="$('#do').val('back');$('form')[0].submit();"><span class="glyphicon glyphicon-chevron-left"></span> 返回</a></li>
  832. <li class="previous"><a href="javascript:;" onclick="if(check(this)){jQuery('#do').val('continue');if($('input[name=type]').val() == 'remote'){alert('在线线安装时,安装程序会下载精简版快速完成安装,完成后请务必注册云服务更新到完整版。')}$('form')[0].submit();}">继续 <span class="glyphicon glyphicon-chevron-right"></span></a></li>
  833. </ul>
  834. </form>
  835. <script>
  836. function check_dblist() {
  837. params="db_host=" + $("input[name='db[server]']").val() + "&"
  838. + "db_user=" + $("input[name='db[username]']").val() + "&"
  839. + "db_pass=" + $("input[name='db[password]']").val();
  840. $.ajax({ url:'./install.php?step=get_dblist',data:params, type:'get', dataType: 'json',async:false,success:function (result) {
  841. if (typeof(result) === "object" && result["code"] === "200") {
  842. // console.log(result["data"].split(","));
  843. var list=result["data"].split(",");
  844. for (var i = 0; i < list.length; i++) {
  845. if ($("input[name='db[name]']").val() === list[i]) {
  846. var answer = confirm("数据库已存在,是否覆盖此数据库?");
  847. if (answer === false) {
  848. $("input[name='db[name]']").val("");
  849. }
  850. }
  851. }
  852. }else {
  853. alert(result.msg);
  854. $("input[name='db[password]']").val("");
  855. return false;
  856. }
  857. },
  858. });
  859. }
  860. var lock = false;
  861. function check(obj) {
  862. if(lock) {
  863. return;
  864. }
  865. $('.form-control').parent().parent().removeClass('has-error');
  866. var error = false;
  867. $('.form-control').each(function(){
  868. if($(this).attr('name') != 'db[password]'){
  869. if($(this).val() == '') {
  870. $(this).parent().parent().addClass('has-error');
  871. this.focus();
  872. error = true;
  873. }
  874. }
  875. });
  876. if(error) {
  877. alert('请检查未填项');
  878. return false;
  879. }
  880. if($(':password').eq(0).val().length < 6) {
  881. $('.user').parent().parent().addClass('has-error');
  882. alert('管理员密码不少于六个字符.');
  883. return false;
  884. }
  885. if($(':password').eq(0).val() != $(':password').eq(1).val()) {
  886. $('.user').parent().parent().addClass('has-error');
  887. alert('确认密码不正确.');
  888. return false;
  889. }
  890. if($(':password').eq(2).val().length < 6) {
  891. $('.store').parent().parent().addClass('has-error');
  892. alert('登录密码不少于六个字符.');
  893. return false;
  894. }
  895. if($(':password').eq(2).val() != $(':password').eq(3).val()) {
  896. $('.store').parent().parent().addClass('has-error');
  897. alert('确认密码不正确.');
  898. return false;
  899. }
  900. lock = true;
  901. $(obj).parent().addClass('disabled');
  902. $(obj).html('正在执行安装');
  903. return true;
  904. }
  905. </script>
  906. EOF;
  907. tpl_frame();
  908. }
  909. function db_config(){
  910. $cfg = <<<EOF
  911. <?php
  912. return [
  913. // 默认使用的数据库连接配置
  914. 'default' => env('database.driver', 'mysql'),
  915. // 自定义时间查询规则
  916. 'time_query_rule' => [],
  917. // 自动写入时间戳字段
  918. // true为自动识别类型 false关闭
  919. // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
  920. 'auto_timestamp' => true,
  921. // 时间字段取出后的默认时间格式
  922. 'datetime_format' => 'Y-m-d H:i:s',
  923. // 数据库连接配置信息
  924. 'connections' => [
  925. 'mysql' => [
  926. // 数据库类型
  927. 'type' => env('database.type', 'mysql'),
  928. // 服务器地址
  929. 'hostname' => env('database.hostname', '{db-server}'),
  930. // 数据库名
  931. 'database' => env('database.database', '{db-name}'),
  932. // 用户名
  933. 'username' => env('database.username', '{db-username}'),
  934. // 密码
  935. 'password' => env('database.password', '{db-password}'),
  936. // 端口
  937. 'hostport' => env('database.hostport', '{db-port}'),
  938. // 数据库连接参数
  939. 'params' => [],
  940. // 数据库编码默认采用utf8
  941. 'charset' => env('database.charset', 'utf8'),
  942. // 数据库表前缀
  943. 'prefix' => env('database.prefix', '{db-prefix}'),
  944. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  945. 'deploy' => 0,
  946. // 数据库读写是否分离 主从式有效
  947. 'rw_separate' => false,
  948. // 读写分离后 主服务器数量
  949. 'master_num' => 1,
  950. // 指定从服务器序号
  951. 'slave_no' => '',
  952. // 是否严格检查字段是否存在
  953. 'fields_strict' => true,
  954. // 是否需要断线重连
  955. 'break_reconnect' => false,
  956. // 监听SQL
  957. 'trigger_sql' => env('app_debug', true),
  958. // 开启字段缓存
  959. 'fields_cache' => false,
  960. // 字段缓存路径
  961. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  962. ],
  963. // 更多的数据库配置信息
  964. ],
  965. ];
  966. EOF;
  967. return trim($cfg);
  968. }
  969. function local_salt($length = 8) {
  970. $result = '';
  971. while(strlen($result) < $length) {
  972. $result .= sha1(uniqid('', true));
  973. }
  974. return substr($result, 0, $length);
  975. }
  976. function tpl_install_finish($url) {
  977. echo <<<EOF
  978. <div class="page-header"><h3 style="text-align:center">安装完成</h3></div>
  979. <div class="alert alert-success">
  980. 恭喜您!已成功安装“DsMall开源商城商城”系统,您现在可以: <a target="_self" class="btn btn-success" href="$url/index.php/home">访问网站首页</a>
  981. <a target="_self" class="btn btn-success" href="$url/index.php/admin">访问网站后台</a>
  982. </div>
  983. EOF;
  984. tpl_frame();
  985. }