国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
7.4KB

  1. <?php
  2. /**
  3. * 选择软件
  4. *
  5. * @version $id:select_soft.php 9:43 2010年7月8日 tianya $
  6. * @package DedeBIZ.Dialog
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (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_soft_dir)) {
  19. $activepath = $cfg_soft_dir;
  20. }
  21. $inpath = $cfg_basedir.$activepath;
  22. $activeurl = '..'.$activepath;
  23. if (empty($f)) {
  24. $f = 'form1.enclosure';
  25. }
  26. if (!is_dir($inpath)) {
  27. die('No Exsits Path');
  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/font-awesome.min.css">
  50. <link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
  51. <link rel="stylesheet" href="/static/web/css/admin.css">
  52. </head>
  53. <body class="body-bg">
  54. <div class="upload-bg shadow-sm">
  55. <table align="center" class="table icon">
  56. <tr>
  57. <td colspan="3">
  58. <form name="myform" action="select_soft_post.php" method="POST" enctype="multipart/form-data">
  59. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  60. <?php $noeditor = !empty($noeditor) ? "<input type='hidden' name='noeditor' value='yes'>" : ''; echo $noeditor;?>
  61. <input type="hidden" name="f" value="<?php echo $f ?>">
  62. <input type="hidden" name="job" value="upload">
  63. <input type="file" name="uploadfile" class="w-50">
  64. <label>改名:<input type="text" name="newname" class="admin-input-sm"></label>
  65. <button type="submit" name="sb1" class="btn btn-success btn-sm">保存</button>
  66. </form>
  67. </td>
  68. </tr>
  69. <tr>
  70. <td colspan="3">点击选择文件,红色字样的为刚上传的文件</td>
  71. </tr>
  72. <tr>
  73. <td width="40%">选择文件</td>
  74. <td width="26%">文件大小</td>
  75. <td>修改时间</td>
  76. </tr>
  77. <?php
  78. $dh = scandir($inpath);
  79. $ty1 = $ty2 = "";
  80. foreach ($dh as $file) {
  81. //计算文件大小和创建时间
  82. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  83. $filesize = filesize("$inpath/$file");
  84. $filesize = $filesize / 1024;
  85. if ($filesize != "")
  86. if ($filesize < 0.1) {
  87. @list($ty1, $ty2) = split("\.", $filesize);
  88. $filesize = $ty1.".".substr($ty2, 0, 2);
  89. } else {
  90. @list($ty1, $ty2) = split("\.", $filesize);
  91. $filesize = $ty1.".".substr($ty2, 0, 1);
  92. }
  93. $filetime = filemtime("$inpath/$file");
  94. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  95. }
  96. //判断文件类型并作处理
  97. if ($file == ".") continue;
  98. else if ($file == "..") {
  99. if ($activepath == "") continue;
  100. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  101. $line = "<tr>
  102. <td><a href='select_soft.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='/static/web/img/icon_dir2.png'>上级目录</a></td>
  103. <td colspan='2'>当前目录:$activepath</td>
  104. </tr>\r\n";
  105. echo $line;
  106. } else if (is_dir("$inpath/$file")) {
  107. if (preg_match("#^_(.*)$#i", $file)) continue;
  108. if (preg_match("#^\.(.*)$#i", $file)) continue;
  109. $line = "<tr>
  110. <td colspan='3'><a href=select_soft.php?f=$f&activepath=".urlencode("$activepath/$file").$addparm."><img src='/static/web/img/icon_dir.png'>$file</a></td>
  111. </tr>";
  112. echo "$line";
  113. } else if (preg_match("#\.(zip|rar|tgr.gz)#i", $file)) {
  114. if ($file == $comeback) $lstyle = "class='text-danger'";
  115. else $lstyle = "";
  116. $reurl = "$activeurl/$file";
  117. $reurl = preg_replace("#^\.\.#", "", $reurl);
  118. $reurl = $reurl;
  119. $line = "<tr>
  120. <td>
  121. <img src='/static/web/img/icon_zip.png'>
  122. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  123. </td>
  124. <td>$filesize KB</td>
  125. <td>$filetime</td>
  126. </tr>";
  127. echo "$line";
  128. } else {
  129. if ($file == $comeback) $lstyle = "class='text-danger'";
  130. else $lstyle = '';
  131. $reurl = "$activeurl/$file";
  132. $reurl = preg_replace("#^\.\.#", "", $reurl);
  133. $reurl = $reurl;
  134. $line = "<tr>
  135. <td>
  136. <img src='/static/web/img/icon_exe.png'>
  137. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  138. </td>
  139. <td>$filesize KB</td>
  140. <td>$filetime</td>
  141. </tr>";
  142. echo "$line";
  143. }
  144. }//End Loop
  145. ?>
  146. </table>
  147. </div>
  148. <script>
  149. function nullLink() {
  150. return;
  151. }
  152. function ReturnValue(reimg) {
  153. var funcNum = <?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>;
  154. if (window.opener.CKEDITOR != null && funcNum != 1) {
  155. window.opener.CKEDITOR.tools.callFunction(funcNum, reimg);
  156. }
  157. if (typeof window.opener.CKEDITOR.instances["<?php echo $f ?>"] !== "undefined") {
  158. let addonHTML = `<a href='${reimg}' target='_blank'><img src='<?php echo $cfg_cmspath ?>/static/web/img/icon_addon.png'>附件:${reimg}</a>`;
  159. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  160. }
  161. if (window.opener.document.<?php echo $f ?> != null) {
  162. window.opener.document.<?php echo $f ?>.value = reimg;
  163. window.close();
  164. return
  165. }
  166. window.close();
  167. }
  168. </script>
  169. </body>
  170. </html>