<?php include("C:\\WebServers\\home\\test1.ru\\www\\new1\\password_protect.php"); ?> <?php ################## config #################### # header & title of this file $title= "File Upload Manager"; # individual file size limit (102400 bytes = 100KB) $file_size_ind = "6000000000"; # the upload store directory (chmod 777) $dir = "store"; # the file type extensions allowed to be uploaded $file_allow_ex = array("gif","jpg","jpeg","png","txt","doc","htm","zip","rar","gz","exe","mp3","avi"); # if you want to password-protect this file, enter "yes" instead of "no" $auth[ReqPass] = "no"; # if you set $auth[ReqPass] to yes, then you must set the username and password $auth[usern] = "Deluxe"; $auth[passw] = "1234"; ################# /config #################### ?> <link rel=STYLESHEET type=text/css href=http://sc-chat.net/style.css> <? if($auth[ReqPass] == "yes") { function error ($error_message) { echo $error_message."<BR>"; exit; } if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $auth[usern]) && ( $PHP_AUTH_PW == "$auth[passw]" )) ) { header("WWW-Authenticate: Basic entrer=\"file upload manager v1.1\""); header("HTTP/1.0 401 Unauthorized"); error("Access Denied! You must enter a valid username & password."); } } ?> <html> <head> <title><? print ($title) ? ($title) : ("File Upload Manager"); ?></title> <link rel="stylesheet" href="img/style-blue.css" type="text/css"> </head> <? function getlast($toget) { $pos=strrpos($toget,"."); $lastext=substr($toget,$pos+1); return $lastext; } function replace($o) { $o=str_replace("/","",$o); $o=str_replace("\\","",$o); $o=str_replace(":","",$o); $o=str_replace("*","",$o); $o=str_replace("?","",$o); $o=str_replace("<","",$o); $o=str_replace(">","",$o); $o=str_replace("\"","",$o); $o=str_replace("|","",$o); return $o; } { if(!$_FILES[fileupload]) { ?> <table width="40%" cellspacing="0" cellpadding="0" border="0" align=left> <form method="post" enctype="multipart/form-data"> <tr> <td>Файл:</td><td><input type="file" name="fileupload" class="textfield" size="30"></td> </tr> <tr> <td>Переименовать:</td><td><input type="text" name="rename" class="textfield" size="46"></td> </tr> <tr> <td>Типы файлов:</td><td><? for($i=0;$i<count($file_allow_ex);$i++) { if(($i<>count($file_allow_ex)-1))$commas=", ";else $commas=""; list($key,$value)=each($file_allow_ex); echo $value.$commas; } ?></td> </tr> <tr> <td>Размер файла:</td><td><?=$file_size_ind?> BYTES <b>(<?=round(($file_size_ind/1024),2)?> KB)</b></td> </tr> <tr> <td colspan="2"><input type="submit" value="Загрузить" class="ok"> <input type="reset" value="Очистить всё" class="ok"></td> </tr> </form> </table> <? if((!$_GET[act]||!$_GET[file])&&$_GET[act]!="delall") { $opendir = @opendir($dir); while ($readdir = @readdir($opendir)) { if($readdir<>"." && $readdir<>"..") { $filearr[] = $readdir; } $sort=array(); for($i=1;$i<=count($filearr);$i++) { $key = sizeof($filearr)-$i; $file = $filearr[$key]; $sort[$i]=$file; } asort($sort); } if(count($filearr)>=1) { if(count($filearr)>1) { ?> <? } else { echo""; } ?> <table width="50%" cellspacing="0" cellpadding="0" border="0" align=right> <tr bgcolor="#DBDBDB"> <td width="350">Название файла</td> <td align="center" width="115">Тип файла</td> <td align="center" width="115">Функции</td> </tr> <? for($i=1;$i<=count($sort);$i++) { list($key,$value)=each($sort); if($value) { $value_en=base64_encode($value); ?> <tr> <td width="350"><?="<a href=\"?act=view&file=$value_en\">$value</a>"?></td> <td align="center" width="115"><? echo strtoupper(getlast($value)); ?></td> <td align="center" width="115"><?="<a href=\"?act=view&file=$value_en\"><view></a>"?> | <?="<a href=\"javascript:;\" onClick=\"cf=confirm('Вы действительно хотите удалить этот файл?');if(cf)window.location='?act=del&file=$value_en'; return false;\"><delete></a>"?></td> </tr> <? } } ?> </table></center> <? } } elseif(($_GET[act]=="del")&&$_GET[file]) { $value_de=base64_decode($_GET[file]); @unlink($dir."/$value_de"); echo"<br><img src=\"img/info.gif\" width=\"15\" height=\"15\"> <b><font size=\"2\">file has been deleted!</font></b><br>»<a href=\"$_SERVER[PHP_SELF]\">back</a> "; } elseif(($_GET[act]=="view")&&$_GET[file]) { $value_de=base64_decode($_GET[file]); echo" <table align=center><td align=\"center\" width=\"115\"><a href=$dir/$value_de>Скачать файл</a></td>"; echo""; } if($_GET[act]=="delall") { $handle=opendir($dir); while($file=readdir($handle)) if(($file != ".")&&($file != "..")) @unlink($dir."/".$file); closedir($handle); echo"<br><img src=\"img/info.gif\" width=\"15\" height=\"15\"> <b><font size=\"2\">all files have been deleted!</font></b><br>»<a href=\"$_SERVER[PHP_SELF]\">back</a>"; } } else { echo"<br><br>"; $uploadpath=$dir."/"; $source=$_FILES[fileupload][tmp_name]; $fileupload_name=$_FILES[fileupload][name]; $weight=$_FILES[fileupload][size]; for($i=0;$i<count($file_allow_ex);$i++) { if(getlast($fileupload_name)!=$file_allow_ex[$i]) $test.="~~"; } $exp=explode("~~",$test); if(count($exp)==(count($file_allow_ex)+1)) { echo"<br><img src=\"img/error.gif\" width=\"15\" height=\"15\"> <b><font size=\"3\"> Такой тип файла загружать запрещенно (".getlast($fileupload_name).")</b> <a href=\"$_SERVER[PHP_SELF]\"><font size=\"3\">Вернуться</a></font>"; } else { if($weight>$file_size_ind) { echo"<br><img src=\"img/error.gif\" width=\"15\" height=\"15\"> <b><font size=\"2\">ERROR: please get the file size less than ".$file_size_ind." BYTES (".round(($file_size_ind/1024),2)." KB)</font></b><br>»<a href=\"$_SERVER[PHP_SELF]\">back</a>"; } else { foreach($_FILES[fileupload] as $key=>$value) { echo"<font color=\"#3399FF\">$key</font> : $value <br>"; } echo "<br>"; $dest = ''; if ( ($source != 'none') && ($source != '' )) { $dest=$uploadpath.$fileupload_name; if ($dest != '') { if(file_exists($uploadpath.$fileupload_name)) { echo"<br><img src=\"img/error.gif\" width=\"15\" height=\"15\"> <b><font size=\"3\">Такой файл уже существует на сервере, попробуйте другой</b> [<a href=\"javascript:history.go(-1)\"><font size=\"3\">Вернуться</a></font>]"; } else { if (copy($source,$dest)) { if($_POST[rename]) { $_POST[rename]=replace($_POST[rename]); $exfile=explode(".",$fileupload_name); if(@rename("$dir/$fileupload_name","$dir/$_POST[rename].".getlast($fileupload_name))) { echo"<br><img src=\"img/info.gif\" width=\"15\" height=\"15\"> <b><font size=\"2\">file has been renamed to $_POST[rename].".getlast($fileupload_name)."!</font></b></font><br>"; } } echo"<br><img src=\"img/info.gif\" width=\"15\" height=\"15\"> <b><font size=\"2\">file has been uploaded!</font></b><br>»<a href=\"$_SERVER[PHP_SELF]\">back</a>"; } else { echo"<br><img src=\"img/error.gif\" width=\"15\" height=\"15\"> <b><font size=\"2\">ERROR: cannot upload, please chmod the dir to 777</font></b><br>»<a href=\"$_SERVER[PHP_SELF]\">back</a>"; } } } } } } } } ?> </body> </html>