A php-like FTP tree directory

Source: Internet
Author: User
Tags explode ftp parent directory

Combined with JS do, the specific words should be modified, such as directory system
[HTML]
<script language= "JavaScript" >
With (document) {
Write ("<style type= ' text/css ' >");
Write (". Child")
Write ("</STYLE>");
}
function Initit () {
Divcoll = Document.all.tags ("DIV");
For (i=0 i<divcoll.length; i++) {
Whichel = Divcoll (i);
if (Whichel.classname = = "Child") WhichEl.style.display = "None";
} }
function ExpandIT (EL) {

Whichel = eval (el + "Child");
if (WhichEl.style.display = = "None") {
WhichEl.style.display = "block";
}
else {
WhichEl.style.display = "None";
}
}
onload = Initit;
</script>
<link href=. /main.css Rel=stylesheet type=text/css>
?
function Hsort ($a)
{
$b = ';
$c = ';
for ($i =0; $i <count ($a); $i + +)
{
$j =substr ($a [$i],0,1);
if ($j = = ' d ')
if ($i ==0)
$b = $a [$i];
Else
$b. = ' &&%% '. $a [$i];
Else
if ($i ==0)
$c = $a [$i];
Else
$c. = ' &&%% '. $a [$i];
}
if ($b = = ")
{
$ff =explode (' &&%% ', $c);
return $FF;
}
Else
{
if ($c = = ")
{
$ff =explode (' &&%% ', $b);
return $FF;
}
Else
{
$f 1= $b. ' &&%% '. $c;
$ff =explode (' &&%% ', $f 1);
return $FF;
}
}
}
Require ("./class/ftp.php");
$HOST = ' localhost ';
$USER = ' Huyang ';
$PASS = ' Huyang ';
function Ftpurl ($url, $konge, $in, $name)
{
if ($konge >10)
{}
Else
{
Global $HOST, $USER, $PASS;
$ftp =new FTP;
$ftp->init ($HOST, $USER, $PASS);
$ftp->initpwd ($url);
$a = $ftp->mulu ();
$ftp->close ();
$a =hsort ($a);
if ($in!=1)
{
$sss = $name. ' Child ';
Echo ' <div id= '. $sss. ' "class=" Child ">";
}
$v = 0;
for ($i =1; $i <count ($a); $i + +)
{
$aa =explode (", $a [$i]);
$j =substr ($aa [0],0,1);
if ($j = = ' t ')
{}
ElseIf ($j = = ' d ')
{
$c =count ($AA);
$c-=1;
if ($aa [$c]== '. ') | | ($aa [$c]== ')]
{}
Else
{
$v + +;
if ($in ==1)
{
$name 1= ' URL '. $v. ' Parent ';
$names = ' URL '. $v;
Echo ' <div id= '. $name 1. ' "class=" parent ">";
Echo ' <a href= ' # "onclick=" ExpandIT (';
echo "'". $names. "'";
Echo '); return false "> '. $aa [$c]. ' </a></div>
';
}
Else
{
$names = $name. ' _ '. $v;
Echo ' <a href= ' # "onclick=" ExpandIT (';
echo "'". $names. "'";
Echo '); return false ' > ';
for ($hu =0; $hu < $konge; $hu + +)
Echo ' Echo ' '. $aa [$c]. ' </a><br>
';
}
$url 1= $url. ' /'. $aa [$c];//may is need to change
$konge 1= $konge +1;
Ftpurl ($url 1, $konge 1,0, $names);
}
}
Else
{
$c =count ($AA);
$c-=1;
if ($in ==1)
{
$name = ' URL '. $i. ' Parent ';
$name 1= ' URL '. $i;
Echo ' <div id= '. $name. ' "class=" parent ">";
Echo ' <a href= "#" > ". $aa [$c]. ' </a></div>
';
}
Else
{
Echo ' <a href= ' ">";
for ($hu =0; $hu < $konge; $hu + +)
Echo ' Echo ' '. $aa [$c]. ' </a><br>
';
}
}
}
if ($in!=1)
Echo ' </div> ';
}
}
$ftp =new FTP;
$ftp->init ($HOST, $USER, $PASS);
$s = $ftp->pwd ();
$ftp->close ();
Ftpurl ($s, 0,1, ' URL1 '); $s May is need to change
?>
[/html]
The following are class files
[HTML]
?
Class FTP
{
var $id, $tid, $HOST, $USER, $PASS, $pwd;
var $china _mulu;
function init ($HOST, $USER, $PASS)
{
$this->host= $HOST;
$this->user= $USER;
$this->pass= $PASS;
$this->setup ();
}
function Setup ()
{
if ($this->host== ') $this->host= ' localhost ';
if ($this->user== ') $this->user= ';
if ($this->pass== ') $this->pass= ';
$this->id=ftp_connect ($this->host) or $this->ftp_msg ("Can Not connect ftp");
$this->tid=ftp_login ($this->id, $this->user, $this->pass) or $this->ftp_msg ("Can not open it");
}
function pwd ()//Get Path
{
$this->pwd=ftp_pwd ($this->id);
return $this->pwd;
}
function Initpwd ($PWD)
{
$this->pwd= $pwd;
}
function Mulu ()//Get Directory
{
if (! $this->pwd)
$this->pwd=ftp_pwd ($this->id);
$this->chinamulu=ftp_rawlist ($this->id, $this->pwd);
return $this->chinamulu;
}
function Upmulu ()//Return to Parent directory
{
$a =ftp_cdup ($this->id) or $this->ftp_msg ("Already be the uppest!!");
}
function Close ()
{
Ftp_quit ($this->id);
}
function Ftp_msg ($err)
{
Print "<font color=red>}
}
?>
[/html]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.