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

201 lines
7.7KB

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