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

108 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) 2020, 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 . "/arc.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. $homeFile = DEDEADMIN . "/" . $position;
  64. $homeFile = str_replace("\\", "/", $homeFile);
  65. $homeFile = str_replace("//", "/", $homeFile);
  66. $fp = fopen($homeFile, "w") or die("你指定的文件名有问题,无法创建文件");
  67. fclose($fp);
  68. if ($saveset == 1) {
  69. $iquery = "UPDATE `#@__homepageset` SET templet='$templet',position='$position' ";
  70. $dsql->ExecuteNoneQuery($iquery);
  71. }
  72. // 判断首页生成模式
  73. if ($showmod == 1) {
  74. // 需要生成静态
  75. $templet = str_replace("{style}", $cfg_df_style, $templet);
  76. $pv = new PartView();
  77. $GLOBALS['_arclistEnv'] = 'index';
  78. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $templet);
  79. $pv->SaveToHtml($homeFile);
  80. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  81. echo "<div class=\"alert alert-success\" role=\"alert\">成功更新主页HTML:" . $homeFile . "<br /><a href='{$position}' target='_blank' class='btn btn-secondary'>浏览...</a></div><br />";
  82. } else {
  83. // 动态浏览
  84. if (file_exists($homeFile)) @unlink($homeFile);
  85. echo "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style>";
  86. echo "<div class=\"alert alert-success\" role=\"alert\">采用动态浏览模式:<a href='../index.php' target='_blank' class='btn btn-secondary'>浏览...</a></div><br />";
  87. }
  88. $iquery = "UPDATE `#@__homepageset` SET showmod='$showmod'";
  89. $dsql->ExecuteNoneQuery($iquery);
  90. if ($serviterm == "") {
  91. $config = array();
  92. } else {
  93. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  94. $config = array(
  95. 'hostname' => $servurl, 'username' => $servuser,
  96. 'password' => $servpwd, 'debug' => 'TRUE'
  97. );
  98. }
  99. exit();
  100. }
  101. $row = $dsql->GetOne("SELECT * FROM `#@__homepageset`");
  102. include DedeInclude('templets/makehtml_homepage.htm');