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

269 lines
9.3KB

  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) 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('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. -------------------------------*/ else if ($dopost == 'save') {
  54. require_once(DEDEINC . '/image.func.php');
  55. require_once(DEDEINC . '/oxwindow.class.php');
  56. $flag = isset($flags) ? join(',', $flags) : '';
  57. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  58. if (empty($typeid2)) $typeid2 = 0;
  59. if (!isset($autokey)) $autokey = 0;
  60. if (!isset($remote)) $remote = 0;
  61. if (!isset($dellink)) $dellink = 0;
  62. if (!isset($autolitpic)) $autolitpic = 0;
  63. if (empty($litpic_b64)) $litpic_b64 = '';
  64. if (empty($typeid)) {
  65. ShowMsg("请指定文档的栏目!", "-1");
  66. exit();
  67. }
  68. if (empty($channelid)) {
  69. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  70. exit();
  71. }
  72. if (!CheckChannel($typeid, $channelid)) {
  73. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  74. exit();
  75. }
  76. if (!TestPurview('a_Edit')) {
  77. if (TestPurview('a_AccEdit')) {
  78. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  79. } else {
  80. CheckArcAdmin($id, $cuserLogin->getUserID());
  81. }
  82. }
  83. //对保存的内容进行处理
  84. $pubdate = GetMkTime($pubdate);
  85. $sortrank = AddDay($pubdate, $sortup);
  86. $ismake = $ishtml == 0 ? -1 : 0;
  87. $autokey = 1;
  88. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  89. $shorttitle = cn_substrR($shorttitle, 36);
  90. $color = cn_substrR($color, 7);
  91. $writer = cn_substrR($writer, 20);
  92. $source = cn_substrR($source, 30);
  93. $description = cn_substrR($description, 250);
  94. $keywords = trim(cn_substrR($keywords, 60));
  95. $filename = trim(cn_substrR($filename, 40));
  96. $isremote = 0;
  97. $serviterm = empty($serviterm) ? "" : $serviterm;
  98. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  99. $arcrank = -1;
  100. }
  101. $adminid = $cuserLogin->getUserID();
  102. //处理上传的缩略图
  103. if (empty($ddisremote)) {
  104. $ddisremote = 0;
  105. }
  106. $litpic = GetDDImage('none', $picname, $ddisremote);
  107. //分析body里的内容
  108. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  109. //分析处理附加表数据
  110. $inadd_f = '';
  111. $inadd_v = '';
  112. if (!empty($dede_addonfields)) {
  113. $addonfields = explode(';', $dede_addonfields);
  114. $inadd_f = '';
  115. $inadd_v = '';
  116. if (is_array($addonfields)) {
  117. foreach ($addonfields as $v) {
  118. if ($v == '') {
  119. continue;
  120. }
  121. $vs = explode(',', $v);
  122. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  123. {
  124. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  125. } else {
  126. if (!isset(${$vs[0]})) {
  127. ${$vs[0]} = '';
  128. }
  129. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  130. }
  131. $inadd_f .= ",`{$vs[0]}` = '" . ${$vs[0]} . "'";
  132. }
  133. }
  134. }
  135. // 处理新的缩略图上传
  136. if ($litpic_b64 != "") {
  137. $data = explode(',', $litpic_b64);
  138. $ntime = time();
  139. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  140. CreateDir($savepath);
  141. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  142. $fullUrl = $fullUrl . ".png";
  143. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  144. // 加水印
  145. WaterImg($cfg_basedir . $fullUrl, 'up');
  146. $litpic = $fullUrl;
  147. }
  148. //处理图片文档的自定义属性
  149. if ($litpic != '' && !preg_match("#p#", $flag)) {
  150. $flag = ($flag == '' ? 'p' : $flag . ',p');
  151. }
  152. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  153. $flag = ($flag == '' ? 'j' : $flag . ',j');
  154. }
  155. //跳转网址的文档强制为动态
  156. if (preg_match("#j#", $flag)) $ismake = -1;
  157. //更新数据库的SQL语句
  158. $query = "UPDATE #@__archives SET
  159. typeid='$typeid',
  160. typeid2='$typeid2',
  161. sortrank='$sortrank',
  162. flag='$flag',
  163. click='$click',
  164. ismake='$ismake',
  165. arcrank='$arcrank',
  166. money='$money',
  167. title='$title',
  168. color='$color',
  169. writer='$writer',
  170. source='$source',
  171. litpic='$litpic',
  172. pubdate='$pubdate',
  173. notpost='$notpost',
  174. description='$description',
  175. keywords='$keywords',
  176. shorttitle='$shorttitle',
  177. filename='$filename',
  178. dutyadmin='$adminid',
  179. weight='$weight'
  180. WHERE id='$id'; ";
  181. if (!$dsql->ExecuteNoneQuery($query)) {
  182. ShowMsg('更新数据库archives表时出错,请检查', -1);
  183. exit();
  184. }
  185. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  186. $addtable = trim($cts['addtable']);
  187. if ($addtable != '') {
  188. $useip = GetIP();
  189. $templet = empty($templet) ? '' : $templet;
  190. $iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
  191. if (!$dsql->ExecuteNoneQuery($iquery)) {
  192. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!", "javascript:;");
  193. exit();
  194. }
  195. }
  196. //生成HTML
  197. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  198. if ($cfg_remote_site == 'Y' && $isremote == "1") {
  199. if ($serviterm != "") {
  200. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  201. $config = array(
  202. 'hostname' => $servurl, 'username' => $servuser,
  203. 'password' => $servpwd, 'debug' => 'TRUE'
  204. );
  205. } else {
  206. $config = array();
  207. }
  208. if (!$ftp->connect($config)) exit('Error:None FTP Connection!');
  209. }
  210. $artUrl = MakeArt($id, true, true, $isremote);
  211. if ($artUrl == '') {
  212. $artUrl = $cfg_phpurl . "/view.php?aid=$id";
  213. }
  214. ClearMyAddon($id, $title);
  215. // 自动更新关联内容
  216. if (is_array($automake)) {
  217. foreach ($automake as $key => $value) {
  218. if (isset(${$key}) && !empty(${$key})) {
  219. $ids = explode(",", ${$key});
  220. foreach ($ids as $id) {
  221. MakeArt($id, true, true, $isremote);
  222. }
  223. }
  224. }
  225. }
  226. //返回成功信息
  227. $msg = "
  228.   请选择你的后续操作:
  229. <a href='article_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>发布新文章</a>
  230. &nbsp;&nbsp;
  231. <a href='archives_do.php?aid=" . $id . "&dopost=editArchives' class='btn btn-secondary btn-sm'>查看更改</a>
  232. &nbsp;&nbsp;
  233. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看文章</a>
  234. &nbsp;&nbsp;
  235. <a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-secondary btn-sm'>管理文章</a>
  236. &nbsp;&nbsp;
  237. $backurl
  238. ";
  239. $wintitle = "成功更改文章!";
  240. $wecome_info = "文章管理::更改文章";
  241. $win = new OxWindow();
  242. $win->AddTitle("成功更改文章:");
  243. $win->AddMsgItem($msg);
  244. $winform = $win->GetWindow("hand", "&nbsp;", false);
  245. $win->Display();
  246. }