国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
10.0KB

  1. <?php
  2. /**
  3. * 图片选择框
  4. *
  5. * @version $Id: select_images.php 1 9:43 2010年7月8日Z tianya $
  6. * @package DedeCMS.Dialog
  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. include(DEDEDATA.'/mark/inc_photowatermark_config.php');
  13. if(empty($activepath))
  14. {
  15. $activepath = '';
  16. }
  17. if(empty($imgstick))
  18. {
  19. $imgstick = '';
  20. }
  21. $noeditor = isset($noeditor)? $noeditor : '';
  22. $activepath = str_replace('.', '', $activepath);
  23. $activepath = preg_replace("#\/{1,}#", '/', $activepath);
  24. if(strlen($activepath) < strlen($cfg_medias_dir))
  25. {
  26. $activepath = $cfg_medias_dir;
  27. }
  28. $inpath = $cfg_basedir.$activepath;
  29. $activeurl = '..'.$activepath;
  30. if(empty($f))
  31. {
  32. $f = 'form1.picname';
  33. }
  34. if(empty($v))
  35. {
  36. $v = 'picview';
  37. }
  38. if(empty($comeback))
  39. {
  40. $comeback = '';
  41. }
  42. $addparm = '';
  43. if (!empty($CKEditor))
  44. {
  45. $addparm = '&CKEditor='.$CKEditor;
  46. $f = $CKEditor;
  47. }
  48. if (!empty($CKEditorFuncNum))
  49. {
  50. $addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum;
  51. }
  52. if (!empty($noeditor))
  53. {
  54. $addparm .= '&noeditor=yes';
  55. }
  56. ?>
  57. <html>
  58. <head>
  59. <meta http-equiv='Content-Type' content='text/html; charset=<?php echo $cfg_soft_lang; ?>'>
  60. <title>图片浏览器</title>
  61. <link href='../../images/img/base.css' rel='stylesheet' type='text/css'>
  62. <style>
  63. .linerow {border-bottom: 1px solid #CBD8AC;}
  64. .napisdiv {left:40;top:3;width:150px;height:100px;position:absolute;z-index:3;display:none;}
  65. </style>
  66. <script>
  67. function nullLink(){ return; }
  68. function ChangeImage(surl){ document.getElementById('picview').src = surl; }
  69. </script>
  70. </head>
  71. <body background='img/allbg.gif' leftmargin='0' topmargin='0'>
  72. <div id="floater" class="napisdiv">
  73. <a href="javascript:nullLink();" onClick="document.getElementById('floater').style.display='none';"><img src='img/picviewnone.gif' id='picview' border='0' alt='单击关闭预览'></a>
  74. </div>
  75. <SCRIPT language=JavaScript src="js/float.js"></SCRIPT>
  76. <SCRIPT language=JavaScript>
  77. function nullLink(){ return; }
  78. function ChangeImage(surl){ document.getElementById('floater').style.display='block';document.getElementById('picview').src = surl; }
  79. function TNav()
  80. {
  81. if(window.navigator.userAgent.indexOf("MSIE")>=1) return 'IE';
  82. else if(window.navigator.userAgent.indexOf("Firefox")>=1) return 'FF';
  83. else return "OT";
  84. }
  85. // 获取地址参数
  86. function getUrlParam(paramName)
  87. {
  88. var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i') ;
  89. var match = window.location.search.match(reParam) ;
  90. return (match && match.length > 1) ? match[1] : '' ;
  91. }
  92. function ReturnImg(reimg)
  93. {
  94. var funcNum = getUrlParam('CKEditorFuncNum');
  95. if(funcNum > 1)
  96. {
  97. var fileUrl = reimg;
  98. window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
  99. }
  100. if(window.opener.document.<?php echo $f?> != null)
  101. {
  102. window.opener.document.<?php echo $f?>.value=reimg;
  103. if(window.opener.document.getElementById('div<?php echo $v?>'))
  104. {
  105. if(TNav()=='IE'){
  106. //window.opener.document.getElementById('div<?php echo $v?>').filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = reimg;
  107. window.opener.document.getElementById('div<?php echo $v?>').src = reimg;
  108. window.opener.document.getElementById('div<?php echo $v?>').style.width = '150px';
  109. window.opener.document.getElementById('div<?php echo $v?>').style.height = '100px';
  110. }
  111. else
  112. window.opener.document.getElementById('div<?php echo $v?>').style.backgroundImage = "url("+reimg+")";
  113. }
  114. else if(window.opener.document.getElementById('<?php echo $v?>')){
  115. window.opener.document.getElementById('<?php echo $v?>').src = reimg;
  116. }
  117. if(document.all) window.opener=true;
  118. }
  119. window.close();
  120. }
  121. </SCRIPT>
  122. <table width='100%' border='0' cellspacing='0' cellpadding='0' align="center">
  123. <tr>
  124. <td colspan='4' align='right'>
  125. <table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#CBD8AC'>
  126. <tr bgcolor='#FFFFFF'>
  127. <td colspan='4'>
  128. <table width='100%' border='0' cellspacing='0' cellpadding='2'>
  129. <tr bgcolor="#CCCCCC">
  130. <td width="8%" align="center" class='linerow' bgcolor='#EEF4EA'><strong>预览</strong></td>
  131. <td width="47%" align="center" background="img/wbg.gif" class='linerow'><strong>点击名称选择图片</strong></td>
  132. <td width="15%" align="center" bgcolor='#EEF4EA' class='linerow'><strong>文件大小</strong></td>
  133. <td width="30%" align="center" background="img/wbg.gif" class='linerow'><strong>最后修改时间</strong></td>
  134. </tr>
  135. <tr>
  136. <td class='linerow' colspan='4' bgcolor='#F9FBF0'>
  137. 点击“V”预览图片,点击图片名选择图片,显示图片后点击该图片关闭预览。
  138. </td>
  139. </tr>
  140. <?php
  141. $dh = dir($inpath);
  142. $ty1="";
  143. $ty2="";
  144. while($file = $dh->read()) {
  145. //-----计算文件大小和创建时间
  146. if($file!="." && $file!=".." && !is_dir("$inpath/$file")){
  147. $filesize = filesize("$inpath/$file");
  148. $filesize = $filesize / 1024;
  149. if($filesize != "")
  150. if($filesize < 0.1){
  151. @list($ty1, $ty2) = split("\.", $filesize);
  152. $filesize = $ty1.".".substr($ty2, 0, 2);
  153. }
  154. else{
  155. @list($ty1, $ty2) = split("\.", $filesize);
  156. $filesize = $ty1.".".substr($ty2, 0, 1);
  157. }
  158. $filetime = filemtime("$inpath/$file");
  159. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  160. }
  161. if($file == ".") continue;
  162. else if($file == "..")
  163. {
  164. if($activepath == "") continue;
  165. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  166. $line = "\n<tr>
  167. <td class='linerow' colspan='2'>
  168. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode($tmp).$addparm."'><img src=img/dir2.gif border=0 width=16 height=16 align=absmiddle>上级目录</a></td>
  169. <td colspan='2' class='linerow'> 当前目录:$activepath</td>
  170. </tr>
  171. ";
  172. echo $line;
  173. }
  174. else if(is_dir("$inpath/$file"))
  175. {
  176. if(preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录
  177. if(preg_match("#^\.(.*)$#i", $file)) continue;
  178. $line = "\n<tr>
  179. <td bgcolor='#F9FBF0' class='linerow' colspan='2'>
  180. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode("$activepath/$file").$addparm."'><img src=img/dir.gif border=0 width=16 height=16 align=absmiddle>$file</a></td>
  181. <td class='linerow'> </td>
  182. <td bgcolor='#F9FBF0' class='linerow'> </td>
  183. </tr>";
  184. echo "$line";
  185. }
  186. else if(preg_match("#\.(gif|png)#i", $file))
  187. {
  188. $reurl = "$activeurl/$file";
  189. $reurl = preg_replace("#^\.\.#", "", $reurl);
  190. if($cfg_remote_site=='Y' && $remoteuploads == 1)
  191. {
  192. $reurl = $remoteupUrl.$reurl;
  193. }else{
  194. $reurl = $reurl;
  195. }
  196. if($file==$comeback) $lstyle = " style='color:red' ";
  197. else $lstyle = "";
  198. $line = "\n<tr>
  199. <td align='center' class='linerow' bgcolor='#F9FBF0'>
  200. <a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='img/picviewnone.gif' width='16' height='16' border='0' align=absmiddle></a>
  201. </td>
  202. <td class='linerow' bgcolor='#F9FBF0'>
  203. <a href=# onclick=\"ReturnImg('$reurl');\" $lstyle><img src=img/gif.gif border=0 width=16 height=16 align=absmiddle>$file</a></td>
  204. <td class='linerow'>$filesize KB</td>
  205. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  206. </tr>";
  207. echo "$line";
  208. }
  209. else if(preg_match("#\.(jpg)#i", $file))
  210. {
  211. $reurl = "$activeurl/$file";
  212. $reurl = preg_replace("#^\.\.#", "", $reurl);
  213. if($cfg_remote_site=='Y' && $remoteuploads == 1)
  214. {
  215. $reurl = $remoteupUrl.$reurl;
  216. }else{
  217. $reurl = $reurl;
  218. }
  219. if($file==$comeback) $lstyle = " style='color:red' ";
  220. else $lstyle = "";
  221. $line = "\n<tr>
  222. <td align='center' class='linerow' bgcolor='#F9FBF0'>
  223. <a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='img/picviewnone.gif' width='16' height='16' border='0' align=absmiddle></a>
  224. </td>
  225. <td class='linerow' bgcolor='#F9FBF0'>
  226. <a href=# onclick=\"ReturnImg('$reurl');\" $lstyle><img src=img/jpg.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  227. </td>
  228. <td class='linerow'>$filesize KB</td>
  229. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  230. </tr>";
  231. echo "$line";
  232. }
  233. }//End Loop
  234. $dh->close();
  235. ?>
  236. <tr>
  237. <td colspan='4' bgcolor='#E8F1DE'>
  238. <table width='100%'>
  239. <form action='select_images_post.php' method='POST' enctype="multipart/form-data" name='myform'>
  240. <?php $noeditor = !empty($noeditor)?"<input type='hidden' name='noeditor' value='yes'>":''; echo $noeditor;//(2011.08.25 根据用户反馈修正图片上传回调 by:织梦的鱼)?>
  241. <input type='hidden' name='activepath' value='<?php echo $activepath?>'>
  242. <input type='hidden' name='f' value='<?php echo $f?>'>
  243. <input type='hidden' name='v' value='<?php echo $v?>'>
  244. <input type='hidden' name='imgstick' value='<?php echo $imgstick?>'>
  245. <input type='hidden' name='CKEditorFuncNum' value='<?php echo isset($CKEditorFuncNum)? $CKEditorFuncNum : 1;?>'>
  246. <input type='hidden' name='job' value='upload'>
  247. <tr>
  248. <td background="img/tbg.gif" bgcolor="#99CC00">
  249. &nbsp;上 传: <input type='file' name='imgfile' style='width:250px'/>
  250. <input type='checkbox' name='needwatermark' value='1' class='np' <?php if($photo_markup=='1') echo "checked"; ?> />水印
  251. <input type='checkbox' name='resize' value='1' class='np' />缩小
  252. 宽:<input type='text' style='width:30' name='iwidth' value='<?php echo $cfg_ddimg_width?>' />
  253. 高:<input type='text' style='width:30' name='iheight' value='<?php echo $cfg_ddimg_height?>' />
  254. <input type='submit' name='sb1' value='确定' />
  255. </td>
  256. </tr>
  257. </form>
  258. </table>
  259. </td>
  260. </tr>
  261. </table>
  262. </td>
  263. </tr>
  264. </table>
  265. </td>
  266. </tr>
  267. </table>
  268. </body>
  269. </html>