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

192 lines
8.6KB

  1. <?php
  2. /**
  3. * 选择多媒体
  4. *
  5. * @version $id:select_media.php 9:43 2010年7月8日 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. if (empty($activepath)) {
  13. $activepath = '';
  14. }
  15. $noeditor = isset($noeditor) ? $noeditor : '';
  16. $activepath = str_replace('.', '', $activepath);
  17. $activepath = preg_replace("#\/{1,}#", '/', $activepath);
  18. if (strlen($activepath) < strlen($cfg_other_medias)) {
  19. $activepath = $cfg_other_medias;
  20. }
  21. $inpath = $cfg_basedir.$activepath;
  22. $activeurl = '..'.$activepath;
  23. if (!is_dir($inpath)) {
  24. die('No Exsits Path');
  25. }
  26. if (empty($f)) {
  27. $f = 'form1.enclosure';
  28. }
  29. if (empty($comeback)) {
  30. $comeback = '';
  31. }
  32. $addparm = '';
  33. if (!empty($CKEditor)) {
  34. $addparm = '&CKEditor='.$CKEditor;
  35. }
  36. if (!empty($CKEditorFuncNum)) {
  37. $addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum;
  38. }
  39. if (!empty($noeditor)) {
  40. $addparm .= '&noeditor=yes';
  41. }
  42. ?>
  43. <!DOCTYPE html>
  44. <html>
  45. <head>
  46. <meta charset="utf-8">
  47. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  48. <title>选择多媒体</title>
  49. <link rel="stylesheet" href="../../static/web/font/css/font-awesome.min.css">
  50. <link rel="stylesheet" href="../../static/web/css/bootstrap.min.css">
  51. <link rel="stylesheet" href="../../static/web/css/admin.css">
  52. <style>body{background:#f5f5f5}.upload-bg{margin:10px;background:#fff;border-radius:.5rem;box-shadow:0 .125rem .25rem rgba(0,0,0,.075)}</style>
  53. </head>
  54. <body>
  55. <div class="upload-bg">
  56. <table align="center" class="table icon">
  57. <tr>
  58. <td colspan="3">
  59. <form action="select_media_post.php" method="POST" enctype="multipart/form-data" name="myform">
  60. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  61. <input type="hidden" name="f" value="<?php echo $f ?>">
  62. <input type="hidden" name="job" value="upload">
  63. <input type="hidden" name="CKEditorFuncNum" value="<?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>">
  64. <input type="file" name="uploadfile" class="w-75">
  65. <button type="submit" name="sb1" class="btn btn-success btn-sm">上传</button>
  66. </form>
  67. </td>
  68. </tr>
  69. <tr>
  70. <td width="50%">点击名称选择文件</td>
  71. <td width="20%">文件大小</td>
  72. <td>最后修改时间</td>
  73. </tr>
  74. <?php
  75. $dh = scandir($inpath);
  76. $ty1 = "";
  77. $ty2 = "";
  78. foreach ($dh as $file) {
  79. //计算文件大小和创建时间
  80. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  81. $filesize = filesize("$inpath/$file");
  82. $filesize = $filesize / 1024;
  83. if ($filesize != "")
  84. if ($filesize < 0.1) {
  85. @list($ty1, $ty2) = split("\.", $filesize);
  86. $filesize = $ty1.".".substr($ty2, 0, 2);
  87. } else {
  88. @list($ty1, $ty2) = split("\.", $filesize);
  89. $filesize = $ty1.".".substr($ty2, 0, 1);
  90. }
  91. $filetime = filemtime("$inpath/$file");
  92. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  93. }
  94. //判断文件类型并作处理
  95. if ($file == ".") continue;
  96. else if ($file == "..") {
  97. if ($activepath == "") continue;
  98. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  99. $line = "<tr>
  100. <td><a href='select_media.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='../../static/web/img/icon_dir2.png'>上级目录</a></td>
  101. <td colspan='2'>当前目录:$activepath</td>
  102. </tr>";
  103. echo $line;
  104. } else if (is_dir("$inpath/$file")) {
  105. if (preg_match("#^_(.*)$#i", $file)) continue;
  106. if (preg_match("#^\.(.*)$#i", $file)) continue;
  107. $line = "<tr>
  108. <td colspan='3'><a href=select_media.php?f=$f&activepath=".urlencode("$activepath/$file").$addparm."><img src='../../static/web/img/icon_dir.png'>$file</a></td>
  109. </tr>";
  110. echo "$line";
  111. } else if (preg_match("#\.(swf|fly|fla|flv)#i", $file)) {
  112. $reurl = "$activeurl/$file";
  113. $reurl = preg_replace("#^\.\.#", "", $reurl);
  114. $reurl = $reurl;
  115. if ($file == $comeback) $lstyle = "class='text-danger'";
  116. else $lstyle = "";
  117. $line = "<tr>
  118. <td>
  119. <img src='../../static/web/img/icon_flash.png'>
  120. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  121. </td>
  122. <td>$filesize KB</td>
  123. <td align='center'>$filetime</td>
  124. </tr>";
  125. echo "$line";
  126. } else if (preg_match("#\.(wmv|avi)#i", $file)) {
  127. $reurl = "$activeurl/$file";
  128. $reurl = preg_replace("#^\.\.#", "", $reurl);
  129. $reurl = $reurl;
  130. if ($file == $comeback) $lstyle = "class='text-danger'";
  131. else $lstyle = "";
  132. $line = "<tr>
  133. <td>
  134. <img src='../../static/web/img/icon_video.png'>
  135. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  136. </td>
  137. <td>$filesize KB</td>
  138. <td align='center'>$filetime</td>
  139. </tr>";
  140. echo "$line";
  141. } else if (preg_match("#\.(rm|rmvb|mp3|mp4)#i", $file)) {
  142. $reurl = "$activeurl/$file";
  143. $reurl = preg_replace("#^\.\.#", "", $reurl);
  144. $reurl = $reurl;
  145. if ($file == $comeback) $lstyle = "class='text-danger'";
  146. else $lstyle = "";
  147. $line = "<tr>
  148. <td>
  149. <img src='../../static/web/img/icon_rm.png'>
  150. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  151. </td>
  152. <td>$filesize KB</td>
  153. <td align='center'>$filetime</td>
  154. </tr>";
  155. echo "$line";
  156. } else if (preg_match("#\.(mp3|wma)#", $file)) {
  157. $reurl = "$activeurl/$file";
  158. $reurl = preg_replace("#^\.\.#", "", $reurl);
  159. $reurl = $reurl;
  160. if ($file == $comeback) $lstyle = "class='text-danger'";
  161. else $lstyle = "";
  162. $line = "<tr>
  163. <td>
  164. <img src='../../static/web/img/icon_music.png'>
  165. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  166. </td>
  167. <td>$filesize KB</td>
  168. <td align='center'>$filetime</td>
  169. </tr>";
  170. echo "$line";
  171. }
  172. }//End Loop
  173. ?>
  174. </table>
  175. </div>
  176. <script>
  177. function nullLink() {
  178. return;
  179. }
  180. function ReturnValue(reimg) {
  181. if (window.opener.document.<?php echo $f ?> != null) {
  182. window.opener.document.<?php echo $f ?>.value = reimg;
  183. }
  184. var funcNum = <?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>;
  185. if (window.opener.CKEDITOR != null && funcNum != 1) {
  186. window.opener.CKEDITOR.tools.callFunction(funcNum, reimg);
  187. }
  188. window.close();
  189. }
  190. </script>
  191. </body>
  192. </html>