国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

188 行
9.0KB

  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><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_htm.png'> $file</a></td>
  109. <td>$filesize KB</td>
  110. <td>$filetime</td>
  111. </tr>";
  112. echo "$line";
  113. } else if (preg_match("#\.(css)#i", $file)) {
  114. if ($file == $comeback) $lstyle = "class='text-danger'";
  115. else $lstyle = "";
  116. $reurl = "$activeurl/$file";
  117. $reurl = preg_replace("#\.\.#", "", $reurl);
  118. $reurl = preg_replace("#".$templetdir."/#", "", $reurl);
  119. $line = "<tr>
  120. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_css.png'> $file</a></td>
  121. <td>$filesize KB</td>
  122. <td>$filetime</td>
  123. </tr>";
  124. echo "$line";
  125. } else if (preg_match("#\.(js)#i", $file)) {
  126. if ($file == $comeback) $lstyle = "class='text-danger'";
  127. else $lstyle = "";
  128. $reurl = "$activeurl/$file";
  129. $reurl = preg_replace("#\.\.#", "", $reurl);
  130. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  131. $line = "<tr>
  132. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_js.png'> $file</a></td>
  133. <td>$filesize KB</td>
  134. <td>$filetime</td>
  135. </tr>";
  136. echo "$line";
  137. } else if (preg_match("#\.(jpg)#i", $file)) {
  138. if ($file == $comeback) $lstyle = "class='text-danger'";
  139. else $lstyle = "";
  140. $reurl = "$activeurl/$file";
  141. $reurl = preg_replace("#\.\.#", "", $reurl);
  142. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  143. $line = "<tr>
  144. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='$reurl'> $file</a></td>
  145. <td>$filesize KB</td>
  146. <td>$filetime</td>
  147. </tr>";
  148. echo "$line";
  149. } else if (preg_match("#\.(gif|png)#i", $file)) {
  150. if ($file == $comeback) $lstyle = "class='text-danger'";
  151. else $lstyle = "";
  152. $reurl = "$activeurl/$file";
  153. $reurl = preg_replace("#\.\.#", "", $reurl);
  154. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  155. $line = "<tr>
  156. <td><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='$reurl'> $file</a></td>
  157. <td>$filesize KB</td>
  158. <td>$filetime</td>
  159. </tr>";
  160. echo "$line";
  161. } else if (preg_match("#\.(txt)#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><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='/static/web/img/icon_text.png'> $file</a></td>
  169. <td>$filesize KB</td>
  170. <td>$filetime</td></tr>";
  171. echo "$line";
  172. }
  173. }//End Loop
  174. ?>
  175. </table>
  176. </div>
  177. <script>
  178. function nullLink() {
  179. return;
  180. }
  181. function ReturnValue(reimg) {
  182. window.opener.document.<?php echo $f ?>.value = reimg;
  183. if (document.all) window.opener = true;
  184. window.close();
  185. }
  186. </script>
  187. </body>
  188. </html>