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

173 lines
7.9KB

  1. <?php
  2. /**
  3. * 软件选择框
  4. *
  5. * @version $Id: select_soft.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. $activepath = str_replace('.', '', $activepath);
  16. $activepath = preg_replace("#\/{1,}#", '/', $activepath);
  17. if (strlen($activepath) < strlen($cfg_soft_dir)) {
  18. $activepath = $cfg_soft_dir;
  19. }
  20. $inpath = $cfg_basedir.$activepath;
  21. $activeurl = '..'.$activepath;
  22. if (empty($f)) {
  23. $f = 'form1.enclosure';
  24. }
  25. if (!is_dir($inpath)) {
  26. die('No Exsits Path');
  27. }
  28. if (empty($comeback)) {
  29. $comeback = '';
  30. }
  31. $addparm = '';
  32. if (!empty($CKEditor)) {
  33. $addparm = '&CKEditor='.$CKEditor;
  34. }
  35. if (!empty($CKEditorFuncNum)) {
  36. $addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum;
  37. }
  38. if (!empty($noeditor)) {
  39. $addparm .= '&noeditor=yes';
  40. }
  41. ?>
  42. <html>
  43. <head>
  44. <meta charset="<?php echo $cfg_soft_lang; ?>">
  45. <title>软件管理器</title>
  46. <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
  47. <link rel="stylesheet" href="../../static/font-awesome/css/font-awesome.min.css">
  48. <link rel="stylesheet" href="../css/base.css">
  49. <style>
  50. html{background:#f2f2f2}
  51. body{margin:0;line-height:1.5;font:12px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif}
  52. a{text-decoration:none!important}
  53. table{background:#fff}
  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. if (window.opener.CKEDITOR.instances.<?php echo $f ?>) {
  72. let addonHTML = `<a href='${reimg}' target='_blank'><img src='<?php echo $cfg_cmspath ?>/static/img/addon.gif'>附件:${reimg}</a>`;
  73. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  74. }
  75. window.close();
  76. }
  77. </script>
  78. <table width="100%" border="0" cellpadding="0" cellspacing="1" align="center" class="table table-borderless">
  79. <tr>
  80. <td colspan="3" height="30">
  81. <form action="select_soft_post.php" method="POST" enctype="multipart/form-data" name='myform'>
  82. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  83. <input type="hidden" name="f" value="<?php echo $f ?>">
  84. <input type="hidden" name="job" value="upload">
  85. 上传:<input type="file" name="uploadfile" size="24" style="border:none">
  86. 改名:<input type="text" name="newname" style="width:160px">
  87. <button type="submit" name="sb1" class="btn btn-success btn-sm">确定</button>
  88. </form>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td colspan="3">
  93. <table width="100%" border="0" cellspacing="0" cellpadding="2">
  94. <tr height="26">
  95. <td width="45%" class="linerow">选择文件</td>
  96. <td width="25%" class="linerow">文件大小</td>
  97. <td width="30%" class="linerow">修改时间</td>
  98. </tr>
  99. <?php
  100. $dh = dir($inpath);
  101. $ty1 = $ty2 = '';
  102. while ($file = $dh->read()) {
  103. //计算文件大小和创建时间
  104. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  105. $filesize = filesize("$inpath/$file");
  106. $filesize = $filesize / 1024;
  107. if ($filesize != "")
  108. if ($filesize < 0.1) {
  109. @list($ty1, $ty2) = split("\.", $filesize);
  110. $filesize = $ty1.".".substr($ty2, 0, 2);
  111. } else {
  112. @list($ty1, $ty2) = split("\.", $filesize);
  113. $filesize = $ty1.".".substr($ty2, 0, 1);
  114. }
  115. $filetime = filemtime("$inpath/$file");
  116. $filetime = MyDate("Y-m-d H:i", $filetime);
  117. }
  118. //判断文件类型并作处理
  119. if ($file == ".") continue;
  120. else if ($file == "..") {
  121. if ($activepath == "") continue;
  122. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  123. $line = "<tr height='26'>
  124. <td class='linerow'><a href='select_soft.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='img/dir2.gif'>上级目录</a></td>
  125. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  126. </tr>\r\n";
  127. echo $line;
  128. } else if (is_dir("$inpath/$file")) {
  129. if (preg_match("#^_(.*)$#i", $file)) continue;
  130. if (preg_match("#^\.(.*)$#i", $file)) continue;
  131. $line = "<tr height='26'>
  132. <td class='linerow'><a href=select_soft.php?f=$f&activepath=".urlencode("$activepath/$file").$addparm."><img src='img/dir.gif'>$file</a></td>
  133. <td class='linerow'></td>
  134. <td class='linerow'></td>
  135. </tr>";
  136. echo "$line";
  137. } else if (preg_match("#\.(zip|rar|tgr.gz)#i", $file)) {
  138. if ($file == $comeback) $lstyle = " style='color:#dc3545' ";
  139. else $lstyle = "";
  140. $reurl = "$activeurl/$file";
  141. $reurl = preg_replace("#^\.\.#", "", $reurl);
  142. $reurl = $reurl;
  143. $line = "<tr height='26'>
  144. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/zip.gif'>$file</a></td>
  145. <td class='linerow'>$filesize KB</td>
  146. <td class='linerow'>$filetime</td>
  147. </tr>";
  148. echo "$line";
  149. } else {
  150. if ($file == $comeback) $lstyle = " style='color:#dc3545' ";
  151. else $lstyle = '';
  152. $reurl = "$activeurl/$file";
  153. $reurl = preg_replace("#^\.\.#", "", $reurl);
  154. $reurl = $reurl;
  155. $line = "<tr height='26'>
  156. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/exe.gif'>$file</a></td>
  157. <td class='linerow'>$filesize KB</td>
  158. <td class='linerow'>$filetime</td>
  159. </tr>";
  160. echo "$line";
  161. }
  162. }//End Loop
  163. $dh->close();
  164. ?>
  165. </table>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td colspan="3" height="30">点击选择的文件,红色字样的为刚上传的文件。</td>
  170. </tr>
  171. </table>
  172. </body>
  173. </html>