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

179 lines
5.7KB

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