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

195 lines
9.1KB

  1. <?php
  2. /**
  3. * 模板选择
  4. *
  5. * @version $Id: select_templets.php 1 9:43 2010年7月8日Z 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="<?php echo $cfg_soft_lang; ?>">
  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>
  44. html{background:#f6f6f6}
  45. table{background:#fff}
  46. a{text-decoration:none!important}
  47. .bg{margin:10px;border-radius:.2rem;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}
  48. .linerow{border-bottom:1px solid #eee!important}
  49. </style>
  50. </head>
  51. <body class="bg">
  52. <script>
  53. function nullLink() {
  54. return;
  55. }
  56. function ReturnValue(reimg) {
  57. window.opener.document.<?php echo $f ?>.value = reimg;
  58. if (document.all) window.opener = true;
  59. window.close();
  60. }
  61. </script>
  62. <table width="100%" cellpadding="0" cellspacing="1" align="center" class="table table-borderless">
  63. <tr>
  64. <td colspan="3" height="26">
  65. <form action="select_templets_post.php" method="POST" enctype="multipart/form-data" name="myform">
  66. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  67. <input type="hidden" name="f" value="<?php echo $f ?>">
  68. <input type="hidden" name="job" value="upload">
  69. 上传:<input type="file" name="uploadfile" style="width:50%;border:none">
  70. 改名:<input type="text" name="filename" style="width:160px">
  71. <button type="submit" name="sb1" class="btn btn-success btn-sm">保存</button>
  72. </form>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td width="50%" class="linerow">选择文件</td>
  77. <td width="20%" class="linerow">文件大小</td>
  78. <td width="30%" class="linerow">修改时间</td>
  79. </tr>
  80. <?php
  81. $dh = scandir($inpath);
  82. $ty1 = "";
  83. $ty2 = "";
  84. foreach ($dh as $file) {
  85. //计算文件大小和创建时间
  86. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  87. $filesize = filesize("$inpath/$file");
  88. $filesize = $filesize / 1024;
  89. if ($filesize != "")
  90. if ($filesize < 0.1) {
  91. @list($ty1, $ty2) = split("\.", $filesize);
  92. $filesize = $ty1.".".substr($ty2, 0, 2);
  93. } else {
  94. @list($ty1, $ty2) = split("\.", $filesize);
  95. $filesize = $ty1.".".substr($ty2, 0, 1);
  96. }
  97. $filetime = filemtime("$inpath/$file");
  98. $filetime = MyDate("Y-m-d H:i", $filetime);
  99. }
  100. //判断文件类型并作处理
  101. if ($file == ".") continue;
  102. else if ($file == "..") {
  103. if ($activepath == "") continue;
  104. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  105. $line = "<tr>
  106. <td class='linerow'><a href='select_templets.php?f=$f&activepath=".urlencode($tmp)."'><img src='../../static/web/img/dir2.gif'>上级目录</a></td>
  107. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  108. </tr>\r\n";
  109. echo $line;
  110. } else if (is_dir("$inpath/$file")) {
  111. if (preg_match("#^_(.*)$#i", $file)) continue;
  112. if (preg_match("#^\.(.*)$#i", $file)) continue;
  113. $line = "<tr>
  114. <td class='linerow'><a href=select_templets.php?f=$f&activepath=".urlencode("$activepath/$file")."><img src='../../static/web/img/dir.gif'>$file</a></td>
  115. <td class='linerow'></td>
  116. <td class='linerow'></td>
  117. </tr>";
  118. echo "$line";
  119. } else if (preg_match("#\.(htm|html)#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 class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/htm.gif'>$file</a></td>
  127. <td class='linerow'>$filesize KB</td>
  128. <td class='linerow'>$filetime</td>
  129. </tr>";
  130. echo "$line";
  131. } else if (preg_match("#\.(css)#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 class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/css.gif'>$file</a></td>
  139. <td class='linerow'>$filesize KB</td>
  140. <td class='linerow'>$filetime</td>
  141. </tr>";
  142. echo "$line";
  143. } else if (preg_match("#\.(js)#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 class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/js.gif'>$file</a></td>
  151. <td class='linerow'>$filesize KB</td>
  152. <td class='linerow'>$filetime</td>
  153. </tr>";
  154. echo "$line";
  155. } else if (preg_match("#\.(jpg)#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 class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/jpg.gif'>$file</a></td>
  163. <td class='linerow'>$filesize KB</td>
  164. <td class='linerow'>$filetime</td>
  165. </tr>";
  166. echo "$line";
  167. } else if (preg_match("#\.(gif|png)#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 class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/gif.gif'>$file</a></td>
  175. <td class='linerow'>$filesize KB</td>
  176. <td class='linerow'>$filetime</td>
  177. </tr>";
  178. echo "$line";
  179. } else if (preg_match("#\.(txt)#i", $file)) {
  180. if ($file == $comeback) $lstyle = " class='text-danger' ";
  181. else $lstyle = "";
  182. $reurl = "$activeurl/$file";
  183. $reurl = preg_replace("#\.\.#", "", $reurl);
  184. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  185. $line = "<tr>
  186. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='../../static/web/img/txt.gif'>$file</a></td>
  187. <td class='linerow'>$filesize KB</td>
  188. <td class='linerow'>$filetime</td></tr>";
  189. echo "$line";
  190. }
  191. }//End Loop
  192. ?>
  193. </table>
  194. </body>
  195. </html>