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

151 lines
6.2KB

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