• 12-11-2007, 17:13:05
    #1
    Üyeliği durduruldu
    Adsense hesabını sitende görünteleme.
    Adsense.php
    Alıntı
    <?php
    /**
    * PHP class ment to collect AdSense account data
    * It can return various data for different periods of time
    *
    * @copyright Copyright © 2007
    * @package AdSense
    */
    class AdSense {
    /**
    * Stores curl connection handle
    *
    * @var resource
    */
    var $curl = null;
    /**
    * Stores TMP folder path
    * This folder must be writeble
    *
    * @var string
    */
    var $tmpPath = '/tmp';
    /**
    * AdSense::AdSense()
    * AdSense class constructor
    */
    function AdSense(){
    $this->coockieFile = tempnam($this->tmpPath, 'cookie');
    $this->curl = curl_init();
    curl_setopt($this->curl, CURLOPT_HEADER, false);
    curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($this->curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7");
    curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookieFile);
    curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookieFile);
    register_shutdown_function(array(&$this, '__destructor'));
    }
    /**
    * AdSense::__destructor()
    * AdSense class destructor
    */
    function __destructor(){
    @curl_close($this->curl);
    @unlink($this->coockieFile);
    }
    /**
    * AdSense::connect()
    * Connects to AdSense account using supplied credentials
    * Returns true on unsuccessful connection, false otherwise
    *
    * @param string $username AdSense username
    * @param string $password AdSense password
    * @return boolean
    */
    function connect($username, $password){
    // phase 1
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginAuth?service=adsense&hl=en-US&ltmpl=login&ifr=true&passive=true&rm=hide&nui=3 &alwf=true&continue=https%3A%2F%2Fwww.google.com%2 Fadsense%2Fgaiaauth&followup=https%3A%2F%2Fwww.goo gle.com%2Fadsense%2Fgaiaauth");
    preg_match_all('<input type="hidden" name="(.*?)" value="(.*?)">', curl_exec($this->curl), $out);
    $params = array();
    foreach($out[1] as $key=>$name) { $params[] = $name . '=' . urlencode($out[2][$key]); }
    $params[] = 'Email=' . urlencode($username);
    $params[] = 'Passwd=' . urlencode($password);
    $params[] = 'null=' . urlencode('Sign in');
    // phase 2
    curl_setopt($this->curl, CURLOPT_POST, true);
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/accounts/ServiceLoginAuth");
    curl_setopt($this->curl, CURLOPT_POSTFIELDS, join('&', $params));
    preg_match("/.*<a target=\"_top\" href=\"(.*)\" style.*/", curl_exec($this->curl), $matches);
    // phase 3
    curl_setopt($this->curl, CURLOPT_POST, false);
    curl_setopt($this->curl, CURLOPT_URL, $matches[1]);
    // did we login ?
    if (eregi("Log out", curl_exec($this->curl))) {
    return true;
    } else {
    return false;
    };
    }
    /**
    * AdSense:arse()
    * Parses AdSense page and gets all stats
    * Returns associative array with collected data
    *
    * @param string $content AdSense page content
    * @return array
    */
    function parse($content){
    preg_match_all('/<td nowrap valign="top" style="text-align:right" class="">(.*?)<\/td>/', $content, $matches);
    return array(
    "impressions" => $matches[1][0],
    "clicks" => $matches[1][1],
    "ctr" => $matches[1][2],
    "ecpm" => $matches[1][3],
    "earnings" => $matches[1][4]
    );
    }
    /**
    * AdSense::today()
    * Gets AdSense data for the period: today
    * Returns associative array with collected data
    *
    * @return array
    */
    function today(){
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=today");
    return $this->parse(curl_exec($this->curl));
    }
    /**
    * AdSense::yesterday()
    * Gets AdSense data for the period: yesterday
    * Returns associative array with collected data
    *
    * @return array
    */
    function yesterday(){
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=yesterday");
    return $this->parse(curl_exec($this->curl));
    }
    /**
    * AdSense::last7days()
    * Gets AdSense data for the period: last7days
    * Returns associative array with collected data
    *
    * @return array
    */
    function last7days(){
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=last7days");
    return $this->parse(curl_exec($this->curl));
    }
    /**
    * AdSense::lastmonth()
    * Gets AdSense data for the period: lastmonth
    * Returns associative array with collected data
    *
    * @return array
    */
    function lastmonth(){
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=lastmonth");
    return $this->parse(curl_exec($this->curl));
    }
    /**
    * AdSense::thismonth()
    * Gets AdSense data for the period: thismonth
    * Returns associative array with collected data
    *
    * @return array
    */
    function thismonth(){
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=thismonth");
    return $this->parse(curl_exec($this->curl));
    }
    /**
    * AdSense::sincelastpayment()
    * Gets AdSense data for the period: sincelastpayment
    * Returns associative array with collected data
    *
    * @return array
    */
    function sincelastpayment(){
    curl_setopt($this->curl, CURLOPT_URL, "https://www.google.com/adsense/report/overview?timePeriod=sincelastpayment");
    return $this->parse(curl_exec($this->curl));
    }
    }
    ?>
    index.php
    Alıntı
    <?php
    include('AdSense.php');
    $adsense = new AdSense();
    if ($adsense->connect('username', 'password')) {
    $data = $adsense->sincelastpayment();
    } else {
    die('Could not login to AdSense account.');
    };
    ?>
    +rep
  • 12-11-2007, 17:14:51
    #2
    AdSense.php nerde ?
  • 12-11-2007, 18:30:13
    #3
    Üyeliği durduruldu
    r10net'de problem var galiba adsense.php'ide atmıştım ama eklemedi :S
  • 12-11-2007, 18:32:24
    #4
    ayrıca bu sayfanın şaftı kaymış. diğer sayfalar normal.
  • 12-11-2007, 18:44:53
    #5
    Üyeliği durduruldu
    evet şaftı kaydııı için olabilirmi
  • 22-11-2007, 14:57:23
    #6
    arkadaşlar bilgisi olan biri söyleyebilirmi?

    ben google hesabımı üyelerime ait bilgisayarlarda açtığım için sanırım tarafından sahte tıklama ile ikaz edildim.

    Şimdi ben bu hesabımı sitede gösatermek istiyorum ama google açısından bir sakınca doğururmu? yani üyelerime ait iplerler bunu gördüğü için gene google tarafından sorun yaşarmıyım

    tam anlatamadım sorunumu inşallah anlamışsınızdır...

    Üye tıklamalarında bu sakınca doğururmu

    ben ana sayfamda tüm üyelerin görmesini istiyorum

    teşekkürler