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

180 lines
8.3KB

  1. <?php
  2. /**
  3. * 图集发布
  4. *
  5. * @version $Id: album_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. //考虑安全原因不管是否开启游客投稿功能,都不允许用户对图集投稿
  13. CheckRank(0, 0);
  14. if ($cfg_mb_lit == 'Y') {
  15. ShowMsg("由于系统开启了精简版会员空间,您访问的功能不可用", "-1");
  16. exit();
  17. }
  18. if ($cfg_mb_album == 'N') {
  19. ShowMsg("对不起,由于系统关闭了图集功能,您访问的功能不可用", "-1");
  20. exit();
  21. }
  22. require_once(DEDEINC."/dedetag.class.php");
  23. require_once(DEDEINC."/userlogin.class.php");
  24. require_once(DEDEINC."/customfields.func.php");
  25. require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
  26. require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
  27. $channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 2;
  28. $typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
  29. $menutype = 'content';
  30. if (empty($formhtml)) $formhtml = 0;
  31. /*-------------
  32. function _ShowForm(){ }
  33. --------------*/
  34. if (empty($dopost)) {
  35. $query = "SELECT * FROM `#@__channeltype` WHERE id='$channelid'; ";
  36. $cInfos = $dsql->GetOne($query);
  37. if (!is_array($cInfos)) {
  38. ShowMsg('模型参数不正确', '-1');
  39. exit();
  40. }
  41. //检查会员等级和类型限制
  42. if ($cInfos['sendrank'] > $cfg_ml->M_Rank) {
  43. $row = $dsql->GetOne("Select membername From `#@__arcrank` where `rank`='".$cInfos['sendrank']."' ");
  44. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档", "-1", "0", 5000);
  45. exit();
  46. }
  47. if ($cInfos['usertype'] != '' && $cInfos['usertype'] != $cfg_ml->M_MbType) {
  48. ShowMsg("对不起,需要[".$cInfos['usertype']."帐号]才能在这个频道发布文档", "-1", "0", 5000);
  49. exit();
  50. }
  51. include(DEDEMEMBER."/templets/album_add.htm");
  52. exit();
  53. }
  54. /*------------------------------
  55. function _SaveArticle(){ }
  56. ------------------------------*/
  57. else if ($dopost == 'save') {
  58. include(DEDEMEMBER.'/inc/archives_check.php');
  59. $svali = GetCkVdValue();
  60. if (preg_match("/1/", $safe_gdopen)) {
  61. if (strtolower($vdcode) != $svali || $svali == '') {
  62. ResetVdValue();
  63. ShowMsg('验证码错误', '-1');
  64. exit();
  65. }
  66. }
  67. $cInfos = $dsql->GetOne("Select * From `#@__channeltype` where id='$channelid'; ");
  68. $maxwidth = isset($maxwidth) && is_numeric($maxwidth) ? $maxwidth : 800;
  69. $pagepicnum = isset($pagepicnum) && is_numeric($pagepicnum) ? $pagepicnum : 12;
  70. $ddmaxwidth = isset($ddmaxwidth) && is_numeric($ddmaxwidth) ? $ddmaxwidth : 200;
  71. $prow = isset($prow) && is_numeric($prow) ? $prow : 3;
  72. $pcol = isset($pcol) && is_numeric($pcol) ? $pcol : 3;
  73. $pagestyle = in_array($pagestyle, array('1', '2', '3')) ? $pagestyle : 2;
  74. include(DEDEMEMBER.'/inc/archives_check.php');
  75. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$prow' col='$pcol' value='$pagestyle'/}\r\n";
  76. $hasone = false;
  77. $ddisfirst = 1;
  78. //只支持填写地址
  79. for ($i = 1; $i <= 120; $i++) {
  80. if (!isset(${'imgfile'.$i})) {
  81. continue;
  82. }
  83. $f = ${'imgfile'.$i};
  84. $msg = isset(${'imgmsg'.$i}) ? ${'imgmsg'.$i} : "";
  85. if (!empty($f) && filter_var($f, FILTER_VALIDATE_URL)) {
  86. $u = str_replace(array("\"", "'"), "`", $f);
  87. $info = str_replace(array("\"", "'"), "`", $msg);
  88. $imgurls .= "{dede:img ddimg='' text='$info'} $u {/dede:img}\r\n";
  89. }
  90. } //循环结束
  91. $imgurls = addslashes($imgurls);
  92. //分析处理附加表数据
  93. $isrm = 1;
  94. if (!isset($formhtml)) {
  95. $formhtml = 0;
  96. }
  97. $inadd_f = $inadd_v = '';
  98. if (!empty($dede_addonfields)) {
  99. $addonfields = explode(';', $dede_addonfields);
  100. $inadd_f = '';
  101. $inadd_v = '';
  102. if (is_array($addonfields)) {
  103. foreach ($addonfields as $v) {
  104. if ($v == '') {
  105. continue;
  106. }
  107. $vs = explode(',', $v);
  108. if (!isset(${$vs[0]})) {
  109. ${$vs[0]} = '';
  110. }
  111. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], 0);
  112. $inadd_f .= ','.$vs[0];
  113. $inadd_v .= " ,'".${$vs[0]}."' ";
  114. }
  115. }
  116. //这里对前台提交的附加数据进行一次校验
  117. $fontiterm = PrintAutoFieldsAdd(stripslashes($cInfos['fieldset']), 'autofield', FALSE);
  118. if ($fontiterm != $inadd_f) {
  119. ShowMsg("提交表单同系统配置不相符,请重新提交", "-1");
  120. exit();
  121. }
  122. }
  123. //生成文档ID
  124. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $mid);
  125. if (empty($arcID)) {
  126. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  127. exit();
  128. }
  129. $description = HtmlReplace($description, -1);
  130. $mtypesid = intval($mtypesid); //对输入参数mtypesid未进行int整型转义,导致SQL注入的发生
  131. //保存到主表
  132. $inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  133. color,writer,source,litpic,pubdate,senddate,mid,description,keywords,mtype)
  134. VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle',
  135. '$color','$writer','$source','','$pubdate','$senddate','$mid','$description','$keywords','$mtypesid'); ";
  136. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  137. $gerr = $dsql->GetError();
  138. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  139. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请联系管理员", "javascript:;");
  140. exit();
  141. }
  142. //保存到附加表
  143. $addtable = trim($cInfos['addtable']);
  144. if (empty($addtable)) {
  145. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  146. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  147. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作", "javascript:;");
  148. exit();
  149. } else {
  150. $query = "INSERT INTO `$addtable`(aid,typeid,userip,redirecturl,templet,pagestyle,maxwidth,imgurls,`row`,col,isrm,ddmaxwidth,pagepicnum{$inadd_f})
  151. Values('$arcID','$typeid','$userip','','','$pagestyle','$maxwidth','$imgurls','$prow','$pcol','$isrm','$ddmaxwidth','$pagepicnum'{$inadd_v}); ";
  152. if (!$dsql->ExecuteNoneQuery($query)) {
  153. $gerr = $dsql->GetError();
  154. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  155. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  156. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员".$gerr, "javascript:;");
  157. exit();
  158. }
  159. }
  160. //增加积分
  161. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET scores=scores+{$cfg_sendarc_scores} WHERE mid='".$cfg_ml->M_ID."' ; ");
  162. //更新统计
  163. countArchives($channelid);
  164. //生成HTML
  165. InsertTags($tags, $arcID);
  166. $artUrl = MakeArt($arcID, true);
  167. if ($artUrl == '') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  168. ClearMyAddon($arcID, $title);
  169. //返回成功信息
  170. $msg = "请选择您的后续操作:<a href='album_add.php?cid=$typeid' class='btn btn-success btn-sm'>继续发布图集</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看图集</a><a href='album_edit.php?aid=".$arcID."&channelid=$channelid' class='btn btn-success btn-sm'>修改图集</a><a href='content_list.php?channelid={$channelid}' class='btn btn-success btn-sm'>已发布图集管理</a>";
  171. $wintitle = "成功发布图集";
  172. $wecome_info = "图集管理::发布图集";
  173. $win = new OxWindow();
  174. $win->AddTitle("成功发布图集:");
  175. $win->AddMsgItem($msg);
  176. $winform = $win->GetWindow("hand", "&nbsp;", false);
  177. $win->Display(DEDEMEMBER."/templets/win_templet.htm");
  178. }