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

175 lines
7.8KB

  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. <!DOCTYPE html>
  43. <html>
  44. <head>
  45. <meta charset="<?php echo $cfg_soft_lang; ?>">
  46. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  47. <title>选择软件</title>
  48. <link rel="stylesheet" href="../../static/web/css/bootstrap.min.css">
  49. <link rel="stylesheet" href="../../static/web/font/css/font-awesome.min.css">
  50. <link rel="stylesheet" href="../../static/web/css/admin.css">
  51. <style>
  52. html{background:#f6f6f6}
  53. table{background:#fff}
  54. a{text-decoration:none!important}
  55. .bg{margin:10px;border-radius:.2rem;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}
  56. .linerow{border-bottom:1px solid #eee!important}
  57. </style>
  58. </head>
  59. <body class="bg">
  60. <script>
  61. function nullLink() {
  62. return;
  63. }
  64. function ReturnValue(reimg) {
  65. var funcNum = <?php echo isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1; ?>;
  66. if (window.opener.CKEDITOR != null && funcNum != 1) {
  67. window.opener.CKEDITOR.tools.callFunction(funcNum, reimg);
  68. }
  69. if (typeof window.opener.CKEDITOR.instances["<?php echo $f ?>"] !== "undefined") {
  70. let addonHTML = `<a href='${reimg}' target='_blank'><img src='<?php echo $cfg_cmspath ?>/static/web/img/addon.gif'>附件:${reimg}</a>`;
  71. window.opener.CKEDITOR.instances["<?php echo $f ?>"].insertHtml(addonHTML);
  72. }
  73. if (window.opener.document.<?php echo $f ?> != null) {
  74. window.opener.document.<?php echo $f ?>.value = reimg;
  75. window.close();
  76. return
  77. }
  78. window.close();
  79. }
  80. </script>
  81. <table width="100%" cellpadding="0" cellspacing="1" align="center" class="table table-borderless">
  82. <tr>
  83. <td colspan="3" height="26">
  84. <form action="select_soft_post.php" method="POST" enctype="multipart/form-data" name='myform'>
  85. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  86. <input type="hidden" name="f" value="<?php echo $f ?>">
  87. <input type="hidden" name="job" value="upload">
  88. 上传:<input type="file" name="uploadfile" size="24" style="width:50%;border:none">
  89. 改名:<input type="text" name="newname" style="width:160px">
  90. <button type="submit" name="sb1" class="btn btn-success btn-sm">保存</button>
  91. </form>
  92. </td>
  93. </tr>
  94. <tr>
  95. <td colspan="3">
  96. <table width="100%" cellspacing="0" cellpadding="2">
  97. <tr>
  98. <td width="45%" class="linerow">选择文件</td>
  99. <td width="25%" class="linerow">文件大小</td>
  100. <td width="30%" class="linerow">修改时间</td>
  101. </tr>
  102. <?php
  103. $dh = scandir($inpath);
  104. $ty1 = $ty2 = "";
  105. foreach ($dh as $file) {
  106. //计算文件大小和创建时间
  107. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  108. $filesize = filesize("$inpath/$file");
  109. $filesize = $filesize / 1024;
  110. if ($filesize != "")
  111. if ($filesize < 0.1) {
  112. @list($ty1, $ty2) = split("\.", $filesize);
  113. $filesize = $ty1.".".substr($ty2, 0, 2);
  114. } else {
  115. @list($ty1, $ty2) = split("\.", $filesize);
  116. $filesize = $ty1.".".substr($ty2, 0, 1);
  117. }
  118. $filetime = filemtime("$inpath/$file");
  119. $filetime = MyDate("Y-m-d H:i", $filetime);
  120. }
  121. //判断文件类型并作处理
  122. if ($file == ".") continue;
  123. else if ($file == "..") {
  124. if ($activepath == "") continue;
  125. $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
  126. $line = "<tr>
  127. <td class='linerow'><a href='select_soft.php?f=$f&activepath=".urlencode($tmp).$addparm."'><img src='../../static/web/img/dir2.gif'>上级目录</a></td>
  128. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  129. </tr>\r\n";
  130. echo $line;
  131. } else if (is_dir("$inpath/$file")) {
  132. if (preg_match("#^_(.*)$#i", $file)) continue;
  133. if (preg_match("#^\.(.*)$#i", $file)) continue;
  134. $line = "<tr>
  135. <td class='linerow'><a href=select_soft.php?f=$f&activepath=".urlencode("$activepath/$file").$addparm."><img src='../../static/web/img/dir.gif'>$file</a></td>
  136. <td class='linerow'></td>
  137. <td class='linerow'></td>
  138. </tr>";
  139. echo "$line";
  140. } else if (preg_match("#\.(zip|rar|tgr.gz)#i", $file)) {
  141. if ($file == $comeback) $lstyle = " class='text-danger' ";
  142. else $lstyle = "";
  143. $reurl = "$activeurl/$file";
  144. $reurl = preg_replace("#^\.\.#", "", $reurl);
  145. $reurl = $reurl;
  146. $line = "<tr>
  147. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/zip.gif'>$file</a></td>
  148. <td class='linerow'>$filesize KB</td>
  149. <td class='linerow'>$filetime</td>
  150. </tr>";
  151. echo "$line";
  152. } else {
  153. if ($file == $comeback) $lstyle = " class='text-danger' ";
  154. else $lstyle = '';
  155. $reurl = "$activeurl/$file";
  156. $reurl = preg_replace("#^\.\.#", "", $reurl);
  157. $reurl = $reurl;
  158. $line = "<tr>
  159. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/exe.gif'>$file</a></td>
  160. <td class='linerow'>$filesize KB</td>
  161. <td class='linerow'>$filetime</td>
  162. </tr>";
  163. echo "$line";
  164. }
  165. }//End Loop
  166. ?>
  167. </table>
  168. </td>
  169. </tr>
  170. <tr>
  171. <td colspan="3" height="26">点击选择的文件,红色字样的为刚上传的文件</td>
  172. </tr>
  173. </table>
  174. </body>
  175. </html>