database.php 5.5 KB

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