filep.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. $link=db_connect();
  7. $empire=new mysqlquery();
  8. $editor=1;
  9. //验证用户
  10. $lur=is_login();
  11. $logininid=$lur['userid'];
  12. $loginin=$lur['username'];
  13. $loginrnd=$lur['rnd'];
  14. $loginlevel=$lur['groupid'];
  15. $loginadminstyleid=$lur['adminstyleid'];
  16. //ehash
  17. $ecms_hashur=hReturnEcmsHashStrAll();
  18. //返回按钮事件
  19. function ToReturnDoFilepButton($doing,$tranfrom,$field,$file,$filename,$fileid,$filesize,$filetype,$no,$type){
  20. if($doing==1)//返回地址
  21. {
  22. $bturl="ChangeFile1(1,'".$file."');";
  23. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  24. }
  25. elseif($doing==2)//返回地址
  26. {
  27. $bturl="ChangeFile1(2,'".$file."');";
  28. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  29. }
  30. else
  31. {
  32. if($tranfrom==1)//编辑器选择
  33. {
  34. $bturl="EditorChangeFile('".$file."','".addslashes($filename)."','".$filetype."','".$filesize."','".addslashes($no)."');";
  35. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  36. }
  37. elseif($tranfrom==2)//特殊字段选择
  38. {
  39. $bturl="SFormIdChangeFile('".addslashes($no)."','$file','$filesize','$filetype','$field');";
  40. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  41. }
  42. else
  43. {
  44. $bturl="InsertFile('".$file."','".addslashes($filename)."','".$fileid."','".$filesize."','".$filetype."','','".$type."');";
  45. $button="<input type=button name=button value='插入' onclick=\"javascript:".$bturl."\">";
  46. }
  47. }
  48. $retr['button']=$button;
  49. $retr['bturl']=$bturl;
  50. return $retr;
  51. }
  52. $classid=(int)$_GET['classid'];
  53. $infoid=(int)$_GET['infoid'];
  54. $filepass=(int)$_GET['filepass'];
  55. $type=(int)$_GET['type'];
  56. $modtype=(int)$_GET['modtype'];
  57. $fstb=(int)$_GET['fstb'];
  58. $doing=(int)$_GET['doing'];
  59. $field=RepPostVar($_GET['field']);
  60. $tranfrom=ehtmlspecialchars($_GET['tranfrom']);
  61. $fileno=ehtmlspecialchars($_GET['fileno']);
  62. $doecmspage=RepPostStr($_GET['doecmspage'],1);
  63. if(empty($field))
  64. {
  65. $field="ecms";
  66. }
  67. include('eshoweditor.php');
  68. $search="&classid=$classid&infoid=$infoid&filepass=$filepass&type=$type&modtype=$modtype&fstb=$fstb&doing=$doing&tranfrom=$tranfrom&field=$field&fileno=$fileno&doecmspage=$doecmspage".$ecms_hashur['ehref'];
  69. //基目录
  70. $basepath=eReturnEcmsMainPortPath()."d/file";//moreport
  71. $filepath=ehtmlspecialchars($_GET['filepath']);
  72. if(strstr($filepath,".."))
  73. {
  74. $filepath="";
  75. }
  76. $filepath=eReturnCPath($filepath,'');
  77. $openpath=$basepath."/".$filepath;
  78. if(!file_exists($openpath))
  79. {
  80. $openpath=$basepath;
  81. }
  82. $hand=@opendir($openpath);
  83. db_close();
  84. $empire=null;
  85. ?>
  86. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  87. <html>
  88. <head>
  89. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  90. <title>选择文件</title>
  91. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  92. <script>
  93. function InsertFile(filename,fname,fileid,filesize,filetype,fileno,dotype){
  94. var vstr="";
  95. if(dotype!=undefined)
  96. {
  97. vstr=showModalDialog("infoeditor/epage/insertfile.php?<?=$ecms_hashur['ehref']?>&ecms="+dotype+"&fname="+fname+"&fileid="+fileid+"&filesize="+filesize+"&filetype="+filetype+"&filename="+filename, "", "dialogWidth:45.5em; dialogHeight:27.5em; status:0");
  98. if(vstr==undefined)
  99. {
  100. return false;
  101. }
  102. }
  103. parent.opener.DoFile(vstr);
  104. parent.window.close();
  105. }
  106. function TInsertFile(vstr){
  107. parent.opener.DoFile(vstr);
  108. parent.window.close();
  109. }
  110. //选择字段
  111. function ChangeFile1(obj,str){
  112. <?php
  113. if(strstr($field,'.'))
  114. {
  115. ?>
  116. parent.<?=$field?>.value=str;
  117. <?php
  118. }
  119. else
  120. {
  121. ?>
  122. if(obj==1)
  123. {
  124. parent.opener.document.add.<?=$field?>.value=str;
  125. }
  126. else
  127. {
  128. parent.opener.document.form1.<?=$field?>.value=str;
  129. }
  130. <?php
  131. }
  132. ?>
  133. parent.window.close();
  134. }
  135. //编辑器选择
  136. function EditorChangeFile(fileurl,filename,filetype,filesize,name){
  137. var returnstr;
  138. returnstr=fileurl;
  139. <?php
  140. $useeditor_r=ECMS_EditorReturnType('');
  141. if($useeditor_r['ftype']==0)
  142. {
  143. ?>
  144. returnstr=fileurl+'##'+name+'##'+filesize;
  145. <?php
  146. }
  147. ?>
  148. window.parent.opener.<?=$useeditor_r['jsfun']?>(returnstr);
  149. parent.window.close();
  150. }
  151. //变量层选择
  152. function SFormIdChangeFile(name,url,filesize,filetype,idvar){
  153. parent.opener.doSpChangeFile(name,url,filesize,filetype,idvar);
  154. parent.window.close();
  155. }
  156. //全选
  157. function CheckAll(form){
  158. for(var i=0;i<form.elements.length;i++)
  159. {
  160. var e = form.elements[i];
  161. if (e.name != 'chkall')
  162. e.checked = form.chkall.checked;
  163. }
  164. }
  165. //重新载入页面
  166. function ReloadChangeFilePage(){
  167. self.location.reload();
  168. }
  169. </script>
  170. </head>
  171. <body>
  172. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  173. <tr>
  174. <td> 当前目录:<strong>/
  175. <?=$filepath?>
  176. </strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<a href="#ecms" onclick="javascript:history.go(-1);">返回上一页</a>]</td>
  177. </tr>
  178. </table>
  179. <br>
  180. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  181. <form name="dofile" method="post" action="../ecmsfile.php">
  182. <?=$ecms_hashur['form']?>
  183. <input name="enews" type="hidden" id="enews" value="DelPathFile">
  184. <input type=hidden name=doecmspage value="<?=$doecmspage?>">
  185. <tr class="header">
  186. <td><div align="center">选择</div></td>
  187. <td height="25"><div align="center">文件名</div></td>
  188. <td><div align="center">大小</div></td>
  189. <td><div align="center">类型</div></td>
  190. <td><div align="center">修改时间</div></td>
  191. </tr>
  192. <?php
  193. $efileurl=eReturnFileUrl(1);
  194. while($file=@readdir($hand))
  195. {
  196. if(empty($filepath))
  197. {
  198. $truefile=$file;
  199. }
  200. else
  201. {
  202. $truefile=$filepath."/".$file;
  203. }
  204. if($file=="."||$file=="..")
  205. {
  206. continue;
  207. }
  208. //目录
  209. $pathfile=$openpath."/".$file;
  210. if(is_dir($pathfile))
  211. {
  212. $filelink="'filep.php?filepath=".$truefile.$search."'";
  213. $filename=$file;
  214. $img="../../data/images/dir/folder.gif";
  215. $target="";
  216. //发布时间
  217. $ftime=@filemtime($pathfile);
  218. $filetime=date("Y-m-d H:i:s",$ftime);
  219. $filesize='<目录>';
  220. $filetype='文件夹';
  221. $button="";
  222. }
  223. //文件
  224. else
  225. {
  226. $filelink="'".eReturnFileUrl().$truefile."'";
  227. $filename=$file;
  228. $ftype=GetFiletype($file);
  229. $img='../../data/images/dir/'.substr($ftype,1,strlen($ftype))."_icon.gif";
  230. if(!file_exists($img))
  231. {
  232. $img='../../data/images/dir/unknown_icon.gif';
  233. }
  234. $target=" target='_blank'";
  235. //发布时间
  236. $ftime=@filemtime($pathfile);
  237. $filetime=date("Y-m-d H:i:s",$ftime);
  238. //文件大小
  239. $fsize=@filesize($pathfile);
  240. $filesize=ChTheFilesize($fsize);
  241. //文件类型
  242. if(strstr($ecms_config['sets']['tranpicturetype'],','.$ftype.','))
  243. {
  244. $filetype='图片';
  245. }
  246. elseif(strstr($ecms_config['sets']['tranflashtype'],','.$ftype.','))
  247. {
  248. $filetype='FLASH';
  249. }
  250. elseif(strstr($ecms_config['sets']['mediaplayertype'],','.$ftype.',')||strstr($ecms_config['sets']['realplayertype'],','.$ftype.','))
  251. {
  252. $filetype='视频';
  253. }
  254. else
  255. {
  256. $filetype='附件';
  257. }
  258. $furl=$efileurl.$truefile;
  259. $buttonr=ToReturnDoFilepButton($doing,$tranfrom,$field,$furl,$file,0,$filesize,$ftype,'',$type);
  260. $button=$buttonr['button'];
  261. $buttonurl=$buttonr['bturl'];
  262. }
  263. ?>
  264. <tr bgcolor="#FFFFFF">
  265. <td width="9%">
  266. <div align="center">
  267. <?=$button?>
  268. </div></td>
  269. <td width="39%" height="25"><img src="<?=$img?>" width="23" height="22"><a href=<?=$filelink?><?=$target?>>
  270. <?=$filename?>
  271. </a></td>
  272. <td width="20%">
  273. <div align="right"><?=$filesize?></div></td>
  274. <td width="11%">
  275. <div align="center"><?=$filetype?></div></td>
  276. <td width="21%">
  277. <div align="center"><?=$filetime?></div></td>
  278. </tr>
  279. <?
  280. }
  281. @closedir($hand);
  282. ?>
  283. </form>
  284. </table>
  285. </body>
  286. </html>