国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

album_edit.php 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <?php
  2. /**
  3. * 图集编辑
  4. *
  5. * @version $Id: album_edit.php 1 8:26 2010年7月12日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('a_Edit,a_AccEdit,a_MyEdit');
  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. {
  18. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  19. require_once(DEDEINC."/dedetag.class.php");
  20. ClearMyAddon();
  21. $aid = intval($aid);
  22. //读取归档信息
  23. $arcQuery = "SELECT ch.typename as channelname,ar.membername as rankname,arc.*
  24. FROM `#@__archives` arc
  25. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  26. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  27. $arcRow = $dsql->GetOne($arcQuery);
  28. if(!is_array($arcRow))
  29. {
  30. ShowMsg("读取档案基本信息出错!","-1");
  31. exit();
  32. }
  33. $query = "SELECT * FROM `#@__channeltype` WHERE id='".$arcRow['channel']."'";
  34. $cInfos = $dsql->GetOne($query);
  35. if(!is_array($cInfos))
  36. {
  37. ShowMsg("读取频道配置信息出错!","javascript:;");
  38. exit();
  39. }
  40. $addtable = $cInfos['addtable'];
  41. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  42. $channelid = $arcRow['channel'];
  43. $imgurls = $addRow["imgurls"];
  44. $maxwidth = $addRow["maxwidth"];
  45. $pagestyle = $addRow["pagestyle"];
  46. $irow = $addRow["row"];
  47. $icol = $addRow["col"];
  48. $isrm = $addRow["isrm"];
  49. $body = $addRow["body"];
  50. $ddmaxwidth = $addRow["ddmaxwidth"];
  51. $pagepicnum = $addRow["pagepicnum"];
  52. $tags = GetTags($aid);
  53. $arcRow=XSSClean($arcRow);$addRow=XSSClean($addRow);
  54. include DedeInclude("templets/album_edit.htm");
  55. exit();
  56. }
  57. /*--------------------------------
  58. function __save(){ }
  59. -------------------------------*/
  60. else if($dopost=='save')
  61. {
  62. require_once(DEDEINC.'/image.func.php');
  63. require_once(DEDEINC.'/oxwindow.class.php');
  64. $flag = isset($flags) ? join(',', $flags) : '';
  65. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  66. if(empty($typeid2)) $typeid2 = 0;
  67. if(!isset($autokey)) $autokey = 0;
  68. if(!isset($remote)) $remote = 0;
  69. if(!isset($dellink)) $dellink = 0;
  70. if(!isset($autolitpic)) $autolitpic = 0;
  71. if(!isset($formhtml)) $formhtml = 0;
  72. if(!isset($albums)) $albums = "";
  73. if(!isset($formzip)) $formzip = 0;
  74. if(!isset($ddisfirst)) $ddisfirst = 0;
  75. if(!isset($delzip)) $delzip = 0;
  76. if($typeid==0)
  77. {
  78. ShowMsg("请指定文档的栏目!","-1");
  79. exit();
  80. }
  81. if(empty($channelid))
  82. {
  83. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!","-1");
  84. exit();
  85. }
  86. if(!CheckChannel($typeid,$channelid))
  87. {
  88. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!","-1");
  89. exit();
  90. }
  91. if(!TestPurview('a_Edit'))
  92. {
  93. if(TestPurview('a_AccEdit'))
  94. {
  95. CheckCatalog($typeid,"对不起,你没有操作栏目 {$typeid} 的文档权限!");
  96. }
  97. else
  98. {
  99. CheckArcAdmin($id,$cuserLogin->getUserID());
  100. }
  101. }
  102. //对保存的内容进行处理
  103. $pubdate = GetMkTime($pubdate);
  104. $sortrank = AddDay($pubdate,$sortup);
  105. $ismake = $ishtml==0 ? -1 : 0;
  106. $title = cn_substrR($title,$cfg_title_maxlen);
  107. $shorttitle = cn_substrR($shorttitle,36);
  108. $color = cn_substrR($color,7);
  109. $writer = cn_substrR($writer,20);
  110. $source = cn_substrR($source,30);
  111. $description = cn_substrR($description,250);
  112. $keywords = trim(cn_substrR($keywords,60));
  113. $filename = trim(cn_substrR($filename,40));
  114. $isremote = (empty($isremote)? 0 : $isremote);
  115. $serviterm=empty($serviterm)? "" : $serviterm;
  116. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  117. {
  118. $arcrank = -1;
  119. }
  120. $adminid = $cuserLogin->getUserID();
  121. //处理上传的缩略图
  122. if(empty($ddisremote))
  123. {
  124. $ddisremote = 0;
  125. }
  126. $litpic = GetDDImage('none', $picname, $ddisremote);
  127. // 处理新的缩略图上传
  128. if ($litpic_b64 != "") {
  129. $data = explode( ',', $litpic_b64 );
  130. $ntime = time();
  131. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  132. CreateDir($savepath);
  133. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  134. $fullUrl = $fullUrl.".png";
  135. file_put_contents($cfg_basedir.$fullUrl, base64_decode( $data[ 1 ] ));
  136. // 加水印
  137. WaterImg($cfg_basedir.$fullUrl, 'up');
  138. $litpic = $fullUrl;
  139. }
  140. //分析body里的内容
  141. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  142. //处理图片文档的自定义属性
  143. if($litpic!='' && !preg_match("#p#", $flag))
  144. {
  145. $flag = ($flag=='' ? 'p' : $flag.',p');
  146. }
  147. if($redirecturl!='' && !preg_match("#j#", $flag))
  148. {
  149. $flag = ($flag=='' ? 'j' : $flag.',j');
  150. }
  151. //跳转网址的文档强制为动态
  152. if(preg_match("#j#", $flag)) $ismake = -1;
  153. //更新数据库的SQL语句
  154. $query = "
  155. UPDATE `#@__archives` SET
  156. typeid='$typeid',
  157. typeid2='$typeid2',
  158. sortrank='$sortrank',
  159. flag='$flag',
  160. click='$click',
  161. ismake='$ismake',
  162. arcrank='$arcrank',
  163. money='$money',
  164. title='$title',
  165. color='$color',
  166. source='$source',
  167. writer='$writer',
  168. litpic='$litpic',
  169. pubdate='$pubdate',
  170. notpost='$notpost',
  171. description='$description',
  172. keywords='$keywords',
  173. shorttitle='$shorttitle',
  174. filename='$filename',
  175. dutyadmin='$adminid'
  176. WHERE id='$id'; ";
  177. if(!$dsql->ExecuteNoneQuery($query))
  178. {
  179. ShowMsg("更新数据库archives表时出错,请检查!".$dsql->GetError(),"javascript:;");
  180. exit();
  181. }
  182. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  183. $hasone = false;
  184. //----------------------------------------
  185. //检查旧的图片是否有更新,并保存
  186. //-----------------------------------------
  187. for($i=1; $i<=120; $i++)
  188. {
  189. if( !isset(${'imgurl'.$i}) ) continue;
  190. $info = '';
  191. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  192. $iurl = stripslashes(${'imgurl'.$i});
  193. $ddurl = stripslashes(${'imgddurl'.$i});
  194. if(preg_match("#swfupload#i", $ddurl)) $ddurl = '';
  195. $imgfile = $cfg_basedir.$iurl;
  196. $litimgfile = $cfg_basedir.$ddurl;
  197. //有上传文件的情况
  198. if( isset(${'imgfile'.$i}) && is_uploaded_file(${'imgfile'.$i}) )
  199. {
  200. $tmpFile = ${'imgfile'.$i};
  201. //检测上传的图片, 如果类型不对,保留原来图片
  202. $imginfos = @GetImageSize($tmpFile, $info);
  203. if(!is_array($imginfos))
  204. {
  205. $imginfos = @GetImageSize($imgfile, $info);
  206. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  207. continue;
  208. }
  209. move_uploaded_file($tmpFile, $imgfile);
  210. $imginfos = @GetImageSize($imgfile, $info);
  211. if($ddurl==$iurl)
  212. {
  213. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  214. $litimgfile = $cfg_basedir.$litpicname;
  215. }
  216. else
  217. {
  218. if($cfg_ddimg_full=='Y') ImageResizeNew($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  219. else ImageResize($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  220. $litpicname = $ddurl;
  221. }
  222. $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  223. }
  224. //没上传图片(只修改msg信息)
  225. else
  226. {
  227. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  228. $iurl = stripslashes(${'imgurl'.$i});
  229. $ddurl = stripslashes(${'imgddurl'.$i});
  230. if(preg_match("#swfupload#i", $ddurl))
  231. {
  232. $ddurl = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  233. }
  234. $imginfos = @GetImageSize($imgfile, $info);
  235. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  236. }
  237. }
  238. //----------------------------
  239. //从HTML中获取新图片
  240. //----------------------------
  241. if($formhtml==1 && !empty($imagebody))
  242. {
  243. $imagebody = stripslashes($imagebody);
  244. $imgurls .= GetCurContentAlbum($imagebody,$copysource,$litpicname);
  245. if($ddisfirst==1 && $litpic=="" && !empty($litpicname))
  246. {
  247. $litpic = $litpicname;
  248. $hasone = true;
  249. }
  250. }
  251. /*---------------------
  252. function _getformzip()
  253. 从ZIP文件中获取新图片
  254. ---------------------*/
  255. if($formzip==1)
  256. {
  257. include_once(DEDEINC."/zip.class.php");
  258. include_once(DEDEADMIN."/file_class.php");
  259. $zipfile = $cfg_basedir.str_replace($cfg_mainsite,'',$zipfile);
  260. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()),16);
  261. $ntime = time();
  262. if(file_exists($zipfile))
  263. {
  264. @mkdir($tmpzipdir,$GLOBALS['cfg_dir_purview']);
  265. @chmod($tmpzipdir,$GLOBALS['cfg_dir_purview']);
  266. $z = new zip();
  267. $z->ExtractAll($zipfile,$tmpzipdir);
  268. $fm = new FileManagement();
  269. $imgs = array();
  270. $fm->GetMatchFiles($tmpzipdir,"jpg|png|gif",$imgs);
  271. $i = 0;
  272. foreach($imgs as $imgold)
  273. {
  274. $i++;
  275. $savepath = $cfg_image_dir."/".MyDate("Y-m",$ntime);
  276. CreateDir($savepath);
  277. $iurl = $savepath."/".MyDate("d",$ntime).dd2char(MyDate("His",$ntime).'-'.$adminid."-{$i}".mt_rand(1000,9999));
  278. $iurl = $iurl.substr($imgold,-4,4);
  279. $imgfile = $cfg_basedir.$iurl;
  280. copy($imgold,$imgfile);
  281. unlink($imgold);
  282. if(is_file($imgfile))
  283. {
  284. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl,$cfg_ddimg_width) : $iurl;
  285. $info = '';
  286. $imginfos = GetImageSize($imgfile,$info);
  287. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  288. //把图片信息保存到媒体文档管理档案中
  289. $inquery = "
  290. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  291. VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminid');
  292. ";
  293. $dsql->ExecuteNoneQuery($inquery);
  294. if(!$hasone && $ddisfirst==1
  295. && $litpic=="" && !empty($litpicname))
  296. {
  297. if( file_exists($cfg_basedir.$litpicname) )
  298. {
  299. $litpic = $litpicname;
  300. $hasone = true;
  301. }
  302. }
  303. }
  304. }
  305. if($delzip==1)
  306. {
  307. unlink($zipfile);
  308. }
  309. $fm->RmDirFiles($tmpzipdir);
  310. }
  311. }
  312. if ($albums !== "") {
  313. $albumsArr = json_decode(stripslashes( $albums), true);
  314. // var_dump($albumsArr);exit;
  315. for ($i=0; $i <= count($albumsArr) - 1; $i++) {
  316. $album = $albumsArr[$i];
  317. $data = explode( ',', $album['img'] );
  318. $ntime = time();
  319. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  320. CreateDir($savepath);
  321. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  322. $fullUrl = $fullUrl.".png";
  323. file_put_contents($cfg_basedir.$fullUrl, base64_decode( $data[ 1 ] ));
  324. $info = '';
  325. $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info);
  326. $v = $fullUrl;
  327. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  328. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  329. }
  330. }
  331. $imgurls = addslashes($imgurls);
  332. //分析处理附加表数据
  333. $inadd_f = '';
  334. $inadd_v = '';
  335. if(!empty($dede_addonfields))
  336. {
  337. $addonfields = explode(';', $dede_addonfields);
  338. $inadd_f = '';
  339. $inadd_v = '';
  340. if(is_array($addonfields))
  341. {
  342. foreach($addonfields as $v)
  343. {
  344. if($v=='')
  345. {
  346. continue;
  347. }
  348. $vs = explode(',',$v);
  349. if($vs[1]=='htmltext'||$vs[1]=='textdata') //HTML文本特殊处理
  350. {
  351. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  352. }else{
  353. if(!isset(${$vs[0]}))
  354. {
  355. ${$vs[0]} = '';
  356. }
  357. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$id);
  358. }
  359. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  360. }
  361. }
  362. }
  363. //更新附加表
  364. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  365. $addtable = trim($cts['addtable']);
  366. if($addtable!='')
  367. {
  368. $useip = GetIP();
  369. $query = "Update `$addtable`
  370. set typeid='$typeid',
  371. pagestyle='$pagestyle',
  372. body='$body',
  373. maxwidth = '$maxwidth',
  374. ddmaxwidth = '$ddmaxwidth',
  375. pagepicnum = '$pagepicnum',
  376. imgurls='$imgurls',
  377. `row`='$row',
  378. col='$col',
  379. isrm='$isrm'{$inadd_f},
  380. redirecturl='$redirecturl',
  381. userip = '$useip'
  382. WHERE aid='$id'; ";
  383. if(!$dsql->ExecuteNoneQuery($query))
  384. {
  385. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!".$dsql->GetError(),"javascript:;");
  386. exit();
  387. }
  388. }
  389. //生成HTML
  390. UpIndexKey($id,$arcrank,$typeid,$sortrank,$tags);
  391. if($cfg_remote_site=='Y' && $isremote=="1")
  392. {
  393. if($serviterm!=""){
  394. list($servurl,$servuser,$servpwd) = explode(',',$serviterm);
  395. $config=array( 'hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE');
  396. }else{
  397. $config=array();
  398. }
  399. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  400. }
  401. $arcUrl = MakeArt($id,true,true,$isremote);
  402. if($arcUrl=='')
  403. {
  404. $arcUrl = $cfg_phpurl."/view.php?aid=$id";
  405. }
  406. ClearMyAddon($id, $title);
  407. //返回成功信息
  408. $msg =
  409. "   请选择你的后续操作:
  410. <a href='album_add.php?cid=$typeid'><u>继续发布图片</u></a>
  411. &nbsp;&nbsp;
  412. <a href='archives_do.php?aid=".$id."&dopost=editArchives'><u>查看更改</u></a>
  413. &nbsp;&nbsp;
  414. <a href='$arcUrl' target='_blank'><u>预览文档</u></a>
  415. &nbsp;&nbsp;
  416. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>管理已发布图片</u></a>
  417. &nbsp;&nbsp;
  418. $backurl
  419. ";
  420. $wintitle = "成功更改图集!";
  421. $wecome_info = "文章管理::更改图集";
  422. $win = new OxWindow();
  423. $win->AddTitle("成功更改一个图集:");
  424. $win->AddMsgItem($msg);
  425. $winform = $win->GetWindow("hand","&nbsp;",false);
  426. $win->Display();
  427. }