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

189 lines
7.2KB

  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) 2021, 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. -------------------------------*/ else if ($dopost == 'save') {
  41. require_once(DEDEINC . '/image.func.php');
  42. require_once(DEDEINC . '/oxwindow.class.php');
  43. if ($typeid == 0) {
  44. ShowMsg("请指定文档的栏目!", "-1");
  45. exit();
  46. }
  47. if (empty($channelid)) {
  48. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  49. exit();
  50. }
  51. if (!CheckChannel($typeid, $channelid)) {
  52. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  53. exit();
  54. }
  55. if (!TestPurview('a_New')) {
  56. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的权限!");
  57. }
  58. //对保存的内容进行处理
  59. if (empty($writer)) $writer = $cuserLogin->getUserName();
  60. if (empty($source)) $source = '未知';
  61. if (empty($flags)) $flag = '';
  62. else $flag = join(',', $flags);
  63. $senddate = time();
  64. if (empty($litpic_b64)) $litpic_b64 = '';
  65. $title = cn_substrR($title, $cfg_title_maxlen);
  66. $isremote = 0;
  67. $serviterm = empty($serviterm) ? "" : $serviterm;
  68. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  69. $adminid = $cuserLogin->getUserID();
  70. $userip = GetIP();
  71. if (empty($ddisremote)) $ddisremote = 0;
  72. $litpic = GetDDImage('none', $picname, $ddisremote);
  73. // 处理新的缩略图上传
  74. if ($litpic_b64 != "") {
  75. $data = explode(',', $litpic_b64);
  76. $ntime = time();
  77. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  78. CreateDir($savepath);
  79. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  80. $fullUrl = $fullUrl . ".png";
  81. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  82. // 加水印
  83. WaterImg($cfg_basedir . $fullUrl, 'up');
  84. $litpic = $fullUrl;
  85. }
  86. //生成文档ID
  87. $arcID = GetIndexKey($arcrank, $typeid, $senddate, $channelid, $senddate, $adminid);
  88. if (empty($arcID)) {
  89. ShowMsg("无法获得主键,因此无法进行后续操作!", "-1");
  90. exit();
  91. }
  92. //分析处理附加表数据
  93. $inadd_f = '';
  94. $inadd_v = '';
  95. if (!empty($dede_addonfields)) {
  96. $addonfields = explode(';', $dede_addonfields);
  97. $inadd_f = '';
  98. $inadd_v = '';
  99. if (is_array($addonfields)) {
  100. foreach ($addonfields as $v) {
  101. if ($v == '') {
  102. continue;
  103. }
  104. $vs = explode(',', $v);
  105. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  106. {
  107. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  108. } else {
  109. if (!isset(${$vs[0]})) {
  110. ${$vs[0]} = '';
  111. }
  112. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  113. }
  114. $inadd_f .= ',' . $vs[0];
  115. $inadd_v .= " ,'" . ${$vs[0]} . "' ";
  116. }
  117. }
  118. }
  119. //处理图片文档的自定义属性
  120. if ($litpic != '' && !preg_match("#p#", $flag)) {
  121. $flag = ($flag == '' ? 'p' : $flag . ',p');
  122. }
  123. //保存到附加表
  124. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  125. $addtable = trim($cts['addtable']);
  126. if (!empty($addtable)) {
  127. $query = "INSERT INTO `{$addtable}`(aid,typeid,channel,arcrank,mid,click,title,senddate,flag,litpic,userip{$inadd_f})
  128. VALUES('$arcID','$typeid','$channelid','$arcrank','$adminid','0','$title','$senddate','$flag','$litpic','$userip'{$inadd_v})";
  129. if (!$dsql->ExecuteNoneQuery($query)) {
  130. $gerr = $dsql->GetError();
  131. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  132. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。" . str_replace('"', '', $gerr), "javascript:;");
  133. exit();
  134. }
  135. }
  136. //生成HTML
  137. if ($cfg_remote_site == 'Y' && $isremote == "1") {
  138. if ($serviterm != "") {
  139. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  140. $config = array('hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd, 'debug' => 'TRUE');
  141. } else {
  142. $config = array();
  143. }
  144. if (!$ftp->connect($config)) exit('Error:None FTP Connection!');
  145. }
  146. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  147. if ($artUrl == '') {
  148. $artUrl = $cfg_phpurl . "/view.php?aid=$arcID";
  149. }
  150. ClearMyAddon($arcID, $title);
  151. //返回成功信息
  152. $msg = "
  153.   请选择你的后续操作:
  154. <a href='archives_sg_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>继续发布文档</a>
  155. &nbsp;&nbsp;
  156. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看文档</a>
  157. &nbsp;&nbsp;
  158. <a href='archives_do.php?aid=" . $arcID . "&dopost=editArchives' class='btn btn-secondary btn-sm'>更改文档</a>
  159. &nbsp;&nbsp;
  160. <a href='content_sg_list.php?cid=$typeid&channelid={$channelid}&dopost=listArchives' class='btn btn-secondary btn-sm'>已发布文档管理</a>
  161. &nbsp;&nbsp;
  162. <a href='catalog_main.php' class='btn btn-secondary btn-sm'>网站栏目管理</a>
  163. ";
  164. $wintitle = "成功发布文档!";
  165. $wecome_info = "文档管理::发布文档";
  166. $win = new OxWindow();
  167. $win->AddTitle("成功发布文档:");
  168. $win->AddMsgItem($msg);
  169. $winform = $win->GetWindow("hand", "&nbsp;", false);
  170. $win->Display();
  171. }