帮代码复制上传你的主机根目录,命名这都随意,例如:ftp.php。然后就可以加你的域名xxx.xxxx.com/ftp.php访问。 密码用户名都是admin 密码可以自己修改,好了仅供大学学习娱乐,勿用于商业用途,转载请注明,谢谢。 <?php /** * 程序说明 * 设置说明 * $sitetitle - 标题名称 * $user - 用户名 * $pass - 密码 * $safe_num - 设置多少次后禁止登陆,为0则不限制,建议为3-5 * $mail - 若有恶意登录,会发邮件到这个邮箱,前提是mail()函数可用! */ header('Content-Type: text/html; charset=utf-8'); date_default_timezone_set('Asia/Shanghai'); session_start(); error_reporting(1); $sitetitle = 'FTP文件在线管理'; $user = 'admin'; $pass = 'admin'; $safe_num = 3;//设置多少次后禁止登陆,为0则不限制,建议为3-5 $mail = '1786444209@qq.com';//若有恶意登录,会发邮件到这个邮箱,前提是mail()函数可用! $meurl = $_SERVER['PHP_SELF']; $os = (DIRECTORY_SEPARATOR=='\\')?"windows":'linux'; $op = (isset($_REQUEST['op']))?htmlentities($_REQUEST['op']):'home'; $action = (isset($_REQUEST['action']))?htmlspecialchars($_REQUEST['action']):''; $folder = (isset($_REQUEST['folder']))?htmlspecialchars($_REQUEST['folder']):'./'; $arr = str_split($folder); if($arr[count($arr)-1]!=='/')$folder .= '/'; while(preg_match('/\.\.\//',$folder))$folder = preg_replace('/\.\.\//','/',$folder); while(preg_match('/\/\//',$folder))$folder = preg_replace('/\/\//','/',$folder); if($folder == '')$folder = "./"; $ufolder = $folder; if($_SESSION['error'] > $safe_num && $safe_num !== 0)printerror('您已经被限制登陆!'); /****************************************************************/ /* 用户登录函数 */ /* */ /* 需要浏览器开启Cookies才可使用 */ /****************************************************************/ if ($_COOKIE['user'] != $user || $_COOKIE['pass'] != md5($pass)) { if (htmlspecialchars($_REQUEST['user']) == $user && htmlspecialchars($_REQUEST['pass']) == $pass) { setcookie('user',$user,time()+60*60*24*1); setcookie('pass',md5($pass),time()+60*60*24*1); }else{ if (htmlspecialchars($_REQUEST['user']) == $user || htmlspecialchars($_REQUEST['pass'])) $er = true; login($er); exit; } } /****************************************************************/ /* function maintop() */ /* */ /* 控制站点的样式和头部内容 */ /* $title -> 顶部标题 $showtop -> 是否显示头部菜单 */ /****************************************************************/ function maintop($title,$showtop = true) { global $meurl,$sitetitle,$op; echo "<!DOCTYPE html>\n<meta name='robots' content='noindex,follow' />\n<head>\n<meta name='viewport' content='width=device-width, initial-scale=1'/>\n" ."<title>$sitetitle - $title</title>\n" ."</head>\n" ."<body>\n" ."<style>\n*{font-family:'Verdana','Microsoft Yahei';}.box{border:1px solid #ccc;background-color:#fff;padding:10px;}abbr{text-decoration:none;}.title{border:1px solid #ccc;border-bottom:0;font-weight:normal;text-align:left;width:678px;padding:10px;font-size:12px;color:#666;background-color:#F0F0F0;}.right{float:right;text-align:right !important;}.content{width:700px;margin:auto;overflow:hidden;font-size:13px;}.login_button{height:43px;line-height:18px;font-family:'Candara';}.login_text{font-family:'Candara','Microsoft Yahei';vertical-align:middle;padding:7px;width:40%;font-size:22px;border:1px #ccc solid;}input[type=text]:focus,input[type=password]:hover{outline:0;background-color:#f8f8f8;}input[type=text]:hover,input[type=password]:hover,input[type=password]:active{outline:0;background-color:#f8f8f8;}h2{color:#514f51;text-align:center;margin:16px 0;font-size:48px;background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#7d7d7d), to(#514f51));-webkit-background-clip: text;background-clip: text;-webkit-text-fill-color: transparent;font-family:'Candara','Lucida Sans','Microsoft Yahei' !important;}span{margin-bottom:8px;}a:visited{color:#333;text-decoration:none;}a:hover{color:#999;text-decoration:none;}a{color:#333;text-decoration:none;border-bottom:1px solid #CCC;}a:active{color:#999;text-decoration:none;}.title a,td a,.menu a{border:0}textarea{outline:none;font-family:'Yahei Consolas Hybrid',Consolas,Verdana,Tahoma,Arial,Helvetica,'Microsoft Yahei',sans-serif !important;font-size:13px;border:1px solid #ccc;margin-top:-1px;padding:8px;line-height:18px;width:682px;max-width:682px;}input.button{background-color:#eeeeee;text-align:center !important;outline:none;border:1px solid #adadad;*display:inline;color:#000;padding:3px 18px;font-size:13px;margin-top:10px;transition: border-color 0.5s;}input.button:hover{background-color:#e5f1fb;border-color:#0078d7;}input.mob{padding:3px 40px;}input.text,select,option,.upload{border:1px solid #ccc;margin:6px 1px;padding:5px;font-size:13px;height:16px;}body{background-color:#fff;margin:0px 0px 10px;}.error{font-size:10pt;color:#AA2222;text-align:left}.menu{position:fixed;font-size:13px;}.menu li{list-style-type:none;padding:7px 25px;border-left:#fff solid 3px;margin-bottom:2px;}.menu li.curr{border-left:#666 solid 3px;background-color:#f7f7f7;} .menu li:hover{border-color:#469;background-color:#ededed;}.odTable span {cursor:pointer;}.odTable b{color:#ccc;font-size:12px;}.menu a:hover{color:#707070;}.table{background-color:#777;color:#fff;}th{text-align:left;height:40px;line-height:40px;border-bottom:3px solid #dbdbdb;font-size:14px;background-color:#f8f8f8 !important;}table{border:1px solid #ccc;border-collapse:collapse;}tr{color:#666;height:31px;font-size:12px;}tr a{color:#333}th{color:#333;}tr:nth-child(odd){background-color:#fff;}tr:nth-child(even){background-color:#f5f5f7;}tr:hover{background-color:#ebeced;}.upload{width:50%;}.home,.com{display:none;}.long{width:70%}.short{width:20%}.open{width:40px;}.rename{width:50px;}\n@media handheld, only screen and (max-width: 960px) {textarea{width: calc(100% - 18px);max-width: calc(100% - 18px);}.upload{width:calc(100% - 18px);}.login_button{width: 100%;margin-top:0 !important;padding:20px 5px !important;height:60px;font-size:23px !important;}.login_text{display: block;margin-bottom: 0;padding:20px 10px;width: 100%;border-bottom:0;}.menu{margin-left: -40px;position: static;padding:0;}.menu li{padding-bottom: 8px;}.title{width:calc(100% - 22px);}input.mob{height:40px;font-size:15px;width:100%;display:block;}.content{width:100%}input.button{padding:3px 10px;}.mobile b,.mobi{display:none;}.com{display:inline;}th{font-weight:normal;font-size:12px;}.open,.rename{width:25px;}}</style>\n"; $back=($op!=='home')?$back = "<a href='{$meurl}?op=home&folder=".$_SESSION['folder']."'><li>返回 ".$_SESSION['folder']."</li></a>\n":$back = ''; echo "<h2>$sitetitle</h2>\n"; if ($showtop) {//头部菜单内容 if($op=='up'||$op=='upload'||$op=='yupload')$up = "class='curr'";if($op=='home'||$op =='edit'||$op =='ren'||$op =='unz')$home = "class='curr'";if($op=='cr'||$op=='create')$cr = "class='curr'";if($op=='sqlb'||$op=='sqlbackup')$sqlb = "class='curr'";if($op=='ftpa'||$op=='ftpall')$ftpa = "class='curr'"; echo "<div class='menu'>\n<ul><a href='{$meurl}?op=home'><li $home>主页</li></a>\n" .$back ."<a href='{$meurl}?op=up'><li $up>上传文件</li></a>\n" ."<a href='{$meurl}?op=cr'><li $cr>创建文件</li></a>\n" ."<a href='{$meurl}?op=sqlb'><li $sqlb>MySQL备份</li></a>\n" ."<a href='{$meurl}?op=ftpa'><li $ftpa>FTP备份</li></a>\n" ."<a href='{$meurl}?op=logout'><li>退出</li></a>\n" ."</ul></div>"; } echo "<div class='content'>\n"; } /****************************************************************/ /* function login() */ /* */ /* 登录验证 $user and md5($pass) */ /* 需要浏览器支持Cookie */ /****************************************************************/ function login($er=false) { global $meurl,$op,$safe_num,$mail; setcookie("user","",time()-60*60*24*1); setcookie("pass","",time()-60*60*24*1); maintop("登录",false); if ($er) { if (isset($_SESSION['error'])){ $_SESSION['error']++; if($_SESSION['error'] > $safe_num && $safe_num !== 0){ mail($mail,'FileBox文件管理器提醒:文件被恶意登录!','该提醒来自FileBox:<br>登录者IP为:'.$_SERVER['REMOTE_ADDR'],'From: <i@hezi.be>'); echo ('<span class="error">ERROR: 您已经被限制登陆!</span>'); exit; } }else{ $_SESSION['error'] = 1; } echo "<span class=error>用户名或密码错误!</span><br>\n"; } echo "<form action='{$meurl}?op=".$op."' method='post'>\n" ."<input type='text' name='user' border='0' class='login_text' placeholder='请输入用户名'>\n" ."<input type='password' name='pass' border='0' class='login_text' placeholder='请输入密码'>\n" ."<input type='submit' name='submitButtonName' value='LOGIN' border='0' class='login_button button'>\n" ."</form>\n"; mainbottom(); } /****************************************************************/ /* function home() */ /* */ /* Main function that displays contents of folders. */ /****************************************************************/ function home() { global $os, $meurl ,$folder, $ufolder; $content1 = ""; $content2 = ""; $folder = gCode($folder); if(opendir($folder)){$style = opendir($folder);}else{printerror("目录不存在!\n");exit;} $a=1;$b=1; if($folder)$_SESSION['folder']=$ufolder; maintop("主页"); echo '<script>var order;function generateCompareTRs(iCol,sDataType,iOrder){return function compareTRs(oTR1,oTR2){vValue1=convert(oTR1.cells[iCol].getAttribute(iOrder),sDataType);vValue2=convert(oTR2.cells[iCol].getAttribute(iOrder),sDataType);order=iOrder;if(vValue1<vValue2){return -1}else{if(vValue1>vValue2){return 1}else{return 0}}}}function convert(sValue,sDataType){switch(sDataType){case"int":return parseInt(sValue);default:return sValue.toString()}}function sortTable(iOrder,iCol,sDataType){var oTable=document.getElementById("tblSort");var oTBody=oTable.tBodies[0];var colDataRows=oTBody.rows;var aTRs=new Array;for(var i=0;i<colDataRows.length;i++){aTRs[i]=colDataRows[i]}if(oTable.sortCol==iCol & iOrder==order){aTRs.reverse()}else{aTRs.sort(generateCompareTRs(iCol,sDataType,iOrder))}var oFragment=document.createDocumentFragment();for(var j=0;j<aTRs.length;j++){oFragment.appendChild(aTRs[j])}oTBody.appendChild(oFragment);oTable.sortCol=iCol;}</script>'; echo "<form method='post'><table border='0' cellpadding='2' cellspacing='0' width=100% class='mytable odTable' id='tblSort'>\n"; while($stylesheet = readdir($style)) { $ufolder = $folder; $sstylesheet = $stylesheet; if($os!=='windows'):$qx = "<td>".substr(sprintf('%o',fileperms($ufolder.$sstylesheet)), -3)."</td>";$xx='<td></td>';else:$qx = '';$xx='';endif; if ($stylesheet !== "." && $stylesheet !== ".." ) { $stylesheet = uCode($stylesheet); $folder = uCode($folder); $trontd = "<tr width=100% onclick='st=document.getElementById(\"$stylesheet\").checked;if(st==true){document.getElementById(\"$stylesheet\").checked=false;this.style.backgroundColor=\"\";}else{document.getElementById(\"$stylesheet\").checked=true;this.style.backgroundColor=\"#e3e3e5\";}'><td><svg width='21' height='21'>"; $rename = "<td><a href='{$meurl}?op=ren&file=".htmlspecialchars($stylesheet)."&folder=$folder'><span class='com'>