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

152 lines
6.6KB

  1. <?php
  2. /**
  3. * 单表模型文档发布
  4. *
  5. * @version $Id: archives_sg_add.php 1 8:26 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  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. CheckPurview('a_New,a_AccNew');
  13. require_once(DEDEINC."/customfields.func.php");
  14. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  15. if (empty($dopost)) $dopost = '';
  16. if ($dopost != 'save') {
  17. require_once(DEDEINC."/dedetag.class.php");
  18. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  19. ClearMyAddon();
  20. $channelid = empty($channelid) ? 0 : intval($channelid);
  21. $cid = empty($cid) ? 0 : intval($cid);
  22. //获得频道模型ID
  23. if ($cid > 0 && $channelid == 0) {
  24. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid'; ");
  25. $channelid = $row['channeltype'];
  26. } else {
  27. if ($channelid == 0) {
  28. ShowMsg("无法识别模型信息,因此无法操作", "-1");
  29. exit();
  30. }
  31. }
  32. //获得频道模型信息
  33. $cInfos = $dsql->GetOne(" SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  34. $channelid = $cInfos['id'];
  35. include DedeInclude("templets/archives_sg_add.htm");
  36. exit();
  37. }
  38. /*--------------------------------
  39. function __save(){ }
  40. -------------------------------*/
  41. else if ($dopost == 'save') {
  42. require_once(DEDEINC.'/image.func.php');
  43. require_once(DEDEINC.'/oxwindow.class.php');
  44. if ($typeid == 0) {
  45. ShowMsg("请指定文档的栏目", "-1");
  46. exit();
  47. }
  48. if (empty($channelid)) {
  49. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  50. exit();
  51. }
  52. if (!CheckChannel($typeid, $channelid)) {
  53. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  54. exit();
  55. }
  56. if (!TestPurview('a_New')) {
  57. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的权限");
  58. }
  59. //对保存的内容进行处理
  60. if (empty($writer)) $writer = $cuserLogin->getUserName();
  61. if (empty($source)) $source = '未知';
  62. if (empty($flags)) $flag = '';
  63. else $flag = join(',', $flags);
  64. $senddate = time();
  65. if (empty($litpic_b64)) $litpic_b64 = '';
  66. $title = cn_substrR($title, $cfg_title_maxlen);
  67. $isremote = 0;
  68. $serviterm = empty($serviterm) ? "" : $serviterm;
  69. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  70. $adminid = $cuserLogin->getUserID();
  71. $userip = GetIP();
  72. if (empty($ddisremote)) $ddisremote = 0;
  73. $litpic = GetDDImage('none', $picname, $ddisremote);
  74. //处理新的缩略图上传
  75. if ($litpic_b64 != "") {
  76. $data = explode(',', $litpic_b64);
  77. $ntime = time();
  78. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  79. CreateDir($savepath);
  80. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  81. $fullUrl = $fullUrl.".png";
  82. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  83. // 加水印
  84. WaterImg($cfg_basedir.$fullUrl, 'up');
  85. $litpic = $fullUrl;
  86. }
  87. //生成文档ID
  88. $arcID = GetIndexKey($arcrank, $typeid, $senddate, $channelid, $senddate, $adminid);
  89. if (empty($arcID)) {
  90. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  91. exit();
  92. }
  93. //分析处理附加表数据
  94. $inadd_f = '';
  95. $inadd_v = '';
  96. if (!empty($dede_addonfields)) {
  97. $addonfields = explode(';', $dede_addonfields);
  98. $inadd_f = '';
  99. $inadd_v = '';
  100. if (is_array($addonfields)) {
  101. foreach ($addonfields as $v) {
  102. if ($v == '') {
  103. continue;
  104. }
  105. $vs = explode(',', $v);
  106. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  107. {
  108. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  109. } else {
  110. if (!isset(${$vs[0]})) {
  111. ${$vs[0]} = '';
  112. }
  113. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  114. }
  115. $inadd_f .= ','.$vs[0];
  116. $inadd_v .= " ,'".${$vs[0]}."' ";
  117. }
  118. }
  119. }
  120. //处理图片文档的自定义属性
  121. if ($litpic != '' && !preg_match("#p#", $flag)) {
  122. $flag = ($flag == '' ? 'p' : $flag.',p');
  123. }
  124. //保存到附加表
  125. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  126. $addtable = trim($cts['addtable']);
  127. if (!empty($addtable)) {
  128. $query = "INSERT INTO `{$addtable}`(aid,typeid,channel,arcrank,mid,click,title,senddate,flag,litpic,userip{$inadd_f})
  129. VALUES('$arcID','$typeid','$channelid','$arcrank','$adminid','0','$title','$senddate','$flag','$litpic','$userip'{$inadd_v})";
  130. if (!$dsql->ExecuteNoneQuery($query)) {
  131. $gerr = $dsql->GetError();
  132. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  133. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  134. exit();
  135. }
  136. }
  137. //生成HTML
  138. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  139. if ($artUrl == '') {
  140. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  141. }
  142. ClearMyAddon($arcID, $title);
  143. //返回成功信息
  144. $msg = "请选择您的后续操作:<a href='archives_sg_add.php?cid=$typeid' class='btn btn-success btn-sm'>继续发布文档</a>&nbsp;&nbsp;<a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看文档</a>&nbsp;&nbsp;<a href='archives_do.php?aid=".$arcID."&dopost=editArchives' class='btn btn-success btn-sm'>更改文档</a>&nbsp;&nbsp;<a href='content_sg_list.php?cid=$typeid&channelid={$channelid}&dopost=listArchives' class='btn btn-success btn-sm'>已发布文档管理</a>&nbsp;&nbsp;<a href='catalog_main.php' class='btn btn-success btn-sm'>网站栏目管理</a>";
  145. $wintitle = "成功发布文档";
  146. $wecome_info = "文档管理::发布文档";
  147. $win = new OxWindow();
  148. $win->AddTitle("成功发布文档:");
  149. $win->AddMsgItem($msg);
  150. $winform = $win->GetWindow("hand", "&nbsp;", false);
  151. $win->Display();
  152. }