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

168 lines
7.5KB

  1. <?php
  2. /**
  3. * 单表模型发布器
  4. *
  5. * @version $Id: archives_sg_add.php 1 13:52 2010年7月9日Z tianya $
  6. * @package DedeBIZ.User
  7. * @copyright Copyright (c) 2022, 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. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid'; ");
  26. if (!is_array($cInfos)) {
  27. ShowMsg('模型不存在', '-1');
  28. exit();
  29. }
  30. //如果限制了会员级别或类型,则允许游客投稿选项无效
  31. if ($cInfos['sendrank'] > 0 || $cInfos['usertype'] != '') {
  32. CheckRank(0, 0);
  33. }
  34. //检查会员等级和类型限制
  35. if ($cInfos['sendrank'] > $cfg_ml->M_Rank) {
  36. $row = $dsql->GetOne("SELECT membername FROM `#@__arcrank` WHERE `rank`='".$cInfos['sendrank']."' ");
  37. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档", "-1", "0", 5000);
  38. exit();
  39. }
  40. if ($cInfos['usertype'] != '' && $cInfos['usertype'] != $cfg_ml->M_MbType) {
  41. ShowMsg("对不起,需要[".$cInfos['usertype']."帐号]才能在这个频道发布文档", "-1", "0", 5000);
  42. exit();
  43. }
  44. include(DEDEMEMBER."/templets/archives_sg_add.htm");
  45. exit();
  46. }
  47. /*------------------------------
  48. function _SaveArticle(){ }
  49. ------------------------------*/
  50. else if ($dopost == 'save') {
  51. include_once(DEDEINC."/image.func.php");
  52. include_once(DEDEINC."/libraries/oxwindow.class.php");
  53. $svali = GetCkVdValue();
  54. if (preg_match("/3/", $safe_gdopen)) {
  55. if (strtolower($vdcode) != $svali || $svali == '') {
  56. ResetVdValue();
  57. ShowMsg('验证码错误', '-1');
  58. exit();
  59. }
  60. }
  61. //校验CSRF
  62. CheckCSRF();
  63. $flag = '';
  64. $autokey = $remote = $dellink = $autolitpic = 0;
  65. $userip = GetIP();
  66. if ($typeid == 0) {
  67. ShowMsg('请指定文档隶属的栏目', '-1');
  68. exit();
  69. }
  70. $query = "SELECT tp.ispart,tp.channeltype,tp.issend,ch.issend AS cissend,ch.sendrank,ch.arcsta,ch.addtable,ch.fieldset,ch.usertype
  71. FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$typeid' ";
  72. $cInfos = $dsql->GetOne($query);
  73. //检测栏目是否有投稿权限
  74. if ($cInfos['issend'] != 1 || $cInfos['ispart'] != 0 || $cInfos['channeltype'] != $channelid || $cInfos['cissend'] != 1) {
  75. ShowMsg("您所选择的栏目不支持投稿", "-1");
  76. exit();
  77. }
  78. //检查频道设定的投稿许可权限
  79. if ($cInfos['sendrank'] > $cfg_ml->M_Rank) {
  80. $row = $dsql->GetOne("Select membername From #@__arcrank where `rank`='".$cInfos['sendrank']."' ");
  81. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档", "-1", "0", 5000);
  82. exit();
  83. }
  84. if ($cInfos['usertype'] != '' && $cInfos['usertype'] != $cfg_ml->M_MbType) {
  85. ShowMsg("对不起,需要[".$cInfos['usertype']."]才能在这个频道发布文档", "-1", "0", 5000);
  86. exit();
  87. }
  88. //文档的默认状态
  89. if ($cInfos['arcsta'] == 0) {
  90. $arcrank = 0;
  91. } else if ($cInfos['arcsta'] == 1) {
  92. $arcrank = 0;
  93. } else {
  94. $arcrank = -1;
  95. }
  96. //对保存的内容进行处理
  97. $sortrank = $senddate = $pubdate = time();
  98. $title = cn_substrR(HtmlReplace($title, 1), $cfg_title_maxlen);
  99. $mid = $cfg_ml->M_ID;
  100. $description = empty($description) ? "" : $description;
  101. //分析处理附加表数据
  102. $inadd_f = $inadd_v = '';
  103. if (!empty($dede_addonfields)) {
  104. $addonfields = explode(';', $dede_addonfields);
  105. $inadd_f = '';
  106. $inadd_v = '';
  107. if (is_array($addonfields)) {
  108. foreach ($addonfields as $v) {
  109. if ($v == '') {
  110. continue;
  111. }
  112. $vs = explode(',', $v);
  113. if (!isset(${$vs[0]})) {
  114. ${$vs[0]} = '';
  115. }
  116. //自动摘要和远程图片本地化
  117. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  118. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $vs[1]);
  119. }
  120. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], 0);
  121. $inadd_f .= ',`'.$vs[0].'`';
  122. $inadd_v .= " ,'".${$vs[0]}."' ";
  123. }
  124. }
  125. //这里对前台提交的附加数据进行一次校验
  126. $fontiterm = PrintAutoFieldsAdd(stripslashes($cInfos['fieldset']), 'autofield', FALSE);
  127. if ($fontiterm != str_replace('`', '', $inadd_f)) {
  128. ShowMsg("提交表单同系统配置不相符,请重新提交", "-1");
  129. exit();
  130. }
  131. }
  132. //生成文档ID
  133. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $mid);
  134. if (empty($arcID)) {
  135. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  136. exit();
  137. }
  138. //保存到附加表
  139. $addtable = trim($cInfos['addtable']);
  140. if (empty($addtable)) {
  141. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  142. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作", "javascript:;");
  143. exit();
  144. } else {
  145. $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})";
  146. if (!$dsql->ExecuteNoneQuery($inquery)) {
  147. $gerr = $dsql->GetError();
  148. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  149. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员", "javascript:;");
  150. exit();
  151. }
  152. }
  153. //增加积分
  154. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET scores=scores+{$cfg_sendarc_scores} WHERE mid='".$cfg_ml->M_ID."' ; ");
  155. //生成HTML
  156. $artUrl = MakeArt($arcID, true);
  157. if ($artUrl == '') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  158. ClearMyAddon($arcID, $title);
  159. //返回成功信息
  160. $msg = "请选择您的后续操作:<a href='archives_sg_add.php?channelid=$channelid' class='btn btn-success btn-sm'>继续发布文档</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看文档</a><a href='archives_sg_edit.php?channelid=$channelid&aid=$arcID' class='btn btn-success btn-sm'>修改文档</a><a href='content_sg_list.php?channelid={$channelid}' class='btn btn-success btn-sm'>已发布文档管理</a>";
  161. $wintitle = "成功发布文档";
  162. $wecome_info = "内容管理::发布文档";
  163. $win = new OxWindow();
  164. $win->AddTitle("成功发布文档");
  165. $win->AddMsgItem($msg);
  166. $winform = $win->GetWindow("hand", "&nbsp;", false);
  167. $win->Display(DEDEMEMBER."/templets/win_templet.htm");
  168. }