1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
| <?php
class module_peakclick { var $user = 'peakuser'; var $pass = 'peakpass'; var $text = 'PeakClick-Period:%s,Today:%s,CPC:%s,Clicks:%s';
function get() { if( !empty( $this->user ) && !empty( $this->pass ) ) { $postdata = 'ac=login'. '&username='.urlencode( $this->user ). '&password='.urlencode( $this->pass ); $s = curl_init(); curl_setopt( $s, CURLOPT_URL, 'https://stats.peakclick.com/' ); curl_setopt( $s, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt( $s, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)' ); curl_setopt( $s, CURLOPT_TIMEOUT, 20 ); curl_setopt( $s, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt( $s, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $s, CURLOPT_COOKIEJAR, '/tmp/cookiefile' ); curl_setopt( $s, CURLOPT_COOKIEFILE, '/tmp/cookiefile' ); curl_setopt( $s, CURLOPT_POSTFIELDS, $postdata ); curl_setopt( $s, CURLOPT_POST, 1 ); $result = curl_exec( $s ); curl_close( $s ); $result = str_replace( array( "\n", "\r", "\t" ), '', $result ); preg_match( '/Period income: <\/td><td.+?><b>([0-9\.]+?) .+?<\/b><\/td><\/tr>.+?<td.+?>Today\'s income: <\/td><td.+?>([0-9\.]+?) .+?<\/td><\/tr>.+?<\/td><\/tr><tr><td.+?>Today\'s CPC: <\/td><td.+?>([0-9\.]+?) .+?<\/td><\/tr>.+?<tr><td.+?>Today\'s clicks: <\/td><td.+?>([0-9]+?)<\/td>/i', $result, $match ); if( isset( $match[1] ) && is_numeric( $match[1] ) ) { return sprintf( $this->text, $match[1], $match[2], $match[3], $match[4] ); } return false; } } }
?>
|