database.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. // ShowDoc安装脚本
  3. // install Showdoc
  4. //
  5. // --------
  6. // 如果你能在浏览器中看到本句话,则证明你没有安装好PHP运行环境。请先安装好PHP运行环境
  7. // --------
  8. include("common.php");
  9. $cur_lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  10. header("Content-type: text/html; charset=utf-8");
  11. // 检测PHP环境
  12. if(version_compare(PHP_VERSION,'5.3.0','<')) die(L('require_php_version'));
  13. if((file_exists('./install.lock') && $f = file_get_contents("./install.lock")){
  14. echo L("lock").'<br>';
  15. exit();
  16. }
  17. $go = 1 ;
  18. //检测文件权限
  19. if(!new_is_writeable("./")){
  20. echo L("not_writable_install").'<br>';
  21. $go = 0;
  22. }
  23. if(!new_is_writeable("../Public/Uploads")){
  24. echo L("not_writable_upload").'<br>';
  25. $go = 0;
  26. }
  27. if(!new_is_writeable("../Application/Runtime")){
  28. echo L("not_writable_runtime").'<br>';
  29. $go = 0;
  30. }
  31. if(!new_is_writeable("../Application/Common/Conf/config.php")){
  32. echo L("not_writable_config").'<br>';
  33. $go = 0;
  34. }
  35. if(!new_is_writeable("../Application/Home/Conf/config.php")){
  36. echo L("not_writable_home_config").'<br>';
  37. $go = 0;
  38. }
  39. //检查扩展
  40. if(!extension_loaded("gd")){
  41. echo '请安装php-gd<br>';
  42. $go = 0;
  43. }
  44. if(!extension_loaded("mcrypt")){
  45. echo '请安装php-mcrypt<br>';
  46. $go = 0;
  47. }
  48. if(!extension_loaded("mbstring")){
  49. echo '请安装php-mbstring<br>';
  50. $go = 0;
  51. }
  52. if(!extension_loaded("zlib")){
  53. echo '请安装php-zlib<br>';
  54. $go = 0;
  55. }
  56. if(!extension_loaded("PDO") && !extension_loaded("pdo") ){
  57. echo '请安装php-pdo<br>';
  58. $go = 0;
  59. }
  60. /*if(extension_loaded("sqlite") || extension_loaded("sqlite3")){
  61. echo '请安装php-sqlite<br>';
  62. $go = 0;
  63. }
  64. */
  65. if (!$go) {
  66. exit();
  67. }
  68. ?>
  69. <!DOCTYPE html>
  70. <html lang="en">
  71. <head>
  72. <meta charset="utf-8">
  73. <title> ShowDoc</title>
  74. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  75. <meta name="description" content="">
  76. <meta name="author" content="">
  77. <link href="../Public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  78. <style type="text/css">
  79. @charset "utf-8";
  80. body {
  81. font:14px/1.5 "Microsoft Yahei","微软雅黑",Tahoma,Arial,Helvetica,STHeiti;
  82. }
  83. .form-signin{
  84. display: none;
  85. }
  86. </style>
  87. </head>
  88. <body>
  89. <link rel="stylesheet" href="../Public/css/login.css" />
  90. <div class="container">
  91. <form class="form-signin" method="post">
  92. <h3 class="form-signin-heading"><?php echo L("install_title");?></h3>
  93. <br>
  94. <div>
  95. <select id="db_type">
  96. <option value="sqlite"><?php echo L("use_sqlite");?></option>
  97. <option value="mysql"><?php echo L("use_mysql");?></option>
  98. </select>
  99. </div>
  100. <br>
  101. <div class="mysql-info" style="display:none">
  102. <input type="text" class="input-block-level" name="db_host" id = "db_host" placeholder="<?php echo L("server_address");?>">
  103. <input type="text" class="input-block-level" name="db_port" id = "db_port" placeholder="<?php echo L("server_port");?>">
  104. <input type="text" class="input-block-level" name="db_name" id = "db_name" placeholder="<?php echo L("db_name");?>">
  105. <input type="text" class="input-block-level" name="db_user" id = "db_user" placeholder="<?php echo L("db_user");?>">
  106. <input type="text" class="input-block-level" name="db_password" id = "db_password" placeholder="<?php echo L("db_password");?>">
  107. </div>
  108. <div class="sqlite_tips" ><?php echo L("sqlite_tips");?></div>
  109. <input type="hidden" value="<?php echo $cur_lang;?>" id="lang">
  110. <br>
  111. <div>
  112. <button class="btn btn-large btn-primary " id="start" type="submit"><?php echo L("go");?>&nbsp;&nbsp;<i class="icon-circle-arrow-right"></i></button>
  113. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.showdoc.cc/help?page_id=16118" target="_blank"><?php echo L("FAQ");?></a>
  114. </div>
  115. </form>
  116. </div> <!-- /container -->
  117. <script src="../Public/js/common/jquery.min.js"></script>
  118. <script src="../Public/bootstrap/js/bootstrap.min.js"></script>
  119. </body>
  120. </html>
  121. <script type="text/javascript">
  122. $(function(){
  123. $("#db_type").change(function(){
  124. if ($("#db_type").val() == 'mysql') {
  125. $(".mysql-info").show();
  126. $(".sqlite_tips").hide();
  127. };
  128. if ($("#db_type").val() == 'sqlite') {
  129. $(".mysql-info").hide();
  130. $(".sqlite_tips").show();
  131. };
  132. });
  133. function install(){
  134. var db_type = $("#db_type").val();
  135. var db_host = $("#db_host").val();
  136. var db_port = $("#db_port").val();
  137. var db_name = $("#db_name").val();
  138. var db_user = $("#db_user").val();
  139. var lang = $("#lang").val();
  140. var db_password = $("#db_password").val();
  141. $.post(
  142. 'ajax.php',
  143. {"lang":lang,"db_type":db_type,"db_host":db_host,"db_port":db_port,"db_name":db_name,"db_user":db_user,"db_password":db_password},
  144. function(data){
  145. if (data.error_code === 0) {
  146. //安装成功
  147. //alert(data.message);
  148. var text = '<div><?php echo L("install_success_help");?></div><br>';
  149. text += '<div><a href="../" ><?php echo L("home");?></a></div>';
  150. $(".form-signin").html(text);
  151. $(".form-signin").show();
  152. }else{
  153. alert(data.message);
  154. }
  155. },
  156. "json"
  157. );
  158. }
  159. $("#start").click(function(){
  160. install();
  161. return false;
  162. });
  163. install();
  164. });
  165. </script>