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

276 lines
13KB

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