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

246 lines
9.9KB

  1. <?php
  2. /**
  3. * 模板选择框
  4. *
  5. * @version $Id: select_templets.php 1 9:43 2010年7月8日Z tianya $
  6. * @package DedeCMS.Dialog
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__) . "/config.php");
  13. if (empty($activepath)) {
  14. $activepath = '';
  15. }
  16. $cfg_txttype = 'htm|html|tpl|txt|dtp';
  17. $activepath = str_replace('.', '', $activepath);
  18. $activepath = preg_replace("#\/{1,}#", '/', $activepath);
  19. $templetdir = $cfg_templets_dir;
  20. if (strlen($activepath) < strlen($templetdir)) {
  21. $activepath = $templetdir;
  22. }
  23. $inpath = $cfg_basedir . $activepath;
  24. $activeurl = '..' . $activepath;
  25. if (!is_dir($inpath)) {
  26. die('No Exsits Path');
  27. }
  28. if (empty($f)) {
  29. $f = 'form1.enclosure';
  30. }
  31. if (empty($comeback)) {
  32. $comeback = '';
  33. }
  34. ?>
  35. <html>
  36. <head>
  37. <meta http-equiv='Content-Type' content='text/html; charset=<?php echo $cfg_soft_lang; ?>'>
  38. <title>模板管理器</title>
  39. <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
  40. <link href="../../static/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  41. <link href='../css/base.css' rel='stylesheet' type='text/css'>
  42. <style>
  43. .linerow {
  44. border-bottom: 1px solid #CBD8AC;
  45. }
  46. </style>
  47. </head>
  48. <body background='img/allbg.gif' leftmargin='0' topmargin='0'>
  49. <SCRIPT language='JavaScript'>
  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. <!-- 开始文件列表 -->
  60. <table width='100%' border='0' align="center" cellspacing='0' cellpadding='2' class="table maintable table-bordered mt-3">
  61. <tr bgcolor="#CCCCCC">
  62. <td width="55%" align="center" background="img/wbg.gif" class='linerow'><strong>点击名称选择文件</strong></td>
  63. <td width="15%" align="center" bgcolor='#EEF4EA' class='linerow'><strong>文件大小</strong></td>
  64. <td width="30%" align="center" background="img/wbg.gif" class='linerow'><strong>最后修改时间</strong></td>
  65. </tr>
  66. <?php
  67. $dh = dir($inpath);
  68. $ty1 = "";
  69. $ty2 = "";
  70. while ($file = $dh->read()) {
  71. //-----计算文件大小和创建时间
  72. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  73. $filesize = filesize("$inpath/$file");
  74. $filesize = $filesize / 1024;
  75. if ($filesize != "")
  76. if ($filesize < 0.1) {
  77. @list($ty1, $ty2) = split("\.", $filesize);
  78. $filesize = $ty1 . "." . substr($ty2, 0, 2);
  79. } else {
  80. @list($ty1, $ty2) = split("\.", $filesize);
  81. $filesize = $ty1 . "." . substr($ty2, 0, 1);
  82. }
  83. $filetime = filemtime("$inpath/$file");
  84. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  85. }
  86. //------判断文件类型并作处理
  87. if ($file == ".") continue;
  88. else if ($file == "..") {
  89. if ($activepath == "") continue;
  90. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  91. $line = "\n<tr>
  92. <td class='linerow'> <a href='select_templets.php?f=$f&activepath=" . urlencode($tmp) . "'><img src=img/dir2.gif border=0 width=16 height=16 align=absmiddle>上级目录</a></td>
  93. <td colspan='2' class='linerow'> 当前目录:$activepath</td>
  94. </tr>\r\n";
  95. echo $line;
  96. } else if (is_dir("$inpath/$file")) {
  97. if (preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录
  98. if (preg_match("#^\.(.*)$#i", $file)) continue;
  99. $line = "\n<tr>
  100. <td bgcolor='#F9FBF0' class='linerow'>
  101. <a href=select_templets.php?f=$f&activepath=" . urlencode("$activepath/$file") . "><img src=img/dir.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  102. </td>
  103. <td class='linerow'>-</td>
  104. <td bgcolor='#F9FBF0' class='linerow'>-</td>
  105. </tr>";
  106. echo "$line";
  107. } else if (preg_match("#\.(htm|html)#i", $file)) {
  108. if ($file == $comeback) $lstyle = " style='color:red' ";
  109. else $lstyle = "";
  110. $reurl = "$activeurl/$file";
  111. $reurl = preg_replace("#\.\.#", "", $reurl);
  112. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  113. $line = "\n<tr>
  114. <td class='linerow' bgcolor='#F9FBF0'>
  115. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/htm.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  116. </td>
  117. <td class='linerow'>$filesize KB</td>
  118. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  119. </tr>";
  120. echo "$line";
  121. } else if (preg_match("#\.(css)#i", $file)) {
  122. if ($file == $comeback) $lstyle = " style='color:red' ";
  123. else $lstyle = "";
  124. $reurl = "$activeurl/$file";
  125. $reurl = preg_replace("#\.\.#", "", $reurl);
  126. $reurl = preg_replace("#" . $templetdir . "/#", "", $reurl);
  127. $line = "\n<tr>
  128. <td class='linerow' bgcolor='#F9FBF0'>
  129. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/css.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  130. </td>
  131. <td class='linerow'>$filesize KB</td>
  132. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  133. </tr>";
  134. echo "$line";
  135. } else if (preg_match("#\.(js)#i", $file)) {
  136. if ($file == $comeback) $lstyle = " style='color:red' ";
  137. else $lstyle = "";
  138. $reurl = "$activeurl/$file";
  139. $reurl = preg_replace("#\.\.#", "", $reurl);
  140. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  141. $line = "\n<tr>
  142. <td class='linerow' bgcolor='#F9FBF0'>
  143. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/js.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  144. </td>
  145. <td class='linerow'>$filesize KB</td>
  146. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  147. </tr>";
  148. echo "$line";
  149. } else if (preg_match("#\.(jpg)#i", $file)) {
  150. if ($file == $comeback) $lstyle = " style='color:red' ";
  151. else $lstyle = "";
  152. $reurl = "$activeurl/$file";
  153. $reurl = preg_replace("#\.\.#", "", $reurl);
  154. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  155. $line = "\n<tr>
  156. <td class='linerow' bgcolor='#F9FBF0'>
  157. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/jpg.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  158. </td>
  159. <td class='linerow'>$filesize KB</td>
  160. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  161. </tr>";
  162. echo "$line";
  163. } else if (preg_match("#\.(gif|png)#i", $file)) {
  164. if ($file == $comeback) $lstyle = " style='color:red' ";
  165. else $lstyle = "";
  166. $reurl = "$activeurl/$file";
  167. $reurl = preg_replace("#\.\.#", "", $reurl);
  168. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  169. $line = "\n<tr>
  170. <td class='linerow' bgcolor='#F9FBF0'>
  171. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/gif.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  172. </td>
  173. <td class='linerow'>$filesize KB</td>
  174. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  175. </tr>";
  176. echo "$line";
  177. } else if (preg_match("#\.(txt)#i", $file)) {
  178. if ($file == $comeback) $lstyle = " style='color:red' ";
  179. else $lstyle = "";
  180. $reurl = "$activeurl/$file";
  181. $reurl = preg_replace("#\.\.#", "", $reurl);
  182. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  183. $line = "\n<tr>
  184. <td class='linerow' bgcolor='#F9FBF0'>
  185. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/txt.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  186. </td>
  187. <td class='linerow'>$filesize KB</td>
  188. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  189. </tr>";
  190. echo "$line";
  191. }
  192. } //End Loop
  193. $dh->close();
  194. ?>
  195. <!-- 文件列表完 -->
  196. <tr>
  197. <td colspan='3' bgcolor='#E8F1DE'>
  198. <table width='100%'>
  199. <form action='select_templets_post.php' method='POST' enctype="multipart/form-data" name='myform'>
  200. <input type='hidden' name='activepath' value='<?php echo $activepath ?>'>
  201. <input type='hidden' name='f' value='<?php echo $f ?>'>
  202. <input type='hidden' name='job' value='upload'>
  203. <tr>
  204. <td background="img/tbg.gif" bgcolor="#99CC00">
  205. &nbsp;上 传: <input type='file' name='uploadfile' style='width:320px'>
  206. 改名:<input type='text' name='filename' value='' style='width:100px'>
  207. <button type='submit' name='sb1' class="btn btn-secondary btn-sm">确定</button>
  208. </td>
  209. </tr>
  210. </form>
  211. </table>
  212. </td>
  213. </tr>
  214. </table>
  215. </body>
  216. </html>