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

181 lines
5.9KB

  1. <?php
  2. /**
  3. * 单表模型编辑器
  4. *
  5. * @version $Id: archives_sg_add.php 1 13:52 2010年7月9日Z tianya $
  6. * @package DedeCMS.Member
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__)."/config.php");
  13. CheckRank(0,0);
  14. require_once(DEDEINC."/dedetag.class.php");
  15. require_once(DEDEINC."/customfields.func.php");
  16. require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
  17. require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
  18. $channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 1;
  19. $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
  20. $mtypesid = isset($mtypesid) && is_numeric($mtypesid) ? $mtypesid : 0;
  21. $menutype = 'content';
  22. /*-------------
  23. function _ShowForm(){ }
  24. --------------*/
  25. if(empty($dopost))
  26. {
  27. //读取归档信息
  28. $arcQuery = "SELECT ch.*,arc.* FROM `#@__arctiny` arc
  29. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='$aid' ";
  30. $cInfos = $dsql->GetOne($arcQuery);
  31. if(!is_array($cInfos))
  32. {
  33. ShowMsg("读取文档信息出错!","-1");
  34. exit();
  35. }
  36. $addRow = $dsql->GetOne("SELECT * FROM `{$cInfos['addtable']}` WHERE aid='$aid'; ");
  37. if($addRow['mid']!=$cfg_ml->M_ID)
  38. {
  39. ShowMsg("对不起,你没权限操作此文档!","-1");
  40. exit();
  41. }
  42. $addRow['id'] = $addRow['aid'];
  43. include(DEDEMEMBER."/templets/archives_sg_edit.htm");
  44. exit();
  45. }
  46. /*------------------------------
  47. function _SaveArticle(){ }
  48. ------------------------------*/
  49. else if($dopost=='save')
  50. {
  51. require_once(DEDEINC."/image.func.php");
  52. require_once(DEDEINC."/oxwindow.class.php");
  53. $flag = '';
  54. $typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
  55. $userip = GetIP();
  56. $svali = GetCkVdValue();
  57. if(preg_match("/3/",$safe_gdopen)){
  58. if(strtolower($vdcode)!=$svali || $svali=='')
  59. {
  60. ResetVdValue();
  61. ShowMsg('验证码错误!', '-1');
  62. exit();
  63. }
  64. }
  65. if($typeid==0)
  66. {
  67. ShowMsg('请指定文档隶属的栏目!','-1');
  68. exit();
  69. }
  70. $query = "SELECT tp.ispart,tp.channeltype,tp.issend,ch.issend AS cissend,ch.sendrank,ch.arcsta,ch.addtable,ch.fieldset,ch.usertype
  71. FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$typeid' ";
  72. $cInfos = $dsql->GetOne($query);
  73. $addtable = $cInfos['addtable'];
  74. //检测栏目是否有投稿权限
  75. if($cInfos['issend']!=1 || $cInfos['ispart']!=0|| $cInfos['channeltype']!=$channelid || $cInfos['cissend']!=1)
  76. {
  77. ShowMsg("你所选择的栏目不支持投稿!","-1");
  78. exit();
  79. }
  80. // 校验CSRF
  81. CheckCSRF();
  82. //文档的默认状态
  83. if($cInfos['arcsta']==0)
  84. {
  85. $arcrank = 0;
  86. }
  87. else if($cInfos['arcsta']==1)
  88. {
  89. $arcrank = 0;
  90. }
  91. else
  92. {
  93. $arcrank = -1;
  94. }
  95. //对保存的内容进行处理
  96. $title = cn_substrR(HtmlReplace($title, 1), $cfg_title_maxlen);
  97. $mid = $cfg_ml->M_ID;
  98. //分析处理附加表数据
  99. $inadd_f = $inadd_m = '';
  100. if(!empty($dede_addonfields))
  101. {
  102. $addonfields = explode(';',$dede_addonfields);
  103. if(is_array($addonfields))
  104. {
  105. foreach($addonfields as $v)
  106. {
  107. if($v=='')
  108. {
  109. continue;
  110. }
  111. $vs = explode(',',$v);
  112. if(!isset(${$vs[0]}))
  113. {
  114. ${$vs[0]} = '';
  115. }
  116. //自动摘要和远程图片本地化
  117. if($vs[1]=='htmltext'||$vs[1]=='textdata')
  118. {
  119. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$vs[1]);
  120. }
  121. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$aid);
  122. $inadd_f .= ',`'.$vs[0]."` ='".${$vs[0]}."' ";
  123. $inadd_m .= ','.$vs[0];
  124. }
  125. }
  126. // 这里对前台提交的附加数据进行一次校验
  127. $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
  128. if ($fontiterm != $inadd_m)
  129. {
  130. ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
  131. exit();
  132. }
  133. }
  134. if($addtable!='')
  135. {
  136. $upQuery = "UPDATE `$addtable` SET `title`='$title',`typeid`='$typeid',`arcrank`='$arcrank',userip='$userip'{$inadd_f} WHERE aid='$aid' ";
  137. if(!$dsql->ExecuteNoneQuery($upQuery))
  138. {
  139. ShowMsg("更新附加表 `$addtable` 时出错,请联系管理员!","javascript:;");
  140. exit();
  141. }
  142. }
  143. UpIndexKey($aid,0,$typeid,$sortrank,'');
  144. $artUrl = MakeArt($aid,true);
  145. if($artUrl=='') $artUrl = $cfg_phpurl."/view.php?aid=$aid";
  146. //返回成功信息
  147. $msg = "请选择你的后续操作:
  148. <a href='archives_sg_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>发布新内容</a>
  149. &nbsp;&nbsp;
  150. <a href='archives_do.php?channelid=$channelid&aid=".$aid."&dopost=edit' class='btn btn-secondary btn-sm'>查看更改</a>
  151. &nbsp;&nbsp;
  152. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看内容</a>
  153. &nbsp;&nbsp;
  154. <a href='content_sg_list.php?channelid=$channelid' class='btn btn-secondary btn-sm'>管理内容</a>
  155. ";
  156. $wintitle = "成功更改内容!";
  157. $wecome_info = "内容管理::更改内容";
  158. $win = new OxWindow();
  159. $win->AddTitle("成功更改内容:");
  160. $win->AddMsgItem($msg);
  161. $winform = $win->GetWindow("hand","&nbsp;",false);
  162. $win->Display();
  163. }