step3.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <!doctype html>
  2. <meta name="renderer" content="webkit">
  3. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
  4. <html>
  5. <head>
  6. <meta charset="UTF-8" />
  7. <meta http-equiv="Content-Language" content="zh-cn"/>
  8. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
  9. <title><?php echo $Title; ?> - <?php echo $Powered; ?></title>
  10. <link rel="stylesheet" href="./css/install.css?v=v1.3.1" />
  11. <script src="./js/jquery.js?v=v1.3.1"></script>
  12. <script src="./../public/plugins/layer-v3.1.0/layer.js?v=v1.3.1"></script>
  13. </head>
  14. <body>
  15. <div class="wrap">
  16. <?php require './templates/header.php';?>
  17. <section class="section">
  18. <div class="blank30"></div>
  19. <div class="go go3"></div>
  20. <div class="blank30"></div>
  21. <form id="J_install_form" action="index.php?step=4" method="post">
  22. <input type="hidden" name="force" value="0" />
  23. <div class="server">
  24. <table width="100%" id="table" border="0" cellspacing="1" cellpadding="4">
  25. <tr>
  26. <td class="td1" colspan="2">数据库信息</td>
  27. </tr>
  28. <tr>
  29. <td class="tar">数据库地址</td>
  30. <td><input type="text" name="dbhost" id="dbhost" value="127.0.0.1" class="input"><div id="J_install_tip_dbhost"><span class="gray">一般为127.0.0.1 或 localhost</span></div></td>
  31. </tr>
  32. <tr>
  33. <td class="tar">数据库端口</td>
  34. <td><input type="text" name="dbport" id="dbport" value="3306" class="input"><div id="J_install_tip_dbport"><span class="gray">一般为3306</span></div></td>
  35. </tr>
  36. <tr>
  37. <td class="tar">数据库账号</td>
  38. <td><input type="text" name="dbuser" id="dbuser" value="root" class="input"><div id="J_install_tip_dbuser"></div></td>
  39. </tr>
  40. <tr>
  41. <td class="tar">数据库密码</td>
  42. <td><input type="password" name="dbpw" id="dbpw" value="" class="input" autoComplete="off" onBlur="TestDbPwd(0)"><div id="J_install_tip_dbpw"></div></td>
  43. </tr>
  44. <tr>
  45. <td class="tar">数据库名</td>
  46. <td><input type="text" name="dbname" id="dbname" value="eyoucms" class="input" onBlur="TestDbPwd(0)"><div id="J_install_tip_dbname"></div></td>
  47. </tr>
  48. <tr>
  49. <td class="tar">数据库表前缀</td>
  50. <td><input type="text" name="dbprefix" id="dbprefix" value="ey_" class="input" ><div id="J_install_tip_dbprefix"><span class="gray">推荐使用&nbsp;ey_</span></div></td>
  51. </tr>
  52. </table>
  53. <table width="100%" id="table" border="0" cellspacing="1" cellpadding="4">
  54. <tr>
  55. <td class="td1" colspan="2">管理员信息</td>
  56. </tr>
  57. <tr>
  58. <td class="tar">管理员帐号</td>
  59. <td><input type="text" name="manager" id="manager" value="admin" class="input"><div id="J_install_tip_manager"></div></td>
  60. </tr>
  61. <tr>
  62. <td class="tar">管理员密码</td>
  63. <td><input type="password" name="manager_pwd" id="manager_pwd" class="input" autoComplete="off"><div id="J_install_tip_manager_pwd"></div></td>
  64. </tr>
  65. <tr>
  66. <td class="tar">请确认密码</td>
  67. <td><input type="password" name="manager_ckpwd" id="manager_ckpwd" class="input" autoComplete="off"><div id="J_install_tip_manager_ckpwd"></div></td>
  68. </tr>
  69. </table>
  70. <div id="J_response_tips" style="display:none;"></div>
  71. </div>
  72. <div class="blank20"></div>
  73. <div class="bottom tac">
  74. <center>
  75. <a href="./index.php?step=2" class="btn_b">上一步</a>
  76. <button id="next_submit" type="button" onClick="checkForm();" class="btn btn_submit J_install_btn">创建数据</button>
  77. </center>
  78. </div>
  79. <div class="blank20"></div>
  80. </form>
  81. </section>
  82. <div style="width:0;height:0;overflow:hidden;"> <img src="./images/pop_loading.gif"> </div>
  83. <script src="./js/jquery.js?v=9.0"></script>
  84. <script src="./js/validate.js?v=9.0"></script>
  85. <script src="./js/ajaxForm.js?v=9.0"></script>
  86. <script src="./../public/plugins/layer-v3.1.0/layer.js?v=9.0"></script>
  87. <script>
  88. function TestDbPwd(connect_db)
  89. {
  90. var dbHost = $('#dbhost').val();
  91. var dbUser = $('#dbuser').val();
  92. var dbPwd = $('#dbpw').val();
  93. var dbName = $('#dbname').val();
  94. var dbport = $('#dbport').val();
  95. var demo = $('#demo').val();
  96. data={'dbHost':dbHost,'dbUser':dbUser,'dbPwd':dbPwd,'dbName':dbName,'dbport':dbport,'demo':demo};
  97. var url = "<?php echo $_SERVER['PHP_SELF']; ?>?step=3&testdbpwd=1";
  98. $.ajax({
  99. type: "POST",
  100. url: url,
  101. data: data,
  102. dataType:'JSON',
  103. beforeSend:function(){
  104. },
  105. success: function(res){
  106. if(res.errcode == 1)
  107. {
  108. if(connect_db == 1)
  109. {
  110. ajaxSubmit(); // ajax 验证通过后再提交表单
  111. return false;
  112. }
  113. $('#J_install_tip_dbpw').html(res.dbpwmsg);
  114. $('#J_install_tip_dbname').html(res.dbnamemsg);
  115. }
  116. else if(res.errcode == -1)
  117. {
  118. $('#J_install_tip_dbpw').html(res.dbpwmsg);
  119. }
  120. else if(res.errcode == -2)
  121. {
  122. $('#J_install_tip_dbname').html(res.dbnamemsg);
  123. }
  124. else
  125. {
  126. $('#J_install_tip_dbpw').html(res.dbpwmsg);
  127. }
  128. },
  129. complete:function(){
  130. },
  131. error:function(){
  132. $('#J_install_tip_dbpw').html('<span for="dbname" generated="true" class="tips_error" style="">数据库连接失败,请重新设定</span>');
  133. }
  134. });
  135. }
  136. function ajaxSubmit()
  137. {
  138. $.ajax({
  139. // async:false,
  140. url: $('#J_install_form').attr('action'),
  141. data: $('#J_install_form').serialize(),
  142. type:'post',
  143. dataType:'json',
  144. success:function(res){
  145. if (1 == res.code) {
  146. window.location.href = res.url;
  147. } else {
  148. layer.closeAll();
  149. layer.msg(res.msg, {icon: 5});
  150. }
  151. return false;
  152. },
  153. error:function() {
  154. layer.closeAll();
  155. layer.alert('网络失败,请刷新页面后重试', {icon: 5, title: false});
  156. return false;
  157. }
  158. });
  159. }
  160. function beforeSubmit()
  161. {
  162. var flag = false;
  163. var dbHost = $('#dbhost').val();
  164. var dbUser = $('#dbuser').val();
  165. var dbPwd = $('#dbpw').val();
  166. var dbName = $('#dbname').val();
  167. var dbport = $('#dbport').val();
  168. data={'dbHost':dbHost,'dbUser':dbUser,'dbPwd':dbPwd,'dbName':dbName,'dbport':dbport};
  169. var url = "<?php echo $_SERVER['PHP_SELF']; ?>?step=3&check=1";
  170. $.ajax({
  171. type: "POST",
  172. url: url,
  173. async: false,
  174. data: data,
  175. dataType:'JSON',
  176. beforeSend:function(){
  177. },
  178. success: function(res){
  179. if (-1 == res.code) {
  180. layer.closeAll();
  181. layer.msg(res.msg, {icon: 5});
  182. } else {
  183. flag = true;
  184. }
  185. },
  186. complete:function(){
  187. },
  188. error:function(){
  189. layer.closeAll();
  190. layer.alert('网络失败,请刷新页面后重试', {icon: 5, title: false});
  191. }
  192. });
  193. return flag;
  194. }
  195. function checkForm()
  196. {
  197. dbhost = $.trim($('#dbhost').val()); //数据库地址
  198. dbport = $.trim($('#dbport').val()); //数据库端口
  199. dbuser = $.trim($('#dbuser').val()); //数据库账号
  200. dbpw = $.trim($('#dbpw').val()); //数据库密码
  201. dbname = $.trim($('#dbname').val()); //数据库名
  202. dbprefix = $.trim($('#dbprefix').val()); //数据库表前缀
  203. manager = $.trim($('#manager').val()); //用户名表单
  204. manager_pwd = $.trim($('#manager_pwd').val()); //密码表单
  205. manager_ckpwd = $.trim($('#manager_ckpwd').val()); //密码提示区
  206. if(dbhost.length == 0 )
  207. {
  208. $('#dbhost').focus();
  209. layer.msg('数据库地址不能为空', {icon: 5, time: 1500});
  210. return false;
  211. }
  212. if(dbport.length == 0 )
  213. {
  214. $('#dbport').focus();
  215. layer.msg('数据库端口不能为空', {icon: 5, time: 1500});
  216. return false;
  217. }
  218. if(dbuser.length == 0 )
  219. {
  220. $('#dbuser').focus();
  221. layer.msg('数据库账号不能为空', {icon: 5, time: 1500});
  222. return false;
  223. }
  224. if(dbpw.length == 0 )
  225. {
  226. $('#dbpw').focus();
  227. layer.msg('数据库密码不能为空', {icon: 5, time: 1500});
  228. return false;
  229. }
  230. if(dbname.length == 0 )
  231. {
  232. $('#dbname').focus();
  233. layer.msg('数据库名不能为空', {icon: 5, time: 1500});
  234. return false;
  235. }
  236. if(dbprefix.length == 0 )
  237. {
  238. $('#dbprefix').focus();
  239. layer.msg('数据库表前缀不能为空', {icon: 5, time: 1500});
  240. return false;
  241. }
  242. if(manager.length == 0 )
  243. {
  244. $('#manager').focus();
  245. layer.msg('管理员账号不能为空', {icon: 5, time: 1500});
  246. return false;
  247. }
  248. if(manager_pwd.length < 5 )
  249. {
  250. $('#manager_pwd').focus();
  251. layer.msg('管理员密码必须5位数以上', {icon: 5, time: 1500});
  252. return false;
  253. }
  254. if(manager_ckpwd != manager_pwd)
  255. {
  256. $('#manager_ckpwd').focus();
  257. layer.msg('两次密码不一致', {icon: 5, time: 1500});
  258. return false;
  259. }
  260. layer_loading('正在安装');
  261. if (!beforeSubmit()) {
  262. return false;
  263. }
  264. TestDbPwd(1);
  265. }
  266. /**
  267. * 封装的加载层
  268. */
  269. function layer_loading(msg){
  270. var loading = layer.msg(
  271. msg+'...<img src="./images/loading-0.gif"/>&nbsp;请勿刷新页面',
  272. {
  273. icon: 1,
  274. time: 3600000, //1小时后后自动关闭
  275. shade: [0.2] //0.1透明度的白色背景
  276. });
  277. return loading;
  278. }
  279. </script>
  280. </div>
  281. <?php require './templates/footer.php';?>
  282. <script type="text/javascript">
  283. $(function(){
  284. $('#next_submit').focus();
  285. $(document).keydown(function(event){
  286. if(event.keyCode ==13){
  287. checkForm();
  288. return false;
  289. }
  290. });
  291. });
  292. </script>
  293. </body>
  294. </html>