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

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