Dynadot โ€” .com Transfer

Gmail backuP?

SpaceshipSpaceship
Watch
Impact
22
have a look at this
is it good enough for gmail backup?

can someone test it?

<?php

function get_cookies($header)
{
preg_match_all('!Set-Cookie: ([^;\s]+)($|;)!', $header, $match);

$cookie = '';
foreach ($match[1] as $val) {
if ($val{0} == '=') {
continue;
}
$cookie .= $val . ';';
}

return substr($cookie, 0, -1);
}

function gmail_login($login, $pass)
{
$postdata = "service=mail&Email=".urlencode($login)."&Passwd=".urlencode($pass)."&null=Sign%20in";

$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginBoxAuth");
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030430 Mozilla Firebird/0.6");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($c);
curl_close($c);

$cookies = get_cookies(substr($result, 0, strpos($result, "\n\n")));
/* js cookie */
preg_match('!var cookieVal= "([^"]+)";!', $result, $match);
$cookies .= ($gv = '; GV='.$match[1]);

$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, "https://www.google.com/accounts/CheckCookie?service=mail&chtml=LoginDoneHtml");
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030430 Mozilla Firebird/0.6");
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_COOKIE, $cookies);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
$ret = curl_exec($c);
curl_close($c);

$data = get_cookies(substr($ret, 0, strpos($ret, "\n\n")));
if (!$data) {
return $cookies;
} else {
return $data . $gv;
}
}

function gmail_fetch_file($login, $pass, $file)
{
$cookie = gmail_login($login, $pass);

$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, "http://gmail.google.com/gmail?search=query&q=".urlencode($file)."&view=tl&start=0");
curl_setopt($c, CURLOPT_COOKIE, $cookie);
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030430 Mozilla Firebird/0.6");
$ret = curl_exec($c);
curl_close($c);

if (preg_match('!D\(\["t",\["([^"]+)",!', $ret, $match)) {
$fp = fopen($file, "wb");

// retrieve file
$c = curl_init();
curl_setopt($c, CURLOPT_FILE, $fp);
curl_setopt($c, CURLOPT_COOKIE, $cookie);
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030430 Mozilla Firebird/0.6");
curl_setopt($c, CURLOPT_URL, "http://gmail.google.com/gmail?view=att&disp=inlined&attid=0.1&th=".$match[1]);
curl_exec($c);
curl_close($c);

fclose($fp);

return true;
}

return false;
}

function gmail_send_file($email, $from, $file)
{
$mime_boundary = "gmail" . md5(uniqid(mt_rand(), 1));

$header = "From: ".$from."\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"".$mime_boundary."\"\n";

$content = "--".$mime_boundary."\n";
$content .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$content .= "Content-Transfer-Encoding: 7bit\n\n";
$content .= "File backup: ".basename($file)."\n";
$content .= "--".$mime_boundary."\n";
$content .= "Content-Disposition: attachment;\n";
$content .= "Content-Type: Application/Octet-Stream;";
$content .= " name=\"".basename($file)."\"\n";
$content .= "Content-Transfer-Encoding: base64\n\n";
$content .= chunk_split(base64_encode(file_get_contents($file)))."\n";
$content .= "--".$mime_boundary."\n";

mail($email, "File backup: ".basename($file), $content, $header);

}

//gmail_fetch_file('login', 'pass', 'filename');
//gmail_send_file('recipient_address', 'sender_address', 'file_to_send');
?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
i dont get it.. what do you do with it?
 
0
•••
i think its meant 2 let you login 2 gmail with out going to gmail site :|
 
0
•••
going by the title i thought it would take a backup of your emails, but it might let you view your mail byn ot going ot the actual site. Anyone try this?
 
0
•••
0
•••
looked blank to me.
 
0
•••
looks to me as if it's supposed to login and send all mail in your gmail to another email for backup purposes
 
0
•••
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back