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

189 lines
9.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 GNU GPL v2 (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 name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  48. <title>选择多媒体</title>
  49. <link rel="stylesheet" href="/static/web/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. </head>
  53. <body class="p-3">
  54. <div class="card shadow-sm mb-3">
  55. <div class="card-body">
  56. <form name="myform" action="select_media_post.php" method="POST" enctype="multipart/form-data">
  57. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  58. <?php $noeditor = !empty($noeditor) ? "<input type='hidden' name='noeditor' value='yes'>" : ''; echo $noeditor;?>
  59. <input type="hidden" name="f" value="<?php echo $f ?>">
  60. <input type="hidden" name="job" value="upload">
  61. <input type="hidden" name="CKEditorFuncNum" value="<?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>">
  62. <input type="file" name="uploadfile">
  63. <button type="submit" class="btn btn-success btn-sm">上传</button>
  64. </form>
  65. </div>
  66. </div>
  67. <div class="card shadow-sm">
  68. <div class="card-header">选择多媒体</div>
  69. <div class="card-body">
  70. <div class="table-responsive">
  71. <table class="table table-borderless icon">
  72. <thead>
  73. <tr>
  74. <td scope="col">文件名称</td>
  75. <td scope="col">文件大小</td>
  76. <td scope="col">修改时间</td>
  77. </tr>
  78. </thead>
  79. <tbody>
  80. <?php
  81. $dh = scandir($inpath);
  82. $ty1 = '';
  83. $ty2 = '';
  84. foreach ($dh as $file) {
  85. //计算文件大小和创建时间
  86. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  87. $filesize = filesize("$inpath/$file");
  88. $filesize = $filesize / 1024;
  89. if ($filesize != "")
  90. if ($filesize < 0.1) {
  91. @list($ty1, $ty2) = split("\.", $filesize);
  92. $filesize = $ty1.".".substr($ty2, 0, 2);
  93. } else {
  94. @list($ty1, $ty2) = split("\.", $filesize);
  95. $filesize = $ty1.".".substr($ty2, 0, 1);
  96. }
  97. $filetime = filemtime("$inpath/$file");
  98. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  99. }
  100. //判断文件类型并作处理
  101. if ($file == ".") continue;
  102. else if ($file == "..") {
  103. if ($activepath == "") continue;
  104. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  105. $line = "<tr>
  106. <td><a href='select_media.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='/static/web/img/icon_dir2.png'> 上级目录</a></td>
  107. <td colspan='2'>当前目录:$activepath</td>
  108. </tr>";
  109. echo $line;
  110. } else if (is_dir("$inpath/$file")) {
  111. if (preg_match("#^_(.*)$#i", $file)) continue;
  112. if (preg_match("#^\.(.*)$#i", $file)) continue;
  113. $line = "<tr>
  114. <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>
  115. </tr>";
  116. echo "$line";
  117. } else if (preg_match("#\.(swf|fly|fla|flv)#i", $file)) {
  118. $reurl = "$activeurl/$file";
  119. $reurl = preg_replace("#^\.\.#", "", $reurl);
  120. $reurl = $reurl;
  121. if ($file == $comeback) $lstyle = "class='text-danger'";
  122. else $lstyle = '';
  123. $line = "<tr>
  124. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_flash.png'> $file</a></td>
  125. <td>$filesize KB</td>
  126. <td align='center'>$filetime</td>
  127. </tr>";
  128. echo "$line";
  129. } else if (preg_match("#\.(wmv|avi)#i", $file)) {
  130. $reurl = "$activeurl/$file";
  131. $reurl = preg_replace("#^\.\.#", "", $reurl);
  132. $reurl = $reurl;
  133. if ($file == $comeback) $lstyle = "class='text-danger'";
  134. else $lstyle = '';
  135. $line = "<tr>
  136. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_video.png'> $file</a></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><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_rm.png'> $file</a></td>
  149. <td>$filesize KB</td>
  150. <td align='center'>$filetime</td>
  151. </tr>";
  152. echo "$line";
  153. } else if (preg_match("#\.(mp3|wma)#", $file)) {
  154. $reurl = "$activeurl/$file";
  155. $reurl = preg_replace("#^\.\.#", "", $reurl);
  156. $reurl = $reurl;
  157. if ($file == $comeback) $lstyle = "class='text-danger'";
  158. else $lstyle = '';
  159. $line = "<tr>
  160. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_music.png'> $file</a></td>
  161. <td>$filesize KB</td>
  162. <td align='center'>$filetime</td>
  163. </tr>";
  164. echo "$line";
  165. }
  166. }
  167. ?>
  168. </tbody>
  169. </table>
  170. </div>
  171. </div>
  172. </div>
  173. <script>
  174. function nullLink() {
  175. return;
  176. }
  177. function ReturnValue(reimg) {
  178. if (window.opener.document.<?php echo $f ?> != null) {
  179. window.opener.document.<?php echo $f ?>.value = reimg;
  180. }
  181. var funcNum = <?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>;
  182. if (window.opener.CKEDITOR != null && funcNum != 1) {
  183. window.opener.CKEDITOR.tools.callFunction(funcNum, reimg);
  184. }
  185. window.close();
  186. }
  187. </script>
  188. </body>
  189. </html>