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

229 lines
7.8KB

  1. <?php
  2. /**
  3. * 单表模型发布器
  4. *
  5. * @version $Id: archives_sg_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(dirname(__FILE__)."/inc/inc_catalog_options.php");
  16. require_once(dirname(__FILE__)."/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_sg_add.htm");
  50. exit();
  51. }
  52. /*------------------------------
  53. function _SaveArticle(){ }
  54. ------------------------------*/
  55. else if($dopost=='save')
  56. {
  57. include_once(DEDEINC."/image.func.php");
  58. include_once(DEDEINC."/oxwindow.class.php");
  59. $svali = GetCkVdValue();
  60. if(preg_match("/3/", $safe_gdopen)){
  61. if(strtolower($vdcode)!=$svali || $svali=='')
  62. {
  63. ResetVdValue();
  64. ShowMsg('验证码错误!', '-1');
  65. exit();
  66. }
  67. }
  68. // 校验CSRF
  69. CheckCSRF();
  70. $flag = '';
  71. $autokey = $remote = $dellink = $autolitpic = 0;
  72. $userip = GetIP();
  73. if($typeid==0)
  74. {
  75. ShowMsg('请指定文档隶属的栏目!','-1');
  76. exit();
  77. }
  78. $query = "SELECT tp.ispart,tp.channeltype,tp.issend,ch.issend AS cissend,ch.sendrank,ch.arcsta,ch.addtable,ch.fieldset,ch.usertype
  79. FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$typeid' ";
  80. $cInfos = $dsql->GetOne($query);
  81. //检测栏目是否有投稿权限
  82. if($cInfos['issend']!=1 || $cInfos['ispart']!=0 || $cInfos['channeltype']!=$channelid || $cInfos['cissend']!=1)
  83. {
  84. ShowMsg("你所选择的栏目不支持投稿!","-1");
  85. exit();
  86. }
  87. //检查频道设定的投稿许可权限
  88. if($cInfos['sendrank'] > $cfg_ml->M_Rank )
  89. {
  90. $row = $dsql->GetOne("Select membername From #@__arcrank where rank='".$cInfos['sendrank']."' ");
  91. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
  92. exit();
  93. }
  94. if($cInfos['usertype'] !='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
  95. {
  96. ShowMsg("对不起,需要[".$cInfos['usertype']."]才能在这个频道发布文档!","-1","0",5000);
  97. exit();
  98. }
  99. //文档的默认状态
  100. if($cInfos['arcsta']==0)
  101. {
  102. $arcrank = 0;
  103. }
  104. else if($cInfos['arcsta']==1)
  105. {
  106. $arcrank = 0;
  107. }
  108. else
  109. {
  110. $arcrank = -1;
  111. }
  112. //对保存的内容进行处理
  113. $sortrank = $senddate = $pubdate = time();
  114. $title = cn_substrR(HtmlReplace($title,1),$cfg_title_maxlen);
  115. $mid = $cfg_ml->M_ID;
  116. $description=empty($description)? "" : $description;
  117. //分析处理附加表数据
  118. $inadd_f = $inadd_v = '';
  119. if(!empty($dede_addonfields))
  120. {
  121. $addonfields = explode(';',$dede_addonfields);
  122. $inadd_f = '';
  123. $inadd_v = '';
  124. if(is_array($addonfields))
  125. {
  126. foreach($addonfields as $v)
  127. {
  128. if($v=='')
  129. {
  130. continue;
  131. }
  132. $vs = explode(',',$v);
  133. if(!isset(${$vs[0]}))
  134. {
  135. ${$vs[0]} = '';
  136. }
  137. //自动摘要和远程图片本地化
  138. if($vs[1]=='htmltext'||$vs[1]=='textdata')
  139. {
  140. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$vs[1]);
  141. }
  142. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],0);
  143. $inadd_f .= ',`'.$vs[0].'`';
  144. $inadd_v .= " ,'".${$vs[0]}."' ";
  145. }
  146. }
  147. // 这里对前台提交的附加数据进行一次校验
  148. $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
  149. if ($fontiterm != str_replace('`', '', $inadd_f))
  150. {
  151. ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
  152. exit();
  153. }
  154. }
  155. //生成文档ID
  156. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$mid);
  157. if(empty($arcID))
  158. {
  159. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  160. exit();
  161. }
  162. //保存到附加表
  163. $addtable = trim($cInfos['addtable']);
  164. if(empty($addtable))
  165. {
  166. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  167. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作。","javascript:;");
  168. exit();
  169. }
  170. else
  171. {
  172. $inquery = "INSERT INTO `{$addtable}`(aid,typeid,arcrank,mid,channel,title,senddate,litpic,userip{$inadd_f}) Values('$arcID','$typeid','$arcrank','$mid','$channelid','$title','$senddate','','$userip'{$inadd_v})";
  173. if(!$dsql->ExecuteNoneQuery($inquery))
  174. {
  175. $gerr = $dsql->GetError();
  176. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  177. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员!","javascript:;");
  178. exit();
  179. }
  180. }
  181. //增加积分
  182. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET scores=scores+{$cfg_sendarc_scores} WHERE mid='".$cfg_ml->M_ID."' ; ");
  183. //生成HTML
  184. $artUrl = MakeArt($arcID,true);
  185. if($artUrl=='') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  186. ClearMyAddon($arcID, $title);
  187. //返回成功信息
  188. $msg = "
  189.   请选择你的后续操作:
  190. <a href='archives_sg_add.php?channelid=$channelid' class='btn btn-secondary btn-sm'>继续发布内容</a>
  191. &nbsp;&nbsp;
  192. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看内容</a>
  193. &nbsp;&nbsp;
  194. <a href='archives_sg_edit.php?channelid=$channelid&aid=$arcID' class='btn btn-secondary btn-sm'>更改内容</a>
  195. &nbsp;&nbsp;
  196. <a href='content_sg_list.php?channelid={$channelid}' class='btn btn-secondary btn-sm'>已发布内容管理</a>
  197. ";
  198. $wintitle = "成功发布内容!";
  199. $wecome_info = "内容管理::发布内容";
  200. $win = new OxWindow();
  201. $win->AddTitle("成功发布内容:");
  202. $win->AddMsgItem($msg);
  203. $winform = $win->GetWindow("hand","&nbsp;",false);
  204. $win->Display();
  205. }