国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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