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

242 lines
8.1KB

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