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

210 lines
9.3KB

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