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

select_images.php 11KB

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