国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

267 lignes
9.5KB

  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 - 2019, 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. $flag = '';
  78. $autokey = $remote = $dellink = $autolitpic = 0;
  79. $userip = GetIP();
  80. if($typeid==0)
  81. {
  82. ShowMsg('请指定文档隶属的栏目!','-1');
  83. exit();
  84. }
  85. $query = "SELECT tp.ispart,tp.channeltype,tp.issend,ch.issend AS cissend,ch.sendrank,ch.arcsta,ch.addtable,ch.fieldset,ch.usertype
  86. FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$typeid' ";
  87. $cInfos = $dsql->GetOne($query);
  88. //检测栏目是否有投稿权限
  89. if($cInfos['issend']!=1 || $cInfos['ispart']!=0 || $cInfos['channeltype']!=$channelid || $cInfos['cissend']!=1)
  90. {
  91. ShowMsg("你所选择的栏目不支持投稿!","-1");
  92. exit();
  93. }
  94. //检查频道设定的投稿许可权限
  95. if($cInfos['sendrank'] > $cfg_ml->M_Rank )
  96. {
  97. $row = $dsql->GetOne("Select membername From #@__arcrank where rank='".$cInfos['sendrank']."' ");
  98. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
  99. exit();
  100. }
  101. if($cInfos['usertype'] !='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
  102. {
  103. ShowMsg("对不起,需要[".$cInfos['usertype']."]才能在这个频道发布文档!","-1","0",5000);
  104. exit();
  105. }
  106. //文档的默认状态
  107. if($cInfos['arcsta']==0)
  108. {
  109. $arcrank = 0;
  110. }
  111. else if($cInfos['arcsta']==1)
  112. {
  113. $arcrank = 0;
  114. }
  115. else
  116. {
  117. $arcrank = -1;
  118. }
  119. //对保存的内容进行处理
  120. $sortrank = $senddate = $pubdate = time();
  121. $title = cn_substrR(HtmlReplace($title,1),$cfg_title_maxlen);
  122. $mid = $cfg_ml->M_ID;
  123. $description=empty($description)? "" : $description;
  124. //处理上传的缩略图
  125. $litpic = MemberUploads('litpic','',$cfg_ml->M_ID,'image','',$cfg_ddimg_width,$cfg_ddimg_height,false);
  126. if($litpic!='') SaveUploadInfo($title,$litpic,1);
  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. if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields.$cfg_cookie_encode))
  158. {
  159. showMsg('数据校验不对,程序返回', '-1');
  160. exit();
  161. }
  162. // 这里对前台提交的附加数据进行一次校验
  163. $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
  164. if ($fontiterm != str_replace('`', '', $inadd_f))
  165. {
  166. ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
  167. exit();
  168. }
  169. }
  170. //生成文档ID
  171. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$mid);
  172. if(empty($arcID))
  173. {
  174. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  175. exit();
  176. }
  177. //保存到附加表
  178. $addtable = trim($cInfos['addtable']);
  179. if(empty($addtable))
  180. {
  181. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  182. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作。","javascript:;");
  183. exit();
  184. }
  185. else
  186. {
  187. $inquery = "INSERT INTO `{$addtable}`(aid,typeid,arcrank,mid,channel,title,senddate,litpic,userip{$inadd_f}) Values('$arcID','$typeid','$arcrank','$mid','$channelid','$title','$senddate','$litpic','$userip'{$inadd_v})";
  188. if(!$dsql->ExecuteNoneQuery($inquery))
  189. {
  190. $gerr = $dsql->GetError();
  191. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  192. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员!","javascript:;");
  193. exit();
  194. }
  195. }
  196. //增加积分
  197. $dsql->ExecuteNoneQuery("Update `#@__member` set scores=scores+{$cfg_sendarc_scores} where mid='".$cfg_ml->M_ID."' ; ");
  198. //生成HTML
  199. $artUrl = MakeArt($arcID,true);
  200. if($artUrl=='') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  201. #api{{
  202. if(defined('UC_API') && @include_once DEDEROOT.'/api/uc.func.php')
  203. {
  204. //推送事件
  205. $feed['icon'] = 'thread';
  206. $feed['title_template'] = '<b>{username} 在网站发布了一篇内容</b>';
  207. $feed['title_data'] = array('username' => $cfg_ml->M_UserName);
  208. $feed['body_template'] = '<b>{subject}</b><br>{message}';
  209. $url = !strstr($artUrl,'http://') ? ($cfg_basehost.$artUrl) : $artUrl;
  210. $feed['body_data'] = array('subject' => "<a href=\"".$url."\">$title</a>", 'message' => cn_substr(strip_tags(preg_replace("/\[.+?\]/is", '', $description)), 150));
  211. $feed['images'][] = array('url' => $cfg_basehost.'/images/scores.gif', 'link'=> $cfg_basehost);
  212. uc_feed_note($cfg_ml->M_LoginID,$feed);
  213. //同步积分
  214. $row = $dsql->GetOne("SELECT `scores`,`userid` FROM `#@__member` WHERE `mid`='".$cfg_ml->M_ID."'");
  215. uc_credit_note($row['userid'],$cfg_sendarc_scores);
  216. }
  217. #/aip}}
  218. //会员动态记录
  219. $cfg_ml->RecordFeeds('add', $title, $description, $arcID);
  220. ClearMyAddon($arcID, $title);
  221. //返回成功信息
  222. $msg = "
  223.   请选择你的后续操作:
  224. <a href='archives_sg_add.php?channelid=$channelid'><u>继续发布内容</u></a>
  225. &nbsp;&nbsp;
  226. <a href='$artUrl' target='_blank'><u>查看内容</u></a>
  227. &nbsp;&nbsp;
  228. <a href='archives_sg_edit.php?channelid=$channelid&aid=$arcID'><u>更改内容</u></a>
  229. &nbsp;&nbsp;
  230. <a href='content_sg_list.php?channelid={$channelid}'><u>已发布内容管理</u></a>
  231. ";
  232. $wintitle = "成功发布内容!";
  233. $wecome_info = "内容管理::发布内容";
  234. $win = new OxWindow();
  235. $win->AddTitle("成功发布内容:");
  236. $win->AddMsgItem($msg);
  237. $winform = $win->GetWindow("hand","&nbsp;",false);
  238. $win->Display();
  239. }