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

170 lines
8.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 name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  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="p-3">
  54. <div class="card shadow-sm mb-3">
  55. <div class="card-body">
  56. <form name="myform" action="select_soft_post.php" method="POST" enctype="multipart/form-data">
  57. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  58. <?php $noeditor = !empty($noeditor) ? "<input type='hidden' name='noeditor' value='yes'>" : ''; echo $noeditor;?>
  59. <input type="hidden" name="f" value="<?php echo $f ?>">
  60. <input type="hidden" name="job" value="upload">
  61. <input type="file" name="uploadfile">
  62. <label>重命名:<input type="text" name="newname" class="admin-input-sm"></label>
  63. <button type="submit" class="btn btn-success btn-sm">保存</button>
  64. </form>
  65. </div>
  66. </div>
  67. <div class="card shadow-sm">
  68. <div class="card-header">选择软件</div>
  69. <div class="card-body">
  70. <div class="table-responsive">
  71. <table class="table table-borderless icon">
  72. <thead>
  73. <tr>
  74. <td scope="col">文件名称</td>
  75. <td scope="col">文件大小</td>
  76. <td scope="col">修改时间</td>
  77. </tr>
  78. </thead>
  79. <tbody>
  80. <?php
  81. $dh = scandir($inpath);
  82. $ty1 = $ty2 = '';
  83. foreach ($dh as $file) {
  84. //计算文件大小和创建时间
  85. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  86. $filesize = filesize("$inpath/$file");
  87. $filesize = $filesize / 1024;
  88. if ($filesize != "")
  89. if ($filesize < 0.1) {
  90. @list($ty1, $ty2) = split("\.", $filesize);
  91. $filesize = $ty1.".".substr($ty2, 0, 2);
  92. } else {
  93. @list($ty1, $ty2) = split("\.", $filesize);
  94. $filesize = $ty1.".".substr($ty2, 0, 1);
  95. }
  96. $filetime = filemtime("$inpath/$file");
  97. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  98. }
  99. //判断文件类型并作处理
  100. if ($file == ".") continue;
  101. else if ($file == "..") {
  102. if ($activepath == "") continue;
  103. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  104. $line = "<tr>
  105. <td><a href='select_soft.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='/static/web/img/icon_dir2.png'> 返回上级</a></td>
  106. <td colspan='2'>当前目录:$activepath</td>
  107. </tr>\r\n";
  108. echo $line;
  109. } else if (is_dir("$inpath/$file")) {
  110. if (preg_match("#^_(.*)$#i", $file)) continue;
  111. if (preg_match("#^\.(.*)$#i", $file)) continue;
  112. $line = "<tr>
  113. <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>
  114. </tr>";
  115. echo "$line";
  116. } else if (preg_match("#\.(zip|rar|tgr.gz)#i", $file)) {
  117. if ($file == $comeback) $lstyle = "class='text-danger'";
  118. else $lstyle = '';
  119. $reurl = "$activeurl/$file";
  120. $reurl = preg_replace("#^\.\.#", "", $reurl);
  121. $reurl = $reurl;
  122. $line = "<tr>
  123. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_zip.png'> $file</a></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><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_exe.png'> $file</a></td>
  136. <td>$filesize KB</td>
  137. <td>$filetime</td>
  138. </tr>";
  139. echo "$line";
  140. }
  141. }
  142. ?>
  143. </tbody>
  144. </table>
  145. </div>
  146. </div>
  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>