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

241 lines
12KB

  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 charset="<?php echo $cfg_soft_lang; ?>">
  52. <title>图片浏览器</title>
  53. <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
  54. <link rel="stylesheet" href="../../static/font-awesome/css/font-awesome.min.css">
  55. <link rel="stylesheet" href="../css/base.css">
  56. <style>
  57. html{background:#f2f2f2}
  58. body{margin:0;line-height:1.5;font:12px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif}
  59. a{text-decoration:none!important}
  60. table{background:#fff}
  61. .bg{margin:10px;border-radius:.2rem;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}
  62. .linerow{border-bottom:1px solid #eee!important}
  63. .napisdiv{left:40;top:10;width:150px;height:100px;position:absolute;z-index:3;display:none}
  64. </style>
  65. <script>
  66. function nullLink() {
  67. return;
  68. }
  69. function ChangeImage(surl) {
  70. document.getElementById('picview').src = surl;
  71. }
  72. </script>
  73. </head>
  74. <body class="bg">
  75. <div id="floater" class="napisdiv">
  76. <a href="javascript:nullLink();" onClick="document.getElementById('floater').style.display='none';"><img src="img/picviewnone.gif" id='picview' alt="关闭预览"></a>
  77. </div>
  78. <script src="../js/float.js"></script>
  79. <script>
  80. function nullLink() {
  81. return;
  82. }
  83. function ChangeImage(surl) {
  84. document.getElementById('floater').style.display = 'block';
  85. document.getElementById('picview').src = surl;
  86. }
  87. function TNav() {
  88. if (window.navigator.userAgent.indexOf("MSIE") >= 1) return 'IE';
  89. else if (window.navigator.userAgent.indexOf("Firefox") >= 1) return 'FF';
  90. else return "OT";
  91. }
  92. //获取地址参数
  93. function getUrlParam(paramName) {
  94. var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i');
  95. var match = window.location.search.match(reParam);
  96. return (match && match.length > 1) ? match[1] : '';
  97. }
  98. function ReturnImg(reimg) {
  99. var funcNum = getUrlParam('CKEditorFuncNum');
  100. if (funcNum > 1) {
  101. var fileUrl = reimg;
  102. window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
  103. }
  104. if (window.opener.document.<?php echo $f ?> != null) {
  105. window.opener.document.<?php echo $f ?>.value = reimg;
  106. if (window.opener.document.getElementById('div<?php echo $v ?>')) {
  107. if (TNav() == 'IE') {
  108. //window.opener.document.getElementById('div<?php echo $v ?>').filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = reimg;
  109. window.opener.document.getElementById('div<?php echo $v ?>').src = reimg;
  110. window.opener.document.getElementById('div<?php echo $v ?>').style.width = '150px';
  111. window.opener.document.getElementById('div<?php echo $v ?>').style.height = '100px';
  112. } else
  113. window.opener.document.getElementById('div<?php echo $v ?>').style.backgroundImage = "url(" + reimg + ")";
  114. } else if (window.opener.document.getElementById('<?php echo $v ?>')) {
  115. window.opener.document.getElementById('<?php echo $v ?>').src = reimg;
  116. }
  117. //适配新的缩略图
  118. if (window.opener.document.getElementById('litPic')) {
  119. window.opener.document.getElementById('litPic').src = reimg;
  120. }
  121. if (document.all) window.opener = true;
  122. }
  123. window.close();
  124. }
  125. </script>
  126. <table width="100%" border="0" cellpadding="0" cellspacing="1" align="center" class="table table-borderless">
  127. <tr>
  128. <td colspan="4">
  129. <table width="100%" border="0" cellspacing="0" cellpadding="2">
  130. <tr>
  131. <td width="10%" class="linerow">预览</td>
  132. <td width="40%" class="linerow">选择图片</td>
  133. <td width="20%" class="linerow">文件大小</td>
  134. <td width="30%" class="linerow">修改时间</td>
  135. </tr>
  136. <tr>
  137. <td class="linerow" colspan="4">点击V预览图片,点击图片名选择图片,显示图片后点击该图片关闭预览</td>
  138. </tr>
  139. <?php
  140. $dh = dir($inpath);
  141. $ty1 = "";
  142. $ty2 = "";
  143. while ($file = $dh->read()) {
  144. //计算文件大小和创建时间
  145. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  146. $filesize = filesize("$inpath/$file");
  147. $filesize = $filesize / 1024;
  148. if ($filesize != "")
  149. if ($filesize < 0.1) {
  150. @list($ty1, $ty2) = split("\.", $filesize);
  151. $filesize = $ty1 . "." . substr($ty2, 0, 2);
  152. } else {
  153. @list($ty1, $ty2) = split("\.", $filesize);
  154. $filesize = $ty1 . "." . substr($ty2, 0, 1);
  155. }
  156. $filetime = filemtime("$inpath/$file");
  157. $filetime = MyDate("Y-m-d H:i", $filetime);
  158. }
  159. if ($file == ".") continue;
  160. else if ($file == "..") {
  161. if ($activepath == "") continue;
  162. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  163. $line = "\n<tr>
  164. <td class='linerow' colspan='2'>
  165. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=" . urlencode($tmp) . $addparm . "'><img src='img/dir2.gif'>上级目录</a></td>
  166. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  167. </tr>";
  168. echo $line;
  169. } else if (is_dir("$inpath/$file")) {
  170. if (preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录
  171. if (preg_match("#^\.(.*)$#i", $file)) continue;
  172. $line = "\n<tr>
  173. <td class='linerow' colspan='2'>
  174. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=" . urlencode("$activepath/$file") . $addparm . "'><img src='img/dir.gif'>$file</a></td>
  175. <td class='linerow'></td>
  176. <td class='linerow'></td>
  177. </tr>";
  178. echo "$line";
  179. } else if (preg_match("#\.(" . $cfg_imgtype . ")#i", $file)) {
  180. $reurl = "$activeurl/$file";
  181. $reurl = preg_replace("#^\.\.#", "", $reurl);
  182. $reurl = $reurl;
  183. if ($file == $comeback) $lstyle = " style='color:red' ";
  184. else $lstyle = "";
  185. $line = "\n<tr>
  186. <td class='linerow'><a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='img/picviewnone.gif'></a>
  187. </td>
  188. <td class='linerow'><a href=# onclick=\"ReturnImg('$reurl');\" $lstyle><img src='img/gif.gif'>$file</a></td>
  189. <td class='linerow'>$filesize KB</td>
  190. <td class='linerow'>$filetime</td>
  191. </tr>";
  192. echo "$line";
  193. } else if (preg_match("#\.(jpg)#i", $file)) {
  194. $reurl = "$activeurl/$file";
  195. $reurl = preg_replace("#^\.\.#", "", $reurl);
  196. $reurl = $reurl;
  197. if ($file == $comeback) $lstyle = " style='color:red' ";
  198. else $lstyle = "";
  199. $line = "\n<tr>
  200. <td class='linerow'><a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='img/picviewnone.gif'></a></td>
  201. <td class='linerow'><a href=# onclick=\"ReturnImg('$reurl');\" $lstyle><img src='img/jpg.gif'>$file</a></td>
  202. <td class='linerow'>$filesize KB</td>
  203. <td class='linerow'>$filetime</td>
  204. </tr>";
  205. echo "$line";
  206. }
  207. } //End Loop
  208. $dh->close();
  209. ?>
  210. <tr>
  211. <td colspan="4">
  212. <table width="100%">
  213. <form action="select_images_post.php" method="POST" enctype="multipart/form-data" name="myform">
  214. <?php $noeditor = !empty($noeditor) ? "<input type='hidden' name='noeditor' value='yes'>" : '';
  215. echo $noeditor; ?>
  216. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  217. <input type="hidden" name="f" value="<?php echo $f ?>">
  218. <input type="hidden" name="v" value="<?php echo $v ?>">
  219. <input type="hidden" name="imgstick" value="<?php echo $imgstick ?>">
  220. <input type="hidden" name="CKEditorFuncNum" value="<?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1; ?>">
  221. <input type="hidden" name="job" value="upload">
  222. <tr>
  223. <td>
  224. 上传:<input type="file" name="imgfile" style="width:160px;border:none">
  225. <label><input type="checkbox" name="needwatermark" value="1" class="np" <?php if ($photo_markup == '1') echo "checked"; ?> /> 水印 </label>
  226. <label><input type="checkbox" name="resize" value="1" class="np"> 缩小 </label>
  227. 宽:<input type="text" name="iwidth" value="<?php echo $cfg_ddimg_width ?>" style="width:46px">
  228. 高:<input type="text" name="iheight" value="<?php echo $cfg_ddimg_height ?>" style="width:46px">
  229. <button type="submit" name="sb1" class="btn btn-success btn-sm">确定</button>
  230. </td>
  231. </tr>
  232. </form>
  233. </table>
  234. </td>
  235. </tr>
  236. </table>
  237. </td>
  238. </tr>
  239. </table>
  240. </body>
  241. </html>