国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.4KB

  1. <?php
  2. /**
  3. * 修改自定义页面
  4. *
  5. * @version $id:templets_one_edit.php 23:07 2010年7月20日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. require(dirname(__FILE__)."/config.php");
  12. CheckPurview('temp_One');
  13. if (empty($dopost)) $dopost = '';
  14. $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
  15. if ($dopost == "saveedit") {
  16. include_once(DEDEINC."/archive/sgpage.class.php");
  17. $files = json_decode(file_get_contents(DEDEDATA.'/admin/files.txt'));
  18. $currentFolder = basename(__DIR__);
  19. $realFiles = array();
  20. foreach ($files as $ff) {
  21. $rfi = preg_replace("#^admin/#",$currentFolder.'/',$ff->filename);
  22. $realFiles[] = $rfi;
  23. }
  24. function realdir($path) {
  25. return dirname(realpath($path));
  26. }
  27. $uptime = time();
  28. $body = str_replace('&quot;', '\\"', $body);
  29. $filename = preg_replace("#^\/#", "", $nfilename);
  30. if (DEDEBIZ_SAFE_MODE) $ismake = 0; //安全模式不允许编译
  31. if (!preg_match('#\.htm$#i', trim($template))) {
  32. ShowMsg("文件扩展名已被系统禁止", "javascript:;");
  33. exit();
  34. }
  35. //如果修改了文件名,删除旧文件
  36. if ($oldfilename != $filename) {
  37. $f = str_replace("..", "", $oldfilename);
  38. $f = $cfg_basedir.$activepath."/$oldfilename";
  39. if (!file_exists(dirname(__FILE__).'/../license.txt')) {
  40. ShowMsg("许可协议不存在,无法重名文件", "javascript:;");
  41. exit();
  42. }
  43. $f = str_replace(realdir(dirname(__FILE__).'/../license.txt').'/', "", $f);
  44. if (in_array($f,$realFiles)) {
  45. ShowMsg("系统文件禁止重名", "javascript:;");
  46. exit();
  47. }
  48. $oldfilename = $cfg_basedir.'/'.$oldfilename;
  49. if (is_file($oldfilename)) {
  50. unlink($oldfilename);
  51. }
  52. }
  53. if ($likeidsel != $oldlikeid) {
  54. $likeid = $likeidsel;
  55. }
  56. $inQuery = "UPDATE `#@__sgpage` SET title='$title',keywords='$keywords',description='$description',likeid='$likeid',ismake='$ismake',filename='$filename',template='$template',uptime='$uptime',body='$body' WHERE aid='$aid'; ";
  57. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  58. ShowMsg("更新页面失败,请检查页面是否有问题", "-1");
  59. exit();
  60. }
  61. $sg = new sgpage($aid);
  62. $sg->SaveToHtml();
  63. ShowMsg("成功修改一个单页", "templets_one.php");
  64. exit();
  65. } else if ($dopost == "delete") {
  66. $row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'");
  67. $filename = preg_replace("#\/{1,}#", "/", $cfg_basedir."/".$row['filename']);
  68. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__sgpage` WHERE aid='$aid' ");
  69. if (is_file($filename)) {
  70. unlink($filename);
  71. }
  72. ShowMsg("成功删除一个单页", "templets_one.php");
  73. exit();
  74. } else if ($dopost == "make") {
  75. include_once(DEDEINC."/archive/sgpage.class.php");
  76. $row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'");
  77. $fileurl = $cfg_cmsurl.'/'.preg_replace("#\/{1,}#", "/", $row['filename']);
  78. $sg = new sgpage($aid);
  79. $sg->SaveToHtml();
  80. ShowMsg("成功更新一个单页", $fileurl);
  81. exit();
  82. } else if ($dopost == "mkall") {
  83. include_once(DEDEINC."/archive/sgpage.class.php");
  84. $dsql->Execute("ex", "SELECT aid FROM `#@__sgpage`");
  85. $i = 0;
  86. while ($row = $dsql->GetArray("ex")) {
  87. $sg = new sgpage($row['aid']);
  88. $sg->SaveToHtml();
  89. $i++;
  90. }
  91. ShowMsg("成功更新".$i."个页面", '-1');
  92. exit();
  93. } else if ($dopost == "mksel") {
  94. if (empty($ids)) {
  95. $ids = '';
  96. }
  97. include_once(DEDEINC."/archive/sgpage.class.php");
  98. $i = 0;
  99. if ($ids == 0) {
  100. ShowMsg('您没有选择需要更新的文档', '-1');
  101. exit();
  102. } else if (is_array($ids)) {
  103. foreach ($ids as $aid) {
  104. $sg = new sgpage($aid);
  105. $sg->SaveToHtml();
  106. $i++;
  107. }
  108. ShowMsg("成功更新".$i."个页面", '-1');
  109. exit();
  110. }
  111. } else if ($dopost == "view") {
  112. if (empty($aid)) {
  113. ShowMsg('预览失败,请重新选择', 'javascript:;');
  114. exit();
  115. }
  116. include_once(DEDEINC."/archive/sgpage.class.php");
  117. $sg = new sgpage($aid);
  118. $sg->display();
  119. exit();
  120. }
  121. $row = $dsql->GetOne("SELECT * FROM `#@__sgpage` WHERE aid='$aid' ");
  122. include(DEDEADMIN."/templets/templets_one_edit.htm");
  123. ?>