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

225 lines
8.7KB

  1. <?php
  2. /**
  3. * 文档编辑
  4. *
  5. * @version $Id: article_edit.php 1 14:12 2010年7月12日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_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('a_Edit,a_AccEdit,a_MyEdit');
  13. require_once(DEDEINC."/customfields.func.php");
  14. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  15. if (file_exists(DEDEDATA.'/template.rand.php')) {
  16. require_once(DEDEDATA.'/template.rand.php');
  17. }
  18. if (empty($dopost)) $dopost = '';
  19. $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
  20. if ($dopost != 'save') {
  21. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  22. require_once(DEDEINC."/dedetag.class.php");
  23. ClearMyAddon();
  24. //读取归档信息
  25. $query = "SELECT ch.typename AS channelname,ar.membername AS rankname,arc.*
  26. FROM `#@__archives` arc
  27. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  28. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  29. $arcRow = $dsql->GetOne($query);
  30. if (!is_array($arcRow)) {
  31. ShowMsg("读取档案基本信息出错", "-1");
  32. exit();
  33. }
  34. $query = "SELECT * FROM `#@__channeltype` WHERE id='".$arcRow['channel']."'";
  35. $cInfos = $dsql->GetOne($query);
  36. if (!is_array($cInfos)) {
  37. ShowMsg("读取频道配置信息出错", "javascript:;");
  38. exit();
  39. }
  40. $addtable = $cInfos['addtable'];
  41. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  42. if (!is_array($addRow)) {
  43. ShowMsg("读取附加信息出错", "javascript:;");
  44. exit();
  45. }
  46. $channelid = $arcRow['channel'];
  47. $tags = GetTags($aid);
  48. include DedeInclude("templets/article_edit.htm");
  49. exit();
  50. }
  51. /*--------------------------------
  52. function __save(){ }
  53. -------------------------------*/
  54. else if ($dopost == 'save') {
  55. require_once(DEDEINC.'/image.func.php');
  56. require_once(DEDEINC.'/oxwindow.class.php');
  57. $flag = isset($flags) ? join(',', $flags) : '';
  58. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  59. if (empty($typeid2)) $typeid2 = 0;
  60. if (!isset($autokey)) $autokey = 0;
  61. if (!isset($remote)) $remote = 0;
  62. if (!isset($dellink)) $dellink = 0;
  63. if (!isset($autolitpic)) $autolitpic = 0;
  64. if (empty($litpic_b64)) $litpic_b64 = '';
  65. if (empty($typeid)) {
  66. ShowMsg("请指定文档的栏目", "-1");
  67. exit();
  68. }
  69. if (empty($channelid)) {
  70. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  71. exit();
  72. }
  73. if (!CheckChannel($typeid, $channelid)) {
  74. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  75. exit();
  76. }
  77. if (!TestPurview('a_Edit')) {
  78. if (TestPurview('a_AccEdit')) {
  79. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  80. } else {
  81. CheckArcAdmin($id, $cuserLogin->getUserID());
  82. }
  83. }
  84. //对保存的内容进行处理
  85. $pubdate = GetMkTime($pubdate);
  86. $sortrank = AddDay($pubdate, $sortup);
  87. $ismake = $ishtml == 0 ? -1 : 0;
  88. $autokey = 1;
  89. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  90. $shorttitle = cn_substrR($shorttitle, 36);
  91. $color = cn_substrR($color, 7);
  92. $writer = cn_substrR($writer, 20);
  93. $source = cn_substrR($source, 30);
  94. $description = cn_substrR($description, 250);
  95. $keywords = trim(cn_substrR($keywords, 60));
  96. $filename = trim(cn_substrR($filename, 40));
  97. $isremote = 0;
  98. $serviterm = empty($serviterm) ? "" : $serviterm;
  99. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  100. $arcrank = -1;
  101. }
  102. $adminid = $cuserLogin->getUserID();
  103. //处理上传的缩略图
  104. if (empty($ddisremote)) {
  105. $ddisremote = 0;
  106. }
  107. $litpic = GetDDImage('none', $picname, $ddisremote);
  108. //分析body里的内容
  109. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  110. //分析处理附加表数据
  111. $inadd_f = '';
  112. $inadd_v = '';
  113. if (!empty($dede_addonfields)) {
  114. $addonfields = explode(';', $dede_addonfields);
  115. $inadd_f = '';
  116. $inadd_v = '';
  117. if (is_array($addonfields)) {
  118. foreach ($addonfields as $v) {
  119. if ($v == '') {
  120. continue;
  121. }
  122. $vs = explode(',', $v);
  123. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  124. {
  125. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  126. } else {
  127. if (!isset(${$vs[0]})) {
  128. ${$vs[0]} = '';
  129. }
  130. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  131. }
  132. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  133. }
  134. }
  135. }
  136. //处理新的缩略图上传
  137. if ($litpic_b64 != "") {
  138. $data = explode(',', $litpic_b64);
  139. $ntime = time();
  140. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  141. CreateDir($savepath);
  142. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  143. $fullUrl = $fullUrl.".png";
  144. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  145. //加水印
  146. WaterImg($cfg_basedir.$fullUrl, 'up');
  147. $litpic = $fullUrl;
  148. }
  149. //处理图片文档的自定义属性
  150. if ($litpic != '' && !preg_match("#p#", $flag)) {
  151. $flag = ($flag == '' ? 'p' : $flag.',p');
  152. }
  153. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  154. $flag = ($flag == '' ? 'j' : $flag.',j');
  155. }
  156. //跳转网址的文档强制为动态
  157. if (preg_match("#j#", $flag)) $ismake = -1;
  158. //更新数据库的SQL语句
  159. $query = "UPDATE `#@__archives` SET
  160. `typeid`='$typeid',
  161. `typeid2`='$typeid2',
  162. `sortrank`='$sortrank',
  163. `flag`='$flag',
  164. `click`='$click',
  165. `ismake`='$ismake',
  166. `arcrank`='$arcrank',
  167. `money`='$money',
  168. `title`='$title',
  169. `color`='$color',
  170. `writer`='$writer',
  171. `source`='$source',
  172. `litpic`='$litpic',
  173. `pubdate`='$pubdate',
  174. `notpost`='$notpost',
  175. `description`='$description',
  176. `keywords`='$keywords',
  177. `shorttitle`='$shorttitle',
  178. `filename`='$filename',
  179. `dutyadmin`='$adminid',
  180. `weight`='$weight'
  181. WHERE `id`='$id'; ";
  182. if (!$dsql->ExecuteNoneQuery($query)) {
  183. ShowMsg('更新数据库archives表时出错,请检查', -1);
  184. exit();
  185. }
  186. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  187. $addtable = trim($cts['addtable']);
  188. if ($addtable != '') {
  189. $useip = GetIP();
  190. $templet = empty($templet) ? '' : $templet;
  191. $iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
  192. if (!$dsql->ExecuteNoneQuery($iquery)) {
  193. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因", "javascript:;");
  194. exit();
  195. }
  196. }
  197. //生成HTML
  198. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  199. $artUrl = MakeArt($id, true, true, $isremote);
  200. if ($artUrl == '') {
  201. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  202. }
  203. ClearMyAddon($id, $title);
  204. //自动更新关联内容
  205. if (is_array($automake)) {
  206. foreach ($automake as $key => $value) {
  207. if (isset(${$key}) && !empty(${$key})) {
  208. $ids = explode(",", ${$key});
  209. foreach ($ids as $id) {
  210. MakeArt($id, true, true, $isremote);
  211. }
  212. }
  213. }
  214. }
  215. //返回成功信息
  216. $msg = "请选择您的后续操作:<a href='article_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布新文章</a>&nbsp;&nbsp;<a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-success btn-sm'>查看更改</a>&nbsp;&nbsp;<a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看文章</a>&nbsp;&nbsp;<a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>管理文章</a>&nbsp;&nbsp;$backurl";
  217. $wintitle = "成功更改文章";
  218. $wecome_info = "文章管理::更改文章";
  219. $win = new OxWindow();
  220. $win->AddTitle("成功更改文章:");
  221. $win->AddMsgItem($msg);
  222. $winform = $win->GetWindow("hand", "&nbsp;", false);
  223. $win->Display();
  224. }