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

167 lines
6.3KB

  1. <?php
  2. /**
  3. * 发布文章
  4. *
  5. * @version $Id: article_add.php 1 8:38 2010年7月9日Z tianya $
  6. * @package DedeCMS.Member
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__)."/config.php");
  13. require_once(DEDEINC."/dedetag.class.php");
  14. require_once(DEDEINC."/userlogin.class.php");
  15. require_once(DEDEINC."/customfields.func.php");
  16. require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
  17. require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
  18. $channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 1;
  19. $typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
  20. $mtypesid = isset($mtypesid) && is_numeric($mtypesid) ? $mtypesid : 0;
  21. $menutype = 'content';
  22. /*-------------
  23. function _ShowForm(){ }
  24. --------------*/
  25. if(empty($dopost))
  26. {
  27. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid'; ");
  28. //如果限制了会员级别或类型,则允许游客投稿选项无效
  29. if($cInfos['sendrank']>0 || $cInfos['usertype']!='') CheckRank(0,0);
  30. //检查会员等级和类型限制
  31. if($cInfos['sendrank'] > $cfg_ml->M_Rank)
  32. {
  33. $row = $dsql->GetOne("SELECT membername FROM `#@__arcrank` WHERE rank='".$cInfos['sendrank']."' ");
  34. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
  35. exit();
  36. }
  37. if($cInfos['usertype']!='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
  38. {
  39. ShowMsg("对不起,需要[".$cInfos['usertype']."帐号]才能在这个频道发布文档!","-1","0",5000);
  40. exit();
  41. }
  42. include(DEDEMEMBER."/templets/article_add.htm");
  43. exit();
  44. }
  45. /*------------------------------
  46. function _SaveArticle(){ }
  47. ------------------------------*/
  48. else if($dopost=='save')
  49. {
  50. include(DEDEMEMBER.'/inc/archives_check.php');
  51. //分析处理附加表数据
  52. $inadd_f = $inadd_v = '';
  53. if(!empty($dede_addonfields))
  54. {
  55. $addonfields = explode(';', $dede_addonfields);
  56. $inadd_f = '';
  57. $inadd_v = '';
  58. if(is_array($addonfields))
  59. {
  60. foreach($addonfields as $v)
  61. {
  62. if($v=='')
  63. {
  64. continue;
  65. }
  66. $vs = explode(',', $v);
  67. if(!isset(${$vs[0]}))
  68. {
  69. ${$vs[0]} = '';
  70. }
  71. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1],0);
  72. $inadd_f .= ','.$vs[0];
  73. $inadd_v .= " ,'".${$vs[0]}."' ";
  74. }
  75. }
  76. }
  77. // 这里对前台提交的附加数据进行一次校验
  78. $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
  79. if ($fontiterm != $inadd_f)
  80. {
  81. ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
  82. exit();
  83. }
  84. $body = AnalyseHtmlBody($body, $description);
  85. $body = HtmlReplace($body, -1);
  86. //生成文档ID
  87. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $mid);
  88. if(empty($arcID))
  89. {
  90. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  91. exit();
  92. }
  93. //保存到主表
  94. $inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  95. color,writer,source,litpic,pubdate,senddate,mid,description,keywords,mtype)
  96. VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle',
  97. '$color','$writer','$source','','$pubdate','$senddate','$mid','$description','$keywords','$mtypesid'); ";
  98. if(!$dsql->ExecuteNoneQuery($inQuery))
  99. {
  100. $gerr = $dsql->GetError();
  101. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  102. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请联系管理员。","javascript:;");
  103. exit();
  104. }
  105. //保存到附加表
  106. $addtable = trim($cInfos['addtable']);
  107. if(empty($addtable))
  108. {
  109. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  110. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  111. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
  112. exit();
  113. }
  114. else
  115. {
  116. $inquery = "INSERT INTO `{$addtable}`(aid,typeid,userip,redirecturl,templet,body{$inadd_f}) Values('$arcID','$typeid','$userip','','','$body'{$inadd_v})";
  117. if(!$dsql->ExecuteNoneQuery($inquery))
  118. {
  119. $gerr = $dsql->GetError();
  120. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  121. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  122. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员!","javascript:;");
  123. exit();
  124. }
  125. }
  126. //增加积分
  127. $dsql->ExecuteNoneQuery("UPDATE `#@__member` set scores=scores+{$cfg_sendarc_scores} WHERE mid='".$cfg_ml->M_ID."' ; ");
  128. //更新统计
  129. countArchives($channelid);
  130. //生成HTML
  131. InsertTags($tags, $arcID);
  132. $artUrl = MakeArt($arcID, TRUE);
  133. if($artUrl=='') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  134. ClearMyAddon($arcID, $title);
  135. //返回成功信息
  136. $msg =
  137. "请选择你的后续操作:
  138. <a href='article_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>继续发布文章</a>
  139. &nbsp;&nbsp;
  140. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看文章</a>
  141. &nbsp;&nbsp;
  142. <a href='article_edit.php?channelid=$channelid&aid=$arcID' class='btn btn-secondary btn-sm'>更改文章</a>
  143. &nbsp;&nbsp;
  144. <a href='content_list.php?channelid={$channelid}' class='btn btn-secondary btn-sm'>已发布文章管理</a>";
  145. $wintitle = "成功发布文章!";
  146. $wecome_info = "文章管理::发布文章";
  147. $win = new OxWindow();
  148. $win->AddTitle("成功发布文章:");
  149. $win->AddMsgItem($msg);
  150. $winform = $win->GetWindow("hand","&nbsp;",false);
  151. $win->Display();
  152. }