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

  1. <?php
  2. /**
  3. * 图片选择
  4. *
  5. * @version $Id: select_images.php 2022-07-01 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. $iseditor = isset($iseditor) ? $iseditor : '';
  21. $activepath = str_replace('.', '', $activepath);
  22. $activepath = preg_replace("#\/{1,}#", '/', $activepath);
  23. if (strlen($activepath) < strlen($cfg_image_dir)) {
  24. $activepath = $cfg_image_dir;
  25. }
  26. $inpath = $cfg_basedir.$activepath;
  27. $activeurl = '..'.$activepath;
  28. if (empty($f)) {
  29. $f = 'form1.picname';
  30. }
  31. $f = RemoveXSS($f);
  32. if (empty($v)) {
  33. $v = 'picview';
  34. }
  35. if (empty($comeback)) {
  36. $comeback = '';
  37. }
  38. $addparm = '';
  39. if (!empty($CKEditor)) {
  40. $addparm = '&CKEditor='.$CKEditor;
  41. $f = $CKEditor;
  42. }
  43. if (!empty($CKEditorFuncNum)) {
  44. $addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum;
  45. }
  46. if (!empty($noeditor)) {
  47. $addparm .= '&noeditor=yes';
  48. }
  49. if (!empty($iseditor)) {
  50. $addparm .= '&iseditor='.$iseditor;
  51. }
  52. ?>
  53. <!DOCTYPE html>
  54. <html>
  55. <head>
  56. <meta charset="<?php echo $cfg_soft_lang;?>">
  57. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  58. <title>选择图片</title>
  59. <link rel="stylesheet" href="../../static/web/css/bootstrap.min.css">
  60. <link rel="stylesheet" href="../../static/web/font/css/font-awesome.min.css">
  61. <link rel="stylesheet" href="../../static/web/css/admin.css">
  62. <style>
  63. html{background:#f6f6f6}
  64. table{background:#fff}
  65. a{text-decoration:none!important}
  66. .bg{margin:10px;border-radius:.2rem;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}
  67. .napisdiv{left:10;top:10;width:150px;height:100px;position:absolute;z-index:3;display:none}
  68. .linerow{border-bottom:1px solid #eee!important}
  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 class="bg">
  80. <div id="floater" class="napisdiv">
  81. <a href="javascript:nullLink();" onClick="document.getElementById('floater').style.display='none';"><img src="../../static/web/img/picviewnone.gif" id="picview" title="关闭预览"></a>
  82. </div>
  83. <script src="../js/float.js"></script>
  84. <script>
  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. var iseditor = parseInt(getUrlParam('iseditor'));
  106. if (funcNum > 1) {
  107. var fileUrl = reimg;
  108. window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
  109. }
  110. if (iseditor==1) {
  111. let addonHTML = `<img src='${reimg}'>`;
  112. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  113. } else {
  114. if (window.opener.document.<?php echo $f ?> != null) {
  115. window.opener.document.<?php echo $f ?>.value = reimg;
  116. if (window.opener.document.getElementById('div<?php echo $v ?>')) {
  117. if (TNav() == 'IE') {
  118. //window.opener.document.getElementById('div<?php echo $v ?>').filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = reimg;
  119. window.opener.document.getElementById('div<?php echo $v ?>').src = reimg;
  120. window.opener.document.getElementById('div<?php echo $v ?>').style.width = '150px';
  121. window.opener.document.getElementById('div<?php echo $v ?>').style.height = '100px';
  122. } else
  123. window.opener.document.getElementById('div<?php echo $v ?>').style.backgroundImage = "url(" + reimg + ")";
  124. } else if (window.opener.document.getElementById('<?php echo $v ?>')) {
  125. window.opener.document.getElementById('<?php echo $v ?>').src = reimg;
  126. }
  127. //适配新的缩略图
  128. if (window.opener.document.getElementById('litPic')) {
  129. window.opener.document.getElementById('litPic').src = reimg;
  130. }
  131. if (document.all) window.opener = true;
  132. } else if (typeof window.opener.CKEDITOR.instances["<?php echo $f ?>"] !== "undefined") {
  133. let addonHTML = `<img src='${reimg}'>`;
  134. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  135. }
  136. }
  137. window.close();
  138. }
  139. </script>
  140. <table width="100%" cellpadding="0" cellspacing="1" align="center" class="table table-borderless">
  141. <tr>
  142. <td colspan="4" height="26">
  143. <form action="select_images_post.php" method="POST" enctype="multipart/form-data" name="myform">
  144. <?php $noeditor = !empty($noeditor) ? "<input type='hidden' name='noeditor' value='yes'>" : ''; echo $noeditor;?>
  145. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  146. <input type="hidden" name="f" value="<?php echo $f ?>">
  147. <input type="hidden" name="v" value="<?php echo $v ?>">
  148. <input type="hidden" name="imgstick" value="<?php echo $imgstick ?>">
  149. <input type="hidden" name="CKEditorFuncNum" value="<?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>">
  150. <input type="hidden" name="job" value="upload">
  151. 上传:<input type="file" name="imgfile" style="width:50%;border:none">
  152. <label><input type="checkbox" name="needwatermark" value="1" class="np" <?php if ($photo_markup == '1') echo "checked";?> /> 水印 </label>
  153. <label><input type="checkbox" name="resize" value="1" class="np"> 缩小 </label>
  154. 宽:<input type="text" name="iwidth" value="<?php echo $cfg_ddimg_width ?>" style="width:46px">
  155. 高:<input type="text" name="iheight" value="<?php echo $cfg_ddimg_height ?>" style="width:46px">
  156. <button type="submit" name="sb1" class="btn btn-success btn-sm">上传</button>
  157. </form>
  158. </td>
  159. </tr>
  160. <tr>
  161. <td width="8%" class="linerow">预览</td>
  162. <td width="40%" class="linerow">选择图片</td>
  163. <td width="22%" class="linerow">文件大小</td>
  164. <td width="30%" class="linerow">修改时间</td>
  165. </tr>
  166. <tr>
  167. <td class="linerow" colspan="4">点击图片预览,点击图片名选择图片,显示图片后点击该图片关闭预览</td>
  168. </tr>
  169. <?php
  170. $dh = scandir($inpath);
  171. $ty1 = "";
  172. $ty2 = "";
  173. foreach ($dh as $file) {
  174. //计算文件大小和创建时间
  175. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  176. $filesize = filesize("$inpath/$file");
  177. $filesize = $filesize / 1024;
  178. if ($filesize != "")
  179. if ($filesize < 0.1) {
  180. @list($ty1, $ty2) = explode("\.", $filesize);
  181. $filesize = $ty1.".".substr($ty2, 0, 2);
  182. } else {
  183. @list($ty1, $ty2) = explode("\.", $filesize);
  184. $filesize = $ty1.".".substr($ty2, 0, 1);
  185. }
  186. $filetime = filemtime("$inpath/$file");
  187. $filetime = MyDate("Y-m-d H:i", $filetime);
  188. }
  189. if ($file == ".") continue;
  190. else if ($file == "..") {
  191. if ($activepath == "") continue;
  192. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  193. $line = "<tr>
  194. <td class='linerow' colspan='2'>
  195. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode($tmp).$addparm."'><img src='../../static/web/img/dir2.gif'>上级目录</a></td>
  196. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  197. </tr>";
  198. echo $line;
  199. } else if (is_dir("$inpath/$file")) {
  200. if (preg_match("#^_(.*)$#i", $file)) continue;
  201. if (preg_match("#^\.(.*)$#i", $file)) continue;
  202. $line = "<tr>
  203. <td class='linerow' colspan='2'>
  204. <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>
  205. <td class='linerow'></td>
  206. <td class='linerow'></td>
  207. </tr>";
  208. echo "$line";
  209. } else if (preg_match("#\.(".$cfg_imgtype.")#i", $file)) {
  210. $reurl = "$activeurl/$file";
  211. $reurl = preg_replace("#^\.\.#", "", $reurl);
  212. $reurl = $reurl;
  213. if ($file == $comeback) $lstyle = " class='text-danger' ";
  214. else $lstyle = "";
  215. $line = "<tr>
  216. <td class='linerow'><a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='../../static/web/img/picviewnone.gif'></a></td>
  217. <td class='linerow'><a href=# onclick=\"ReturnImg('$reurl');\" $lstyle><img src='../../static/web/img/gif.gif'>$file</a></td>
  218. <td class='linerow'>$filesize KB</td>
  219. <td class='linerow'>$filetime</td>
  220. </tr>";
  221. echo "$line";
  222. } else if (preg_match("#\.(jpg)#i", $file)) {
  223. $reurl = "$activeurl/$file";
  224. $reurl = preg_replace("#^\.\.#", "", $reurl);
  225. $reurl = $reurl;
  226. if ($file == $comeback) $lstyle = " class='text-danger' ";
  227. else $lstyle = "";
  228. $line = "<tr>
  229. <td class='linerow'><a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='../../static/web/img/picviewnone.gif'></a></td>
  230. <td class='linerow'><a href=# onclick=\"ReturnImg('$reurl');\" $lstyle><img src='../../static/web/img/jpg.gif'>$file</a></td>
  231. <td class='linerow'>$filesize KB</td>
  232. <td class='linerow'>$filetime</td>
  233. </tr>";
  234. echo "$line";
  235. }
  236. }//End Loop
  237. ?>
  238. </tr>
  239. </table>
  240. </body>
  241. </html>