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

164 lines
7.2KB

  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>
  54. <div class="upload-box shadow-sm">
  55. <table 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><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_zip.png'> $file</a></td>
  121. <td>$filesize KB</td>
  122. <td>$filetime</td>
  123. </tr>";
  124. echo "$line";
  125. } else {
  126. if ($file == $comeback) $lstyle = "class='text-danger'";
  127. else $lstyle = '';
  128. $reurl = "$activeurl/$file";
  129. $reurl = preg_replace("#^\.\.#", "", $reurl);
  130. $reurl = $reurl;
  131. $line = "<tr>
  132. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_exe.png'> $file</a></td>
  133. <td>$filesize KB</td>
  134. <td>$filetime</td>
  135. </tr>";
  136. echo "$line";
  137. }
  138. }//End Loop
  139. ?>
  140. </table>
  141. </div>
  142. <script>
  143. function nullLink() {
  144. return;
  145. }
  146. function ReturnValue(reimg) {
  147. var funcNum = <?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;?>;
  148. if (window.opener.CKEDITOR != null && funcNum != 1) {
  149. window.opener.CKEDITOR.tools.callFunction(funcNum, reimg);
  150. }
  151. if (typeof window.opener.CKEDITOR.instances["<?php echo $f ?>"] !== "undefined") {
  152. let addonHTML = `<a href='${reimg}' target='_blank'><img src='/static/web/img/icon_addon.png'> 附件:${reimg}</a>`;
  153. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  154. }
  155. if (window.opener.document.<?php echo $f ?> != null) {
  156. window.opener.document.<?php echo $f ?>.value = reimg;
  157. window.close();
  158. return
  159. }
  160. window.close();
  161. }
  162. </script>
  163. </body>
  164. </html>