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

139 lines
6.5KB

  1. <?php
  2. /**
  3. * 文档发布器
  4. *
  5. * @version $Id: archives_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(DEDEMEMBER."/inc/inc_catalog_options.php");
  16. require_once(DEDEMEMBER."/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_add.htm");
  45. exit();
  46. }
  47. /*------------------------------
  48. function _SaveArticle(){ }
  49. ------------------------------*/
  50. else if ($dopost == 'save') {
  51. include(dirname(__FILE__).'/inc/archives_check.php');
  52. //分析处理附加表数据
  53. $inadd_f = $inadd_v = '';
  54. if (!empty($dede_addonfields)) {
  55. $addonfields = explode(';', $dede_addonfields);
  56. $inadd_f = '';
  57. $inadd_v = '';
  58. if (is_array($addonfields)) {
  59. foreach ($addonfields as $v) {
  60. if ($v == '') {
  61. continue;
  62. }
  63. $vs = explode(',', $v);
  64. if (!isset(${$vs[0]})) {
  65. ${$vs[0]} = '';
  66. }
  67. //自动摘要和远程图片本地化
  68. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  69. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $vs[1]);
  70. }
  71. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], 0);
  72. $inadd_f .= ','.$vs[0];
  73. $inadd_v .= " ,'".${$vs[0]}."' ";
  74. }
  75. }
  76. //这里对前台提交的附加数据进行一次校验
  77. $fontiterm = PrintAutoFieldsAdd(stripslashes($cInfos['fieldset']), 'autofield', FALSE);
  78. if ($fontiterm != $inadd_f) {
  79. ShowMsg("提交表单同系统配置不相符,请重新提交", "-1");
  80. exit();
  81. }
  82. }
  83. //处理图片文档的自定义属性
  84. if ($litpic != '') $flag = 'p';
  85. //生成文档ID
  86. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $mid);
  87. if (empty($arcID)) {
  88. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  89. exit();
  90. }
  91. //保存到主表
  92. $inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,description,keywords,mtype)
  93. VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$mid','$description','$keywords','$mtypesid'); ";
  94. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  95. $gerr = $dsql->GetError();
  96. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID' ");
  97. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请联系管理员", "javascript:;");
  98. exit();
  99. }
  100. //保存到附加表
  101. $addtable = trim($cInfos['addtable']);
  102. if (empty($addtable)) {
  103. $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
  104. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  105. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作", "javascript:;");
  106. exit();
  107. } else {
  108. $inquery = "INSERT INTO `{$addtable}`(aid,typeid,userip,redirecturl,templet{$inadd_f}) Values('$arcID','$typeid','$userip','',''{$inadd_v})";
  109. if (!$dsql->ExecuteNoneQuery($inquery)) {
  110. $gerr = $dsql->GetError();
  111. $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
  112. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  113. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错<br>error:{$gerr},请联系管理员", "javascript:;");
  114. exit();
  115. }
  116. }
  117. //增加积分
  118. $dsql->ExecuteNoneQuery("Update `#@__member` set scores=scores+{$cfg_sendarc_scores} where mid='".$cfg_ml->M_ID."' ; ");
  119. //更新统计
  120. countArchives($channelid);
  121. //生成HTML
  122. InsertTags($tags, $arcID);
  123. $artUrl = MakeArt($arcID, true);
  124. if ($artUrl == '') {
  125. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  126. }
  127. ClearMyAddon($arcID, $title);
  128. //返回成功信息
  129. $msg = "请选择您的后续操作:<a href='archives_add.php?cid=$typeid&channelid=$channelid' class='btn btn-success btn-sm'>继续发布文档</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看文档</a><a href='archives_edit.php?channelid=$channelid&aid=$arcID' class='btn btn-success btn-sm'>修改文档</a><a href='content_list.php?channelid={$channelid}' class='btn btn-success btn-sm'>已发布文档管理</a>";
  130. $wintitle = "成功发布文档";
  131. $wecome_info = "内容管理::发布文档";
  132. $win = new OxWindow();
  133. $win->AddTitle("成功发布文档");
  134. $win->AddMsgItem($msg);
  135. $winform = $win->GetWindow("hand", "&nbsp;", false);
  136. $win->Display(DEDEMEMBER."/templets/win_templet.htm");
  137. }