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

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