ajax.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. // --------
  3. // 如果你能在浏览器中看到本句话,则证明你没有安装好PHP运行环境。请先安装好PHP运行环境
  4. // --------
  5. ini_set("display_errors", "Off");
  6. error_reporting(E_ALL | E_STRICT);
  7. header("Content-type: text/html; charset=utf-8");
  8. include("common.php");
  9. if(file_exists('./install.lock') && $f = file_get_contents("./install.lock")){
  10. ajax_out(L("lock"),10099);
  11. }
  12. if(!new_is_writeable("./")){
  13. ajax_out(L("not_writable_install"),10098);
  14. }
  15. if(!new_is_writeable("../Public/Uploads")){
  16. ajax_out(L("not_writable_upload"),10098);
  17. }
  18. if(!new_is_writeable("../Application/Runtime")){
  19. ajax_out(L("not_writable_runtime"),10095);
  20. }
  21. if(!new_is_writeable("../Application/Common/Conf/config.php")){
  22. ajax_out(L("not_writable_config"),10094);
  23. }
  24. if(!new_is_writeable("../Application/Home/Conf/config.php")){
  25. ajax_out(L("not_writable_home_config"),10098);
  26. }
  27. $db_type = $_POST["db_type"] ? $_POST["db_type"] :"sqlite";
  28. if ($db_type == "sqlite") {
  29. if(!new_is_writeable("../Sqlite")){
  30. ajax_out(L("not_writable_sqlite"),10097);
  31. }
  32. if(!new_is_writeable("../Sqlite/showdoc.db.php")){
  33. ajax_out(L("not_writable_sqlite_db"),10096);
  34. }
  35. user_sqlite();
  36. }
  37. elseif ($db_type == "mysql") {
  38. //user_mysql();
  39. }
  40. function user_sqlite(){
  41. clear_runtime();//清除缓存
  42. write_home_config();
  43. $config =
  44. <<<EOD
  45. <?php
  46. return array(
  47. //'配置项'=>'配置值'
  48. //使用sqlite数据库(ShowDoc默认)
  49. 'DB_TYPE' => 'Sqlite',
  50. 'DB_NAME' => 'Sqlite/showdoc.db.php',
  51. //使用mysql数据库
  52. //'DB_TYPE' => 'mysql',
  53. //'DB_NAME' => 'showdoc',
  54. 'DB_HOST' => 'localhost',
  55. 'DB_USER' => 'showdoc',
  56. 'DB_PWD' => 'showdoc123456',
  57. 'DB_PORT' => 3306, // 端口
  58. 'DB_PREFIX' => '', // 数据库表前缀
  59. 'DB_CHARSET'=> 'utf8', // 字符集
  60. 'DB_DEBUG' => TRUE, // 数据库调试模式 开启后可以记录SQL日志
  61. 'URL_HTML_SUFFIX' => '',//url伪静态后缀
  62. 'URL_MODEL' => 3 ,//URL兼容模式
  63. 'URL_ROUTER_ON' => true,
  64. 'URL_ROUTE_RULES'=>array(
  65. ':id\d' => 'Home/Item/show?item_id=:1',
  66. ':domain\s$' => 'Home/Item/show?item_domain=:1',//item的个性域名
  67. 'uid/:id\d' => 'Home/Item/showByUid?uid=:1',
  68. 'page/:id\d' => 'Home/Page/single?page_id=:1',
  69. ),
  70. 'URL_CASE_INSENSITIVE'=>true,
  71. 'SHOW_ERROR_MSG' => true, // 显示错误信息,这样在部署模式下也能显示错误
  72. 'STATS_CODE' =>'', //可选,统计代码
  73. 'TMPL_CACHE_ON' => false,//禁止模板编译缓存
  74. 'HTML_CACHE_ON' => false,//禁止静态缓存
  75. //上传文件到七牛的配置
  76. 'UPLOAD_SITEIMG_QINIU' => array(
  77. 'maxSize' => 5 * 1024 * 1024,//文件大小
  78. 'rootPath' => './',
  79. 'saveName' => array ('uniqid', ''),
  80. 'driver' => 'Qiniu',
  81. 'driverConfig' => array (
  82. 'secrectKey' => '',
  83. 'accessKey' => '',
  84. 'domain' => '',
  85. 'bucket' => '',
  86. )
  87. ),
  88. );
  89. EOD;
  90. $ret = file_put_contents("../Application/Common/Conf/config.php", $config);
  91. if ($ret) {
  92. file_put_contents("./install.lock","http://www.showdoc.cc/");
  93. ajax_out(L("install_success"));
  94. }else{
  95. ajax_out(L("install_config_not_writable"),10001);
  96. }
  97. }
  98. function write_home_config(){
  99. $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  100. if ($lang == 'en') {
  101. $DEFAULT_LANG = 'en-us';
  102. }else{
  103. $DEFAULT_LANG = 'zh-cn';
  104. }
  105. $config = "<?php ";
  106. $config .= "
  107. return array(
  108. //'配置项'=>'配置值'
  109. 'LANG_SWITCH_ON' => true, // 开启语言包功能
  110. 'LANG_AUTO_DETECT' => false, // 自动侦测语言 开启多语言功能后有效
  111. 'DEFAULT_LANG' => '{$DEFAULT_LANG}', // 默认语言
  112. 'LANG_LIST' => 'zh-cn,en-us', // 允许切换的语言列表 用逗号分隔
  113. 'VAR_LANGUAGE' => 'l', // 默认语言切换变量
  114. );";
  115. $ret = file_put_contents("../Application/Home/Conf/config.php", $config);
  116. }