<?php function getMoneyGoogleAdsense($sLogin, $sPass, $cookiePath='cookie.txt') { $c = curl_init('https://www.google.com/adsense/'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com/adsense/'); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init('https://www.google.com/adsense/'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com'.$sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init('https://www.google.com/adsense/'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com'.$sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init('https://www.google.com/adsense/'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com'.$sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init('https://www.google.com/adsense/'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com/accounts/ServiceLoginBoxAuth'); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_POSTFIELDS, 'continue=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&followup=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&service=adsense&nui=15&fpui=3&ifr=true&rm=hide<mpl=login&hl=pl&alwf=true&GA3T=1hXNw5FJHzY&GALX=CChwX7HQKf8&Email='.$sLogin.'&Passwd='.urlencode($sPass)); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init('https://www.google.com/accounts/ServiceLoginBoxAuth'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com/accounts/CheckCookie?continue=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&followup=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&service=adsense&hl=pl&chtml=LoginDoneHtml'); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $sLink = str_replace('&', '&', preg_replace('!.*<meta http-equiv="refresh" content="0; url='(.+)'">.*!is', '$1', $s)); $c = curl_init('https://www.google.com/accounts/CheckCookie?continue=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&followup=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&service=adsense&hl=pl&chtml=LoginDoneHtml'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, $sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init($sLink); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, $sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init($sLink); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com'.$sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init($sLink); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com'.$sLink); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $c = curl_init('https://www.google.com/adsense/report/overview'); curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($c, CURLOPT_URL, 'https://www.google.com/adsense/report/overview?timePeriod=alltime'); curl_setopt($c, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_getinfo($c); $s = curl_exec($c); curl_close($c); $sMoney = preg_replace('!.*Razem dochody</td>.*?<td style="font-weight:bold;" nowrap>([0-9,]+) US$.*!is', '$1', $s); return $sMoney; } ?>
I przyk³ad u¿ycia:
<?php $sLogin = '****'; //bez @gmail.com $sPass = '******'; $sCache = 'money.cache'; $iPeriod = 3600*24; { } else { $ileNaKoncie = getMoneyGoogleAdsense($sLogin, $sPass); $ilePotrzeba = 100; $value = '$'; $percent = ($ileNaKoncie/$ilePotrzeba)*100; $im = imagecreatetruecolor(148, 40); $color = imagecolorallocatealpha($im, 255, 255, 255, 0); $black = imagecolorallocate($im, 0, 0, 0); imagefillalpha($im, $color); { if($percent<=50) { $iGreen = ($percent==50)?255:((int)$percent*5); $color_percent = imagecolorallocate($im,255,$iGreen,0); } elseif($percent>50) { $iGreen = ($percent==51)?251:502-($percent*5)-1; $color_percent = imagecolorallocate($im,$iGreen,255,0); } } imagefilledrectangle($im, 24, 0, $percent+24, 12, $color_percent); imagerectangle($im, 24, 0, 124, 12, $black); imagestring($im, 2, 5, 15, ''.$ileNaKoncie.$value.' z '.$ilePotrzeba.$value.' potrzebnych', $black); imagesavealpha($im); imagepng($im, $sCache); imagepng($im); imagedestroy($im); } function ImageFillAlpha($image, $color) { imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), $color); } ?>
I wygl±da to tak:
