[PHP] Transfer dua files from gaming server to webserver in 1 click

I have put together a script which helps me transfer the 100s of little dua cache files from my gaming server to my web server for my fast download. I thought this might be useful to some people so enjoy.

This php script will delete all the old dua files and then redownload them from your gaming server each time you run it.


//FTP Server IP.
$host = "127.0.0.1";
//FTP Username.
$user = "Username";
//FTP Password.
$pass = "Password";
//Dua dir on the gaming server.
$dir = "/orangebox/garrysmod/cache/dua/";
//Dua directory from the position of the file.
$duadir = "dua";

$files = scandir("$duadir/");
foreach($files as $key => $value)
{
    if(!is_dir("$duadir/$value"))
    {
        unlink("$duadir/$value");
    }
}
if(is_dir("$duadir/"))
{
    rmdir("$duadir");
}
mkdir("$duadir");

$conn = ftp_connect($host);
if(!$conn)
{
    exit("Could not connect to server: $host
");
}

if(!ftp_login($conn,$user,$pass))
{
    ftp_quit($conn);
    exit("Could not log in
");
}

ftp_pasv($conn,true);
ftp_chdir($conn,$dir);

$files = ftp_nlist($conn,".");

for($i=0;$i<count($files);$i++)
{
    if(!ftp_get($conn,"$duadir/$files[$i]",$files[$i],FTP_BINARY))
    {
        echo "Could not download {$files[$i]}
";
    }
    print `bzip2 -f "$duadir/$files[$i]"`;
}

ftp_quit($conn);

or vdir it.

I know like nothing about linux and wasn’t even aware of such a command until you mentioned it… This only took me like 20 mins to do so… meh

Virtual directories can definitely be done in Windows - My community uses them for the cache ( Or at least I think we do. I didn’t set it up) . Probably can be done in Linux too though.

[editline]01:39PM[/editline]

Seems you got confused with the Linux directory listing.

Well I googled it and the first thing that came up was linux command so I just assumed you were talking about that. Didn’t actually click the link tho lol

http://dl.dropbox.com/u/3659637/lua.jpg

lua != php

That might be true but I didn’t see where else to put it. There isn’t a section for ‘other releases’ for non-lua things.