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

187 lines
7.9KB

  1. <?php
  2. /**
  3. * 多媒体选择框
  4. *
  5. * @version $Id: select_media.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. 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. <html>
  44. <head>
  45. <meta http-equiv='Content-Type' content='text/html; charset=<?php echo $cfg_soft_lang; ?>'>
  46. <title>媒体文件管理器</title>
  47. <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
  48. <link rel="stylesheet" href="../../static/font-awesome/css/font-awesome.min.css">
  49. <link rel="stylesheet" href="../css/base.css">
  50. <style>
  51. html{background:#f2f2f2}
  52. body{margin:0;line-height:1.5;font:12px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif}
  53. a{text-decoration:none!important}
  54. table{background:#fff}
  55. .bg{margin:10px;border-radius:.2rem;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}
  56. .linerow{border-bottom:1px solid #eee!important}
  57. </style>
  58. </head>
  59. <body class="bg">
  60. <script>
  61. function nullLink() {
  62. return;
  63. }
  64. function ReturnValue(reimg) {
  65. if (window.opener.document.<?php echo $f ?> != null) {
  66. window.opener.document.<?php echo $f ?>.value = reimg;
  67. }
  68. var funcNum = <?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1; ?>;
  69. if (window.opener.CKEDITOR != null && funcNum != 1) {
  70. window.opener.CKEDITOR.tools.callFunction(funcNum, reimg);
  71. }
  72. window.close();
  73. }
  74. </script>
  75. <table width="100%" border="0" align="center" cellspacing="0" cellpadding="2" class="table table-borderless">
  76. <tr>
  77. <td colspan="3" height="30">
  78. <form action="select_media_post.php" method="POST" enctype="multipart/form-data" name="myform">
  79. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  80. <input type="hidden" name="f" value="<?php echo $f ?>">
  81. <input type="hidden" name="job" value="upload">
  82. <input type="hidden" name="CKEditorFuncNum" value="<?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1; ?>">
  83. 上传:<input type="file" name="uploadfile" style="width:160px;border:none">
  84. <button type="submit" name="sb1" class="btn btn-success btn-sm">确定</button>
  85. </form>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td width="55%" align="center" class="linerow">点击名称选择文件</td>
  90. <td width="15%" align="center" class="linerow">文件大小</td>
  91. <td width="30%" align="center" class="linerow">最后修改时间</td>
  92. </tr>
  93. <?php
  94. $dh = dir($inpath);
  95. $ty1 = "";
  96. $ty2 = "";
  97. while ($file = $dh->read()) {
  98. //计算文件大小和创建时间
  99. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  100. $filesize = filesize("$inpath/$file");
  101. $filesize = $filesize / 1024;
  102. if ($filesize != "")
  103. if ($filesize < 0.1) {
  104. @list($ty1, $ty2) = split("\.", $filesize);
  105. $filesize = $ty1.".".substr($ty2, 0, 2);
  106. } else {
  107. @list($ty1, $ty2) = split("\.", $filesize);
  108. $filesize = $ty1.".".substr($ty2, 0, 1);
  109. }
  110. $filetime = filemtime("$inpath/$file");
  111. $filetime = MyDate("Y-m-d H:i", $filetime);
  112. }
  113. //判断文件类型并作处理
  114. if ($file == ".") continue;
  115. else if ($file == "..") {
  116. if ($activepath == "") continue;
  117. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  118. $line = "<tr>
  119. <td class='linerow'><a href='select_media.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='img/dir2.gif'>上级目录</a></td>
  120. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  121. </tr>";
  122. echo $line;
  123. } else if (is_dir("$inpath/$file")) {
  124. if (preg_match("#^_(.*)$#i", $file)) continue;
  125. if (preg_match("#^\.(.*)$#i", $file)) continue;
  126. $line = "<tr>
  127. <td class='linerow'><a href=select_media.php?f=$f&activepath=".urlencode("$activepath/$file").$addparm."><img src='img/dir.gif'>$file</a></td>
  128. <td class='linerow'></td>
  129. <td class='linerow'></td>
  130. </tr>";
  131. echo "$line";
  132. } else if (preg_match("#\.(swf|fly|fla|flv)#i", $file)) {
  133. $reurl = "$activeurl/$file";
  134. $reurl = preg_replace("#^\.\.#", "", $reurl);
  135. $reurl = $reurl;
  136. if ($file == $comeback) $lstyle = " style='color:red' ";
  137. else $lstyle = "";
  138. $line = "<tr>
  139. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\"><img src='img/flash.gif'>$file</a></td>
  140. <td class='linerow'>$filesize KB</td>
  141. <td align='center' class='linerow'>$filetime</td>
  142. </tr>";
  143. echo "$line";
  144. } else if (preg_match("#\.(wmv|avi)#i", $file)) {
  145. $reurl = "$activeurl/$file";
  146. $reurl = preg_replace("#^\.\.#", "", $reurl);
  147. $reurl = $reurl;
  148. if ($file == $comeback) $lstyle = " style='color:red' ";
  149. else $lstyle = "";
  150. $line = "<tr>
  151. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\"><img src='img/wmv.gif'>$file</a></td>
  152. <td class='linerow'>$filesize KB</td>
  153. <td class='linerow' align='center'>$filetime</td>
  154. </tr>";
  155. echo "$line";
  156. } else if (preg_match("#\.(rm|rmvb)#i", $file)) {
  157. $reurl = "$activeurl/$file";
  158. $reurl = preg_replace("#^\.\.#", "", $reurl);
  159. $reurl = $reurl;
  160. if ($file == $comeback) $lstyle = " style='color:red' ";
  161. else $lstyle = "";
  162. $line = "<tr>
  163. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\"><img src='img/rm.gif'>$file</a></td>
  164. <td class='linerow'>$filesize KB</td>
  165. <td class='linerow' align='center'>$filetime</td>
  166. </tr>";
  167. echo "$line";
  168. } else if (preg_match("#\.(mp3|wma)#", $file)) {
  169. $reurl = "$activeurl/$file";
  170. $reurl = preg_replace("#^\.\.#", "", $reurl);
  171. $reurl = $reurl;
  172. if ($file == $comeback) $lstyle = " style='color:red' ";
  173. else $lstyle = "";
  174. $line = "<tr>
  175. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\"><img src='img/mp3.gif'>$file</a></td>
  176. <td class='linerow'>$filesize KB</td>
  177. <td class='linerow' align='center'>$filetime</td>
  178. </tr>";
  179. echo "$line";
  180. }
  181. }//End Loop
  182. $dh->close();
  183. ?>
  184. </table>
  185. </body>
  186. </html>