国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

207 lignes
9.7KB

  1. <?php
  2. /**
  3. * 选择模板
  4. *
  5. * @version $id:select_templets.php 9:43 2010年7月8日 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. $cfg_txttype = 'htm|html|tpl|txt|dtp';
  16. $activepath = str_replace('.', '', $activepath);
  17. $activepath = preg_replace("#\/{1,}#", '/', $activepath);
  18. $templetdir = $cfg_templets_dir;
  19. if (strlen($activepath) < strlen($templetdir)) {
  20. $activepath = $templetdir;
  21. }
  22. $inpath = $cfg_basedir.$activepath;
  23. $activeurl = '..'.$activepath;
  24. if (!is_dir($inpath)) {
  25. die('No Exsits Path');
  26. }
  27. if (empty($f)) {
  28. $f = 'form1.enclosure';
  29. }
  30. if (empty($comeback)) {
  31. $comeback = '';
  32. }
  33. ?>
  34. <!DOCTYPE html>
  35. <html>
  36. <head>
  37. <meta charset="utf-8">
  38. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  39. <title>选择模板</title>
  40. <link rel="stylesheet" href="../../static/web/font/css/font-awesome.min.css">
  41. <link rel="stylesheet" href="../../static/web/css/bootstrap.min.css">
  42. <link rel="stylesheet" href="../../static/web/css/admin.css">
  43. <style>body{background:#f5f5f5}.upload-bg{margin:10px;background:#fff;border-radius:.5rem;box-shadow:0 .125rem .25rem rgba(0,0,0,.075)}</style>
  44. </head>
  45. <body>
  46. <div class="upload-bg">
  47. <table cellpadding="0" cellspacing="1" align="center" class="table icon">
  48. <tr>
  49. <td colspan="3">
  50. <form action="select_templets_post.php" method="POST" enctype="multipart/form-data" name="myform">
  51. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  52. <input type="hidden" name="f" value="<?php echo $f ?>">
  53. <input type="hidden" name="job" value="upload">
  54. <input type="file" name="uploadfile" class="w-50">
  55. <label>改名:<input type="text" name="filename" class="admin-input-sm"></label>
  56. <button type="submit" name="sb1" class="btn btn-success btn-sm">保存</button>
  57. </form>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td width="50%">选择文件</td>
  62. <td width="20%">文件大小</td>
  63. <td>修改时间</td>
  64. </tr>
  65. <?php
  66. $dh = scandir($inpath);
  67. $ty1 = "";
  68. $ty2 = "";
  69. foreach ($dh as $file) {
  70. //计算文件大小和创建时间
  71. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  72. $filesize = filesize("$inpath/$file");
  73. $filesize = $filesize / 1024;
  74. if ($filesize != "")
  75. if ($filesize < 0.1) {
  76. @list($ty1, $ty2) = split("\.", $filesize);
  77. $filesize = $ty1.".".substr($ty2, 0, 2);
  78. } else {
  79. @list($ty1, $ty2) = split("\.", $filesize);
  80. $filesize = $ty1.".".substr($ty2, 0, 1);
  81. }
  82. $filetime = filemtime("$inpath/$file");
  83. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  84. }
  85. //判断文件类型并作处理
  86. if ($file == ".") continue;
  87. else if ($file == "..") {
  88. if ($activepath == "") continue;
  89. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  90. $line = "<tr>
  91. <td><a href='select_templets.php?f=$f&activepath=".urlencode($tmp)."'><img src='../../static/web/img/icon_dir2.png'>上级目录</a></td>
  92. <td colspan='2'>当前目录:$activepath</td>
  93. </tr>\r\n";
  94. echo $line;
  95. } else if (is_dir("$inpath/$file")) {
  96. if (preg_match("#^_(.*)$#i", $file)) continue;
  97. if (preg_match("#^\.(.*)$#i", $file)) continue;
  98. $line = "<tr>
  99. <td colspan='3'><a href=select_templets.php?f=$f&activepath=".urlencode("$activepath/$file")."><img src='../../static/web/img/icon_dir.png'>$file</a></td>
  100. </tr>";
  101. echo "$line";
  102. } else if (preg_match("#\.(htm|html)#i", $file)) {
  103. if ($file == $comeback) $lstyle = "class='text-danger'";
  104. else $lstyle = "";
  105. $reurl = "$activeurl/$file";
  106. $reurl = preg_replace("#\.\.#", "", $reurl);
  107. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  108. $line = "<tr>
  109. <td>
  110. <img src='../../static/web/img/icon_htm.png'>
  111. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  112. </td>
  113. <td>$filesize KB</td>
  114. <td>$filetime</td>
  115. </tr>";
  116. echo "$line";
  117. } else if (preg_match("#\.(css)#i", $file)) {
  118. if ($file == $comeback) $lstyle = "class='text-danger'";
  119. else $lstyle = "";
  120. $reurl = "$activeurl/$file";
  121. $reurl = preg_replace("#\.\.#", "", $reurl);
  122. $reurl = preg_replace("#".$templetdir."/#", "", $reurl);
  123. $line = "<tr>
  124. <td>
  125. <img src='../../static/web/img/icon_css.png'>
  126. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  127. </td>
  128. <td>$filesize KB</td>
  129. <td>$filetime</td>
  130. </tr>";
  131. echo "$line";
  132. } else if (preg_match("#\.(js)#i", $file)) {
  133. if ($file == $comeback) $lstyle = "class='text-danger'";
  134. else $lstyle = "";
  135. $reurl = "$activeurl/$file";
  136. $reurl = preg_replace("#\.\.#", "", $reurl);
  137. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  138. $line = "<tr>
  139. <td>
  140. <img src='../../static/web/img/icon_js.png'>
  141. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  142. </td>
  143. <td>$filesize KB</td>
  144. <td>$filetime</td>
  145. </tr>";
  146. echo "$line";
  147. } else if (preg_match("#\.(jpg)#i", $file)) {
  148. if ($file == $comeback) $lstyle = "class='text-danger'";
  149. else $lstyle = "";
  150. $reurl = "$activeurl/$file";
  151. $reurl = preg_replace("#\.\.#", "", $reurl);
  152. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  153. $line = "<tr>
  154. <td>
  155. <img src='$reurl'>
  156. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  157. </td>
  158. <td>$filesize KB</td>
  159. <td>$filetime</td>
  160. </tr>";
  161. echo "$line";
  162. } else if (preg_match("#\.(gif|png)#i", $file)) {
  163. if ($file == $comeback) $lstyle = "class='text-danger'";
  164. else $lstyle = "";
  165. $reurl = "$activeurl/$file";
  166. $reurl = preg_replace("#\.\.#", "", $reurl);
  167. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  168. $line = "<tr>
  169. <td>
  170. <img src='$reurl'>
  171. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  172. </td>
  173. <td>$filesize KB</td>
  174. <td>$filetime</td>
  175. </tr>";
  176. echo "$line";
  177. } else if (preg_match("#\.(txt)#i", $file)) {
  178. if ($file == $comeback) $lstyle = "class='text-danger'";
  179. else $lstyle = "";
  180. $reurl = "$activeurl/$file";
  181. $reurl = preg_replace("#\.\.#", "", $reurl);
  182. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  183. $line = "<tr>
  184. <td>
  185. <img src='../../static/web/img/icon_text.png'>
  186. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  187. </td>
  188. <td>$filesize KB</td>
  189. <td>$filetime</td></tr>";
  190. echo "$line";
  191. }
  192. }//End Loop
  193. ?>
  194. </table>
  195. </div>
  196. <script>
  197. function nullLink() {
  198. return;
  199. }
  200. function ReturnValue(reimg) {
  201. window.opener.document.<?php echo $f ?>.value = reimg;
  202. if (document.all) window.opener = true;
  203. window.close();
  204. }
  205. </script>
  206. </body>
  207. </html>