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

230 lines
10KB

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