国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

select_images.php 9.4KB

2 年前
2 年前
2 年前
2 年前
2 年前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
10 个月前
1年前
2 年前
2 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 GNU GPL v2 (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) ? intval($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="utf-8">
  57. <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  58. <title>选择图片</title>
  59. <link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
  60. <link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
  61. <link rel="stylesheet" href="/static/web/css/admin.css">
  62. <script src="/static/web/js/jquery.min.js"></script>
  63. </head>
  64. <body class="p-3">
  65. <div class="card shadow-sm mb-3">
  66. <div class="card-body">
  67. <form name="myform" action="select_images_post.php" method="POST" enctype="multipart/form-data">
  68. <?php $noeditor = !empty($noeditor) ? "<input type='hidden' name='noeditor' value='yes'>" : ''; echo $noeditor;?>
  69. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  70. <input type="hidden" name="f" value="<?php echo $f ?>">
  71. <input type="hidden" name="v" value="<?php echo $v ?>">
  72. <input type="hidden" name="iseditor" value="<?php echo $iseditor ?>">
  73. <input type="hidden" name="imgstick" value="<?php echo $imgstick ?>">
  74. <input type="hidden" name="CKEditorFuncNum" value="<?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>">
  75. <input type="hidden" name="job" value="upload">
  76. <input type="file" name="imgfile">
  77. <label><input type="checkbox" name="needwatermark" value="1" <?php if ($photo_markup == '1') echo 'checked';?>> 水印</label>
  78. <label><input type="checkbox" name="resize" value="1"> 缩小</label>
  79. <label><input type="text" name="iwidth" value="<?php echo $cfg_ddimg_width ?>" class="admin-input-xs"> 宽</label>
  80. <label><input type="text" name="iheight" value="<?php echo $cfg_ddimg_height ?>" class="admin-input-xs"> 高</label>
  81. <button type="submit" class="btn btn-success btn-sm">上传</button>
  82. </form>
  83. </div>
  84. </div>
  85. <div class="card shadow-sm">
  86. <div class="card-header">选择图片</div>
  87. <div class="card-body opt-img">
  88. <?php
  89. $dh = scandir($inpath);
  90. $ty1 = "";
  91. $ty2 = "";
  92. foreach ($dh as $file) {
  93. //计算文件大小和创建时间
  94. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  95. $filesize = filesize("$inpath/$file");
  96. $filesize = $filesize / 1024;
  97. if ($filesize != "")
  98. if ($filesize < 0.1) {
  99. @list($ty1, $ty2) = split("\.", $filesize);
  100. $filesize = $ty1.".".substr($ty2, 0, 2);
  101. } else {
  102. @list($ty1, $ty2) = split("\.", $filesize);
  103. $filesize = $ty1.".".substr($ty2, 0, 1);
  104. }
  105. $filetime = filemtime("$inpath/$file");
  106. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  107. }
  108. //判断文件类型并作处理
  109. if ($file == ".") continue;
  110. else if ($file == "..") {
  111. if ($activepath == "") continue;
  112. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  113. $line = "<div class='d-flex justify-content-between align-items-center mb-3'>
  114. <span>当前目录:$activepath</span>
  115. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode($tmp).$addparm."'><img src='/static/web/img/icon_dir2.png'> 返回上级</a>
  116. </div>";
  117. echo $line;
  118. } else if (is_dir("$inpath/$file")) {
  119. if (preg_match("#^_(.*)$#i", $file)) continue;
  120. if (preg_match("#^\.(.*)$#i", $file)) continue;
  121. $line = "<div class='list dir'>
  122. <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode("$activepath/$file").$addparm."'>
  123. <img src='/static/web/img/icon_dir.png'>
  124. </a>
  125. <span>$file</span>
  126. </div>";
  127. echo "$line";
  128. } else if (preg_match("#\.(".$cfg_imgtype.")#i", $file)) {
  129. $reurl = "$activeurl/$file";
  130. $reurl = preg_replace("#^\.\.#", "", $reurl);
  131. if ($cfg_remote_site == 'Y' && $remoteuploads == 1) {
  132. $reurl = $remoteupUrl.$reurl;
  133. }
  134. if ($file == $comeback) $lstyle = "class='text-danger'";
  135. else $lstyle = '';
  136. $line = "<div class='list'>
  137. <a href='$reurl' onclick=\"ReturnImg('$reurl');\">
  138. <img src='$reurl' title='$file'>
  139. </a>
  140. <span $lstyle>$file</span>
  141. </div>";
  142. echo "$line";
  143. } else if (preg_match("#\.(jpg)#i", $file)) {
  144. $reurl = "$activeurl/$file";
  145. $reurl = preg_replace("#^\.\.#", "", $reurl);
  146. if ($cfg_remote_site == 'Y' && $remoteuploads == 1) {
  147. $reurl = $remoteupUrl.$reurl;
  148. }
  149. if ($file == $comeback) $lstyle = "class='text-danger'";
  150. else $lstyle = '';
  151. $line = "<div class='list'>
  152. <a href='$reurl' onclick=\"ReturnImg('$reurl');\">
  153. <img src='$reurl' title='$file'>
  154. </a>
  155. <span $lstyle>$file</span>
  156. </div>";
  157. echo "$line";
  158. }
  159. }
  160. ?>
  161. </div>
  162. </div>
  163. <script>
  164. function nullLink() {
  165. return;
  166. }
  167. //获取地址参数
  168. function getUrlParam(paramName) {
  169. var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i');
  170. var match = window.location.search.match(reParam);
  171. return (match && match.length > 1) ? match[1] : '';
  172. }
  173. function ReturnImg(reimg) {
  174. var funcNum = getUrlParam('CKEditorFuncNum');
  175. var iseditor = parseInt(getUrlParam('iseditor'));
  176. if (funcNum > 1) {
  177. var fileUrl = reimg;
  178. window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
  179. }
  180. if (iseditor==1) {
  181. let addonHTML = `<img src='${reimg}'>`;
  182. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  183. } else {
  184. if (window.opener.document.<?php echo $f ?> != null) {
  185. window.opener.document.<?php echo $f ?>.value = reimg;
  186. if (window.opener.document.getElementById('div<?php echo $v ?>')) {
  187. window.opener.document.getElementById('<?php echo $v ?>').src = reimg;
  188. }
  189. //适配新的缩略图
  190. if (window.opener.document.getElementById('litPic')) {
  191. window.opener.document.getElementById('litPic').src = reimg;
  192. }
  193. if (document.all) window.opener = true;
  194. } else if (typeof window.opener.CKEDITOR.instances["<?php echo $f ?>"] !== "undefined") {
  195. let addonHTML = `<img src='${reimg}'>`;
  196. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  197. }
  198. }
  199. window.close();
  200. }
  201. </script>
  202. </body>
  203. </html>