码迷,mamicode.com
首页 > 其他好文 > 详细

文件扫描(探针)

时间:2018-10-02 20:21:03      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:其他   count   远程文件   坐标   continue   网络连接   系统信息   date   表单   

  1 <?php
  2 header(Content-type:text/html;charset=utf-8);
  3 //预格式化数组
  4 function FP($arr){
  5 echo <pre>;print_r($arr);echo </pre>;}
  6 //转码
  7 function gbk($str){return iconv(utf-8,gbk,$str);}
  8 function utf8($str){return iconv(gbk,utf-8,$str);}
  9 //路径格式化(替换双斜线为单斜线)
 10 function path_formate($str){
 11     return str_replace(\\\\,\\,$str);
 12 }
 13 //默认获得文件修改时间
 14 function filetime($way,$char=m){
 15     date_default_timezone_set(PRC);
 16     switch($char){
 17         case c:$localtime = date(Y-m-d H:i:s,filectime($way));
 18         break;
 19         case m:$localtime = date(Y-m-d H:i:s,filemtime($way));
 20         break;
 21         case a:$localtime = date(Y-m-d H:i:s,fileatime($way));
 22         break;
 23     }
 24     return $localtime;
 25 }
 26 function f_dirname($f_path){
 27     return substr($f_path,0,strrpos($f_path,\\));
 28 }
 29 //判断后缀类型
 30 function suffixtype($f_path){
 31     $info = pathinfo($f_path);
 32     $f_type = file;
 33     switch(strtolower(@$info["extension"])){
 34         case jpg:case jpeg:case gif:
 35         case png:case bmp:$f_type = image;break;
 36         case pl:case c:case cpp:case log:case asp:case php:case jsp:case txt:case xml:case html:case htm:case phtml:case jhtml:case java:case cfg:case ini:
 37         case text:case bat:$f_type = text;break;
 38     }
 39     return $f_type;
 40 }
 41 //判断路径是文件还是目录
 42 function f_type($f_path){
 43     return is_dir($f_path)?dir:suffixtype($f_path);
 44 }
 45 //字节大小格式化
 46 function size_formate($byte){
 47     if($byte>1073741824)//1024<<20
 48         $size = round(($byte/1073741824),2).GB;
 49     else if($byte>1048576)//1024<<10
 50         $size = round(($byte/1048576),2).MB;
 51     else if($byte>1024)
 52         $size = round(($byte/1024),2).KB;
 53     else $size = $byte.B;
 54     return $size;
 55 }
 56 //计算文件或目录字节大小
 57 function bytesize_calc($f_path){
 58     if(!is_dir($f_path)){
 59         return sprintf("%u", filesize($f_path));}
 60     $bytesize = 0;
 61     $f_arr = scandir($f_path);
 62     $size = count($f_arr);
 63     for($i=0;$i<$size;$i++){
 64         if(.==$f_arr[$i]||..==$f_arr[$i])continue;
 65         $file_or_dir = $f_path./.$f_arr[$i];
 66         $bytesize += bytesize_calc($file_or_dir);
 67     }
 68     return $bytesize;
 69 }
 70 //获得文件大小
 71 function f_size($f_path){
 72     return size_formate(bytesize_calc($f_path));
 73 }
 74 $title=<<<EOF
 75 <div class=title>文件探测器(FileScanner)&nbsp;v2.8&nbsp;作者:PHPkiller</div>
 76 EOF;
 77 $fn=f28.php;//外部文件名
 78 function uploadfile($curdir){
 79     $upret=‘‘;
 80     switch(@$_FILES[upfile][error]){
 81         case 0:$upret=上传成功;break;
 82         case 1:$upret=大小超过上传约定;break;
 83         case 2:$upret=大小超过HTML表单限制;break;
 84         case 3:$upret=只有部分被上传;break;
 85         case 4:$upret=没有文件被上传;break;
 86         case 6:$upret=找不到临时文件夹;break;
 87         case 7:$upret=写入失败;break;
 88     }
 89     if(@$_FILES[upfile][error]>0){
 90         return $upret;}
 91     $upfile=@$_FILES[upfile][tmp_name];
 92     if(is_uploaded_file($upfile)){
 93         $destfile=$curdir./.@$_FILES[upfile][name];
 94         if(!move_uploaded_file($upfile,gbk($destfile))){
 95             $upret=文件移动失败!;
 96         }else $upret=上传成功!;
 97     }else{$upret=非POST上传!;}
 98     return $upret;
 99 }
100 //斜线处理
101 function bias_deal($way){
102     $dir =dirname(utf8($way));
103     if(substr($dir,-1)==\\){$dir = substr($dir,0,2);}
104     return urlencode(gbk($dir));
105 }
106 //对搜索结果返回json数据
107 function json_handler($path,$file_name){
108     $file_name=utf8($file_name);
109     $loca_dir=utf8(str_replace(\\,/,f_dirname($path)));
110     $filesize =f_size($path);
111     $filetime=filetime($path);
112     $f_type = f_type($path);
113     $p_utf8 = urlencode($path);
114     $f_op = ‘‘;
115     switch($f_type){
116         case image:
117             $f_op = <span href="#" onmouseover="sidesame(this)" onmouseout="recover(this)" onclick="ajax_view(this,".$p_utf8.");">预览</span>&nbsp;/&nbsp;;
118             break;
119         case text:
120             $f_op = <a href="#" onclick="ajax_edit(".$p_utf8.");">编辑</a>&nbsp;/&nbsp;;
121             break;
122     }
123     $f_op .= <a href="#" onclick="ajax_del(this,".$p_utf8.");">删除</a>&nbsp;/;
124     $f_op .= &nbsp;<a href="?op=dnd&way=.$p_utf8.">下载</a></td>;
125     $f_info="{f_name:‘$file_name‘,loca_dir:‘$loca_dir‘,f_size:‘$filesize‘,f_time:‘$filetime‘,f_op:‘$f_op‘}";
126     return $f_info.,;
127 }
128 //回调函数:正则查找
129 function preg_find($path,$reg){
130     $file_name = basename($path);
131     if(preg_match($reg,$file_name)){
132         return json_handler($path,$file_name);
133     }
134     return ‘‘;
135 }
136 //回调函数:位置查找
137 function pos_find($path,$key){
138     $file_name = basename($path);
139     if(strpos($file_name,$key)!==false){
140         return json_handler($path,$file_name);
141     }
142     return ‘‘;
143 }
144 //目录深度搜索
145 function search_file($dir,$reg_or_key,$callback)
146 {
147     $dir = gbk($dir);
148     if(!is_dir($dir)){
149         return $callback($dir,$reg_or_key);
150     }
151     $f_info_all=‘‘;
152     $lists = scandir($dir);
153     $len = count($lists);
154     for($i=0;$i<$len;$i++){
155         if(.==$lists[$i]||..==$lists[$i])continue;
156         $file_or_dir = utf8($dir.\\.$lists[$i]);
157         $f_info_all.=search_file($file_or_dir,$reg_or_key,$callback);
158     }
159     return $f_info_all;
160 }
161 
162 /******以下为根据op参数进行相应的操作逻辑**********************/
163 //类似百度谷歌搜索的建议提示操作
164 if(!empty($_GET[op]) && $_GET[op]==query){
165     if(empty($_GET[s_key]))exit();
166     $data_arr=array(*.avi,*.jpg,*.gif,*.mp3,*.php,*.txt,*.htm,*.html,*.rmvb,*.wav,avi,mp3,php,gif,jpg,bmp,txt,.avi,.jpg,.gif,.mp3,.php,.txt,.htm,.html,.rmvb,.wav);
167     $ret=‘‘;
168     $key = $_GET[s_key];
169     //$key = utf8($_GET[‘s_key‘]);//若关键字中有中文,需要转码
170     foreach($data_arr as $data){
171         if(($pos =strpos($data,$key))!==false && 0==$pos){
172             $ret.=$data.|;
173         }
174     }
175     echo $ret;
176     exit();
177 }
178 //删除操作
179 if(!empty($_GET[op]) && $_GET[op]==del){
180     if(empty($_GET[way]))exit();
181     $way = path_formate($_GET[way]);
182     if(!empty($_GET[flag]) && $_GET[flag]==ajax_del){
183         echo unlink($way)?1:0;//echo ‘1‘;
184         exit();
185     }
186     if(is_dir($way))
187         $ifsucc = rmdir($way)?成功!:失败!;
188     else
189         $ifsucc = unlink($way)?成功!:失败!;
190     $dirname = bias_deal($way);
191     echo <script>javascript:alert("删除.$ifsucc.");location.href="?dir=.$dirname."</script>;
192     return;
193 }//下载操作
194 else if(!empty($_GET[op]) && $_GET[op]==dnd){
195     if(empty($_GET[way]))exit();
196     $file_path = $_GET[way];
197     $file_size =filesize($file_path);
198     header(Content-type:application/octet-stream);
199     header(Accept-Ranges:bytes);
200     header(Accept-Length:.$file_size);
201     header(Content-Disposition:attachment;filename=.basename($file_path));
202     readfile($file_path);
203     return;
204 }//预览操作
205 else if(!empty($_GET[op]) && $_GET[op]==view){
206     if(empty($_GET[way]))exit();
207     //$file_path = $_GET[‘way‘];
208     if(!empty($_GET[flag]) && $_GET[flag]==ajax_view){
209         file_put_contents(tmp.png,file_get_contents($_GET[way]));
210         echo tmp.png;
211         exit();
212     }
213     header(content-type:image/png);
214     echo file_get_contents($_GET[way]);
215     exit;
216 }//编辑操作
217 else if(!empty($_GET[op]) && $_GET[op]==edt){
218     if(empty($_GET[way]))exit();
219     $way = path_formate($_GET[way]);
220     echo utf8($way).&nbsp;内容:若以下内容出现乱码,请点击;
221     if(!empty($_GET[flag]) && $_GET[flag]==ajax_edt){
222         echo <a href="#" onclick="ajax_fixcode(\‘.urlencode($way).\‘)">修正乱码</a>试试!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;
223         if(is_writable($way)){
224         echo <input type="button" onclick="ajax_save(\‘.urlencode($way).\‘)" value="保存">&nbsp;;}
225         else echo 此文件不可写!;
226         echo <a href="#" onclick="ajax_back()" >返回</a>;
227         echo <textarea id="f_ctx" rows="30" cols="100">;
228         if(!empty($_GET[cd]) &&$_GET[cd]=revise)
229         echo htmlspecialchars(utf8(file_get_contents($way)));
230         else echo htmlspecialchars(file_get_contents($way));
231         echo </textarea>;
232         exit();
233     }
234     echo <a href="?op=edt&way=.urlencode($way).&cd=revise">修正乱码</a>试试!<br/>;
235     echo <pre>;
236     echo <form action="?op=save&way=.urlencode($way)." method="post"><textarea name="f_ctx" rows="30" cols="100">;
237     if(!empty($_GET[cd]) &&$_GET[cd]=revise)
238         echo htmlspecialchars(utf8(file_get_contents($way)));
239     else echo htmlspecialchars(file_get_contents($way));
240     echo </textarea>;
241     echo </pre>;
242     $dirname = bias_deal($way);
243     if(is_writable($way)){
244     echo <input type="submit" value="保存">&nbsp;;}
245     else echo 此文件不可写!;
246     echo <a href="?dir=.$dirname.">返回</a></form>;
247     exit();
248 }//保存操作
249 else if(!empty($_GET[op]) && $_GET[op]==save){
250     if(empty($_GET[way]))exit();
251     $way = path_formate($_GET[way]);
252     $f_ctx = get_magic_quotes_gpc()?stripslashes($_POST[f_ctx]):$_POST[f_ctx];
253     if(!empty($_GET[flag]) && $_GET[flag]==ajax_save){
254         echo file_put_contents($way,$f_ctx)?保存成功!:保存失败!;
255         exit();
256     }
257     $ifsucc = file_put_contents($way,$f_ctx)?成功!:失败!;
258     $dirname = bias_deal($way);
259     echo <script>javascript:alert(\‘保存.$ifsucc.\‘);location.href="?dir=.$dirname.";</script>;
260     exit();
261 }//上传操作
262 else if(!empty($_GET[op]) && $_GET[op]==up){
263     if(empty($_GET[dir]))exit();
264     $curdir =path_formate($_GET[dir]);
265     if(!empty($_FILES)){//echo ‘sss‘;
266         echo <script>javascript:alert(\‘.uploadfile($curdir).\‘);location.href="?dir=.urlencode($curdir).";</script>;
267     }
268     exit();
269 }//计算目录大小ajax
270 else if(!empty($_GET[op]) && $_GET[op]==dirsize){
271     if(empty($_GET[calcdir]))exit();
272     echo f_size($_GET[calcdir]);exit();
273 }//文件搜索ajax
274 else if(!empty($_GET[op]) && $_GET[op]==filesearch){
275     if(empty($_GET[curdir]))exit();
276     if(empty($_GET[seach_key]))exit();
277     $s_key = trim($_GET[seach_key]);
278     if(‘‘==$s_key)exit();
279     $curdir =path_formate($_GET[curdir]);
280     $pos = strpos($s_key,*);
281     if($pos!==false){
282         switch($pos){
283             case 0:
284                 $s_key = substr($s_key,1);
285                 $s_key = preg_replace(/(\W)/i,\\\${1},$s_key);
286                 $pattern =/\w*.$s_key.$/i;
287                 break;
288             case (strlen($s_key)-1):
289                 $s_key = substr($s_key,0,-1);
290                 $s_key = preg_replace(/(\W)/i,\\\${1},$s_key);
291                 $pattern =/^.$s_key.\w*/i;
292                 break;
293             default:
294                 $key1 = substr($s_key,0,$pos);
295                 $key1 = preg_replace(/(\W)/i,\\\${1},$key1);
296                 $key2 = substr($s_key,$pos+1);
297                 $key2 = preg_replace(/(\W)/i,\\\${1},$key2);
298                 $pattern =/^.$key1..*.$key2.$/i;
299                 break;
300         }
301         $f_info_all= search_file($curdir,$pattern,preg_find);
302     }else{
303         try{
304         $f_info_all= search_file($curdir,$s_key,pos_find);
305         } catch (Exception $e) {
306             file_put_contents(search_error.log,$e);
307         }
308     }
309     echo (‘‘==$f_info_all)?empty:$f_info_all;
310     exit();
311 }//新建文件操作
312 else if(!empty($_GET[op]) && $_GET[op]==newfile){
313     if(empty($_GET[dir]))exit();
314     $dir = path_formate($_GET[dir]);
315     if(!empty($_GET[file])){
316         $file = $dir.\\.gbk($_GET[file]);
317         $ifsucc = touch($file)?成功!:失败!;
318         echo <script>javascript:alert(\‘创建.$ifsucc.\‘);location.href="?dir=.urlencode($dir).";</script>;
319         return;
320     }
321     exit();
322 }//新建目录操作
323 else if(!empty($_GET[op]) && $_GET[op]==newdir){
324     if(empty($_GET[dir]))exit();
325     $dir = path_formate($_GET[dir]);
326     if(!empty($_GET[dirname])){
327         $dirname = $dir.\\.gbk($_GET[dirname]);
328         $ifsucc = mkdir($dirname)?成功!:失败!;
329         echo <script>javascript:alert(\‘创建.$ifsucc.\‘);location.href="?dir=.urlencode($dir).";</script>;
330         return;
331     }
332     exit();
333 }//其他信息
334 else if(!empty($_GET[op]) && $_GET[op]==other){
335     if(empty($_GET[dir]))exit();
336     $os = php_uname();
337     $s_soft = $_SERVER[SERVER_SOFTWARE];
338     $php_ini = PHP_CONFIG_FILE_PATH;
339     $doc_root = $_SERVER[DOCUMENT_ROOT];
340     $s_addr=$_SERVER[SERVER_ADDR].:.$_SERVER["SERVER_PORT"];
341     $c_addr=$_SERVER[REMOTE_ADDR].:.$_SERVER["REMOTE_PORT"];
342     $auf_cfg = ini_get(allow_url_fopen)?YES:NO;
343     $mqg_cfg = ini_get(magic_quotes_gpc)?YES:NO;
344     $de_cfg = ini_get(display_errors)?YES:NO;
345     $upsize = ini_get(upload_max_filesize);
346     $reg_glo = ini_get(register_globals)?YES:NO;
347     $sess_auto = ini_get(session.auto_start)?YES:NO;
348     $sess_savepath = ini_get(session.save_path);
349     $sess_savepath = $sess_savepath?$sess_savepath:C:\WINDOWS\Temp;
350     $sess_lifetime = ini_get(session.cookie_lifetime);
351     $sess_gc_mlt = ini_get(session.gc_maxlifetime);
352 $otherinfo = <<<EOF
353 <span style="color:red;font-size:16px">如果你发现错误或者有好的建议请直接飞秋,我的IP:192.168.1.200.飞秋名"PHPkiller"</span><br/>
354 <span style="font-size:14px">以下为系统有关信息</span>
355 <table style="font-size:14px" bgcolor="#e8e6ec"  cellspacing="1" cellpadding="1" border="3" width="100%">
356 <tr><td>&nbsp;服务器IP</td><td>&nbsp;$s_addr</td></tr>
357 <tr><td>&nbsp;操作系统</td><td>&nbsp;$os</td></tr>
358 <tr><td>&nbsp;网站架构</td><td>&nbsp;$s_soft</td></tr>
359 <tr><td>&nbsp;php.ini路径</td><td>&nbsp;$php_ini</td></tr>
360 <tr><td>&nbsp;你的IP</td><td>&nbsp;$c_addr</td></tr>
361 <tr><td>&nbsp;网站根目录</td><td>&nbsp;$doc_root</td></tr>
362 <tr><td>&nbsp;注册全局变量</td><td>&nbsp;$reg_glo</td></tr>
363 <tr><td>&nbsp;自动启用session</td><td>&nbsp;$sess_auto</td></tr>
364 <tr><td>&nbsp;session路径</td><td>&nbsp;$sess_savepath</td></tr>
365 <tr><td>&nbsp;session生命周期</td><td>&nbsp;$sess_lifetime</td></tr>
366 <tr><td>&nbsp;session最大生命周期</td><td>&nbsp;$sess_gc_mlt</td></tr>
367 <tr><td>&nbsp;远程文件访问</td><td>&nbsp;$auf_cfg</td></tr>
368 <tr><td>&nbsp;对GPC增加斜线</td><td>&nbsp;$mqg_cfg</td></tr>
369 <tr><td>&nbsp;上传大小限制</td><td>&nbsp;$upsize</td></tr>
370 <tr><td>&nbsp;显示系统错误</td><td>&nbsp;$de_cfg</td></tr>
371 </table><br/>
372 <span style="font-size:14px">以下为更改历史</span><br/>
373 <table style="font-size:14px" width="100%">
374 <tr><td>FileScanner2.8 增加类似百度谷歌等搜索提示功能</td></tr>
375 <tr><td>FileScanner2.7 增加文件搜索查询结果的操作(如预览,编辑等)采用ajax实现,后台数据的返回采用json封装</td></tr>
376 <tr><td>FileScanner2.6 增加文件搜索普通查询如搜mp3,将会对查询结果关键字高亮显示</td></tr>
377 <tr><td>FileScanner2.5 搜索框输入关键字后回车即可搜索</td></tr>
378 <tr><td>FileScanner2.4 增加文件搜索功能,支持*查询,如*.avi</td></tr>
379 <tr><td>FileScanner2.3 在其他信息中增加session信息</td></tr>
380 <tr><td>FileScanner2.2 调整部分div+css效果,标题挪到右边显示</td></tr>
381 <tr><td>FileScanner2.1 增加高亮显示表行js效果及显示目录大小通过ajax实现</td></tr>
382 <tr><td>FileScanner2.0 增加新建,显示系统信息,界面稍微美化即其它细节问题,改动比较多,升级为2.0</td></tr>
383 <tr><td>FileScanner1.3 增加上传功能</td></tr>
384 <tr><td>FileScanner1.2 解决相应操作后应返回当前目录及双斜线显示问题</td></tr>
385 <tr><td>FileScanner1.1 解决不能文件下载的问题,header函数前不能有输出语句</td></tr>
386 <tr><td>FileScanner1.0 基本功能的实现,面向过程模式编写,有时间在考虑对象重构</td></tr>
387 </table>
388 EOF;
389 echo $otherinfo;
390     $curdir =path_formate($_GET[dir]);
391     echo <a href="?dir=.urlencode($curdir).">返回</a>&nbsp;;
392     exit();
393 }/**************************************************/
394 $curdirver =null;
395 $catalog = (!empty($_GET[dir]))?$_GET[dir]:getcwd();
396 $curdir = path_formate($catalog);
397 echo <div id="head"><span class="dirinfo"><select id="driver" name="ss" onchange="selectdisk(this.value)";>;
398 for($i=65;$i<91;$i++){
399     $vol = chr($i).:;
400     if(is_dir($vol)){
401         if(substr($curdir,0,2)==$vol){
402             $select =selected; 
403             $curdirver=$vol;
404         }else {$select =‘‘;}
405     echo <option value=".$vol.".$select.>.$vol.</option>;
406     }
407 }
408 echo </select>;
409 echo &nbsp;当前目录=><span id="curdir">.utf8($curdir).</span></span>;
410 echo $title;
411 echo </div><div id="nav"><hr>;
412 $para=dir=.urlencode($curdir).‘‘;
413 echo ||&nbsp;<a href="#" onclick="creatediv(this,3);">上传文件</a>&nbsp;;
414 echo ||&nbsp;<a href="#" onclick="creatediv(this,1);">新建文件</a>&nbsp;;
415 echo ||&nbsp;<a href="#" onclick="creatediv(this,2);">新建目录</a>&nbsp;;
416 /*****网站根目录start****/
417 $doc_root = str_replace(/,\\,$_SERVER[DOCUMENT_ROOT]);
418 $rootdir = dir=.urlencode($doc_root).‘‘;
419 echo ||&nbsp;<a href="?.$rootdir.">网站根目录</a>&nbsp;||;
420 /*****网站根目录end****/
421 echo &nbsp;<a style="color:#9933ff" href="?op=other&.$para.">其他信息</a>&nbsp;||;
422 /*****上级目录start*****/
423 $updir = substr($curdir,0,strripos($curdir,\\));
424 echo $updir?&nbsp;<a href="?dir=.urlencode($updir).">上级目录</a>:‘‘;
425 /*****上级目录end*****/
426 $search_form=<<<EOF
427 &nbsp;&nbsp;<span id="search"><input class=sear_text type="text" id="search_key" onkeyup="keyup(event)">&nbsp;<input title=支持模糊查询(如*.avi) type="button" value="文件搜索" id="f_so" onclick="searchfile()">&nbsp;<span id="s_plan"></span></span>
428 EOF;
429 echo $search_form;
430 echo <hr></div>;
431 /*****以下为目录遍历逻辑*******/
432 $f_arr = @scandir($curdir) or die(failed to open .$curdir.!!);
433 $f_num = count($f_arr);
434 ?>
435 <div id=showctx></div>
436 <table id=result border=0 cellspacing=1 cellpadding=1 width=100%>
437 <tr bgcolor=#b0c4de><th>名称</th><th>类型</th><th>大小</th>
438 <th>修改时间</th><th>操作</th></tr>
439 <?php
440 $dir_num=0;//记录目录数量
441 $file_um=0;//记录文件数量
442 $trcolor=#e8e6ec;
443 for($i=0;$i<$f_num;$i++){
444     if(.==$f_arr[$i]||..==$f_arr[$i])continue;
445     $path = $curdir.\\.$f_arr[$i];
446     $p_utf8 = urlencode($path);
447     $f_utf8 = utf8($f_arr[$i]);
448     $trcolor = ($trcolor==#e8e6ec)?#ffffff:#e8e6ec;
449     //echo $trcolor.‘<br/>‘;
450     echo <tr bgcolor=".$trcolor." onmouseover="blink(this);" onMouseOut="unblink(this);">;
451     if(is_dir($path)){
452         echo <td><a href="?dir=.$p_utf8.">.$f_utf8.</a></td>;
453         echo <td>.f_type($path).</td>;
454         echo <td>&nbsp;</td>;
455         echo <td>.filetime($path).</td>;
456         echo <td><a href="#" onclick="getDirSize(this,\‘.$p_utf8.\‘);">大小</a>&nbsp;/&nbsp;;
457 
458         echo <a onclick=\‘return suredel();\‘ href="?op=del&way=.$p_utf8.">删除</a></td>;
459         $dir_num++;
460     }
461     else{
462         $f_type = f_type($path);
463         echo <td>.$f_utf8.</td>;
464         echo <td>.$f_type.</td>;
465         echo <td>.f_size($path).</td>;
466         echo <td>.filetime($path).</td><td>;
467         if($f_type==image)
468         {echo <a href="?op=view&way=.$p_utf8.">预览</a>&nbsp;/&nbsp;;}else if($f_type==text)
469         {echo <a href="?op=edt&way=.$p_utf8.">编辑</a>&nbsp;/&nbsp;;}
470         echo <a onclick=\‘return suredel();\‘ href="?op=del&way=.$p_utf8.">删除</a>&nbsp;/;
471         echo &nbsp;<a href="?op=dnd&way=.$p_utf8.">下载</a></td>;
472         $file_um++;
473     }
474     echo </tr>;
475 }
476 ?>
477 </table>
478 <div id=tableinfo>
479 <?php
480 echo 当前目录文件总数:.($f_num-2).,其中目录数:.$dir_num.,文件数.$file_um;
481 echo &nbsp;.&nbsp;.$curdirver.容量:.size_formate(disk_total_space($curdirver));
482 echo &nbsp;&nbsp;.$curdirver.剩余:.size_formate(disk_free_space($curdirver));
483 ?>
484 </div><!--tableinfo-->
485 <style type="text/css">
486     *{font-size: 14px;}
487     a{text-decoration:none;color:#cc6666;}
488     a:hover{color:red;text-decoration:underline}
489     div#nav a:hover{position:relative;left:1px;top:-5px;
490     font-weight:bold;text-decoration:none;}
491     #result span{color:#cc6666;}
492     div#head{height:1.2em;}
493     div#head .dirinfo{float:left;}
494     div#head .title{color:red;font-size:1.2em;
495     font-weight:bold;text-align:right;}
496     .sear_text,#suggest{width:150px;}
497     #suggest{background-color:white;position:absolute;
498     width:150px;border:1px solid gray;display:none;}
499     .vote_w{width:149px;}
500     #upform{display:inline;}
501 </style>
502 <script type="text/javascript">
503 <!--
504     function $(s_id){return document.getElementById(s_id);}
505     function PT(str){return document.write(str+<br/>);}
506     function val(s_id,val){return $(s_id).value=val;}
507     function text(s_id,text){return $(s_id).innerText=text;}
508     function html(s_id,html){return $(s_id).innerHTML=html;}
509 
510     var fn="f28.php";
511     function suredel()
512     {return confirm(确定删除?此操作不可恢复!);};
513     function selectdisk(value){
514     $(ff).action = ?dir=+value;
515     $(ff).submit();}
516     var origin = ‘‘;
517     function blink(obj)
518     {origin=obj.style.backgroundColor;
519     obj.style.backgroundColor=#98bcf3;}
520     function unblink(obj)
521     {obj.style.backgroundColor=origin;}
522 
523     //根据传入类型创建相应的div;
524     function creatediv(obj,type){
525         switch(type){
526             case 1:
527                 with($(div_newfile).style){
528                     position=absolute;
529                     top=obj.offsetTop+30;left=obj.offsetLeft-30;
530                     padding=5;filter = "alpha(opacity=88)";
531                     opacity = 0.88;background=#d8e1ef;display=‘‘;
532                 }$(div_upform).style.display=none;
533                 $(div_newdir).style.display=none;break;
534             case 2:
535                 with($(div_newdir).style){
536                     position=absolute;
537                     top=obj.offsetTop+30;left=obj.offsetLeft-30;
538                     padding=5;filter = "alpha(opacity=88)";
539                     opacity = 0.88;background=#d8e1ef;display=‘‘;
540                 }$(div_newfile).style.display=none;
541                 $(div_upform).style.display=none;break;
542             case 3:
543                 with($(div_upform).style){
544                     position=absolute;
545                     top=obj.offsetTop+30;left=obj.offsetLeft;
546                     padding=5;filter = "alpha(opacity=88)";
547                     opacity = 0.88;background=#d8e1ef;display=‘‘;
548                 }$(div_newfile).style.display=none;
549                 $(div_newdir).style.display=none;break;
550         }
551     }
552     //提交新建文件
553     function newfile(){
554         if($(file).value.replace(/(^\s*)|(\s*$)/g, ‘‘)==‘‘)return;
555         $(ff).action=?op=newfile&dir=;
556         $(ff).action+=encodeURI($(curdir).innerHTML+&file=+$(file).value);$(ff).submit();
557     }
558     //提交新建目录
559     function newdir(){
560         if($(dirname).value.replace(/(^\s*)|(\s*$)/g, ‘‘)==‘‘)return;
561         $(ff).action=?op=newdir&dir=;
562         $(ff).action+=encodeURI($(curdir).innerHTML+&dirname=+$(dirname).value);$(ff).submit();
563     }
564     //提交上传文件
565     function upfile(){
566         if($(upform).upfile.value.replace(/(^\s*)|(\s*$)/g, ‘‘)==‘‘)return;
567         $(upform).action=?op=up&dir=;
568         $(upform).action+=encodeURI($(curdir).innerHTML);
569         $(upform).submit();
570     }
571     /**********ajax***********/
572     function getAjax(){
573         var xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}
574         catch (e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
575         catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
576         return xmlHttp;
577     }
578     //封装ajax的get请求,只关心返回来的数据
579     function ajax_get(queryurl,callback_Complete){
580         var xmlHttp=getAjax();
581         if(xmlHttp==null){alert("您的浏览器不支持ajax");
582             return;}
583         xmlHttp.onreadystatechange=function(){
584             if(4==xmlHttp.readyState && 200==xmlHttp.status){
585                 callback_Complete(xmlHttp.responseText);
586             }}
587         xmlHttp.open("GET",queryurl,true);xmlHttp.send(null);
588     }
589     //封装ajax的post请求,只关心返回来的数据
590     function ajax_post(url,data,callback_Complete){
591         var xmlHttp=getAjax();
592         if(xmlHttp==null){alert("您的浏览器不支持ajax");
593             return;}
594         xmlHttp.onreadystatechange=function(){
595             if(4==xmlHttp.readyState && 200==xmlHttp.status){
596                 callback_Complete(xmlHttp.responseText);
597             }}
598         xmlHttp.open("POST",url,true);
599         xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.send(data);
600     }
601 
602     function keyup(event){
603         if(event.keyCode==13 && ‘‘==$(s_plan).innerHTML){
604             $(f_so).click();$(search_key).blur();
605             $(suggest).style.display=none;return;
606         }
607         var url=fn+"?op=query&s_key="+$(search_key).value;
608         var suggest_Complete = function(responseText){
609             if(‘‘==responseText){
610                 $(suggest).style.display="none";return;
611             }
612             var data_arr = responseText.split(|);
613             $(suggest).innerHTML = ‘‘;
614             if($(search_key).value.indexOf(*)>-1){
615                 for(var i=0;i<data_arr.length-1;i++){
616                     $(suggest).innerHTML+=<div class="vote_w" onmouseover="select(this)" onmouseout="select(this)" onclick="fillin(this)">+data_arr[i]+</div>;
617                 }
618             }else{
619                 for(var i=0;i<data_arr.length-1;i++){
620                     $(suggest).innerHTML+=<div class="vote_w" onmouseover="select(this)" onmouseout="select(this)" onclick="fillin(this)">+data_arr[i].replace(eval(/(+$(search_key).value+)/),"<a style=‘color:red‘>$1</a>")+</div>;
621                 }
622             }
623             $(suggest).style.left=$(search_key).offsetLeft;
624             $(suggest).style.top=$(search_key).offsetTop+$(search_key).offsetHeight;
625             $(suggest).style.cursor="hand";
626             $(suggest).style.display="block";
627         }
628         ajax_get(url,suggest_Complete);
629     }
630     function select(obj){
631         obj.style.backgroundColor = (obj.style.backgroundColor==#f0f0f0)?white:#f0f0f0;
632     }
633     function fillin(obj){
634         $(search_key).focus();
635         $(search_key).value = obj.innerText||obj.textContent;
636         $(suggest).style.display="none";
637     }
638     //无刷新删除
639     function ajax_del(obj,p_utf8){
640         if(!confirm(确定删除?此操作不可恢复!))return;
641         var url=fn+"?op=del&way="+p_utf8+"&flag=ajax_del";
642         var del_Complete = function(responseText){
643             if(1==responseText){
644                 var curtr = obj.parentNode.parentNode;
645                 curtr.parentNode.removeChild(curtr);
646                 alert(删除成功);
647             }
648         }
649         ajax_get(url,del_Complete);
650     }
651     function sidesame(obj){//预览标签span修改其样式和旁边的一样
652         obj.style.color=red;
653         obj.style.textDecoration=underline;
654         obj.style.cursor=pointer;
655     }
656     function recover(obj){//预览标签span恢复,和anchor效果一样
657         obj.style.color=#cc6666;
658         obj.style.textDecoration=none;
659     }
660     ////无刷新预览
661     function ajax_view(obj,p_utf8){
662         var ex = event.clientX;var ey = event.clientY;
663         var url=fn+"?op=view&way="+p_utf8+"&flag=ajax_view&q="+Math.random();
664         var view_Complete = function(responseText){
665             openView(responseText,ex,ey);
666         }
667         ajax_get(url,view_Complete);
668     }
669     //打开预览
670     function openView(imgsrc,ex,ey){
671         var viewer = $("viewer");
672         viewer.src = imgsrc+?q=+Math.random();
673             viewer.style.display = "";
674             viewer.style.position="absolute";
675             viewer.style.left=130;
676             viewer.style.left=(viewer.width>=ex)?0:ex -viewer.width-30;
677             var yt = ey+document.body.scrollTop;
678             var yh =yt+viewer.height;//图片实际y坐标+图片高
679             var ch =document.body.clientHeight+document.body.scrollTop;
680             viewer.style.top = (yh>ch)?yt-(yh-ch):yt;
681     }
682     //单击关闭预览
683     function closeView(){$(viewer).style.display = "none";}
684     //无刷新进入编辑状态
685     function ajax_edit(p_utf8){
686         var url=fn+"?op=edt&way="+p_utf8+"&flag=ajax_edt&q="+Math.random();
687         var edit_Complete = function(responseText){
688             $(result).style.display=none;
689             $(tableinfo).style.display=none;
690             $(showctx).style.display=‘‘;
691             html(showctx,responseText);
692             $(search).style.display=none;
693             $(suggest).style.display=none;
694         }
695         ajax_get(url,edit_Complete);
696     }
697     //无刷新修正乱码
698     function ajax_fixcode(p_utf8){
699         var url=fn+"?op=edt&way="+p_utf8+"&flag=ajax_edt&cd=revise";
700         var fixcode_Complete = function(responseText){
701                 html(showctx,responseText);
702         }
703         ajax_get(url,fixcode_Complete);
704     }
705     //无刷新保存操作
706     function ajax_save(p_utf8){
707         var url =fn+"?op=save&way="+p_utf8+"&flag=ajax_save&q="+Math.random();
708         var data="f_ctx="+$(f_ctx).innerHTML;
709         var save_Complete = function(responseText){
710                 alert(responseText);
711                 ajax_back();
712         }
713         ajax_post(url,data,save_Complete);
714     }
715     function ajax_back(){
716         html(showctx,‘‘);
717         $(showctx).style.display=none;
718         $(result).style.display=‘‘;
719         $(tableinfo).style.display=‘‘;
720         $(search).style.display=‘‘;
721     }
722     //无刷新取得目录大小
723     function getDirSize(obj,p_utf8){
724         var xmlHttp=getAjax();
725         if(xmlHttp==null){alert("您的浏览器不支持ajax");
726             return;}    
727         var url=fn+"?op=dirsize&calcdir="+p_utf8;
728         xmlHttp.onreadystatechange=function()
729         {var curtr = obj.parentNode.parentNode;
730          var sizeNode=curtr.childNodes[2];
731             if(xmlHttp.readyState==1){
732             sizeNode.innerHTML=loading...;
733             }if(xmlHttp.readyState==4){
734             sizeNode.innerHTML=xmlHttp.responseText;
735             }}
736         xmlHttp.open("GET",url,true);xmlHttp.send(null);
737     }
738     //模拟加载中效果
739     function loading(str){
740         var dot=‘‘;var timer;
741         return function(){
742             if(dot==....){dot=‘‘;}
743             if(dot<....){
744                 dot+=.;
745                 if($(ctx).value!=‘‘){
746                     clearTimeout(timer);timer=null;dot=null;
747                     html(s_plan,‘‘);
748                 }else{
749                     timer = setTimeout(arguments.callee,200);
750                     html(s_plan,str+dot);
751                 }
752             }
753         }
754     }
755     //无刷搜索文件
756     function searchfile(){
757         var seach_key=$(search_key).value;
758         if(seach_key.replace(/(^\s*)|(\s*$)/g, ‘‘)==‘‘)return;
759         html(tableinfo,‘‘);val(ctx,‘‘);
760         $(suggest).style.display=none;
761         var curdir=$(curdir).innerHTML;
762         if(‘‘==curdir){return;}
763         xmlHttp=getAjax();
764         if(xmlHttp==null){alert("您的浏览器不支持ajax");
765             return;}
766         url=fn+"?op=filesearch&seach_key="+seach_key+"&curdir="+encodeURI(curdir)+&q=+Math.random();
767         var orig_width = $(f_so).style.width;
768         xmlHttp.onreadystatechange=function(){
769             if(xmlHttp.readyState==1){
770                 loading(真正查找,请稍候)();
771                 $(f_so).style.display="none";}
772             if(xmlHttp.readyState==4){
773                 if(xmlHttp.responseText.indexOf(Fatal error)>0){
774                     alert(搜索失败!!! 搜索结果或速度取决于你的网络连接和目录嵌套深度,建议搜索嵌套深度相对浅的目录,不怕文件多,只怕目录深 -_-!);
775                     val(ctx,xxx);
776                     $(f_so).style.display="";
777                     return;
778                 }
779                 val(ctx,xxx);
780                 $(f_so).style.display="";
781                 if(empty!=xmlHttp.responseText){
782                     var json =xmlHttp.responseText.substr(0,xmlHttp.responseText.lastIndexOf(,));//alert(json);
783                     var json_obj = eval(([+json+]));
784                     jsontable(json_obj);
785                 }else{
786                     emptytable();
787                 }
788             }
789         }
790         xmlHttp.open("GET",url,true);xmlHttp.send(null);
791     }
792     function jsontable(json_obj){
793         var table_search=$(result);
794         var rowlen=table_search.rows.length;
795         for (var i=0;i<rowlen-1;i++){
796             table_search.deleteRow(1);
797         }
798         //修改头部信息,‘类型‘->‘所在目录‘
799         var head_tr = table_search.rows[0];
800         var head_th1=head_tr.cells[1];
801         head_th1.innerHTML=所在目录;
802         var trcolor = #e8e6ec;///772 line
803         //针对星号是否高亮显示关键字
804         var hightlight =($(search_key).value.indexOf(*)==-1)?1:0;
805         //alert(hightlight);
806         for(var i=0;i<json_obj.length;i++){
807             var tr = table_search.insertRow(i+1);
808             trcolor = (trcolor==#e8e6ec)?#ffffff:#e8e6ec;
809             tr.style.backgroundColor=trcolor;
810             tr.onmouseover=function(){blink(this)}
811             tr.onmouseout=function(){unblink(this)}//
812             //var f_name = json_obj[i].f_name.replace(eval(‘/(‘+$(‘search_key‘).value+‘)/‘),"<a style=‘color:red‘>$1</a>");
813             var f_name = hightlight?json_obj[i].f_name.replace(eval(/(+$(search_key).value+)/),"<a style=‘color:red‘>$1</a>"):json_obj[i].f_name;
814             var td0 = tr.insertCell(0);td0.innerHTML=f_name;
815             var td1 = tr.insertCell(1);td1.innerHTML=json_obj[i].loca_dir;
816             var td2 = tr.insertCell(2);td2.innerHTML=json_obj[i].f_size;
817             var td3 = tr.insertCell(3);td3.innerHTML=json_obj[i].f_time;
818             var f_opi = json_obj[i].f_op.replace(/\(([^"]*)"([^"]*)"\)/g,"($1‘$2‘)");
819             var td4 = tr.insertCell(4);td4.innerHTML=f_opi;
820         }
821     }
822     function emptytable(){/***空的情况*******/
823         var table_search=$(result);
824         var rowlen=table_search.rows.length;
825         for (var i=0;i<rowlen-1;i++){
826             table_search.deleteRow(1);
827         }
828         //修改头部信息,‘类型‘->‘所在目录‘
829         var head_tr = table_search.rows[0];
830         var head_th1=head_tr.cells[1];
831         head_th1.innerHTML=所在目录;
832         var one_tr = table_search.insertRow(1);
833         var one_td0 = one_tr.insertCell(0);
834         one_td0.colSpan =5;
835         var noret=<a style="color:red">搜索完毕,没有结果可显示!</a>;one_td0.innerHTML=noret;
836     }
837 //-->
838 </script>
839 <form id=ff method=post action=‘‘></form>
840 <input type=hidden id=ctx>
841 <img id="viewer" onclick=closeView(); style=display:none/>
842 <div id="suggest"></div>
843 <div id="div_newfile" style=display:none>
844 &nbsp;输入文件名(带后缀):<input type="text" id="file">
845 <input type="button" value="确定" onclick="newfile();"></div>
846 <div id="div_newdir" style=display:none>
847 &nbsp;输入目录名:<input type="text" id="dirname">
848 <input type="button" value="确定" onclick="newdir();"></div>
849 <div id="div_upform" style=display:none>
850 <input type="button" value="上传" onclick="upfile();">
851 <form id =upform enctype="multipart/form-data" method="post" action="">
852 <input type="file" name="upfile"></form></div>

 

文件扫描(探针)

标签:其他   count   远程文件   坐标   continue   网络连接   系统信息   date   表单   

原文地址:https://www.cnblogs.com/hzg8754/p/9737260.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!