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

261 lines
8.7KB

  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 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. if(empty($activepath))
  13. {
  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. {
  22. $activepath = $templetdir;
  23. }
  24. $inpath = $cfg_basedir.$activepath;
  25. $activeurl = '..'.$activepath;
  26. if (!is_dir($inpath) )
  27. {
  28. die('No Exsits Path');
  29. }
  30. if(empty($f))
  31. {
  32. $f='form1.enclosure';
  33. }
  34. if(empty($comeback))
  35. {
  36. $comeback = '';
  37. }
  38. ?>
  39. <html>
  40. <head>
  41. <meta http-equiv='Content-Type' content='text/html; charset=<?php echo $cfg_soft_lang; ?>'>
  42. <title>模板管理器</title>
  43. <link href='../../images/img/base.css' rel='stylesheet' type='text/css'>
  44. <style>
  45. .linerow {border-bottom: 1px solid #CBD8AC;}
  46. </style>
  47. </head>
  48. <body background='img/allbg.gif' leftmargin='0' topmargin='0'>
  49. <SCRIPT language='JavaScript'>
  50. function nullLink()
  51. {
  52. return;
  53. }
  54. function ReturnValue(reimg)
  55. {
  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' bgcolor='#CBD8AC' align="center">
  62. <tr bgcolor='#FFFFFF'>
  63. <td colspan='3'>
  64. <!-- 开始文件列表 -->
  65. <table width='100%' border='0' cellspacing='0' cellpadding='2'>
  66. <tr bgcolor="#CCCCCC">
  67. <td width="55%" align="center" background="img/wbg.gif" class='linerow'><strong>点击名称选择文件</strong></td>
  68. <td width="15%" align="center" bgcolor='#EEF4EA' class='linerow'><strong>文件大小</strong></td>
  69. <td width="30%" align="center" background="img/wbg.gif" class='linerow'><strong>最后修改时间</strong></td>
  70. </tr>
  71. <?php
  72. $dh = dir($inpath);
  73. $ty1="";
  74. $ty2="";
  75. while($file = $dh->read()) {
  76. //-----计算文件大小和创建时间
  77. if($file!="." && $file!=".." && !is_dir("$inpath/$file")){
  78. $filesize = filesize("$inpath/$file");
  79. $filesize = $filesize / 1024;
  80. if($filesize != "")
  81. if($filesize < 0.1)
  82. {
  83. @list($ty1,$ty2) = split("\.", $filesize);
  84. $filesize=$ty1.".".substr($ty2, 0, 2);
  85. } else {
  86. @list($ty1,$ty2) = split("\.", $filesize);
  87. $filesize=$ty1.".".substr($ty2, 0, 1);
  88. }
  89. $filetime = filemtime("$inpath/$file");
  90. $filetime = MyDate("Y-m-d H:i:s", $filetime);
  91. }
  92. //------判断文件类型并作处理
  93. if($file == ".") continue;
  94. else if($file == "..")
  95. {
  96. if($activepath == "") continue;
  97. $tmp = preg_replace("#[\/][^\/]*$#", "", $activepath);
  98. $line = "\n<tr>
  99. <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>
  100. <td colspan='2' class='linerow'> 当前目录:$activepath</td>
  101. </tr>\r\n";
  102. echo $line;
  103. }
  104. else if(is_dir("$inpath/$file"))
  105. {
  106. if(preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录
  107. if(preg_match("#^\.(.*)$#i", $file)) continue;
  108. $line = "\n<tr>
  109. <td bgcolor='#F9FBF0' class='linerow'>
  110. <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>
  111. </td>
  112. <td class='linerow'>-</td>
  113. <td bgcolor='#F9FBF0' class='linerow'>-</td>
  114. </tr>";
  115. echo "$line";
  116. } else if(preg_match("#\.(htm|html)#i", $file))
  117. {
  118. if($file==$comeback) $lstyle = " style='color:red' ";
  119. else $lstyle = "";
  120. $reurl = "$activeurl/$file";
  121. $reurl = preg_replace("#\.\.#", "", $reurl);
  122. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  123. $line = "\n<tr>
  124. <td class='linerow' bgcolor='#F9FBF0'>
  125. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/htm.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  126. </td>
  127. <td class='linerow'>$filesize KB</td>
  128. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  129. </tr>";
  130. echo "$line";
  131. } else if(preg_match("#\.(css)#i", $file))
  132. {
  133. if($file==$comeback) $lstyle = " style='color:red' ";
  134. else $lstyle = "";
  135. $reurl = "$activeurl/$file";
  136. $reurl = preg_replace("#\.\.#", "", $reurl);
  137. $reurl = preg_replace("#".$templetdir."/#", "", $reurl);
  138. $line = "\n<tr>
  139. <td class='linerow' bgcolor='#F9FBF0'>
  140. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/css.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  141. </td>
  142. <td class='linerow'>$filesize KB</td>
  143. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  144. </tr>";
  145. echo "$line";
  146. } else if(preg_match("#\.(js)#i", $file))
  147. {
  148. if( $file == $comeback ) $lstyle = " style='color:red' ";
  149. else $lstyle = "";
  150. $reurl = "$activeurl/$file";
  151. $reurl = preg_replace("#\.\.#", "", $reurl);
  152. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  153. $line = "\n<tr>
  154. <td class='linerow' bgcolor='#F9FBF0'>
  155. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/js.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  156. </td>
  157. <td class='linerow'>$filesize KB</td>
  158. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  159. </tr>";
  160. echo "$line";
  161. } else if(preg_match("#\.(jpg)#i", $file))
  162. {
  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/jpg.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("#\.(gif|png)#i", $file))
  177. {
  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/gif.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. else if(preg_match("#\.(txt)#i", $file))
  193. {
  194. if($file==$comeback) $lstyle = " style='color:red' ";
  195. else $lstyle = "";
  196. $reurl = "$activeurl/$file";
  197. $reurl = preg_replace("#\.\.#", "", $reurl);
  198. $reurl = preg_replace("#".$templetdir."\/#", "", $reurl);
  199. $line = "\n<tr>
  200. <td class='linerow' bgcolor='#F9FBF0'>
  201. <a href=\"javascript:ReturnValue('$reurl');\" $lstyle><img src=img/txt.gif border=0 width=16 height=16 align=absmiddle>$file</a>
  202. </td>
  203. <td class='linerow'>$filesize KB</td>
  204. <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
  205. </tr>";
  206. echo "$line";
  207. }
  208. }//End Loop
  209. $dh->close();
  210. ?>
  211. <!-- 文件列表完 -->
  212. <tr>
  213. <td colspan='3' bgcolor='#E8F1DE'>
  214. <table width='100%'>
  215. <form action='select_templets_post.php' method='POST' enctype="multipart/form-data" name='myform'>
  216. <input type='hidden' name='activepath' value='<?php echo $activepath?>'>
  217. <input type='hidden' name='f' value='<?php echo $f?>'>
  218. <input type='hidden' name='job' value='upload'>
  219. <tr>
  220. <td background="img/tbg.gif" bgcolor="#99CC00">
  221. &nbsp;上 传: <input type='file' name='uploadfile' style='width:320px'>
  222. 改名:<input type='text' name='filename' value='' style='width:100px'>
  223. <input type='submit' name='sb1' value='确定'>
  224. </td>
  225. </tr>
  226. </form>
  227. </table>
  228. </td>
  229. </tr>
  230. </table>
  231. </td>
  232. </tr>
  233. </table>
  234. </body>
  235. </html>