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

195 lines
8.0KB

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