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

201 lines
9.6KB

  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) 2021, 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. <html>
  35. <head>
  36. <meta charset="<?php echo $cfg_soft_lang; ?>">
  37. <title>模板管理器</title>
  38. <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
  39. <link rel="stylesheet" href="../../static/font-awesome/css/font-awesome.min.css">
  40. <link rel="stylesheet" href="../css/base.css">
  41. <style>
  42. html{background:#f2f2f2}
  43. body{margin:0;line-height:22px;font:12px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif}
  44. a{text-decoration:none!important}
  45. table{background:#fff}
  46. .bg{margin:10px;border-radius:2px;box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}
  47. .linerow{border-bottom:1px solid #eee!important}
  48. </style>
  49. </head>
  50. <body class="bg">
  51. <script>
  52. function nullLink() {
  53. return;
  54. }
  55. function ReturnValue(reimg) {
  56. window.opener.document.<?php echo $f ?>.value = reimg;
  57. if (document.all) window.opener = true;
  58. window.close();
  59. }
  60. </script>
  61. <table width="100%" border="0" cellpadding="0" cellspacing="1" align="center" class="table table-borderless">
  62. <tr>
  63. <td width="50%" class="linerow">选择文件</td>
  64. <td width="20%" class="linerow">文件大小</td>
  65. <td width="30%" class="linerow">修改时间</td>
  66. </tr>
  67. <?php
  68. $dh = dir($inpath);
  69. $ty1 = "";
  70. $ty2 = "";
  71. while ($file = $dh->read()) {
  72. //计算文件大小和创建时间
  73. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  74. $filesize = filesize("$inpath/$file");
  75. $filesize = $filesize / 1024;
  76. if ($filesize != "")
  77. if ($filesize < 0.1) {
  78. @list($ty1, $ty2) = split("\.", $filesize);
  79. $filesize = $ty1 . "." . substr($ty2, 0, 2);
  80. } else {
  81. @list($ty1, $ty2) = split("\.", $filesize);
  82. $filesize = $ty1 . "." . substr($ty2, 0, 1);
  83. }
  84. $filetime = filemtime("$inpath/$file");
  85. $filetime = MyDate("Y-m-d H:i", $filetime);
  86. }
  87. //判断文件类型并作处理
  88. if ($file == ".") continue;
  89. else if ($file == "..") {
  90. if ($activepath == "") continue;
  91. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  92. $line = "\n<tr>
  93. <td class='linerow'><a href='select_templets.php?f=$f&activepath=" . urlencode($tmp) . "'><img src='img/dir2.gif'>上级目录</a></td>
  94. <td colspan='2' class='linerow'>当前目录:$activepath</td>
  95. </tr>\r\n";
  96. echo $line;
  97. } else if (is_dir("$inpath/$file")) {
  98. if (preg_match("#^_(.*)$#i", $file)) continue;
  99. if (preg_match("#^\.(.*)$#i", $file)) continue;
  100. $line = "\n<tr>
  101. <td class='linerow'><a href=select_templets.php?f=$f&activepath=" . urlencode("$activepath/$file") . "><img src='img/dir.gif'>$file</a></td>
  102. <td class='linerow'></td>
  103. <td class='linerow'></td>
  104. </tr>";
  105. echo "$line";
  106. } else if (preg_match("#\.(htm|html)#i", $file)) {
  107. if ($file == $comeback) $lstyle = " style='color:red' ";
  108. else $lstyle = "";
  109. $reurl = "$activeurl/$file";
  110. $reurl = preg_replace("#\.\.#", "", $reurl);
  111. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  112. $line = "\n<tr>
  113. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/htm.gif'>$file</a></td>
  114. <td class='linerow'>$filesize KB</td>
  115. <td class='linerow'>$filetime</td>
  116. </tr>";
  117. echo "$line";
  118. } else if (preg_match("#\.(css)#i", $file)) {
  119. if ($file == $comeback) $lstyle = " style='color:red' ";
  120. else $lstyle = "";
  121. $reurl = "$activeurl/$file";
  122. $reurl = preg_replace("#\.\.#", "", $reurl);
  123. $reurl = preg_replace("#" . $templetdir . "/#", "", $reurl);
  124. $line = "\n<tr>
  125. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/css.gif'>$file</a></td>
  126. <td class='linerow'>$filesize KB</td>
  127. <td class='linerow'>$filetime</td>
  128. </tr>";
  129. echo "$line";
  130. } else if (preg_match("#\.(js)#i", $file)) {
  131. if ($file == $comeback) $lstyle = " style='color:red' ";
  132. else $lstyle = "";
  133. $reurl = "$activeurl/$file";
  134. $reurl = preg_replace("#\.\.#", "", $reurl);
  135. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  136. $line = "\n<tr>
  137. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/js.gif'>$file</a></td>
  138. <td class='linerow'>$filesize KB</td>
  139. <td class='linerow'>$filetime</td>
  140. </tr>";
  141. echo "$line";
  142. } else if (preg_match("#\.(jpg)#i", $file)) {
  143. if ($file == $comeback) $lstyle = " style='color:red' ";
  144. else $lstyle = "";
  145. $reurl = "$activeurl/$file";
  146. $reurl = preg_replace("#\.\.#", "", $reurl);
  147. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  148. $line = "\n<tr>
  149. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/jpg.gif'>$file</a></td>
  150. <td class='linerow'>$filesize KB</td>
  151. <td class='linerow'>$filetime</td>
  152. </tr>";
  153. echo "$line";
  154. } else if (preg_match("#\.(gif|png)#i", $file)) {
  155. if ($file == $comeback) $lstyle = " style='color:red' ";
  156. else $lstyle = "";
  157. $reurl = "$activeurl/$file";
  158. $reurl = preg_replace("#\.\.#", "", $reurl);
  159. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  160. $line = "\n<tr>
  161. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/gif.gif'>$file</a></td>
  162. <td class='linerow'>$filesize KB</td>
  163. <td class='linerow'>$filetime</td>
  164. </tr>";
  165. echo "$line";
  166. } else if (preg_match("#\.(txt)#i", $file)) {
  167. if ($file == $comeback) $lstyle = " style='color:red' ";
  168. else $lstyle = "";
  169. $reurl = "$activeurl/$file";
  170. $reurl = preg_replace("#\.\.#", "", $reurl);
  171. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  172. $line = "\n<tr>
  173. <td class='linerow'><a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src='img/txt.gif'>$file</a></td>
  174. <td class='linerow'>$filesize KB</td>
  175. <td class='linerow'>$filetime</td></tr>";
  176. echo "$line";
  177. }
  178. }//End Loop
  179. $dh->close();
  180. ?>
  181. <tr>
  182. <td colspan="3">
  183. <table width="100%">
  184. <form action="select_templets_post.php" method="POST" enctype="multipart/form-data" name="myform">
  185. <input type="hidden" name="activepath" value="<?php echo $activepath ?>">
  186. <input type="hidden" name="f" value='<?php echo $f ?>'>
  187. <input type="hidden" name="job" value="upload">
  188. <tr>
  189. <td>
  190. &nbsp;上传:<input type="file" name="uploadfile" style="width:260px">
  191. 改名:<input type="text" name="filename" style="width:160px">
  192. <button type="submit" name="sb1" class="btn btn-success btn-sm">确定</button>
  193. </td>
  194. </tr>
  195. </form>
  196. </table>
  197. </td>
  198. </tr>
  199. </table>
  200. </body>
  201. </html>