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

article_add.php 9.2KB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php
  2. /**
  3. * 发布文档模型
  4. *
  5. * @version $id:article_add.php 2020年9月14日 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 (file_exists(DEDEDATA.'/template.rand.php')) {
  16. require_once(DEDEDATA.'/template.rand.php');
  17. }
  18. if (empty($dopost)) $dopost = '';
  19. if ($dopost != 'save') {
  20. require_once(DEDEINC."/dedetag.class.php");
  21. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  22. ClearMyAddon();
  23. $channelid = empty($channelid) ? 0 : intval($channelid);
  24. $cid = empty($cid) ? 0 : intval($cid);
  25. if (empty($geturl)) $geturl = '';
  26. $keywords = $writer = $source = $body = $description = $title = '';
  27. //获得栏目模型id
  28. if ($cid > 0 && $channelid == 0) {
  29. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid';");
  30. $channelid = $row['channeltype'];
  31. } else {
  32. if ($channelid == 0) {
  33. $channelid = 1;
  34. }
  35. }
  36. //获得栏目模型信息
  37. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  38. //获取文档最大id+1以确定当前权重
  39. $maxWright = $dsql->GetOne("SELECT id+1 AS cc FROM `#@__archives` ORDER BY id DESC LIMIT 1");
  40. $maxWright = empty($maxWright)? array('cc'=>1) : $maxWright;
  41. include DedeInclude("templets/article_add.htm");
  42. exit();
  43. } else if ($dopost == 'save') {
  44. require_once(DEDEINC.'/image.func.php');
  45. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  46. $flag = isset($flags) ? join(',', $flags) : '';
  47. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  48. if (empty($typeid2)) $typeid2 = '';
  49. if (!isset($autokey)) $autokey = 0;
  50. if (!isset($remote)) $remote = 0;
  51. if (!isset($dellink)) $dellink = 0;
  52. if (!isset($autolitpic)) $autolitpic = 0;
  53. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(1000,6000) : $cfg_arc_click);
  54. if (empty($typeid)) {
  55. ShowMsg("请指定文档的栏目", "-1");
  56. exit();
  57. }
  58. if (empty($channelid)) {
  59. ShowMsg("文档为非指定类型,请检查您发布文档是否正确", "-1");
  60. exit();
  61. }
  62. if (!CheckChannel($typeid, $channelid)) {
  63. ShowMsg("您所选择的栏目与当前模型不相符,请重新选择", "-1");
  64. exit();
  65. }
  66. if (!TestPurview('a_New')) {
  67. CheckCatalog($typeid, "您没有操作栏目<span class='text-primary'>{$typeid}</span>权限");
  68. }
  69. //对保存的文档进行处理
  70. if (empty($writer)) $writer = $cuserLogin->getUserName();
  71. if (empty($source)) $source = '未知';
  72. $pubdate = GetMkTime($pubdate);
  73. $senddate = time();
  74. $sortrank = AddDay($pubdate, $sortup);
  75. $ismake = $ishtml == 0 ? -1 : 0;
  76. $title = preg_replace("#\"#", '"', $title);
  77. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  78. $shorttitle = cn_substrR($shorttitle, 36);
  79. $color = cn_substrR($color, 7);
  80. $writer = cn_substrR($writer, 20);
  81. $source = cn_substrR($source, 30);
  82. $description = cn_substrR($description, $cfg_auot_description);
  83. $keywords = cn_substrR($keywords, 60);
  84. $filename = trim(cn_substrR($filename, 40));
  85. $userip = GetIP();
  86. $isremote = 0;
  87. $serviterm = empty($serviterm) ? "" : $serviterm;
  88. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  89. $arcrank = -1;
  90. }
  91. $adminid = $cuserLogin->getUserID();
  92. //处理上传的缩略图
  93. if (empty($ddisremote)) {
  94. $ddisremote = 0;
  95. }
  96. $litpic = GetDDImage('none', $picname, $ddisremote);
  97. //生成文档id
  98. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  99. if (empty($arcID)) {
  100. ShowMsg("获取主键失败,无法进行后续操作", "-1");
  101. exit();
  102. }
  103. if (trim($title) == '') {
  104. ShowMsg('标题不能为空', '-1');
  105. exit();
  106. }
  107. //处理body字段自动摘要、自动提取缩略图等
  108. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  109. //自动分页
  110. if ($sptype == 'auto') {
  111. $body = SpLongBody($body, $spsize * 1024, "#p#分页标题#e#");
  112. }
  113. //分析处理附加表数据
  114. $inadd_f = $inadd_v = '';
  115. if (!empty($dede_addonfields)) {
  116. $addonfields = explode(';', $dede_addonfields);
  117. if (is_array($addonfields)) {
  118. foreach ($addonfields as $v) {
  119. if ($v == '') continue;
  120. $vs = explode(',', $v);
  121. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  122. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  123. } else {
  124. if (!isset(${$vs[0]})) ${$vs[0]} = '';
  125. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  126. }
  127. $inadd_f .= ','.$vs[0];
  128. $inadd_v .= " ,'".${$vs[0]}."' ";
  129. }
  130. }
  131. }
  132. //处理图片文档的自定义属性
  133. if ($litpic != '' && !preg_match("#p#", $flag)) {
  134. $flag = ($flag == '' ? 'p' : $flag.',p');
  135. }
  136. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  137. $flag = ($flag == '' ? 'j' : $flag.',j');
  138. }
  139. //跳转网址的文档强制为动态
  140. if (preg_match("#j#", $flag)) $ismake = -1;
  141. //保存到主表
  142. $query = "INSERT INTO `#@__archives` (id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight) VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  143. if (!$dsql->ExecuteNoneQuery($query)) {
  144. $gerr = $dsql->GetError();
  145. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  146. ShowMsg("数据保存到数据库文档主表出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  147. exit();
  148. }
  149. //保存到附加表
  150. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  151. $addtable = trim($cts['addtable']);
  152. if (empty($addtable)) {
  153. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  154. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  155. ShowMsg("没找到模型<span class='text-primary'>{$channelid}</span>主表信息,无法完成操作", "javascript:;");
  156. exit();
  157. }
  158. $useip = GetIP();
  159. $templet = empty($templet) ? '' : $templet;
  160. $query = "INSERT INTO `{$addtable}` (aid,typeid,redirecturl,templet,userip,body{$inadd_f}) VALUES ('$arcID','$typeid','$redirecturl','$templet','$useip','$body'{$inadd_v})";
  161. if (!$dsql->ExecuteNoneQuery($query)) {
  162. $gerr = $dsql->GetError();
  163. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  164. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  165. ShowMsg("数据保存到数据库附加表出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  166. exit();
  167. }
  168. //生成网页
  169. InsertTags($tags, $arcID);
  170. $picTitle = false;
  171. if (count($_SESSION['bigfile_info']) > 0) {
  172. foreach ($_SESSION['bigfile_info'] as $k => $v) {
  173. if (!empty($v)) {
  174. $pictitle = ${'picinfook'.$k};
  175. $titleSet = '';
  176. if (!empty($pictitle)) {
  177. $picTitle = TRUE;
  178. $titleSet = ",title='{$pictitle}'";
  179. }
  180. $dsql->ExecuteNoneQuery("UPDATE `#@__uploads` SET arcid='{$arcID}'{$titleSet} WHERE url LIKE '{$v}';");
  181. }
  182. }
  183. }
  184. $artUrl = MakeArt($arcID, true, true, $isremote);
  185. if ($artUrl == '') {
  186. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  187. }
  188. ClearMyAddon($arcID, $title);
  189. //自动更新关联文档
  190. if (is_array($automake)) {
  191. foreach ($automake as $key => $value) {
  192. if (isset(${$key}) && !empty(${$key})) {
  193. $ids = explode(",", ${$key});
  194. foreach ($ids as $id) {
  195. MakeArt($id, true, true, $isremote);
  196. }
  197. }
  198. }
  199. }
  200. //返回成功信息
  201. $msg = "<tr><td>请选择后续操作:<a href='article_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布文档</a><a href='archives_do.php?aid=".$arcID."&dopost=editArchives' class='btn btn-success btn-sm'>修改文档</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>浏览文档</a><a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>管理文档</a>$backurl</td></tr>";
  202. $msg = "{$msg}".GetUpdateTest();
  203. $wintitle = "成功发布文档";
  204. $wecome_info = "文档管理 - 发布文档";
  205. $win = new OxWindow();
  206. $win->AddTitle("成功发布文档");
  207. $win->AddMsgItem($msg);
  208. $winform = $win->GetWindow("hand", false);
  209. $win->Display();
  210. }
  211. ?>