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

209 lines
10KB

  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/css/bootstrap.min.css">
  41. <link rel="stylesheet" href="../../static/web/font/css/font-awesome.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 width="100%" cellpadding="0" cellspacing="1" align="center" class="table table-borderless 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. <span>选择:<input type="file" name="uploadfile" class="w-50"></span>
  65. <span>改名:<input type="text" name="filename" class="admin-input-sm"></span>
  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%" class="admin-td">选择文件</td>
  72. <td width="20%" class="admin-td">文件大小</td>
  73. <td class="admin-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 class='admin-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' class='admin-td'>当前目录:$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 class='admin-td'><a href=select_templets.php?f=$f&activepath=".urlencode("$activepath/$file")."><img src='../../static/web/img/icon_dir.png'>$file</a></td>
  110. <td class='admin-td'></td>
  111. <td class='admin-td'></td>
  112. </tr>";
  113. echo "$line";
  114. } else if (preg_match("#\.(htm|html)#i", $file)) {
  115. if ($file == $comeback) $lstyle = "class='text-danger'";
  116. else $lstyle = "";
  117. $reurl = "$activeurl/$file";
  118. $reurl = preg_replace("#\.\.#", "", $reurl);
  119. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  120. $line = "<tr>
  121. <td class='admin-td'>
  122. <img src='../../static/web/img/icon_htm.png'>
  123. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  124. </td>
  125. <td class='admin-td'>$filesize KB</td>
  126. <td class='admin-td'>$filetime</td>
  127. </tr>";
  128. echo "$line";
  129. } else if (preg_match("#\.(css)#i", $file)) {
  130. if ($file == $comeback) $lstyle = "class='text-danger'";
  131. else $lstyle = "";
  132. $reurl = "$activeurl/$file";
  133. $reurl = preg_replace("#\.\.#", "", $reurl);
  134. $reurl = preg_replace("#".$templetdir."/#", "", $reurl);
  135. $line = "<tr>
  136. <td class='admin-td'>
  137. <img src='../../static/web/img/icon_css.png'>
  138. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  139. </td>
  140. <td class='admin-td'>$filesize KB</td>
  141. <td class='admin-td'>$filetime</td>
  142. </tr>";
  143. echo "$line";
  144. } else if (preg_match("#\.(js)#i", $file)) {
  145. if ($file == $comeback) $lstyle = "class='text-danger'";
  146. else $lstyle = "";
  147. $reurl = "$activeurl/$file";
  148. $reurl = preg_replace("#\.\.#", "", $reurl);
  149. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  150. $line = "<tr>
  151. <td class='admin-td'>
  152. <img src='../../static/web/img/icon_js.png'>
  153. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  154. </td>
  155. <td class='admin-td'>$filesize KB</td>
  156. <td class='admin-td'>$filetime</td>
  157. </tr>";
  158. echo "$line";
  159. } else if (preg_match("#\.(jpg)#i", $file)) {
  160. if ($file == $comeback) $lstyle = "class='text-danger'";
  161. else $lstyle = "";
  162. $reurl = "$activeurl/$file";
  163. $reurl = preg_replace("#\.\.#", "", $reurl);
  164. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  165. $line = "<tr>
  166. <td class='admin-td'>
  167. <img src='$reurl'>
  168. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  169. </td>
  170. <td class='admin-td'>$filesize KB</td>
  171. <td class='admin-td'>$filetime</td>
  172. </tr>";
  173. echo "$line";
  174. } else if (preg_match("#\.(gif|png)#i", $file)) {
  175. if ($file == $comeback) $lstyle = "class='text-danger'";
  176. else $lstyle = "";
  177. $reurl = "$activeurl/$file";
  178. $reurl = preg_replace("#\.\.#", "", $reurl);
  179. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  180. $line = "<tr>
  181. <td class='admin-td'>
  182. <img src='$reurl'>
  183. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  184. </td>
  185. <td class='admin-td'>$filesize KB</td>
  186. <td class='admin-td'>$filetime</td>
  187. </tr>";
  188. echo "$line";
  189. } else if (preg_match("#\.(txt)#i", $file)) {
  190. if ($file == $comeback) $lstyle = "class='text-danger'";
  191. else $lstyle = "";
  192. $reurl = "$activeurl/$file";
  193. $reurl = preg_replace("#\.\.#", "", $reurl);
  194. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  195. $line = "<tr>
  196. <td class='admin-td'>
  197. <img src='../../static/web/img/icon_text.png'>
  198. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle>$file</a>
  199. </td>
  200. <td class='admin-td'>$filesize KB</td>
  201. <td class='admin-td'>$filetime</td></tr>";
  202. echo "$line";
  203. }
  204. }//End Loop
  205. ?>
  206. </table>
  207. </div>
  208. </body>
  209. </html>