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

161 lines
7.3KB

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