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

199 lines
9.0KB

  1. <?php
  2. /**
  3. * 文档发布
  4. *
  5. * @version $Id: archives_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. //获取文章最大id以确定当前权重
  36. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  37. include DedeInclude('templets/archives_add.htm');
  38. exit();
  39. }
  40. /*--------------------------------
  41. function __save(){ }
  42. -------------------------------*/
  43. else if ($dopost == 'save') {
  44. require_once(DEDEINC.'/image.func.php');
  45. require_once(DEDEINC.'/oxwindow.class.php');
  46. $flag = isset($flags) ? join(',', $flags) : '';
  47. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  48. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  49. if (empty($litpic_b64)) $litpic_b64 = '';
  50. if (empty($typeid2)) $typeid2 = 0;
  51. if (!isset($autokey)) $autokey = 0;
  52. if (!isset($remote)) $remote = 0;
  53. if (!isset($dellink)) $dellink = 0;
  54. if (!isset($autolitpic)) $autolitpic = 0;
  55. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  56. if ($typeid == 0) {
  57. ShowMsg('请指定文档的栏目', '-1');
  58. exit();
  59. }
  60. if (empty($channelid)) {
  61. ShowMsg('文档为非指定的类型,请检查您发布内容的表单是否合法', '-1');
  62. exit();
  63. }
  64. if (!CheckChannel($typeid, $channelid)) {
  65. ShowMsg('您所选择的栏目与当前模型不相符,请选择白色的选项', '-1');
  66. exit();
  67. }
  68. if (!TestPurview('a_New')) {
  69. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的权限");
  70. }
  71. //对保存的内容进行处理
  72. if (empty($writer)) $writer = $cuserLogin->getUserName();
  73. if (empty($source)) $source = '未知';
  74. $pubdate = GetMkTime($pubdate);
  75. $senddate = time();
  76. $sortrank = AddDay($pubdate, $sortup);
  77. $ismake = $ishtml == 0 ? -1 : 0;
  78. $title = preg_replace("#\"#", '"', $title);
  79. $title = cn_substrR($title, $cfg_title_maxlen);
  80. $shorttitle = cn_substrR($shorttitle, 36);
  81. $color = cn_substrR($color, 7);
  82. $writer = cn_substrR($writer, 20);
  83. $source = cn_substrR($source, 30);
  84. $description = cn_substrR($description, $cfg_auot_description);
  85. $keywords = cn_substrR($keywords, 60);
  86. $filename = trim(cn_substrR($filename, 40));
  87. $userip = GetIP();
  88. $isremote = 0;
  89. $voteid = (empty($voteid) ? 0 : $voteid);
  90. $serviterm = empty($serviterm) ? "" : $serviterm;
  91. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  92. $arcrank = -1;
  93. }
  94. $adminid = $cuserLogin->getUserID();
  95. //处理上传的缩略图
  96. if (empty($ddisremote)) {
  97. $ddisremote = 0;
  98. }
  99. $litpic = GetDDImage('none', $picname, $ddisremote);
  100. // 处理新的缩略图上传
  101. if ($litpic_b64 != "") {
  102. $data = explode(',', $litpic_b64);
  103. $ntime = time();
  104. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  105. CreateDir($savepath);
  106. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  107. $fullUrl = $fullUrl.".png";
  108. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  109. //加水印
  110. WaterImg($cfg_basedir.$fullUrl, 'up');
  111. $litpic = $fullUrl;
  112. }
  113. //生成文档ID
  114. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  115. if (empty($arcID)) {
  116. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  117. exit();
  118. }
  119. //分析处理附加表数据
  120. $inadd_f = $inadd_v = '';
  121. if (!empty($dede_addonfields)) {
  122. $addonfields = explode(';', $dede_addonfields);
  123. if (is_array($addonfields)) {
  124. foreach ($addonfields as $v) {
  125. if ($v == '') continue;
  126. $vs = explode(',', $v);
  127. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  128. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  129. } else {
  130. if (!isset(${$vs[0]})) ${$vs[0]} = '';
  131. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  132. }
  133. $inadd_f .= ','.$vs[0];
  134. $inadd_v .= " ,'".${$vs[0]}."' ";
  135. }
  136. }
  137. }
  138. //处理图片文档的自定义属性
  139. if ($litpic != '' && !preg_match("#p#", $flag)) {
  140. $flag = ($flag == '' ? 'p' : $flag.',p');
  141. }
  142. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  143. $flag = ($flag == '' ? 'j' : $flag.',j');
  144. }
  145. //跳转网址的文档强制为动态
  146. if (preg_match("#j#", $flag)) $ismake = -1;
  147. //保存到主表
  148. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
  149. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  150. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  151. if (!$dsql->ExecuteNoneQuery($query)) {
  152. $gerr = $dsql->GetError();
  153. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  154. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  155. exit();
  156. }
  157. //保存到附加表
  158. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  159. $addtable = trim($cts['addtable']);
  160. if (!empty($addtable)) {
  161. $useip = GetIP();
  162. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,userip{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  163. if (!$dsql->ExecuteNoneQuery($query)) {
  164. $gerr = $dsql->GetError();
  165. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  166. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  167. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  168. exit();
  169. }
  170. }
  171. //生成HTML
  172. InsertTags($tags, $arcID);
  173. $artUrl = MakeArt($arcID, true, true, $isremote);
  174. if ($artUrl == '') {
  175. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  176. }
  177. ClearMyAddon($arcID, $title);
  178. //自动更新关联内容
  179. if (is_array($automake)) {
  180. foreach ($automake as $key => $value) {
  181. if (isset(${$key}) && !empty(${$key})) {
  182. $ids = explode(",", ${$key});
  183. foreach ($ids as $id) {
  184. MakeArt($id, true, true, $isremote);
  185. }
  186. }
  187. }
  188. }
  189. //返回成功信息
  190. $msg = "请选择您的后续操作:<a href='archives_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='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>已发布文档管理</a>&nbsp;&nbsp;$backurl";
  191. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  192. $wintitle = '成功发布文档';
  193. $wecome_info = '文档管理::发布文档';
  194. $win = new OxWindow();
  195. $win->AddTitle('成功发布文档:');
  196. $win->AddMsgItem($msg);
  197. $winform = $win->GetWindow('hand', '&nbsp;', false);
  198. $win->Display();
  199. }