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

283 lines
9.9KB

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