国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
11KB

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