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

183 lines
6.7KB

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