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

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