non_interactive.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. echo L("lock")."\n";
  11. }else{
  12. user_sqlite();
  13. }
  14. function user_sqlite(){
  15. clear_runtime();//清除缓存
  16. write_js_lang();
  17. $ret = write_home_config();
  18. if ($ret) {
  19. file_put_contents("./install.lock","https://www.showdoc.cc/");
  20. echo 'install success !!!'."\n";
  21. }else{
  22. echo "\n".L("not_writable_home_config")."\n";
  23. }
  24. }
  25. function write_home_config(){
  26. $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  27. if ($lang == 'en') {
  28. $DEFAULT_LANG = 'en-us';
  29. }else{
  30. $DEFAULT_LANG = 'zh-cn';
  31. }
  32. $config = "<?php ";
  33. $config .= "
  34. return array(
  35. //'配置项'=>'配置值'
  36. 'DB_TYPE' => 'Sqlite',
  37. 'DB_NAME' => './Sqlite/showdoc.db.php',
  38. 'LANG_SWITCH_ON' => true, // 开启语言包功能
  39. 'LANG_AUTO_DETECT' => false, // 自动侦测语言 开启多语言功能后有效
  40. 'DEFAULT_LANG' => '{$DEFAULT_LANG}', // 默认语言
  41. 'LANG_LIST' => 'zh-cn,en-us', // 允许切换的语言列表 用逗号分隔
  42. 'VAR_LANGUAGE' => 'l', // 默认语言切换变量
  43. );";
  44. $ret = file_put_contents("../server/Application/Home/Conf/config.php", $config);
  45. return $ret ;
  46. }
  47. function write_js_lang(){
  48. $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] :"zh";
  49. if ($lang == 'en') {
  50. replace_file_content("../web/index.html","zh-cn","en") ;
  51. replace_file_content("../web_src/index.html","zh-cn","en") ;
  52. }
  53. }