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

207 lines
9.5KB

  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. <script>
  45. function nullLink() {
  46. return;
  47. }
  48. function ReturnValue(reimg) {
  49. window.opener.document.<?php echo $f ?>.value = reimg;
  50. if (document.all) window.opener = true;
  51. window.close();
  52. }
  53. </script>
  54. </head>
  55. <body>
  56. <div class="upload-bg">
  57. <table cellpadding="0" cellspacing="1" align="center" class="table icon">
  58. <tr>
  59. <td colspan="3">
  60. <form action="select_templets_post.php" method="POST" enctype="multipart/form-data" name="myform">
  61. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  62. <input type="hidden" name="f" value="<?php echo $f ?>">
  63. <input type="hidden" name="job" value="upload">
  64. <input type="file" name="uploadfile" class="w-50">
  65. <label>改名:<input type="text" name="filename" class="admin-input-sm"></label>
  66. <button type="submit" name="sb1" class="btn btn-success btn-sm">保存</button>
  67. </form>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td width="50%">选择文件</td>
  72. <td width="20%">文件大小</td>
  73. <td>修改时间</td>
  74. </tr>
  75. <?php
  76. $dh = scandir($inpath);
  77. $ty1 = "";
  78. $ty2 = "";
  79. foreach ($dh as $file) {
  80. //计算文件大小和创建时间
  81. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  82. $filesize = filesize("$inpath/$file");
  83. $filesize = $filesize / 1024;
  84. if ($filesize != "")
  85. if ($filesize < 0.1) {
  86. @list($ty1, $ty2) = split("\.", $filesize);
  87. $filesize = $ty1.".".substr($ty2, 0, 2);
  88. } else {
  89. @list($ty1, $ty2) = split("\.", $filesize);
  90. $filesize = $ty1.".".substr($ty2, 0, 1);
  91. }
  92. $filetime = filemtime("$inpath/$file");
  93. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  94. }
  95. //判断文件类型并作处理
  96. if ($file == ".") continue;
  97. else if ($file == "..") {
  98. if ($activepath == "") continue;
  99. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  100. $line = "<tr>
  101. <td><a href='select_templets.php?f=$f&activepath=".urlencode($tmp)."'><img src='../../static/web/img/icon_dir2.png'>上级目录</a></td>
  102. <td colspan='2'>当前目录:$activepath</td>
  103. </tr>\r\n";
  104. echo $line;
  105. } else if (is_dir("$inpath/$file")) {
  106. if (preg_match("#^_(.*)$#i", $file)) continue;
  107. if (preg_match("#^\.(.*)$#i", $file)) continue;
  108. $line = "<tr>
  109. <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>
  110. </tr>";
  111. echo "$line";
  112. } else if (preg_match("#\.(htm|html)#i", $file)) {
  113. if ($file == $comeback) $lstyle = "class='text-danger'";
  114. else $lstyle = "";
  115. $reurl = "$activeurl/$file";
  116. $reurl = preg_replace("#\.\.#", "", $reurl);
  117. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  118. $line = "<tr>
  119. <td>
  120. <img src='../../static/web/img/icon_htm.png'>
  121. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  122. </td>
  123. <td>$filesize KB</td>
  124. <td>$filetime</td>
  125. </tr>";
  126. echo "$line";
  127. } else if (preg_match("#\.(css)#i", $file)) {
  128. if ($file == $comeback) $lstyle = "class='text-danger'";
  129. else $lstyle = "";
  130. $reurl = "$activeurl/$file";
  131. $reurl = preg_replace("#\.\.#", "", $reurl);
  132. $reurl = preg_replace("#".$templetdir."/#", "", $reurl);
  133. $line = "<tr>
  134. <td>
  135. <img src='../../static/web/img/icon_css.png'>
  136. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  137. </td>
  138. <td>$filesize KB</td>
  139. <td>$filetime</td>
  140. </tr>";
  141. echo "$line";
  142. } else if (preg_match("#\.(js)#i", $file)) {
  143. if ($file == $comeback) $lstyle = "class='text-danger'";
  144. else $lstyle = "";
  145. $reurl = "$activeurl/$file";
  146. $reurl = preg_replace("#\.\.#", "", $reurl);
  147. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  148. $line = "<tr>
  149. <td>
  150. <img src='../../static/web/img/icon_js.png'>
  151. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  152. </td>
  153. <td>$filesize KB</td>
  154. <td>$filetime</td>
  155. </tr>";
  156. echo "$line";
  157. } else if (preg_match("#\.(jpg)#i", $file)) {
  158. if ($file == $comeback) $lstyle = "class='text-danger'";
  159. else $lstyle = "";
  160. $reurl = "$activeurl/$file";
  161. $reurl = preg_replace("#\.\.#", "", $reurl);
  162. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  163. $line = "<tr>
  164. <td>
  165. <img src='$reurl'>
  166. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  167. </td>
  168. <td>$filesize KB</td>
  169. <td>$filetime</td>
  170. </tr>";
  171. echo "$line";
  172. } else if (preg_match("#\.(gif|png)#i", $file)) {
  173. if ($file == $comeback) $lstyle = "class='text-danger'";
  174. else $lstyle = "";
  175. $reurl = "$activeurl/$file";
  176. $reurl = preg_replace("#\.\.#", "", $reurl);
  177. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  178. $line = "<tr>
  179. <td>
  180. <img src='$reurl'>
  181. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  182. </td>
  183. <td>$filesize KB</td>
  184. <td>$filetime</td>
  185. </tr>";
  186. echo "$line";
  187. } else if (preg_match("#\.(txt)#i", $file)) {
  188. if ($file == $comeback) $lstyle = "class='text-danger'";
  189. else $lstyle = "";
  190. $reurl = "$activeurl/$file";
  191. $reurl = preg_replace("#\.\.#", "", $reurl);
  192. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  193. $line = "<tr>
  194. <td>
  195. <img src='../../static/web/img/icon_text.png'>
  196. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  197. </td>
  198. <td>$filesize KB</td>
  199. <td>$filetime</td></tr>";
  200. echo "$line";
  201. }
  202. }//End Loop
  203. ?>
  204. </table>
  205. </div>
  206. </body>
  207. </html>