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

314 lines
15KB

  1. <?php
  2. /**
  3. * 图集发布
  4. *
  5. * @version $Id: album_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) $channelid = 2;
  28. }
  29. //获得频道模型信息
  30. $cInfos = $dsql->GetOne(" SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  31. $channelid = $cInfos['id'];
  32. //获取文章最大id以确定当前权重
  33. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  34. include DedeInclude("templets/album_add.htm");
  35. exit();
  36. }
  37. /*--------------------------------
  38. function __save(){ }
  39. -------------------------------*/
  40. else if ($dopost == 'save') {
  41. require_once(DEDEINC.'/image.func.php');
  42. require_once(DEDEINC.'/oxwindow.class.php');
  43. $flag = isset($flags) ? join(',', $flags) : '';
  44. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  45. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  46. if (!isset($typeid2)) $typeid2 = 0;
  47. if (!isset($autokey)) $autokey = 0;
  48. if (!isset($remote)) $remote = 0;
  49. if (!isset($dellink)) $dellink = 0;
  50. if (!isset($autolitpic)) $autolitpic = 0;
  51. if (!isset($formhtml)) $formhtml = 0;
  52. if (!isset($formzip)) $formzip = 0;
  53. if (!isset($ddisfirst)) $ddisfirst = 0;
  54. if (!isset($albums)) $albums = "";
  55. if (!isset($delzip)) $delzip = 0;
  56. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  57. if ($typeid == 0) {
  58. ShowMsg("请指定文档的栏目", "-1");
  59. exit();
  60. }
  61. if (empty($channelid)) {
  62. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  63. exit();
  64. }
  65. if (!CheckChannel($typeid, $channelid)) {
  66. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  67. exit();
  68. }
  69. if (!TestPurview('a_New')) {
  70. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的权限");
  71. }
  72. //对保存的内容进行处理
  73. if (empty($writer)) $writer = $cuserLogin->getUserName();
  74. if (empty($source)) $source = '未知';
  75. $pubdate = GetMkTime($pubdate);
  76. $senddate = time();
  77. $sortrank = AddDay($pubdate, $sortup);
  78. $ismake = $ishtml == 0 ? -1 : 0;
  79. $title = preg_replace("#\"#", '"', $title);
  80. $title = cn_substrR($title, $cfg_title_maxlen);
  81. $shorttitle = cn_substrR($shorttitle, 36);
  82. $color = cn_substrR($color, 7);
  83. $writer = cn_substrR($writer, 20);
  84. $source = cn_substrR($source, 30);
  85. $description = cn_substrR($description, $cfg_auot_description);
  86. $keywords = cn_substrR($keywords, 60);
  87. $filename = trim(cn_substrR($filename, 40));
  88. $userip = GetIP();
  89. $isremote = 0;
  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)) $ddisremote = 0;
  97. $litpic = GetDDImage('none', $picname, $ddisremote);
  98. // 处理新的缩略图上传
  99. if ($litpic_b64 != "") {
  100. $data = explode(',', $litpic_b64);
  101. $ntime = time();
  102. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  103. CreateDir($savepath);
  104. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  105. $fullUrl = $fullUrl.".png";
  106. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  107. //加水印
  108. WaterImg($cfg_basedir.$fullUrl, 'up');
  109. $litpic = $fullUrl;
  110. }
  111. //生成文档ID
  112. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  113. if (empty($arcID)) {
  114. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  115. exit();
  116. }
  117. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  118. $hasone = FALSE;
  119. //处理并保存从网上复制的图片
  120. /*---------------------
  121. function _getformhtml()
  122. ------------------*/
  123. if ($formhtml == 1) {
  124. $imagebody = stripslashes($imagebody);
  125. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  126. if ($ddisfirst == 1 && $litpic == '' && !empty($litpicname)) {
  127. $litpic = $litpicname;
  128. $hasone = TRUE;
  129. }
  130. }
  131. /*---------------------
  132. function _getformzip()
  133. 处理从ZIP中解压的图片
  134. ---------------------*/
  135. if ($formzip == 1) {
  136. include_once(DEDEINC."/zip.class.php");
  137. include_once(DEDEADMIN."/file_class.php");
  138. $zipfile = $cfg_basedir.str_replace($cfg_mainsite, '', $zipfile);
  139. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()), 16);
  140. $ntime = time();
  141. if (file_exists($zipfile)) {
  142. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  143. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  144. $z = new zip();
  145. $z->ExtractAll($zipfile, $tmpzipdir);
  146. $fm = new FileManagement();
  147. $imgs = array();
  148. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  149. $i = 0;
  150. foreach ($imgs as $imgold) {
  151. $i++;
  152. $savepath = $cfg_image_dir."/".MyDate("Y-m", $ntime);
  153. CreateDir($savepath);
  154. $iurl = $savepath."/".MyDate("d", $ntime).dd2char(MyDate("His", $ntime).'-'.$adminid."-{$i}".mt_rand(1000, 9999));
  155. $iurl = $iurl.substr($imgold, -4, 4);
  156. $imgfile = $cfg_basedir.$iurl;
  157. copy($imgold, $imgfile);
  158. unlink($imgold);
  159. if (is_file($imgfile)) {
  160. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  161. //指定了提取第一张为缩略图的情况强制使用第一张缩略图
  162. if ($i == '1') {
  163. if (!$hasone && $ddisfirst == 1 && $litpic == '' && empty($litpicname)) {
  164. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  165. }
  166. }
  167. $info = '';
  168. $imginfos = GetImageSize($imgfile, $info);
  169. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  170. //把图片信息保存到媒体文档管理档案中
  171. $inquery = "
  172. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  173. VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminid');";
  174. $dsql->ExecuteNoneQuery($inquery);
  175. $fid = $dsql->GetLastID();
  176. AddMyAddon($fid, $iurl);
  177. WaterImg($imgfile, 'up');
  178. if (!$hasone && $ddisfirst == 1 && $litpic == '') {
  179. if (empty($litpicname)) {
  180. $litpicname = $iurl;
  181. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  182. }
  183. $litpic = $litpicname;
  184. $hasone = TRUE;
  185. }
  186. }
  187. }
  188. if ($delzip == 1) unlink($zipfile);
  189. $fm->RmDirFiles($tmpzipdir);
  190. }
  191. }
  192. if ($albums !== "") {
  193. $albumsArr = json_decode(stripslashes($albums), true);
  194. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  195. $album = $albumsArr[$i];
  196. $data = explode(',', $album['img']);
  197. $ntime = time();
  198. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  199. CreateDir($savepath);
  200. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  201. $fullUrl = $fullUrl.".png";
  202. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  203. $info = '';
  204. $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info);
  205. $v = $fullUrl;
  206. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  207. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  208. if ($ddisfirst == 1 && $litpic == '' && !empty($fullUrl)) {
  209. $litpic = $fullUrl;
  210. }
  211. }
  212. }
  213. $imgurls = addslashes($imgurls);
  214. //处理body字段自动摘要、自动提取缩略图等
  215. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  216. //分析处理附加表数据
  217. $inadd_f = '';
  218. $inadd_v = '';
  219. if (!empty($dede_addonfields)) {
  220. $addonfields = explode(';', $dede_addonfields);
  221. $inadd_f = '';
  222. $inadd_v = '';
  223. if (is_array($addonfields)) {
  224. foreach ($addonfields as $v) {
  225. if ($v == '') {
  226. continue;
  227. }
  228. $vs = explode(',', $v);
  229. if (!isset(${$vs[0]})) {
  230. ${$vs[0]} = '';
  231. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  232. {
  233. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  234. } else {
  235. if (!isset(${$vs[0]})) {
  236. ${$vs[0]} = '';
  237. }
  238. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  239. }
  240. $inadd_f .= ','.$vs[0];
  241. $inadd_v .= " ,'".${$vs[0]}."' ";
  242. }
  243. }
  244. }
  245. //处理图片文档的自定义属性
  246. if ($litpic != '' && !preg_match("#p#", $flag)) {
  247. $flag = ($flag == '' ? 'p' : $flag.',p');
  248. }
  249. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  250. $flag = ($flag == '' ? 'j' : $flag.',j');
  251. }
  252. //跳转网址的文档强制为动态
  253. if (preg_match("#j#", $flag)) $ismake = -1;
  254. //加入主档案表
  255. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  256. color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight)
  257. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  258. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight'); ";
  259. if (!$dsql->ExecuteNoneQuery($query)) {
  260. $gerr = $dsql->GetError();
  261. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  262. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  263. exit();
  264. }
  265. //加入附加表
  266. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  267. $addtable = trim($cts['addtable']);
  268. if (empty($addtable)) {
  269. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  270. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  271. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作。", "javascript:;");
  272. exit();
  273. }
  274. $useip = GetIP();
  275. $query = "INSERT INTO `$addtable`(aid,typeid,redirecturl,userip,pagestyle,maxwidth,imgurls,`row`,col,isrm,ddmaxwidth,pagepicnum,body{$inadd_f})
  276. Values('$arcID','$typeid','$redirecturl','$useip','$pagestyle','$maxwidth','$imgurls','$row','$col','$isrm','$ddmaxwidth','$pagepicnum','$body'{$inadd_v}); ";
  277. if (!$dsql->ExecuteNoneQuery($query)) {
  278. $gerr = $dsql->GetError();
  279. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  280. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  281. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  282. exit();
  283. }
  284. //生成HTML
  285. InsertTags($tags, $arcID);
  286. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  287. if ($artUrl == '') {
  288. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  289. }
  290. ClearMyAddon($arcID, $title);
  291. //自动更新关联内容
  292. if (is_array($automake)) {
  293. foreach ($automake as $key => $value) {
  294. if (isset(${$key}) && !empty(${$key})) {
  295. $ids = explode(",", ${$key});
  296. foreach ($ids as $id) {
  297. MakeArt($id, true, true, $isremote);
  298. }
  299. }
  300. }
  301. }
  302. //返回成功信息
  303. $msg = "请选择您的后续操作:<a href='album_add.php?cid=$typeid' 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='$artUrl' target='_blank' 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";
  304. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  305. $wintitle = "成功发布一个图集";
  306. $wecome_info = "文章管理::发布图集";
  307. $win = new OxWindow();
  308. $win->AddTitle("成功发布一个图集:");
  309. $win->AddMsgItem($msg);
  310. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  311. $win->Display();
  312. }