Code: Select all
Tuesday 09th of January 2007 09:19:35 PMModerator: General Moderators
Code: Select all
Tuesday 09th of January 2007 09:19:35 PMCode: Select all
<?php
// FTP Info
$ftpdir = date('l dS \of F Y h:i:s A');
echo $ftpdir;
// set up basic connection
$conn_id = ftp_connect($ftp_server);
echo '<p>Connected, logging in...';
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
echo '<p>Logged in, creating directory....';
// try to create the directory $dir
if (ftp_mkdir($conn_id, $ftpdir)) {
echo "successfully created the directory $ftpdir. Moving onto Backup...<br>\n";
} else {
echo "There was a problem while creating the directory $ftpdir. Exiting...\n";
exit();
}
# FTP File Transfer Code here...
$directory = '/..';
$file1 = scandir($directory);
foreach ($file1 as $file) {
if ($file != "." && $file != "..") {
$localfile = $file;
$remote_file = "$ftpdir/$file";
// upload a file
if (ftp_put($conn_id, $remote_file, $localfile, FTP_ASCII)) {
echo "Successfully uploaded <font color=green><b>$localfile</b></color><br>\n";
} else {
echo "There was a problem while uploading <font color=red><b>$localfile</b></font><br>\n";
}
}
}
// close the connection
ftp_close($conn_id);
?>Code: Select all
<?php
$dir = date('l dS \of F Y h:i:s A');
echo "Folder name: ".$ftpdir."<p>";
$relativedir = "backup/$dir";
$foldir = "../$relativedir";
// try to create the directory $dir
if (mkdir($foldir, 0700)) {
echo "Successfully created the directory $dir. Moving onto Backup...<br>\n";
} else {
echo "There was a problem while creating the directory $dir. Exiting...\n";
exit();
}
$directory = '/..';
$file1 = scandir($directory);
foreach ($file1 as $file) {
if ($file != "." && $file != "..") {
$localfile = $file;
$remote_file = "$relativedir/$file";
// upload a file
if (copy($localfile, $remotefile)) {
echo "Successfully uploaded <font color=green><b>$localfile</b></color><br>\n";
} else {
echo "There was a problem while uploading <font color=red><b>$localfile</b></font><br>\n";
}
}
}
?>Code: Select all
Folder name:
Successfully created the directory Thursday 11th of January 2007 07:11:32 PM. Moving onto Backup...
Warning: copy(../Packages) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../Packages
Warning: copy(../__db.001) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../__db.001
Warning: copy(../__db.002) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../__db.002
Warning: copy(../__db.003) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../__db.003
Warning: copy(../bin) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../bin
Warning: copy(../boot) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../boot
Warning: copy(../cgi) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../cgi
Warning: copy(../cgi-bin) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../cgi-bin
Warning: copy(../cgi-gd) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../cgi-gd
Warning: copy(../cgi-pl) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../cgi-pl
Warning: copy(../dev) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../dev
Warning: copy(../etc) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../etc
Warning: copy(../home) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../home
Warning: copy(../initrd) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../initrd
Warning: copy(../lib) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../lib
Warning: copy(../mnt) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../mnt
Warning: copy(../opt) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../opt
Warning: copy(../proc) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../proc
Warning: copy(../root) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../root
Warning: copy(../sbin) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../sbin
Warning: copy(../tmp) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../tmp
Warning: copy(../tmpdata) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../tmpdata
Warning: copy(../usr) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../usr
Warning: copy(../var) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../var
Warning: copy(../web) [function.copy]: failed to open stream: No such file or directory in /home/content/a/n/i/animestome/html/admin/backup.php5 on line 22
There was a problem while uploading ../webCode: Select all
<?php
set_time_limit(60000000);
$dir = date('l dS \of F Y h:i:s A');
echo "Folder name: ".$dir."<p>";
$relativedir = "backup/$dir";
$foldir = "../$relativedir";
// try to create the directory $dir
if (mkdir($foldir, 0700)) {
echo "Successfully created the directory $dir. Moving onto Backup...<br>\n";
} else {
echo "There was a problem while creating the directory $dir. Exiting...\n";
exit();
}
include('copyr.php5');
$directory = '../';
$file1 = scandir($directory);
foreach ($file1 as $file) {
if ($file != "." && $file != ".." && $file != "CORRUPT DIR" && $file != "backup") {
$localfile = "../$file";
$remote_file = "$foldir/$file";
// upload a file
if (copyr($localfile, $remote_file)) {
echo "Successfully uploaded <font color=green><b>$localfile</b></font><br>\n";
} else {
echo "There was a problem while uploading <font color=red><b>$localfile</b></font><br>\n";
}
}
}
?>Code: Select all
<?PHP
function copyr($source, $dest){
// Simple copy for a file
if (is_file($source)) {
$c = copy($source, $dest);
chmod($dest, 0777);
return $c;
}
// Make destination directory
if (!is_dir($dest)) {
$oldumask = umask(0);
mkdir($dest, 0777);
umask($oldumask);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if ($dest !== "$source/$entry") {
copyr("$source/$entry", "$dest/$entry");
}
}
// Clean up
$dir->close();
return true;
}
?>