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

173 lines
7.8KB

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