ajax.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  10. if(file_exists('./install.lock') && $f = file_get_contents("./install.lock")){
  11. ajax_out(L("lock"),10099);
  12. }
  13. if(!new_is_writeable("./")){
  14. ajax_out(L("not_writable_install"),10098);
  15. }
  16. if(!new_is_writeable("../Public/Uploads")){
  17. ajax_out(L("not_writable_upload"),10098);
  18. }
  19. if(!new_is_writeable("../server/Application/Runtime")){
  20. ajax_out(L("not_writable_server_runtime"),10095);
  21. }
  22. if(!new_is_writeable("../Sqlite")){
  23. ajax_out(L("not_writable_sqlite"),10097);
  24. }
  25. if(!new_is_writeable("../Sqlite/showdoc.db.php")){
  26. ajax_out(L("not_writable_sqlite_db"),10096);
  27. }
  28. if($lang == 'en'){
  29. if(!new_is_writeable("../server/Application/Home/Conf/config.php")){
  30. ajax_out(L("not_writable_home_config"),10096);
  31. }
  32. if(!new_is_writeable("../web/index.html")){
  33. ajax_out(L("not_writable_web_docconfig"),10096);
  34. }
  35. if(!new_is_writeable("../web_src/index.html")){
  36. ajax_out(L("not_writable_web_src_docconfig"),10096);
  37. }
  38. replace_file_content("../web/index.html","zh-cn","en") ;
  39. replace_file_content("../web_src/index.html","zh-cn","en") ;
  40. clear_runtime();//清除缓存
  41. $config = "<?php ";
  42. $config .= "
  43. return array(
  44. //'配置项'=>'配置值'
  45. 'DB_TYPE' => 'Sqlite',
  46. 'DB_NAME' => './Sqlite/showdoc.db.php',
  47. 'LANG_SWITCH_ON' => true, // 开启语言包功能
  48. 'LANG_AUTO_DETECT' => false, // 自动侦测语言 开启多语言功能后有效
  49. 'DEFAULT_LANG' => 'en-us', // 默认语言
  50. 'LANG_LIST' => 'zh-cn,en-us', // 允许切换的语言列表 用逗号分隔
  51. 'VAR_LANGUAGE' => 'l', // 默认语言切换变量
  52. );";
  53. $ret = file_put_contents("../server/Application/Home/Conf/config.php", $config);
  54. if (!$ret) {
  55. ajax_out(L("not_writable_home_config"),10001);
  56. }
  57. }
  58. clear_runtime();//清除缓存
  59. file_put_contents("./install.lock","https://www.showdoc.com.cn/");
  60. ajax_out(L("install_success"));