Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

212 řádky
5.7 KiB

před 3 roky
  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("../server/Application/Runtime")){
  28. echo L("not_writable_server_runtime").'<br>';
  29. $go = 0;
  30. }
  31. if(!new_is_writeable("../server/Application/Common/Conf/config.php")){
  32. echo L("not_writable_config").'<br>';
  33. $go = 0;
  34. }
  35. if(!new_is_writeable("../server/Application/Home/Conf/config.php")){
  36. echo L("not_writable_home_config").'<br>';
  37. $go = 0;
  38. }
  39. if ($cur_lang == 'en') {
  40. if(!new_is_writeable("../web/index.html")){
  41. echo L("not_writable_web_docconfig").'<br>';
  42. $go = 0;
  43. }
  44. if(!new_is_writeable("../web_src/index.html")){
  45. echo L("not_writable_web_src_docconfig").'<br>';
  46. $go = 0;
  47. }
  48. }
  49. //检查扩展
  50. if(!extension_loaded("gd")){
  51. echo '请安装php-gd<br>';
  52. $go = 0;
  53. }
  54. /*
  55. if(!extension_loaded("mcrypt")){
  56. echo '请安装php-mcrypt<br>';
  57. $go = 0;
  58. }
  59. */
  60. if(!extension_loaded("mbstring")){
  61. echo '请安装php-mbstring<br>';
  62. $go = 0;
  63. }
  64. if(!extension_loaded("zlib")){
  65. echo '请安装php-zlib<br>';
  66. $go = 0;
  67. }
  68. if(!extension_loaded("PDO") && !extension_loaded("pdo") ){
  69. echo '请安装php-pdo<br>';
  70. $go = 0;
  71. }
  72. /*if(extension_loaded("sqlite") || extension_loaded("sqlite3")){
  73. echo '请安装php-sqlite<br>';
  74. $go = 0;
  75. }
  76. */
  77. if (!$go) {
  78. exit();
  79. }
  80. ?>
  81. <!DOCTYPE html>
  82. <html lang="en">
  83. <head>
  84. <meta charset="utf-8">
  85. <title> ShowDoc</title>
  86. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  87. <meta name="description" content="">
  88. <meta name="author" content="">
  89. <link href="../Public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  90. <style type="text/css">
  91. @charset "utf-8";
  92. body {
  93. font:14px/1.5 "Microsoft Yahei","微软雅黑",Tahoma,Arial,Helvetica,STHeiti;
  94. }
  95. .form-signin{
  96. display: none;
  97. }
  98. </style>
  99. </head>
  100. <body>
  101. <link rel="stylesheet" href="../Public/css/login.css" />
  102. <div class="container">
  103. <form class="form-signin" method="post">
  104. <h3 class="form-signin-heading"><?php echo L("install_title");?></h3>
  105. <br>
  106. <div>
  107. <select id="db_type">
  108. <option value="sqlite"><?php echo L("use_sqlite");?></option>
  109. <option value="mysql"><?php echo L("use_mysql");?></option>
  110. </select>
  111. </div>
  112. <br>
  113. <div class="mysql-info" style="display:none">
  114. <input type="text" class="input-block-level" name="db_host" id = "db_host" placeholder="<?php echo L("server_address");?>">
  115. <input type="text" class="input-block-level" name="db_port" id = "db_port" placeholder="<?php echo L("server_port");?>">
  116. <input type="text" class="input-block-level" name="db_name" id = "db_name" placeholder="<?php echo L("db_name");?>">
  117. <input type="text" class="input-block-level" name="db_user" id = "db_user" placeholder="<?php echo L("db_user");?>">
  118. <input type="text" class="input-block-level" name="db_password" id = "db_password" placeholder="<?php echo L("db_password");?>">
  119. </div>
  120. <div class="sqlite_tips" ><?php echo L("sqlite_tips");?></div>
  121. <input type="hidden" value="<?php echo $cur_lang;?>" id="lang">
  122. <br>
  123. <div>
  124. <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>
  125. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.showdoc.cc/help?page_id=16118" target="_blank"><?php echo L("FAQ");?></a>
  126. </div>
  127. </form>
  128. </div> <!-- /container -->
  129. <script src="../Public/js/common/jquery.min.js"></script>
  130. <script src="../Public/bootstrap/js/bootstrap.min.js"></script>
  131. </body>
  132. </html>
  133. <script type="text/javascript">
  134. $(function(){
  135. $("#db_type").change(function(){
  136. if ($("#db_type").val() == 'mysql') {
  137. $(".mysql-info").show();
  138. $(".sqlite_tips").hide();
  139. };
  140. if ($("#db_type").val() == 'sqlite') {
  141. $(".mysql-info").hide();
  142. $(".sqlite_tips").show();
  143. };
  144. });
  145. function install(){
  146. var db_type = $("#db_type").val();
  147. var db_host = $("#db_host").val();
  148. var db_port = $("#db_port").val();
  149. var db_name = $("#db_name").val();
  150. var db_user = $("#db_user").val();
  151. var lang = $("#lang").val();
  152. var db_password = $("#db_password").val();
  153. $.post(
  154. 'ajax.php',
  155. {"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},
  156. function(data){
  157. if (data.error_code === 0) {
  158. //安装成功
  159. //alert(data.message);
  160. var text = '<div><?php echo L("install_success_help");?></div><br>';
  161. text += '<div><a href="../" ><?php echo L("home");?></a></div>';
  162. $(".form-signin").html(text);
  163. $(".form-signin").show();
  164. }else{
  165. alert(data.message);
  166. }
  167. },
  168. "json"
  169. );
  170. }
  171. $("#start").click(function(){
  172. install();
  173. return false;
  174. });
  175. //showdoc不再支持mysql,所以不再让用户选择数据库,而是直接跳过去.
  176. install();
  177. });
  178. </script>