国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

190 lignes
8.2KB

  1. <?php
  2. /**
  3. * 发布专题
  4. *
  5. * @version $id:spec_add.php 16:22 2010年7月20日 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_New,a_AccNew');
  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(DEDEINC.'/dedetag.class.php');
  18. require_once(DEDEADMIN.'/inc/inc_catalog_options.php');
  19. ClearMyAddon();
  20. $channelid = -1;
  21. $cid = isset($cid) && is_numeric($cid) ? $cid : 0;
  22. //获得栏目模型信息
  23. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  24. include DedeInclude("templets/spec_add.htm");
  25. exit();
  26. } else if ($dopost == 'save') {
  27. require_once(DEDEINC.'/image.func.php');
  28. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  29. $flag = isset($flags) ? join(',', $flags) : '';
  30. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  31. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(1000,6000) : $cfg_arc_click);
  32. $channelid = -1;
  33. $money = 0;
  34. if (!isset($tags)) $tags = '';
  35. //处理自定义字段会用到这些变量
  36. if (!isset($autokey)) $autokey = 0;
  37. if (!isset($remote)) $remote = 0;
  38. if (!isset($dellink)) $dellink = 0;
  39. if (!isset($autolitpic)) $autolitpic = 0;
  40. //对保存的文档进行处理
  41. if (empty($writer)) $writer = $cuserLogin->getUserName();
  42. if (empty($source)) $source = '未知';
  43. $pubdate = GetMkTime($pubdate);
  44. $senddate = time();
  45. $sortrank = AddDay($pubdate, $sortup);
  46. if ($ishtml == 0) $ismake = -1;
  47. else $ismake = 0;
  48. $title = preg_replace('#"#', '"', $title);
  49. $title = cn_substrR($title, $cfg_title_maxlen);
  50. $shorttitle = cn_substrR($shorttitle, 36);
  51. $color = cn_substrR($color, 7);
  52. $writer = cn_substrR($writer, 20);
  53. $source = cn_substrR($source, 30);
  54. $description = cn_substrR($description, $cfg_auot_description);
  55. $keywords = cn_substrR($keywords, 60);
  56. $filename = trim(cn_substrR($filename, 40));
  57. $isremote = 0;
  58. $serviterm = empty($serviterm) ? "" : $serviterm;
  59. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  60. $adminid = $cuserLogin->getUserID();
  61. //处理上传的缩略图
  62. if (empty($ddisremote)) {
  63. $ddisremote = 0;
  64. }
  65. $litpic = GetDDImage('none', $picname, $ddisremote);
  66. //生成文档id
  67. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  68. if (empty($arcID)) {
  69. ShowMsg("无法获得主键,无法进行后续操作", "-1");
  70. exit();
  71. }
  72. //保存到主表
  73. $inQuery = "INSERT INTO `#@__archives` (id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename) VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename');";
  74. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  75. echo $inQuery;
  76. $gerr = $dsql->GetError();
  77. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  78. ShowMsg("数据保存到数据库文档主表出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  79. exit();
  80. }
  81. //专题节点列表
  82. $arcids = array();
  83. $notelist = '';
  84. for ($i = 1; $i <= $cfg_specnote; $i++) {
  85. if (!empty(${'notename'.$i})) {
  86. $notename = str_replace("'", "", trim(${'notename'.$i}));
  87. $arcid = trim(${'arcid'.$i});
  88. $col = trim(${'col'.$i});
  89. $imgwidth = trim(${'imgwidth'.$i});
  90. $imgheight = trim(${'imgheight'.$i});
  91. $titlelen = trim(${'titlelen'.$i});
  92. $infolen = trim(${'infolen'.$i});
  93. $listtmp = trim(${'listtmp'.$i});
  94. $noteid = trim(${'noteid'.$i});
  95. $isauto = trim(${'isauto'.$i});
  96. $keywords = str_replace("'", "", trim(${'keywords'.$i}));
  97. $typeid = trim(${'typeid'.$i});
  98. if (!empty(${'rownum'.$i})) $rownum = trim(${'rownum'.$i});
  99. else $rownum = 0;
  100. $arcid = preg_replace("#[^0-9,]#", "", $arcid);
  101. $ids = explode(",", $arcid);
  102. $okids = "";
  103. if (is_array($ids)) {
  104. foreach ($ids as $mid) {
  105. $mid = trim($mid);
  106. if ($mid == "") continue;
  107. if (!isset($arcids[$mid])) {
  108. if ($okids == "") {
  109. $okids .= $mid;
  110. } else {
  111. $okids .= ",".$mid;
  112. }
  113. $arcids[$mid] = 1;
  114. }
  115. }
  116. }
  117. $notelist .= "{dede:specnote imgheight=\\'$imgheight\\' imgwidth=\\'$imgwidth\\' infolen=\\'$infolen\\' titlelen=\\'$titlelen\\' col=\\'$col\\' idlist=\\'$okids\\' name=\\'$notename\\' noteid=\\'$noteid\\' isauto=\'$isauto\' rownum=\\'$rownum\\' keywords=\\'$keywords\\' typeid=\\'$typeid\\'} $listtmp {/dede:specnote}\r\n";
  118. }
  119. }
  120. //分析处理附加表数据
  121. $inadd_f = '';
  122. $inadd_v = '';
  123. if (!empty($dede_addonfields)) {
  124. $addonfields = explode(';', $dede_addonfields);
  125. $inadd_f = '';
  126. $inadd_v = '';
  127. if (is_array($addonfields)) {
  128. foreach ($addonfields as $v) {
  129. if ($v == '') {
  130. continue;
  131. }
  132. $vs = explode(',', $v);
  133. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //网页文本特殊处理
  134. {
  135. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  136. } else {
  137. if (!isset(${$vs[0]})) {
  138. ${$vs[0]} = '';
  139. }
  140. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  141. }
  142. $inadd_f .= ','.$vs[0];
  143. $inadd_v .= " ,'".${$vs[0]}."' ";
  144. }
  145. }
  146. }
  147. //处理图片文档的自定义属性
  148. if ($litpic != '' && !preg_match('#p#', $flag)) {
  149. $flag = ($flag == '' ? 'p' : $flag.',p');
  150. }
  151. $useip = GetIP();
  152. //加入附加表
  153. $inQuery = "INSERT INTO `#@__addonspec` (aid,typeid,userip,templet,note{$inadd_f}) VALUES ('$arcID','$typeid','$useip','$templet','$notelist'{$inadd_v});";
  154. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  155. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  156. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  157. ShowMsg("数据保存到数据库附加表出错,请检查数据库字段", "-1");
  158. exit();
  159. }
  160. //生成网页
  161. InsertTags($tags, $arcID);
  162. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  163. if ($artUrl == '') {
  164. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  165. }
  166. ClearMyAddon($arcID, $title);
  167. //自动更新关联文档
  168. if (is_array($automake)) {
  169. foreach ($automake as $key => $value) {
  170. if (isset(${$key}) && !empty(${$key})) {
  171. $ids = explode(",", ${$key});
  172. foreach ($ids as $id) {
  173. MakeArt($id, true, true, $isremote);
  174. }
  175. }
  176. }
  177. }
  178. //返回成功信息
  179. $msg = "<tr>
  180. <td bgcolor='#f5f5f5' align='center'><a href='spec_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布专题</a><a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-success btn-sm'>修改专题</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>浏览专题</a><a href='content_s_list.php' class='btn btn-success btn-sm'>管理专题</a></td>
  181. </tr>";
  182. $wintitle = "成功发布专题";
  183. $wecome_info = "专题管理 - 发布专题";
  184. $win = new OxWindow();
  185. $win->AddTitle("成功发布专题");
  186. $win->AddMsgItem($msg);
  187. $winform = $win->GetWindow("hand", FALSE);
  188. $win->Display();
  189. }
  190. ?>