<title>Janissaries Alexa & Pagerank Checker [ MultiThread ]</title>
<?php
ob_start();
set_time_limit(0);

/*

/etc/named.conf Sites Pagerank & Alexa Checker
Coded by miyaChung
miyachung@hotmail.com

*/


	Function pagerank($sites,$thread,$limit)
	{
	
		echo "<font color='red'>----------------------------------------PAGERANK CHECK-----------------------------</font><br>";
		ob_flush();
		flush();

			$multi = curl_multi_init();
			$sites = array_chunk($sites,$thread);
				foreach($sites as $id => $chunk)
				{
					foreach($chunk as $i => $url)
					{
						$curl[$id][$i] = curl_init();
						curl_setopt($curl[$id][$i],CURLOPT_RETURNTRANSFER,true);
						curl_setopt($curl[$id][$i],CURLOPT_URL,"http://www.ayazoglu.org/ayazoglu.org/static/multirank/check.php");
						curl_setopt($curl[$id][$i],CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
						curl_setopt($curl[$id][$i],CURLOPT_POST,true);
						curl_setopt($curl[$id][$i],CURLOPT_POSTFIELDS,"site=$url");
						curl_setopt($curl[$id][$i],CURLOPT_CONNECTTIMEOUT,30);					
						curl_multi_add_handle($multi,$curl[$id][$i]);
					}
					do
					{
						curl_multi_exec($multi,$running);
					}while( $running > 0 );
					
						foreach($curl[$id] as $i => $data)
						{
							$c[$i] = curl_multi_getcontent($data);
							preg_match('#/rank/pagerank(.*?).gif#si',$c[$i],$pr);
							
							$pr = (int)$pr[1];
							
							if($pr >= $limit)
							{
								echo "<a href='http://$chunk[$i]'>$chunk[$i]</a> <font color='red'> ".$pr."</font><br>";
								ob_flush();
								flush();
							}
						
							
							curl_multi_remove_handle($multi,$data);
							
						}
				}
			
		
	}

		
	Function alexa($sites,$thread)
	{
		global $timefirst;
		
		echo "<br><font color='red'>----------------------------------------ALEXA CHECK-----------------------------</font><br>";
		ob_flush();
		flush();
	
		$multi = curl_multi_init();
		$sites = array_chunk($sites,$thread);
		foreach($sites as $id => $chunk)
		{
			foreach($chunk as $i => $url)
			{
				$curl[$id][$i] = curl_init();
				curl_setopt($curl[$id][$i],CURLOPT_RETURNTRANSFER,true);
				curl_setopt($curl[$id][$i],CURLOPT_URL,$url);
				curl_setopt($curl[$id][$i],CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
				curl_setopt($curl[$id][$i],CURLOPT_CONNECTTIMEOUT,30);
				curl_multi_add_handle($multi,$curl[$id][$i]);
			}
			do
			{
				curl_multi_exec($multi,$running);
			}while( $running > 0 );
		
			foreach($curl[$id] as $i => $data)
			{
			$c[$i] = curl_multi_getcontent($data);
			$link = explode("=",$chunk[$i]);
			
			preg_match_all('#<div class="row">(.*?)</div>#si',$c[$i],$d);
			$strip = strip_tags($d[0][1]);
			$strip = trim($strip);
			
			if(preg_match('/Traffic Rank in/',$strip))
			{
			echo "<a href='http://$link[1]'>$link[1]</a> <font color='red'> ".$strip."</font><br>";
			ob_flush();
			flush();
			}
				curl_multi_remove_handle($multi,$data);
			}
		}
		
	$timelast = time();
	$fark = ($timelast-$timefirst);
	
	echo "<br><strong>Geçen Süre: $fark saniye</strong><br>";
	echo "<br><h1 style='margin:0;padding:0;font:bold 17px tahoma;'>Checking finished..</h1><br>";
	echo "<strong>Coded by miyaChung</strong><br>";
	echo "<strong>Special Thanks : burtay</strong><br>";
	echo "<strong style='color:red'>Janissaries.Org</strong>";
		
			
	}

	
	
	// CONTROL BABY
	
	if($_GET['read'])
	{
	
			// 1 STEP GET SITES
	
			$file = $_GET['read'];
			$thread = (int)$_GET['th'] ? $_GET['th'] : 20;
			$prlimit = (int)$_GET['prlimit'] ? $_GET['prlimit'] : 3;
			
			if(!file_exists($file))
			{
			exit("can't find the file");
			}
			$open = file_get_contents($file);
			$prurl = array();
			$alexaurl = array();
			
			preg_match_all("#zone \"(.*?)\"#si",$open,$sites);
			
			// preg_match_all('#/home/httpd/vhosts/(.*?):/#si',$open,$sites);
			
			
			
			foreach(array_filter(array_unique($sites[1])) as $urls)
			{
			$urls = trim($urls);
			$prurl[] = $urls;
			$alexaurl[] = "http://www.alexa.com/search?q=".$urls;
			}
			
			echo "<h1 style='margin:0;padding:0;font:bold 17px tahoma;'>Janissaries Alexa & Pagerank Checker [ MultiThread ]</h1><br>";
			echo "<strong>File : ".$_GET['read']."</strong><br>";
			if(!$_GET['th']){echo "<strong>Thread : $thread [ Default ]</strong><br>";}else{echo "<strong>Thread : $thread</strong><br>";}
			if(!$_GET['prlimit']){echo "<strong>Pagerank Limit : $prlimit [ Default ]</strong><br>";}else{echo "<strong>Pagerank Limit : $prlimit</strong><br>";}
			echo "<strong style='color:red'>Total URLS : ".count(array_filter(array_unique($sites[1])))."</strong><br>";
			ob_flush();
			flush();
			
			$timefirst = time();
			
			// Check Pagerank
			
			pagerank($prurl,$thread,$prlimit);
			
			// Check Alexa
	
			alexa($alexaurl,$thread);
		
			
			
			
	}
	else
	{
	echo "read => file.txt<br>";
	echo "th => 10 -> Default 20<br>";
	echo "prlimit => 4 -> Default 3<br>";
	}


?>