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

245 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) 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 http-equiv='Content-Type' content='text/html; charset=<?php echo $cfg_soft_lang; ?>'>
  37. <title>模板管理器</title>
  38. <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
  39. <link href="../../static/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  40. <link href='../css/base.css' rel='stylesheet' type='text/css'>
  41. <style>
  42. .linerow {
  43. border-bottom: 1px solid #CBD8AC;
  44. }
  45. </style>
  46. </head>
  47. <body background='img/allbg.gif' leftmargin='0' topmargin='0'>
  48. <SCRIPT language='JavaScript'>
  49. function nullLink() {
  50. return;
  51. }
  52. function ReturnValue(reimg) {
  53. window.opener.document.<?php echo $f ?>.value = reimg;
  54. if (document.all) window.opener = true;
  55. window.close();
  56. }
  57. </SCRIPT>
  58. <!-- 开始文件列表 -->
  59. <table width='100%' border='0' align="center" cellspacing='0' cellpadding='2' class="table maintable table-bordered mt-3">
  60. <tr bgcolor="#CCCCCC">
  61. <td width="55%" align="center" background="img/wbg.gif" class='linerow'><strong>点击名称选择文件</strong></td>
  62. <td width="15%" align="center" bgcolor='#EEF4EA' class='linerow'><strong>文件大小</strong></td>
  63. <td width="30%" align="center" background="img/wbg.gif" class='linerow'><strong>最后修改时间</strong></td>
  64. </tr>
  65. <?php
  66. $dh = dir($inpath);
  67. $ty1 = "";
  68. $ty2 = "";
  69. while ($file = $dh->read()) {
  70. //-----计算文件大小和创建时间
  71. if ($file != "." && $file != ".." && !is_dir("$inpath/$file")) {
  72. $filesize = filesize("$inpath/$file");
  73. $filesize = $filesize / 1024;
  74. if ($filesize != "")
  75. if ($filesize < 0.1) {
  76. @list($ty1, $ty2) = split("\.", $filesize);
  77. $filesize = $ty1 . "." . substr($ty2, 0, 2);
  78. } else {
  79. @list($ty1, $ty2) = split("\.", $filesize);
  80. $filesize = $ty1 . "." . substr($ty2, 0, 1);
  81. }
  82. $filetime = filemtime("$inpath/$file");
  83. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  84. }
  85. //------判断文件类型并作处理
  86. if ($file == ".") continue;
  87. else if ($file == "..") {
  88. if ($activepath == "") continue;
  89. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  90. $line = "\n<tr>
  91. <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>
  92. <td colspan='2' class='linerow'> 当前目录:$activepath</td>
  93. </tr>\r\n";
  94. echo $line;
  95. } else if (is_dir("$inpath/$file")) {
  96. if (preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录
  97. if (preg_match("#^\.(.*)$#i", $file)) continue;
  98. $line = "\n<tr>
  99. <td bgcolor='#F9FBF0' class='linerow'>
  100. <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>
  101. </td>
  102. <td class='linerow'>-</td>
  103. <td bgcolor='#F9FBF0' 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' bgcolor='#F9FBF0'>
  114. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/htm.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  115. </td>
  116. <td class='linerow'>$filesize KB</td>
  117. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  118. </tr>";
  119. echo "$line";
  120. } else if (preg_match("#\.(css)#i", $file)) {
  121. if ($file == $comeback) $lstyle = " style='color:red' ";
  122. else $lstyle = "";
  123. $reurl = "$activeurl/$file";
  124. $reurl = preg_replace("#\.\.#", "", $reurl);
  125. $reurl = preg_replace("#" . $templetdir . "/#", "", $reurl);
  126. $line = "\n<tr>
  127. <td class='linerow' bgcolor='#F9FBF0'>
  128. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/css.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  129. </td>
  130. <td class='linerow'>$filesize KB</td>
  131. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  132. </tr>";
  133. echo "$line";
  134. } else if (preg_match("#\.(js)#i", $file)) {
  135. if ($file == $comeback) $lstyle = " style='color:red' ";
  136. else $lstyle = "";
  137. $reurl = "$activeurl/$file";
  138. $reurl = preg_replace("#\.\.#", "", $reurl);
  139. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  140. $line = "\n<tr>
  141. <td class='linerow' bgcolor='#F9FBF0'>
  142. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/js.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  143. </td>
  144. <td class='linerow'>$filesize KB</td>
  145. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  146. </tr>";
  147. echo "$line";
  148. } else if (preg_match("#\.(jpg)#i", $file)) {
  149. if ($file == $comeback) $lstyle = " style='color:red' ";
  150. else $lstyle = "";
  151. $reurl = "$activeurl/$file";
  152. $reurl = preg_replace("#\.\.#", "", $reurl);
  153. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  154. $line = "\n<tr>
  155. <td class='linerow' bgcolor='#F9FBF0'>
  156. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/jpg.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  157. </td>
  158. <td class='linerow'>$filesize KB</td>
  159. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  160. </tr>";
  161. echo "$line";
  162. } else if (preg_match("#\.(gif|png)#i", $file)) {
  163. if ($file == $comeback) $lstyle = " style='color:red' ";
  164. else $lstyle = "";
  165. $reurl = "$activeurl/$file";
  166. $reurl = preg_replace("#\.\.#", "", $reurl);
  167. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  168. $line = "\n<tr>
  169. <td class='linerow' bgcolor='#F9FBF0'>
  170. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/gif.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  171. </td>
  172. <td class='linerow'>$filesize KB</td>
  173. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  174. </tr>";
  175. echo "$line";
  176. } else if (preg_match("#\.(txt)#i", $file)) {
  177. if ($file == $comeback) $lstyle = " style='color:red' ";
  178. else $lstyle = "";
  179. $reurl = "$activeurl/$file";
  180. $reurl = preg_replace("#\.\.#", "", $reurl);
  181. $reurl = preg_replace("#" . $templetdir . "\/#", "", $reurl);
  182. $line = "\n<tr>
  183. <td class='linerow' bgcolor='#F9FBF0'>
  184. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/txt.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  185. </td>
  186. <td class='linerow'>$filesize KB</td>
  187. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  188. </tr>";
  189. echo "$line";
  190. }
  191. } //End Loop
  192. $dh->close();
  193. ?>
  194. <!-- 文件列表完 -->
  195. <tr>
  196. <td colspan='3' bgcolor='#E8F1DE'>
  197. <table width='100%'>
  198. <form action='select_templets_post.php' method='POST' enctype="multipart/form-data" name='myform'>
  199. <input type='hidden' name='activepath' value='<?php echo $activepath ?>'>
  200. <input type='hidden' name='f' value='<?php echo $f ?>'>
  201. <input type='hidden' name='job' value='upload'>
  202. <tr>
  203. <td background="img/tbg.gif" bgcolor="#99CC00">
  204. &nbsp;上 传: <input type='file' name='uploadfile' style='width:320px'>
  205. 改名:<input type='text' name='filename' value='' style='width:100px'>
  206. <button type='submit' name='sb1' class="btn btn-success btn-sm">确定</button>
  207. </td>
  208. </tr>
  209. </form>
  210. </table>
  211. </td>
  212. </tr>
  213. </table>
  214. </body>
  215. </html>