install.php 46 KB

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