国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

166 řádky
6.2KB

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