<?php

App::import('Controller', array('Webval'));
App::import('Vendor', 'cURL', array ( 'file' => 'curl.php'));

class TestsController extends WebvalController
{
	var $uses = array();
	
	function index()
	{		
		$url = 'http://joj.sk';
		$fp = FirePHP::getInstance(true);
		
		$curl = new cURL();
		
		$GooglePageRankURL = 'http://www.google.com/search?client=navclient-auto&ch=6-1484155081&features=Rank&q=info:'.$url;
		$content = $curl->get($GooglePageRankURL);
		preg_match('/[0-9]+$/', $content, $matches);
		$googlePageRank = $matches[0];
		$fp->log($googlePageRank, 'Google Pagerank');
		
		// alexa
		/*$alexaURL = 'http://www.alexa.com/siteinfo/'.urlencode($url);
		$content = $curl->get($alexaURL);
		$doc = new DOMDocument();
		@$doc->loadHTML($content);
		$xpath = new DOMXPath($doc);
		$xquery = '//div[@class="data down"]';		
		$entries = $xpath->query($xquery);
		foreach ($entries as $entry)
		{
			$alexaRank = $entry->nodeValue;
			break;
		}
		$fp->log($alexaRank,'Alexa');*/
		
		
		
	}
	
}

?>