国内流行的内容管理系统(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.

109 lines
5.2KB

  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. if ($data) {
  29. $rs = (array)($data->result);
  30. if ($rs["admin_pwd_exists"] == "false") {
  31. //设定dedebiz admin密码
  32. if ($dedebiz_admin == "" || $dedebiz_admin !== $re_dedebiz_admin) {
  33. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/web/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  34. echo "<div class=\"alert alert-danger\">DedeBIZ操作密码为空或两次指定的密码不符</div><br>";
  35. $client->Close();
  36. exit;
  37. }
  38. $data = $client->AdminPWDCreate($dedebiz_admin);
  39. if ($data->data != "ok") {
  40. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/web/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  41. echo "<div class=\"alert alert-danger\">DedeBIZ设定操作密码失败:${$data}</div><br>";
  42. $client->Close();
  43. exit;
  44. }
  45. } else {
  46. if ($dedebiz_admin == "") {
  47. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/web/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  48. echo "<div class=\"alert alert-danger\">DedeBIZ操作密码为空</div><br>";
  49. $client->Close();
  50. exit;
  51. }
  52. $data = $client->AdminSetIndexLockState($dedebiz_admin, $lockindex);
  53. if ($data->data != "ok") {
  54. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/web/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  55. echo "<div class=\"alert alert-danger\">DedeBIZ操作密码失败,填写正确的操作密码</div><br>";
  56. $client->Close();
  57. exit;
  58. }
  59. }
  60. }
  61. $client->Close();
  62. }
  63. $remotepos = empty($remotepos) ? '/index.html' : $remotepos;
  64. $serviterm = empty($serviterm) ? "" : $serviterm;
  65. if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)$#i', trim($position))) {
  66. ShowMsg("指定的文件名已被系统禁止", "javascript:;");
  67. exit();
  68. }
  69. $homeFile = DEDEADMIN."/".$position;
  70. $homeFile = str_replace("\\", "/", $homeFile);
  71. $homeFile = str_replace("//", "/", $homeFile);
  72. $fp = fopen($homeFile, "w") or die("您指定的文件名有问题,无法创建文件");
  73. fclose($fp);
  74. if ($saveset == 1) {
  75. $iquery = "UPDATE `#@__homepageset` SET templet='$templet',position='$position' ";
  76. $dsql->ExecuteNoneQuery($iquery);
  77. }
  78. //判断首页生成模式
  79. if ($showmod == 1) {
  80. //需要生成静态
  81. $templet = str_replace("{style}", $cfg_df_style, $templet);
  82. $pv = new PartView();
  83. $GLOBALS['_arclistEnv'] = 'index';
  84. $pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
  85. $pv->SaveToHtml($homeFile);
  86. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/web/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  87. echo "<div class=\"alert alert-success\">成功更新首页:".$position." <a href='{$position}' target='_blank' class='btn btn-success btn-sm'>浏览</a></div>";
  88. } else {
  89. //动态浏览
  90. if (file_exists($homeFile)) @unlink($homeFile);
  91. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/web/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  92. echo "<div class=\"alert alert-success\">采用动态浏览:<a href='../index.php' target='_blank' class='btn btn-success btn-sm'>浏览</a></div>";
  93. }
  94. $iquery = "UPDATE `#@__homepageset` SET showmod='$showmod'";
  95. $dsql->ExecuteNoneQuery($iquery);
  96. if ($serviterm == "") {
  97. $config = array();
  98. } else {
  99. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  100. $config = array(
  101. 'hostname' => $servurl, 'username' => $servuser,
  102. 'password' => $servpwd, 'debug' => 'TRUE'
  103. );
  104. }
  105. exit();
  106. }
  107. $row = $dsql->GetOne("SELECT * FROM `#@__homepageset`");
  108. include DedeInclude('templets/makehtml_homepage.htm');
  109. ?>