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

245 lines
8.4KB

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