step3.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8"/>
  5. <title><?php echo $Title; ?> - <?php echo $Powered; ?></title>
  6. <link rel="stylesheet" href="./css/install.css?v=9.0"/>
  7. <link rel="stylesheet" href="./css/step3.css"/>
  8. <!-- 引入样式 -->
  9. <link rel="stylesheet" href="./css/theme-chalk.css">
  10. <!-- import Vue before Element -->
  11. <script src="./js/vue2.6.11.js"></script>
  12. <!-- import JavaScript -->
  13. <script src="./js/element-ui.js?v=9.0"></script>
  14. </head>
  15. <body>
  16. <div class="wrap" id="step3">
  17. <div class="title">
  18. 创建数据
  19. </div>
  20. <section class="section">
  21. <form id="J_install_form" action="index.php?step=4" method="post">
  22. <div class="server" ref="mianscroll">
  23. <table width="100%">
  24. <tr>
  25. <td class="td1" width="100">数据库信息</td>
  26. <td class="td1" width="200">&nbsp;</td>
  27. <td class="td1">&nbsp;</td>
  28. </tr>
  29. <tr>
  30. <td class="tar">数据库用户名:</td>
  31. <td><input type="text" name="dbuser" id="dbuser" value="root" class="input"></td>
  32. <td>
  33. <div id="J_install_tip_dbuser"></div>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td class="tar">数据库密码:</td>
  38. <td><input type="password" name="dbpw" id="dbpw" value="" class="input" autoComplete="off"></td>
  39. <td>
  40. <div id="J_install_tip_dbpw"></div>
  41. </td>
  42. </tr>
  43. <tr>
  44. <td class="tar">数据库名:</td>
  45. <td><input type="text" name="dbname" id="dbname" value="crmeb" class="input"></td>
  46. <td>
  47. <div id="J_install_tip_dbname"></div>
  48. </td>
  49. </tr>
  50. <tr>
  51. <td class="tar">高级设置:</td>
  52. <td colspan="2">
  53. <el-switch
  54. v-model="value"
  55. active-color="#37CA71"
  56. inactive-color="#575869">
  57. </el-switch>
  58. </td>
  59. <td>
  60. </td>
  61. </tr>
  62. <tr v-show="value">
  63. <td class="tar">数据库服务器:</td>
  64. <td><input type="text" name="dbhost" id="dbhost" value="127.0.0.1" class="input"></td>
  65. <td>
  66. <div id="J_install_tip_dbhost"></div>
  67. </td>
  68. </tr>
  69. <tr v-show="value">
  70. <td class="tar">数据库端口:</td>
  71. <td><input type="text" name="dbport" id="dbport" value="3306" class="input"
  72. onBlur="mysqlDbPwd(0)"></td>
  73. <td>
  74. <div id="J_install_tip_dbport"></div>
  75. </td>
  76. </tr>
  77. <tr v-show="value">
  78. <td class="tar">数据库表前缀:</td>
  79. <td><input type="text" name="dbprefix" id="dbprefix" value="eb_" class="input"></td>
  80. <td></td>
  81. </tr>
  82. <tr v-show="value">
  83. <td class="tar">演示数据:</td>
  84. <td colspan="2"><input style="width:14px;height:14px;" type="checkbox" id="demo" name="demo"
  85. value="demo" checked></td>
  86. </tr>
  87. </table>
  88. <table width="100%">
  89. <tr>
  90. <td class="td1" width="100">管理员信息</td>
  91. <td class="td1" width="200">&nbsp;</td>
  92. <td class="td1">&nbsp;</td>
  93. </tr>
  94. <tr>
  95. <td class="tar">管理员帐号:</td>
  96. <td><input type="text" name="manager" id="manager" value="admin" class="input"
  97. onblur="checkForm()"></td>
  98. <td>
  99. <div id="J_install_tip_manager"></div>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td class="tar">管理员密码:</td>
  104. <td><input type="password" name="manager_pwd" id="manager_pwd" class="input" autoComplete="off"
  105. placeholder="请输入密码(至少6个字符)" placeholder-class="pl-style" onblur="checkForm()">
  106. </td>
  107. <td>
  108. <div id="J_install_tip_manager_pwd"><span class="gray">请输入至少6个字符密码</span></div>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td class="tar">重复密码:</td>
  113. <td><input type="password" name="manager_ckpwd" id="manager_ckpwd" class="input"
  114. autoComplete="off" placeholder="请再次输入密码" onkeyup="checkForm()"></td>
  115. <td>
  116. <div id="J_install_tip_manager_ckpwd"></div>
  117. </td>
  118. </tr>
  119. </table>
  120. <table>
  121. <tr>
  122. <td class="td1" width="100">缓存设置</td>
  123. <td class="td1" width="200">&nbsp;</td>
  124. <td class="td1">&nbsp;</td>
  125. </tr>
  126. <tr>
  127. <td class="tar">缓存方式:</td>
  128. <td>
  129. <el-radio v-model="radio" :label="0" name="cache_type" id="cache_type1">文件缓存</el-radio>
  130. <el-radio v-model="radio" :label="1" name="cache_type" id="cache_type2">redis缓存</el-radio>
  131. </td>
  132. <td></td>
  133. </tr>
  134. <tr v-show="radio == 1">
  135. <td class="tar">服务器地址:</td>
  136. <td><input type="text" name="rbhost" id="rbhost" value="127.0.0.1" class="input"></td>
  137. <td>
  138. <div id="J_install_redis_host"><span class="gray">redis服务器地址,一般为127.0.0.1</span></div>
  139. </td>
  140. </tr>
  141. <tr v-show="radio == 1">
  142. <td class="tar">端口号:</td>
  143. <td><input type="text" name="rbport" id="rbport" value="6379" class="input" autoComplete="off">
  144. </td>
  145. <td>
  146. <div id="J_install_redis_port"><span class="gray">redis端口,默认为6379</span></div>
  147. </td>
  148. </tr>
  149. <tr v-show="radio == 1">
  150. <td class="tar">数据库:</td>
  151. <td><input type="text" name="rbselect" id="rbselect" value="0" class="input" autoComplete="off">
  152. </td>
  153. <td>
  154. <div id="J_install_redis_select"><span class="gray">redis数据库,默认为0,一般不做更改</span></div>
  155. </td>
  156. </tr>
  157. <tr v-show="radio == 1" id="scrollBtn">
  158. <td class="tar">数据库密码:</td>
  159. <td><input type="text" name="rbpw" id="rbpw" value="" class="input" autoComplete="off"></td>
  160. <td>
  161. <div id="J_install_redis_dbpw"><span class="gray">redis数据库密码</span></div>
  162. </td>
  163. </tr>
  164. </table>
  165. </div>
  166. <div class="bottom-btn">
  167. <div class="bottom tac up-btn">
  168. <a href="./index.php?step=2" class="btn">上一步</a>
  169. </div>
  170. <div class="bottom tac next">
  171. <a @click="submitForm();" class="btn">下一步</a>
  172. </div>
  173. </div>
  174. </form>
  175. </section>
  176. <div style="width:0;height:0;overflow:hidden;"><img src="./images/install/pop_loading.gif"></div>
  177. <script src="./js/jquery.js?v=9.0"></script>
  178. <script src="./js/validate.js?v=9.0"></script>
  179. <script src="./js/ajaxForm.js?v=9.0"></script>
  180. <script>
  181. //验证管理员信息
  182. function checkForm() {
  183. let manager = $.trim($('#manager').val()); //用户名表单
  184. let manager_pwd = $.trim($('#manager_pwd').val()); //密码表单
  185. let manager_ckpwd = $.trim($('#manager_ckpwd').val()); //密码提示区
  186. if (manager.length == 0) {
  187. $('#J_install_tip_manager').html('<span for="dbname" generated="true" class="tips_error" style="">请输入管理账号</span>');
  188. return false;
  189. }
  190. if (!(/^[a-zA-Z0-9]{0,32}$/.test(manager))) {
  191. $('#J_install_tip_manager').html('<span generated="true" class="tips_error" style="">账号必须为英文或者数字</span>');
  192. return false;
  193. } else {
  194. $('#J_install_tip_manager').html('<span generated="true" class="tips_success" style="">用户名可用</span>');
  195. }
  196. if (manager_pwd.length < 6) {
  197. $('#J_install_tip_manager_pwd').html('<span for="dbname" generated="true" class="tips_error" style="">管理员密码必须5位数以上</span>');
  198. return false;
  199. } else {
  200. $('#J_install_tip_manager_pwd').html('<span generated="true" class="tips_success" style="">密码可用</span>');
  201. }
  202. if (manager_ckpwd != manager_pwd) {
  203. $('#J_install_tip_manager_ckpwd').html('<span for="dbname" generated="true" class="tips_error" style="">两次密码不一致</span>');
  204. return false;
  205. } else {
  206. $('#J_install_tip_manager_ckpwd').html('<span generated="true" class="tips_success" style="">密码正确</span>');
  207. }
  208. return true;
  209. }
  210. new Vue({
  211. el: '#step3',
  212. data() {
  213. return {value: false, radio: 0}
  214. },
  215. created() {
  216. },
  217. methods: {
  218. mysqlDbPwd() {
  219. let data = {
  220. 'dbHost': $('#dbhost').val(),
  221. 'dbUser': $('#dbuser').val(),
  222. 'dbPwd': $('#dbpw').val(),
  223. 'dbName': $('#dbname').val(),
  224. 'dbport': $('#dbport').val(),
  225. 'demo': $('#demo').val()
  226. };
  227. let url = "<?php echo $_SERVER['PHP_SELF']; ?>?step=3&mysqldbpwd=1";
  228. return new Promise((resolve, reject) => {
  229. $.ajax({
  230. type: "POST",
  231. url: url,
  232. data: data,
  233. dataType: 'JSON',
  234. success: (msg) => {
  235. resolve(msg);
  236. },
  237. error: (err) => {
  238. reject(err)
  239. }
  240. });
  241. })
  242. },
  243. redisDbPwd() {
  244. let data = {
  245. rbhost: $('#rbhost').val(),
  246. rbport: $("#rbport").val(),
  247. rbselect: $("#rbselect").val(),
  248. rbpw: $('#rbpw').val(),
  249. };
  250. let url = "<?php echo $_SERVER['PHP_SELF']; ?>?step=3&redisdbpwd=1";
  251. return new Promise((resolve, reject) => {
  252. $.ajax({
  253. type: "POST",
  254. url: url,
  255. data: data,
  256. dataType: 'JSON',
  257. success: function (msg) {
  258. resolve(msg)
  259. },
  260. error: function () {
  261. reject()
  262. }
  263. });
  264. })
  265. },
  266. jumpButton(){
  267. this.$refs.mianscroll.scrollTop = this.$refs.mianscroll.clientHeight
  268. },
  269. submitForm() {
  270. this.mysqlDbPwd().then(res => {
  271. if (res == 2002) {
  272. this.value = true
  273. $('#J_install_tip_dbhost').html('<span for="dbname" generated="true" class="tips_error" >地址或端口错误</span>');
  274. $('#J_install_tip_dbport').html('<span for="dbname" generated="true" class="tips_error" >地址或端口错误</span>');
  275. return false;
  276. } else if (res == -1) {
  277. $('#J_install_tip_dbhost').html('');
  278. $('#J_install_tip_dbport').html('');
  279. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >数据库链接配置失败</span>');
  280. return false;
  281. } else if (res == -2) {
  282. $('#J_install_tip_dbhost').html('');
  283. $('#J_install_tip_dbport').html('');
  284. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >请在mysql配置文件修sql-mode或sql_mode为NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION</span><a href="https://doc.crmeb.com/web/single/crmeb_v4/936" target="_blank">查看文档</a>');
  285. return false;
  286. } else if (res == 1045) {
  287. $('#J_install_tip_dbhost').html('');
  288. $('#J_install_tip_dbport').html('');
  289. $('#J_install_tip_dbname').html('');
  290. $('#J_install_tip_dbuser').html('<span for="dbname" generated="true" class="tips_error" >用户名或密码错误</span>');
  291. $('#J_install_tip_dbpw').html('<span for="dbname" generated="true" class="tips_error" >用户名或密码错误</span>');
  292. return false;
  293. } else if (res == -4) {
  294. $('#J_install_tip_dbhost').html('');
  295. $('#J_install_tip_dbport').html('');
  296. $('#J_install_tip_dbuser').html('');
  297. $('#J_install_tip_dbpw').html('');
  298. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >无权限创建数据,请先手动创建数据库</span>');
  299. return false;
  300. } else if (res == -3) {
  301. $('#J_install_tip_dbhost').html('');
  302. $('#J_install_tip_dbport').html('');
  303. $('#J_install_tip_dbuser').html('');
  304. $('#J_install_tip_dbpw').html('');
  305. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >数据库不为空,请更换一个数据库</span>');
  306. return false;
  307. } else if (res == -5) {
  308. $('#J_install_tip_dbhost').html('');
  309. $('#J_install_tip_dbport').html('');
  310. $('#J_install_tip_dbuser').html('');
  311. $('#J_install_tip_dbpw').html('');
  312. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >MySql数据库必须是5.6及以上版本</span>');
  313. return false;
  314. } else if (res == 1) {
  315. $('#J_install_tip_dbhost').html('');
  316. $('#J_install_tip_dbport').html('');
  317. $('#J_install_tip_dbuser').html('');
  318. $('#J_install_tip_dbpw').html('');
  319. $('#J_install_tip_dbname').html('<span generated="true" class="tips_success" style="">数据库配置成功</span>');
  320. } else {
  321. $('#J_install_tip_dbhost').html('');
  322. $('#J_install_tip_dbport').html('');
  323. $('#J_install_tip_dbuser').html('');
  324. $('#J_install_tip_dbpw').html('');
  325. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >未知错误</span>');
  326. return false;
  327. }
  328. let redisStatus = $("input[name='cache_type']:checked").val();
  329. if (redisStatus == 1) {
  330. this.redisDbPwd().then(msg => {
  331. if (msg == -1) {
  332. $('#J_install_redis_host').html('<span for="dbname" generated="true" class="tips_error" style="">Redis扩展没有安装</span>');
  333. this.$nextTick(() => {this.jumpButton()});
  334. return false;
  335. } else if (msg == -3) {
  336. $('#J_install_redis_host').html('');
  337. $('#J_install_redis_dbpw').html('<span for="dbname" generated="true" class="tips_error" style="">Redis数据库没有启动或者配置错误</span>');
  338. this.$nextTick(() => {this.jumpButton()});
  339. return false;
  340. } else if (msg == 1) {
  341. $('#J_install_redis_host').html('');
  342. $('#J_install_redis_dbpw').html('<span generated="true" class="tips_success" style="">Redis配置成功</span>');
  343. } else {
  344. $('#J_install_redis_host').html('');
  345. $('#J_install_redis_dbpw').html('<span for="dbname" generated="true" class="tips_error" style="">Redis配置失败</span>');
  346. this.$nextTick(() => {this.jumpButton()});
  347. return false;
  348. }
  349. if (checkForm()) {
  350. $("#J_install_form").submit(); // ajax 验证通过后再提交表单
  351. }
  352. }).catch(err => {
  353. $('#J_install_redis_host').html('');
  354. $('#J_install_redis_dbpw').html('<span for="dbname" generated="true" class="tips_error" >未知错误</span>');
  355. this.$nextTick(() => {this.jumpButton()});
  356. return false;
  357. })
  358. } else {
  359. if (checkForm()) {
  360. $("#J_install_form").submit(); // ajax 验证通过后再提交表单
  361. }
  362. }
  363. }).catch(err => {
  364. $('#J_install_tip_dbhost').html('');
  365. $('#J_install_tip_dbport').html('');
  366. $('#J_install_tip_dbuser').html('');
  367. $('#J_install_tip_dbpw').html('');
  368. $('#J_install_tip_dbname').html('<span for="dbname" generated="true" class="tips_error" >未知错误1</span>');
  369. return false;
  370. })
  371. }
  372. }
  373. })
  374. </script>
  375. </div>
  376. <?php require './templates/footer.php'; ?>
  377. </body>
  378. </html>