Location: PHPKode > scripts > Cpanel Backup > cpanel-backup/cpanel.class.php
<?php	
/**
Original written by Sanjoy Ganguly at http://www.phpclasses.org/browse/package/5088.html
Just improved by Jakob G. Thomsen
*/
	class CpanelBackup{
		var $cpaneluser; 
		var $cpanelpass; 
		var $domain; 
		var $skin = "x3"; 	//Cpanel skin name 
		var $ftpuser; 
		var $ftppass; 
		var $ftphost; 
		var $ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive) it could also be scp, for secure ssh transfer
		var $ftpport = 21; //
		var $remoteFolder;
		var $NotificationEmail;	
		var $secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
		var $debug = 0; // Set to 1 to have web page result appear in your cron log
		
		
		
		function GetCpanelBackup(){
			
			if ($this->secure) {
			   $url = "ssl://".$this->domain;
			   $port = 2083;
			} else {
			   $url = $this->domain;
			   $port = 2082;
			}
			
			$socket = fsockopen($url,$port);
			if (!$socket) { echo "Failed to open socket connectionÂ… Bailing out!\n"; exit; }
			
			// Encode authentication string
			$authstr = $this->cpaneluser.":".$this->cpanelpass;
			$pass = base64_encode($authstr);
			
			$params = "dest=$this->ftpmode&email=$this->NotificationEmail&server=$this->ftphost&user=$this->ftpuser&pass=$this->ftppass&port=$this->ftpport&rdir=$this->remoteFolder&submit=Generate Backup";
			echo 'Sending these params: ' . $params;
			// Make POST to cPanel
			fputs($socket,"POST /frontend/".$this->skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
			fputs($socket,"Host: $domain\r\n");
			fputs($socket,"Authorization: Basic $pass\r\n");
			fputs($socket,"Connection: Close\r\n");
			fputs($socket,"\r\n");
			
			// Grab response even if we don't do anything with it.
			while (!feof($socket)) {
			  $response = fgets($socket,4096);
			  if ($this->debug) echo $response;
			}
			
			fclose($socket);
		}
		
	}	
	
?>
Return current item: Cpanel Backup