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

237 lines
9.3KB

  1. <?php
  2. /**
  3. * 专题添加
  4. *
  5. * @version $Id: spec_add.php 1 16:22 2010年7月20日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_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. }
  27. /*--------------------------------
  28. function __save(){ }
  29. -------------------------------*/ else if ($dopost == 'save') {
  30. require_once(DEDEINC . '/image.func.php');
  31. require_once(DEDEINC . '/oxwindow.class.php');
  32. $flag = isset($flags) ? join(',', $flags) : '';
  33. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  34. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  35. $channelid = -1;
  36. $money = 0;
  37. if (!isset($tags)) $tags = '';
  38. //处理自定义字段会用到这些变量
  39. if (!isset($autokey)) $autokey = 0;
  40. if (!isset($remote)) $remote = 0;
  41. if (!isset($dellink)) $dellink = 0;
  42. if (!isset($autolitpic)) $autolitpic = 0;
  43. //对保存的内容进行处理
  44. if (empty($writer)) $writer = $cuserLogin->getUserName();
  45. if (empty($source)) $source = '未知';
  46. $pubdate = GetMkTime($pubdate);
  47. $senddate = time();
  48. $sortrank = AddDay($pubdate, $sortup);
  49. if ($ishtml == 0) $ismake = -1;
  50. else $ismake = 0;
  51. $title = preg_replace('#"#', '"', $title);
  52. $title = cn_substrR($title, $cfg_title_maxlen);
  53. $shorttitle = cn_substrR($shorttitle, 36);
  54. $color = cn_substrR($color, 7);
  55. $writer = cn_substrR($writer, 20);
  56. $source = cn_substrR($source, 30);
  57. $description = cn_substrR($description, $cfg_auot_description);
  58. $keywords = cn_substrR($keywords, 60);
  59. $filename = trim(cn_substrR($filename, 40));
  60. $isremote = 0;
  61. $serviterm = empty($serviterm) ? "" : $serviterm;
  62. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  63. $adminid = $cuserLogin->getUserID();
  64. //处理上传的缩略图
  65. if (empty($ddisremote)) {
  66. $ddisremote = 0;
  67. }
  68. $litpic = GetDDImage('none', $picname, $ddisremote);
  69. // 处理新的缩略图上传
  70. if ($litpic_b64 != "") {
  71. $data = explode(',', $litpic_b64);
  72. $ntime = time();
  73. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  74. CreateDir($savepath);
  75. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  76. $fullUrl = $fullUrl . ".png";
  77. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  78. // 加水印
  79. WaterImg($cfg_basedir . $fullUrl, 'up');
  80. $litpic = $fullUrl;
  81. }
  82. //生成文档ID
  83. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  84. if (empty($arcID)) {
  85. ShowMsg("无法获得主键,无法进行后续操作!", "-1");
  86. exit();
  87. }
  88. //保存到主表
  89. $inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  90. color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename)
  91. VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  92. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','0','$notpost','$description','$keywords','$filename');";
  93. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  94. echo $inQuery;
  95. $gerr = $dsql->GetError();
  96. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  97. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。" . str_replace('"', '', $gerr), "javascript:;");
  98. exit();
  99. }
  100. //专题节点列表
  101. $arcids = array();
  102. $notelist = '';
  103. for ($i = 1; $i <= $cfg_specnote; $i++) {
  104. if (!empty(${'notename' . $i})) {
  105. $notename = str_replace("'", "", trim(${'notename' . $i}));
  106. $arcid = trim(${'arcid' . $i});
  107. $col = trim(${'col' . $i});
  108. $imgwidth = trim(${'imgwidth' . $i});
  109. $imgheight = trim(${'imgheight' . $i});
  110. $titlelen = trim(${'titlelen' . $i});
  111. $infolen = trim(${'infolen' . $i});
  112. $listtmp = trim(${'listtmp' . $i});
  113. $noteid = trim(${'noteid' . $i});
  114. $isauto = trim(${'isauto' . $i});
  115. $keywords = str_replace("'", "", trim(${'keywords' . $i}));
  116. $typeid = trim(${'typeid' . $i});
  117. if (!empty(${'rownum' . $i})) $rownum = trim(${'rownum' . $i});
  118. else $rownum = 0;
  119. $arcid = preg_replace("#[^0-9,]#", "", $arcid);
  120. $ids = explode(",", $arcid);
  121. $okids = "";
  122. if (is_array($ids)) {
  123. foreach ($ids as $mid) {
  124. $mid = trim($mid);
  125. if ($mid == "") continue;
  126. if (!isset($arcids[$mid])) {
  127. if ($okids == "") {
  128. $okids .= $mid;
  129. } else {
  130. $okids .= "," . $mid;
  131. }
  132. $arcids[$mid] = 1;
  133. }
  134. }
  135. }
  136. $notelist .= "{dede:specnote imgheight=\\'$imgheight\\' imgwidth=\\'$imgwidth\\'
  137. infolen=\\'$infolen\\' titlelen=\\'$titlelen\\' col=\\'$col\\' idlist=\\'$okids\\'
  138. name=\\'$notename\\' noteid=\\'$noteid\\' isauto=\'$isauto\' rownum=\\'$rownum\\'
  139. keywords=\\'$keywords\\' typeid=\\'$typeid\\'}
  140. $listtmp
  141. {/dede:specnote}\r\n";
  142. }
  143. }
  144. //分析处理附加表数据
  145. $inadd_f = '';
  146. $inadd_v = '';
  147. if (!empty($dede_addonfields)) {
  148. $addonfields = explode(';', $dede_addonfields);
  149. $inadd_f = '';
  150. $inadd_v = '';
  151. if (is_array($addonfields)) {
  152. foreach ($addonfields as $v) {
  153. if ($v == '') {
  154. continue;
  155. }
  156. $vs = explode(',', $v);
  157. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  158. {
  159. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  160. } else {
  161. if (!isset(${$vs[0]})) {
  162. ${$vs[0]} = '';
  163. }
  164. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  165. }
  166. $inadd_f .= ',' . $vs[0];
  167. $inadd_v .= " ,'" . ${$vs[0]} . "' ";
  168. }
  169. }
  170. }
  171. //处理图片文档的自定义属性
  172. if ($litpic != '' && !preg_match('#p#', $flag)) {
  173. $flag = ($flag == '' ? 'p' : $flag . ',p');
  174. }
  175. $useip = GetIP();
  176. //加入附加表
  177. $inQuery = "INSERT INTO `#@__addonspec`(aid,typeid,userip,templet,note{$inadd_f}) VALUES ('$arcID','$typeid','$useip','$templet','$notelist'{$inadd_v});";
  178. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  179. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  180. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  181. ShowMsg("把数据保存到数据库附加表 addonspec 时出错,请检查原因!", "-1");
  182. exit();
  183. }
  184. //生成HTML
  185. InsertTags($tags, $arcID);
  186. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  187. if ($artUrl == '') {
  188. $artUrl = $cfg_phpurl . "/view.php?aid=$arcID";
  189. }
  190. ClearMyAddon($arcID, $title);
  191. // 自动更新关联内容
  192. if (is_array($automake)) {
  193. foreach ($automake as $key => $value) {
  194. if (isset(${$key}) && !empty(${$key})) {
  195. $ids = explode(",", ${$key});
  196. foreach ($ids as $id) {
  197. MakeArt($id, true, true, $isremote);
  198. }
  199. }
  200. }
  201. }
  202. //返回成功信息
  203. $msg = "
  204.   请选择你的后续操作:
  205. <a href='spec_add.php?cid=$typeid' class='btn btn-success btn-sm'>创建新专题</a>
  206. &nbsp;&nbsp;
  207. <a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看专题</a>
  208. &nbsp;&nbsp;
  209. <a href='content_s_list.php' class='btn btn-success btn-sm'>已发布专题管理</a>
  210. ";
  211. $wintitle = "成功创建专题!";
  212. $wecome_info = "文章管理::发布专题";
  213. $win = new OxWindow();
  214. $win->AddTitle("成功创建专题:");
  215. $win->AddMsgItem($msg);
  216. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  217. $win->Display();
  218. }