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

117 line
5.2KB

  1. <?php
  2. /**
  3. * 修改分类文档模型
  4. *
  5. * @version $id:archives_sg_add.php 13:52 2010年7月9日 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. 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. if (empty($dopost)) {
  22. //读取归档信息
  23. $arcQuery = "SELECT ch.*,arc.* FROM `#@__arctiny` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='$aid' ";
  24. $cInfos = $dsql->GetOne($arcQuery);
  25. if (!is_array($cInfos)) {
  26. ShowMsg("读取文档信息出错", "index.php");
  27. exit();
  28. }
  29. $addRow = $dsql->GetOne("SELECT * FROM `{$cInfos['addtable']}` WHERE aid='$aid';");
  30. if ($addRow['mid'] != $cfg_ml->M_ID) {
  31. ShowMsg("您没有操作此文档权限", "-1");
  32. exit();
  33. }
  34. $addRow['id'] = $addRow['aid'];
  35. include(DEDEMEMBER."/templets/archives_sg_edit.htm");
  36. exit();
  37. } else if ($dopost == 'save') {
  38. require_once(DEDEINC."/image.func.php");
  39. require_once(DEDEINC."/libraries/oxwindow.class.php");
  40. $flag = '';
  41. $typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
  42. $userip = GetIP();
  43. if ($typeid == 0) {
  44. ShowMsg('您还没选择栏目,请选择发布文档栏目', '-1');
  45. exit();
  46. }
  47. $query = "SELECT tp.ispart,tp.channeltype,tp.issend,ch.issend AS cissend,ch.sendrank,ch.arcsta,ch.addtable,ch.fieldset,ch.usertype FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$typeid' ";
  48. $cInfos = $dsql->GetOne($query);
  49. $addtable = $cInfos['addtable'];
  50. //检测栏目是否有投稿权限
  51. if ($cInfos['issend'] != 1 || $cInfos['ispart'] != 0 || $cInfos['channeltype'] != $channelid || $cInfos['cissend'] != 1) {
  52. ShowMsg("您所选择的栏目不支持投稿", "-1");
  53. exit();
  54. }
  55. //校验CSRF
  56. CheckCSRF();
  57. //文档的默认状态
  58. if ($cInfos['arcsta'] == 0) {
  59. $arcrank = 0;
  60. } else if ($cInfos['arcsta'] == 1) {
  61. $arcrank = 0;
  62. } else {
  63. $arcrank = -1;
  64. }
  65. //对保存的文档进行处理
  66. $title = cn_substrR(HtmlReplace($title, 1), $cfg_title_maxlen);
  67. $mid = $cfg_ml->M_ID;
  68. //分析处理附加表数据
  69. $inadd_f = $inadd_m = '';
  70. if (!empty($dede_addonfields)) {
  71. $addonfields = explode(';', $dede_addonfields);
  72. if (is_array($addonfields)) {
  73. foreach ($addonfields as $v) {
  74. if ($v == '') {
  75. continue;
  76. }
  77. $vs = explode(',', $v);
  78. if (!isset(${$vs[0]})) {
  79. ${$vs[0]} = '';
  80. }
  81. //自动摘要和远程图片本地化
  82. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  83. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $vs[1]);
  84. }
  85. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $aid);
  86. $inadd_f .= ',`'.$vs[0]."` ='".${$vs[0]}."' ";
  87. $inadd_m .= ','.$vs[0];
  88. }
  89. }
  90. //这里对前台提交的附加数据进行一次校验
  91. $fontiterm = PrintAutoFieldsAdd(stripslashes($cInfos['fieldset']), 'autofield', FALSE);
  92. if ($fontiterm != $inadd_m) {
  93. ShowMsg("提交的信息有错误,请修改重新提交", "-1");
  94. exit();
  95. }
  96. }
  97. if ($addtable != '') {
  98. $litpic = isset($litpic)? HtmlReplace($litpic, 1) : '';
  99. $upQuery = "UPDATE `$addtable` SET `title`='$title',`typeid`='$typeid',`arcrank`='$arcrank',litpic='$litpic',userip='$userip'{$inadd_f} WHERE aid='$aid' ";
  100. if (!$dsql->ExecuteNoneQuery($upQuery)) {
  101. ShowMsg("数据保存到数据库附加表出错,请联系管理员", "javascript:;");
  102. exit();
  103. }
  104. }
  105. UpIndexKey($aid, 0, $typeid, $sortrank, '');
  106. $artUrl = MakeArt($aid, true);
  107. if ($artUrl == '') $artUrl = $cfg_phpurl."/view.php?aid=$aid";
  108. //返回成功信息
  109. $msg = "<a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>浏览分类文档</a><a href='archives_sg_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布分类文档</a><a href='archives_do.php?channelid=$channelid&aid=".$aid."&dopost=edit' class='btn btn-success btn-sm'>修改分类文档</a><a href='content_sg_list.php?channelid=$channelid' class='btn btn-success btn-sm'>管理分类文档</a>";
  110. $wintitle = "成功修改分类文档";
  111. $wecome_info = "文档管理 - 修改分类文档";
  112. $win = new OxWindow();
  113. $win->AddMsgItem("$msg");
  114. $winform = $win->GetWindow("hand", false);
  115. $win->Display(DEDEMEMBER."/templets/win_templet.htm");
  116. }
  117. ?>