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

115 line
5.1KB

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