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

386 lines
16KB

  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) 2020, 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. -------------------------------*/ else if ($dopost == 'save') {
  40. require_once(DEDEINC . '/image.func.php');
  41. require_once(DEDEINC . '/oxwindow.class.php');
  42. $flag = isset($flags) ? join(',', $flags) : '';
  43. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  44. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  45. if (!isset($typeid2)) $typeid2 = 0;
  46. if (!isset($autokey)) $autokey = 0;
  47. if (!isset($remote)) $remote = 0;
  48. if (!isset($dellink)) $dellink = 0;
  49. if (!isset($autolitpic)) $autolitpic = 0;
  50. if (!isset($formhtml)) $formhtml = 0;
  51. if (!isset($formzip)) $formzip = 0;
  52. if (!isset($ddisfirst)) $ddisfirst = 0;
  53. if (!isset($albums)) $albums = "";
  54. if (!isset($delzip)) $delzip = 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. $serviterm = empty($serviterm) ? "" : $serviterm;
  90. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  91. $arcrank = -1;
  92. }
  93. $adminid = $cuserLogin->getUserID();
  94. //处理上传的缩略图
  95. if (empty($ddisremote)) $ddisremote = 0;
  96. $litpic = GetDDImage('none', $picname, $ddisremote);
  97. // 处理新的缩略图上传
  98. if ($litpic_b64 != "") {
  99. $data = explode(',', $litpic_b64);
  100. $ntime = time();
  101. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  102. CreateDir($savepath);
  103. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  104. $fullUrl = $fullUrl . ".png";
  105. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  106. // 加水印
  107. WaterImg($cfg_basedir . $fullUrl, 'up');
  108. $litpic = $fullUrl;
  109. }
  110. // 处理新的缩略图上传
  111. if ($litpic_b64 != "") {
  112. $data = explode(',', $litpic_b64);
  113. $ntime = time();
  114. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  115. CreateDir($savepath);
  116. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  117. $fullUrl = $fullUrl . ".png";
  118. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  119. // 加水印
  120. WaterImg($cfg_basedir . $fullUrl, 'up');
  121. $litpic = $fullUrl;
  122. }
  123. //使用第一张图作为缩略图
  124. if ($ddisfirst == 1 && $litpic == '') {
  125. if (isset($imgurl1)) {
  126. $litpic = GetDDImage('ddfirst', $imgurl1, $isrm);
  127. }
  128. }
  129. //生成文档ID
  130. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  131. if (empty($arcID)) {
  132. ShowMsg("无法获得主键,因此无法进行后续操作!", "-1");
  133. exit();
  134. }
  135. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  136. $hasone = FALSE;
  137. //处理并保存从网上复制的图片
  138. /*---------------------
  139. function _getformhtml()
  140. ------------------*/
  141. if ($formhtml == 1) {
  142. $imagebody = stripslashes($imagebody);
  143. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  144. if ($ddisfirst == 1 && $litpic == '' && !empty($litpicname)) {
  145. $litpic = $litpicname;
  146. $hasone = TRUE;
  147. }
  148. }
  149. /*---------------------
  150. function _getformzip()
  151. 处理从ZIP中解压的图片
  152. ---------------------*/
  153. if ($formzip == 1) {
  154. include_once(DEDEINC . "/zip.class.php");
  155. include_once(DEDEADMIN . "/file_class.php");
  156. $zipfile = $cfg_basedir . str_replace($cfg_mainsite, '', $zipfile);
  157. $tmpzipdir = DEDEDATA . '/ziptmp/' . cn_substr(md5(ExecTime()), 16);
  158. $ntime = time();
  159. if (file_exists($zipfile)) {
  160. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  161. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  162. $z = new zip();
  163. $z->ExtractAll($zipfile, $tmpzipdir);
  164. $fm = new FileManagement();
  165. $imgs = array();
  166. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  167. $i = 0;
  168. foreach ($imgs as $imgold) {
  169. $i++;
  170. $savepath = $cfg_image_dir . "/" . MyDate("Y-m", $ntime);
  171. CreateDir($savepath);
  172. $iurl = $savepath . "/" . MyDate("d", $ntime) . dd2char(MyDate("His", $ntime) . '-' . $adminid . "-{$i}" . mt_rand(1000, 9999));
  173. $iurl = $iurl . substr($imgold, -4, 4);
  174. $imgfile = $cfg_basedir . $iurl;
  175. copy($imgold, $imgfile);
  176. unlink($imgold);
  177. if (is_file($imgfile)) {
  178. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  179. //指定了提取第一张为缩略图的情况强制使用第一张缩略图
  180. if ($i == '1') {
  181. if (!$hasone && $ddisfirst == 1 && $litpic == '' && empty($litpicname)) {
  182. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  183. }
  184. }
  185. $info = '';
  186. $imginfos = GetImageSize($imgfile, $info);
  187. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $iurl {/dede:img}\r\n";
  188. //把图片信息保存到媒体文档管理档案中
  189. $inquery = "
  190. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  191. VALUES ('{$title}','{$iurl}','1','" . $imginfos[0] . "','" . $imginfos[1] . "','0','" . filesize($imgfile) . "','" . $ntime . "','$adminid');
  192. ";
  193. $dsql->ExecuteNoneQuery($inquery);
  194. $fid = $dsql->GetLastID();
  195. AddMyAddon($fid, $iurl);
  196. WaterImg($imgfile, 'up');
  197. if (!$hasone && $ddisfirst == 1 && $litpic == '') {
  198. if (empty($litpicname)) {
  199. $litpicname = $iurl;
  200. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  201. }
  202. $litpic = $litpicname;
  203. $hasone = TRUE;
  204. }
  205. }
  206. }
  207. if ($delzip == 1) unlink($zipfile);
  208. $fm->RmDirFiles($tmpzipdir);
  209. }
  210. }
  211. if ($albums !== "") {
  212. $albumsArr = json_decode(stripslashes($albums), true);
  213. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  214. $album = $albumsArr[$i];
  215. $data = explode(',', $album['img']);
  216. $ntime = time();
  217. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  218. CreateDir($savepath);
  219. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  220. $fullUrl = $fullUrl . ".png";
  221. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  222. $info = '';
  223. $imginfos = GetImageSize($cfg_basedir . $fullUrl, $info);
  224. $v = $fullUrl;
  225. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  226. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $v {/dede:img}\r\n";
  227. }
  228. }
  229. $imgurls = addslashes($imgurls);
  230. //处理body字段自动摘要、自动提取缩略图等
  231. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  232. //分析处理附加表数据
  233. $inadd_f = '';
  234. $inadd_v = '';
  235. if (!empty($dede_addonfields)) {
  236. $addonfields = explode(';', $dede_addonfields);
  237. $inadd_f = '';
  238. $inadd_v = '';
  239. if (is_array($addonfields)) {
  240. foreach ($addonfields as $v) {
  241. if ($v == '') {
  242. continue;
  243. }
  244. $vs = explode(',', $v);
  245. if (!isset(${$vs[0]})) {
  246. ${$vs[0]} = '';
  247. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  248. {
  249. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  250. } else {
  251. if (!isset(${$vs[0]})) {
  252. ${$vs[0]} = '';
  253. }
  254. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  255. }
  256. $inadd_f .= ',' . $vs[0];
  257. $inadd_v .= " ,'" . ${$vs[0]} . "' ";
  258. }
  259. }
  260. }
  261. //处理图片文档的自定义属性
  262. if ($litpic != '' && !preg_match("#p#", $flag)) {
  263. $flag = ($flag == '' ? 'p' : $flag . ',p');
  264. }
  265. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  266. $flag = ($flag == '' ? 'j' : $flag . ',j');
  267. }
  268. //跳转网址的文档强制为动态
  269. if (preg_match("#j#", $flag)) $ismake = -1;
  270. //加入主档案表
  271. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  272. color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight)
  273. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  274. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight'); ";
  275. if (!$dsql->ExecuteNoneQuery($query)) {
  276. $gerr = $dsql->GetError();
  277. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  278. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。" . str_replace('"', '', $gerr), "javascript:;");
  279. exit();
  280. }
  281. //加入附加表
  282. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  283. $addtable = trim($cts['addtable']);
  284. if (empty($addtable)) {
  285. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  286. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  287. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。", "javascript:;");
  288. exit();
  289. }
  290. $useip = GetIP();
  291. $query = "INSERT INTO `$addtable`(aid,typeid,redirecturl,userip,pagestyle,maxwidth,imgurls,`row`,col,isrm,ddmaxwidth,pagepicnum,body{$inadd_f})
  292. Values('$arcID','$typeid','$redirecturl','$useip','$pagestyle','$maxwidth','$imgurls','$row','$col','$isrm','$ddmaxwidth','$pagepicnum','$body'{$inadd_v}); ";
  293. if (!$dsql->ExecuteNoneQuery($query)) {
  294. $gerr = $dsql->GetError();
  295. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  296. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  297. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。" . str_replace('"', '', $gerr), "javascript:;");
  298. exit();
  299. }
  300. //生成HTML
  301. InsertTags($tags, $arcID);
  302. if ($cfg_remote_site == 'Y' && $isremote == "1") {
  303. if ($serviterm != "") {
  304. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  305. $config = array('hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd, 'debug' => 'TRUE');
  306. } else {
  307. $config = array();
  308. }
  309. if (!$ftp->connect($config)) exit('Error:None FTP Connection!');
  310. }
  311. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  312. if ($artUrl == '') {
  313. $artUrl = $cfg_phpurl . "/view.php?aid=$arcID";
  314. }
  315. ClearMyAddon($arcID, $title);
  316. // 自动更新关联内容
  317. if (is_array($automake)) {
  318. foreach ($automake as $key => $value) {
  319. if (isset(${$key}) && !empty(${$key})) {
  320. $ids = explode(",", ${$key});
  321. foreach ($ids as $id) {
  322. MakeArt($id, true, true, $isremote);
  323. }
  324. }
  325. }
  326. }
  327. //返回成功信息
  328. $msg = "
  329.   请选择你的后续操作:
  330. <a href='album_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>继续发布图片</a>
  331. &nbsp;&nbsp;
  332. <a href='archives_do.php?aid=" . $arcID . "&dopost=editArchives' class='btn btn-secondary btn-sm'>更改图集</a>
  333. &nbsp;&nbsp;
  334. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>预览文档</a>
  335. &nbsp;&nbsp;
  336. <a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-secondary btn-sm'>已发布图片管理</a>
  337. &nbsp;&nbsp;
  338. $backurl
  339. ";
  340. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>" . GetUpdateTest();
  341. $wintitle = "成功发布一个图集!";
  342. $wecome_info = "文章管理::发布图集";
  343. $win = new OxWindow();
  344. $win->AddTitle("成功发布一个图集:");
  345. $win->AddMsgItem($msg);
  346. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  347. $win->Display();
  348. }