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

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