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

193 lines
9.0KB

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