ajax.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. //showdoc不再支持mysql http://www.showdoc.cc/help?page_id=31990
  39. }
  40. function user_sqlite(){
  41. clear_runtime();//清除缓存
  42. write_home_config();
  43. $config =
  44. <<<EOD
  45. <?php
  46. return array(
  47. //'配置项'=>'配置值'
  48. //使用sqlite数据库
  49. 'DB_TYPE' => 'Sqlite',
  50. 'DB_NAME' => 'Sqlite/showdoc.db.php',
  51. //showdoc不再支持mysql http://www.showdoc.cc/help?page_id=31990
  52. 'DB_HOST' => 'localhost',
  53. 'DB_USER' => 'showdoc',
  54. 'DB_PWD' => 'showdoc123456',
  55. 'DB_PORT' => 3306, // 端口
  56. 'DB_PREFIX' => '', // 数据库表前缀
  57. 'DB_CHARSET'=> 'utf8', // 字符集
  58. 'DB_DEBUG' => TRUE, // 数据库调试模式 开启后可以记录SQL日志
  59. 'URL_HTML_SUFFIX' => '',//url伪静态后缀
  60. 'URL_MODEL' => 3 ,//URL兼容模式
  61. 'URL_ROUTER_ON' => true,
  62. 'URL_ROUTE_RULES'=>array(
  63. ':id\d' => 'Home/Item/show?item_id=:1',
  64. ':domain\s$' => 'Home/Item/show?item_domain=:1',//item的个性域名
  65. 'uid/:id\d' => 'Home/Item/showByUid?uid=:1',
  66. 'page/:id\d' => 'Home/Page/single?page_id=:1',
  67. ),
  68. 'URL_CASE_INSENSITIVE'=>true,
  69. 'SHOW_ERROR_MSG' => true, // 显示错误信息,这样在部署模式下也能显示错误
  70. 'STATS_CODE' =>'', //可选,统计代码
  71. 'TMPL_CACHE_ON' => false,//禁止模板编译缓存
  72. 'HTML_CACHE_ON' => false,//禁止静态缓存
  73. //上传文件到七牛的配置
  74. 'UPLOAD_SITEIMG_QINIU' => array(
  75. 'maxSize' => 5 * 1024 * 1024,//文件大小
  76. 'rootPath' => './',
  77. 'saveName' => array ('uniqid', ''),
  78. 'driver' => 'Qiniu',
  79. 'driverConfig' => array (
  80. 'secrectKey' => '',
  81. 'accessKey' => '',
  82. 'domain' => '',
  83. 'bucket' => '',
  84. )
  85. ),
  86. );
  87. EOD;
  88. $ret = file_put_contents("../Application/Common/Conf/config.php", $config);
  89. if ($ret) {
  90. file_put_contents("./install.lock","http://www.showdoc.cc/");
  91. ajax_out(L("install_success"));
  92. }else{
  93. ajax_out(L("install_config_not_writable"),10001);
  94. }
  95. }
  96. function write_home_config(){
  97. $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  98. if ($lang == 'en') {
  99. $DEFAULT_LANG = 'en-us';
  100. }else{
  101. $DEFAULT_LANG = 'zh-cn';
  102. }
  103. $config = "<?php ";
  104. $config .= "
  105. return array(
  106. //'配置项'=>'配置值'
  107. 'LANG_SWITCH_ON' => true, // 开启语言包功能
  108. 'LANG_AUTO_DETECT' => false, // 自动侦测语言 开启多语言功能后有效
  109. 'DEFAULT_LANG' => '{$DEFAULT_LANG}', // 默认语言
  110. 'LANG_LIST' => 'zh-cn,en-us', // 允许切换的语言列表 用逗号分隔
  111. 'VAR_LANGUAGE' => 'l', // 默认语言切换变量
  112. );";
  113. $ret = file_put_contents("../Application/Home/Conf/config.php", $config);
  114. }