Download ALL attachments from your forum!
	$start1 = 0;
	$start1 = intval($_GET['start']);
$host = "localhost";
$user = "root";
$pass = "";
$name = "dbname";
$forumurl = "";

$con = mysql_connect($host, $user, $pass);
mysql_select_db($name, $con);
$query = mysql_query("select * from `mybb_attachments` LIMIT {$start1} , 10");
$rows = $start1;
while($a = mysql_fetch_assoc($query)){
	echo "Downloading <a href=\"{$forumurl}/{$a['attachname']}\">{$a['filename']}</a>.........";
	$start = time();
	system("wget {$forumurl}/uploads/{$a['attachname']} -o {$a['filename']}",$output);
	$stop = time();
	echo "<font color=\"green\">Finished in ".intval($stop - $start)." seconds</font><br />\n";
if($rows == 10){
	echo "Waiting...";
	echo '    <meta http-equiv="refresh" content="2;url=index.php?start='.intval($start1 + 10).'"> ';

it will download all the files to the directory you put this script in. It will not keep the .attach format, but change back to it's original! (If for some reason you want to keep the .attach and keep everything in correct directories remove "-o {$a['filename']}" and put "-x" instead.

Enjoy :p
Very cool.
-Paul H.

Cogisne lingua latina?
only if your server allows the system function, it is usually disabled as an "unsafe" function for security purposes.
Lost interest, sold my sites, will browse here once in a while. It's been fun.
I believe this is meant to be run from localhost via remote SQL?
-Paul H.

Cogisne lingua latina?
I suppose that it is, but I like to run my tests on a matching setup. I could re-enable the system function for the time I was going to run that script I suppose.

However, if you already have the DB on your localhost, then why not FTP the whole uploads to your localhost and just run a rename script instead of doing a wget 10 files at a time?
Lost interest, sold my sites, will browse here once in a while. It's been fun.
I made this for use on my local computer (where i allowed system()) so i could get all of the attachments from my forum (for a backup of the original files)
Also, i no longer had FTP access to the site and all i had was the database connection. that's what made it more useful to me :p

Forum Jump:

Users browsing this thread: 1 Guest(s)