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

240 lines
8.2KB

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