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

111 lines
3.6KB

  1. <?php
  2. /**
  3. * 编辑一个模板
  4. *
  5. * @version $Id: templets_one_edit.php 1 23:07 2010年7月20日Z 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(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. $uptime = time();
  18. $body = str_replace('&quot;', '\\"', $body);
  19. $filename = preg_replace("#^\/#", "", $nfilename);
  20. if (!preg_match('#\.htm$#i', trim($template))) {
  21. ShowMsg("您指定的文件名被系统禁止", "javascript:;");
  22. exit();
  23. }
  24. //如果修改了文件名,删除旧文件
  25. if ($oldfilename != $filename) {
  26. $oldfilename = $cfg_basedir.$cfg_cmspath."/".$oldfilename;
  27. if (is_file($oldfilename)) {
  28. unlink($oldfilename);
  29. }
  30. }
  31. if ($likeidsel != $oldlikeid) {
  32. $likeid = $likeidsel;
  33. }
  34. $inQuery = "
  35. UPDATE `#@__sgpage` SET
  36. title='$title',
  37. keywords='$keywords',
  38. description='$description',
  39. likeid='$likeid',
  40. ismake='$ismake',
  41. filename='$filename',
  42. template='$template',
  43. uptime='$uptime',
  44. body='$body'
  45. WHERE aid='$aid'; ";
  46. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  47. ShowMsg("更新页面数据时失败,请检查长相是否有问题", "-1");
  48. exit();
  49. }
  50. $sg = new sgpage($aid);
  51. $sg->SaveToHtml();
  52. ShowMsg("成功修改一个页面", "templets_one.php");
  53. exit();
  54. } else if ($dopost == "delete") {
  55. $row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'");
  56. $filename = preg_replace("#\/{1,}#", "/", $cfg_basedir.$cfg_cmspath."/".$row['filename']);
  57. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__sgpage` WHERE aid='$aid' ");
  58. if (is_file($filename)) {
  59. unlink($filename);
  60. }
  61. ShowMsg("成功删除一个页面", "templets_one.php");
  62. exit();
  63. } else if ($dopost == "make") {
  64. include_once(DEDEINC."/archive/sgpage.class.php");
  65. $row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'");
  66. $fileurl = $cfg_cmsurl.'/'.preg_replace("#\/{1,}#", "/", $row['filename']);
  67. $sg = new sgpage($aid);
  68. $sg->SaveToHtml();
  69. ShowMsg("成功更新一个页面", $fileurl);
  70. exit();
  71. } else if ($dopost == "mkall") {
  72. include_once(DEDEINC."/archive/sgpage.class.php");
  73. $dsql->Execute("ex", "SELECT aid FROM `#@__sgpage` ");
  74. $i = 0;
  75. while ($row = $dsql->GetArray("ex")) {
  76. $sg = new sgpage($row['aid']);
  77. $sg->SaveToHtml();
  78. $i++;
  79. }
  80. ShowMsg("成功更新 $i 个页面", '-1');
  81. exit();
  82. } else if ($dopost == "mksel") {
  83. if (empty($ids)) {
  84. $ids = '';
  85. }
  86. include_once(DEDEINC."/archive/sgpage.class.php");
  87. $i = 0;
  88. if ($ids == 0) {
  89. ShowMsg('您没有选择需要更新的文档', '-1');
  90. exit();
  91. } else if (is_array($ids)) {
  92. foreach ($ids as $aid) {
  93. $sg = new sgpage($aid);
  94. $sg->SaveToHtml();
  95. $i++;
  96. }
  97. ShowMsg("成功更新 $i 个页面", '-1');
  98. exit();
  99. }
  100. } else if ($dopost == "view") {
  101. if (empty($aid)) {
  102. ShowMsg('错误的ID', 'javascript:;');
  103. exit();
  104. }
  105. include_once(DEDEINC."/archive/sgpage.class.php");
  106. $sg = new sgpage($aid);
  107. $sg->display();
  108. exit();
  109. }
  110. $row = $dsql->GetOne("SELECT * FROM `#@__sgpage` WHERE aid='$aid' ");
  111. include(DEDEADMIN."/templets/templets_one_edit.htm");