database.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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($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("PDO") && !extension_loaded("pdo") ){
  53. echo '请安装php-pdo<br>';
  54. $go = 0;
  55. }
  56. /*if(extension_loaded("sqlite") || extension_loaded("sqlite3")){
  57. echo '请安装php-sqlite<br>';
  58. $go = 0;
  59. }
  60. */
  61. if (!$go) {
  62. exit();
  63. }
  64. ?>
  65. <!DOCTYPE html>
  66. <html lang="en">
  67. <head>
  68. <meta charset="utf-8">
  69. <title> ShowDoc</title>
  70. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  71. <meta name="description" content="">
  72. <meta name="author" content="">
  73. <link href="../Public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  74. <style type="text/css">
  75. @charset "utf-8";
  76. body {
  77. font:14px/1.5 "Microsoft Yahei","微软雅黑",Tahoma,Arial,Helvetica,STHeiti;
  78. }
  79. .form-signin{
  80. display: none;
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <link rel="stylesheet" href="../Public/css/login.css" />
  86. <div class="container">
  87. <form class="form-signin" method="post">
  88. <h3 class="form-signin-heading"><?php echo L("install_title");?></h3>
  89. <br>
  90. <div>
  91. <select id="db_type">
  92. <option value="sqlite"><?php echo L("use_sqlite");?></option>
  93. <option value="mysql"><?php echo L("use_mysql");?></option>
  94. </select>
  95. </div>
  96. <br>
  97. <div class="mysql-info" style="display:none">
  98. <input type="text" class="input-block-level" name="db_host" id = "db_host" placeholder="<?php echo L("server_address");?>">
  99. <input type="text" class="input-block-level" name="db_port" id = "db_port" placeholder="<?php echo L("server_port");?>">
  100. <input type="text" class="input-block-level" name="db_name" id = "db_name" placeholder="<?php echo L("db_name");?>">
  101. <input type="text" class="input-block-level" name="db_user" id = "db_user" placeholder="<?php echo L("db_user");?>">
  102. <input type="text" class="input-block-level" name="db_password" id = "db_password" placeholder="<?php echo L("db_password");?>">
  103. </div>
  104. <div class="sqlite_tips" ><?php echo L("sqlite_tips");?></div>
  105. <input type="hidden" value="<?php echo $cur_lang;?>" id="lang">
  106. <br>
  107. <div>
  108. <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>
  109. &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>
  110. </div>
  111. </form>
  112. </div> <!-- /container -->
  113. <script src="../Public/js/common/jquery.min.js"></script>
  114. <script src="../Public/bootstrap/js/bootstrap.min.js"></script>
  115. </body>
  116. </html>
  117. <script type="text/javascript">
  118. $(function(){
  119. $("#db_type").change(function(){
  120. if ($("#db_type").val() == 'mysql') {
  121. $(".mysql-info").show();
  122. $(".sqlite_tips").hide();
  123. };
  124. if ($("#db_type").val() == 'sqlite') {
  125. $(".mysql-info").hide();
  126. $(".sqlite_tips").show();
  127. };
  128. });
  129. function install(){
  130. var db_type = $("#db_type").val();
  131. var db_host = $("#db_host").val();
  132. var db_port = $("#db_port").val();
  133. var db_name = $("#db_name").val();
  134. var db_user = $("#db_user").val();
  135. var lang = $("#lang").val();
  136. var db_password = $("#db_password").val();
  137. $.post(
  138. 'ajax.php',
  139. {"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},
  140. function(data){
  141. if (data.error_code === 0) {
  142. //安装成功
  143. //alert(data.message);
  144. var text = '<div><?php echo L("install_success_help");?></div><br>';
  145. text += '<div><a href="../" ><?php echo L("home");?></a></div>';
  146. $(".form-signin").html(text);
  147. $(".form-signin").show();
  148. }else{
  149. alert(data.message);
  150. }
  151. },
  152. "json"
  153. );
  154. }
  155. $("#start").click(function(){
  156. install();
  157. return false;
  158. });
  159. install();
  160. });
  161. </script>