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

184 lines
6.8KB

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