国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
5.1KB

  1. <?php
  2. /**
  3. * 生成首页
  4. *
  5. * @version $Id: makehtml_homepage.php 2 9:30 2010-11-11 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('sys_MakeHtml');
  13. require_once(DEDEINC."/archive/partview.class.php");
  14. if (empty($dopost)) $dopost = '';
  15. if ($dopost == "view") {
  16. $pv = new PartView();
  17. $templet = str_replace("{style}", $cfg_df_style, $templet);
  18. $pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
  19. $pv->Display();
  20. exit();
  21. } else if ($dopost == "make") {
  22. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  23. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  24. $client->appid = $cfg_bizcore_appid;
  25. $client->key = $cfg_bizcore_key;
  26. $data = $client->AdminPWDExists();
  27. $data = json_decode($data->data);
  28. $rs = (array)($data->result);
  29. if ($rs["admin_pwd_exists"] == "false") {
  30. //设定dedebiz admin密码
  31. if ($dedebiz_admin == "" || $dedebiz_admin !== $re_dedebiz_admin) {
  32. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  33. echo "<div class=\"alert alert-danger\" role=\"alert\">DedeBIZ操作密码为空或两次指定的密码不符</div><br>";
  34. $client->Close();
  35. exit;
  36. }
  37. $data = $client->AdminPWDCreate($dedebiz_admin);
  38. if ($data->data != "ok") {
  39. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  40. echo "<div class=\"alert alert-danger\" role=\"alert\">DedeBIZ设定操作密码失败:${$data}</div><br>";
  41. $client->Close();
  42. exit;
  43. }
  44. } else {
  45. if ($dedebiz_admin == "") {
  46. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  47. echo "<div class=\"alert alert-danger\" role=\"alert\">DedeBIZ操作密码为空</div><br>";
  48. $client->Close();
  49. exit;
  50. }
  51. $data = $client->AdminSetIndexLockState($dedebiz_admin, $lockindex);
  52. if ($data->data != "ok") {
  53. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  54. echo "<div class=\"alert alert-danger\" role=\"alert\">DedeBIZ操作密码失败,填写正确的操作密码</div><br>";
  55. $client->Close();
  56. exit;
  57. }
  58. }
  59. $client->Close();
  60. }
  61. $remotepos = empty($remotepos) ? '/index.html' : $remotepos;
  62. $serviterm = empty($serviterm) ? "" : $serviterm;
  63. if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)$#i', trim($position))) {
  64. ShowMsg("您指定的文件名被系统禁止", "javascript:;");
  65. exit();
  66. }
  67. $homeFile = DEDEADMIN."/".$position;
  68. $homeFile = str_replace("\\", "/", $homeFile);
  69. $homeFile = str_replace("//", "/", $homeFile);
  70. $fp = fopen($homeFile, "w") or die("您指定的文件名有问题,无法创建文件");
  71. fclose($fp);
  72. if ($saveset == 1) {
  73. $iquery = "UPDATE `#@__homepageset` SET templet='$templet',position='$position' ";
  74. $dsql->ExecuteNoneQuery($iquery);
  75. }
  76. //判断首页生成模式
  77. if ($showmod == 1) {
  78. //需要生成静态
  79. $templet = str_replace("{style}", $cfg_df_style, $templet);
  80. $pv = new PartView();
  81. $GLOBALS['_arclistEnv'] = 'index';
  82. $pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
  83. $pv->SaveToHtml($homeFile);
  84. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  85. echo "<div class=\"alert alert-success\" role=\"alert\">成功更新首页:".$homeFile." <a href='{$position}' target='_blank' class='btn btn-success btn-sm'>浏览</a></div>";
  86. } else {
  87. //动态浏览
  88. if (file_exists($homeFile)) @unlink($homeFile);
  89. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  90. echo "<div class=\"alert alert-success\" role=\"alert\">采用动态浏览:<a href='../index.php' target='_blank' class='btn btn-success btn-sm'>浏览</a></div>";
  91. }
  92. $iquery = "UPDATE `#@__homepageset` SET showmod='$showmod'";
  93. $dsql->ExecuteNoneQuery($iquery);
  94. if ($serviterm == "") {
  95. $config = array();
  96. } else {
  97. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  98. $config = array(
  99. 'hostname' => $servurl, 'username' => $servuser,
  100. 'password' => $servpwd, 'debug' => 'TRUE'
  101. );
  102. }
  103. exit();
  104. }
  105. $row = $dsql->GetOne("SELECT * FROM `#@__homepageset`");
  106. include DedeInclude('templets/makehtml_homepage.htm');