"; $from = "Automated Backup "; $subject = "Mysql Backup"; $mymessage = "Your Mysql GZIP Backup"; # Edit cpanel backup info # login is cpanel login username and password $user_name = "byron"; $user_pass = "********"; $database = "byron_test"; $domain = "byron.heliohost.org"; $url = "http://$domain:2082/getsqlbackup/$database.sql.gz"; $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; $cook_file = "curl_login_cookie.txt"; # get file extension $extract = pathinfo($url); $fname = ($extract['basename']); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_REFERER, "http://$domain"); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true); curl_setopt($ch, CURLOPT_USERPWD, "$user_name:$user_pass"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cook_file); curl_setopt($ch, CURLOPT_COOKIEJAR, $cook_file); $result = curl_exec($ch); $extract = curl_getinfo($ch); $httpcode = $extract['http_code']; curl_close($ch); if ($httpcode >= 200 && $httpcode < 303) { ####### Email gzip attachment ####### $content = chunk_split(base64_encode($result)); $uid = md5(uniqid(time())); $header = "From: $from\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $message = "This is a multi-part message in MIME format.\r\n"; $message .= "--".$uid."\r\n"; $message .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $message .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $message .= $mymessage."\r\n\r\n"; $message .= "--".$uid."\r\n"; $message .= "Content-Type: application/x-gzip; name=\"".$fname."\"\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n"; $message .= "Content-Disposition: attachment; filename=\"".$fname."\"\r\n\r\n"; $message .= $content."\r\n\r\n"; $message .= "--".$uid."--"; mail($to, $subject, $message, $header); ####### End email attachment ######## } else { echo "cPanel Login Failed!"; } # delete cookie file if (file_exists($cook_file)) { unlink($cook_file); } ?>