pull.php 15.6 KB
Newer Older
MatrixCrawler's avatar
MatrixCrawler committed
1
<?php 
MatrixCrawler's avatar
MatrixCrawler committed
2 3 4 5 6 7 8
/** 
 * Copyright (c) 2011, David Morley. 
 * This file is licensed under the Affero General Public License version 3 or later. 
 * See the COPYRIGHT file. 
 */

require_once "Net/GeoIP.php";
MatrixCrawler's avatar
MatrixCrawler committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

define("CURL_POST", 0);
define("CURL_HEADER", 0);
define("CURL_CONNECTTIMEOUT", 5);
define("CURL_RETURNTRANSFER", 1);
define("CURL_NOBODY", 0);

define("DB_DRIVER","mysql");
define("DB_NAME","dbname");
define("DB_HOST","localhost");
define("DB_USER","dbUser");
define("DB_PASSWORD","dbPassword");

define("DEBUG", true);

class Pull {
	
MatrixCrawler's avatar
MatrixCrawler committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
	public static function getCurlResultAndInfo($url, &$result, &$info) {
		$curl = curl_init();
		
		curl_setopt($mv, CURLOPT_URL, $url);
		curl_setopt($mv, CURLOPT_POST, CURL_POST);
		curl_setopt($mv, CURLOPT_HEADER, CURL_HEADER);
		curl_setopt($mv, CURLOPT_CONNECTTIMEOUT, CURL_CONNECTTIMEOUT);
		curl_setopt($mv, CURLOPT_RETURNTRANSFER, CURL_RETURNTRANSFER);
		curl_setopt($mv, CURLOPT_NOBODY, CURL_NOBODY);
		
		$result = curl_exec($curl);
		$info = curl_getinfo($curl);
		curl_close($curl);
	}
	
	public static function getCurlResult($url) {
MatrixCrawler's avatar
MatrixCrawler committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
		$curl = curl_init();

		curl_setopt($mv, CURLOPT_URL, $url);
		curl_setopt($mv, CURLOPT_POST, CURL_POST);
		curl_setopt($mv, CURLOPT_HEADER, CURL_HEADER);
		curl_setopt($mv, CURLOPT_CONNECTTIMEOUT, CURL_CONNECTTIMEOUT);
		curl_setopt($mv, CURLOPT_RETURNTRANSFER, CURL_RETURNTRANSFER);
		curl_setopt($mv, CURLOPT_NOBODY, CURL_NOBODY);
		
		$result = curl_exec($curl);
		curl_close($curl);
		
		return $result;
	}

	public static function getDatabaseConnection() {
		$dsn = DB_DRIVER.":dbname=".DB_NAME.";host=".DB_HOST;
				
		try {
			$connection = new PDO($dsn, DB_USER, DB_PASSWORD);
			return $connection;
		} catch (PDOException $e) {
			die('Connection to databse failed: ' . $e->getMessage());
		}
	}
	
MatrixCrawler's avatar
MatrixCrawler committed
68 69 70 71 72 73
	public static function getRatings(&$adminRating=0, &$userRating=0, String $podUrl, PDO $db) {
		$adminRatingCounter = 0;
		$userRatingCounter = 0;
		$adminRatingTemp = 0;
		$userRatingTemp = 0;
		$sql = "SELECT * FROM rating_comments WHERE domain = ".$podUrl;
MatrixCrawler's avatar
MatrixCrawler committed
74
		
MatrixCrawler's avatar
MatrixCrawler committed
75
		$quotedSql = $db->quote($sql);
MatrixCrawler's avatar
MatrixCrawler committed
76
		
MatrixCrawler's avatar
MatrixCrawler committed
77 78 79 80
		if ($quotedSql === false) {
			die('Problem with SQL Statement. '.$sql);
		} else {
			$result = $db->query($quotedSql);
MatrixCrawler's avatar
MatrixCrawler committed
81
			
MatrixCrawler's avatar
MatrixCrawler committed
82 83
			if (!result) {
				die("Error fetching SQL Result for Ratings. Error: ".$result->errorCode());
MatrixCrawler's avatar
MatrixCrawler committed
84 85
			}
			
MatrixCrawler's avatar
MatrixCrawler committed
86 87 88 89 90 91 92 93
			while ($row = $result->fetchAll()) {
				if ($row['admin'] == 1) {
					$adminRatingCounter++;
					$adminRatingTemp += $row['rating'];
				} elseif ($row['admin'] == 0) {
					$userRatingCounter++;
					$userRatingTemp += $row['rating'];
				}
MatrixCrawler's avatar
MatrixCrawler committed
94 95
			}
			
MatrixCrawler's avatar
MatrixCrawler committed
96 97 98 99 100 101 102 103 104 105
			// Set the Ratingvalues
			$adminRating = round($adminRatingTemp/$adminRatingCounter,22);
			$userRating = round($userRatingTemp/$userRatingCounter, 2);
		}
	}
	
	public static function parseHeader($header, &$gitdate, &$gitrev, &$xdver, &$diasporaVersion, &$runtime, &$server, &$encoding) {
		
		preg_match('/X-Git-Update: (.*?)\n/', $header, $xgitdate);
		$gitdate = trim($xgitdate[1]);
MatrixCrawler's avatar
MatrixCrawler committed
106
			
MatrixCrawler's avatar
MatrixCrawler committed
107 108
		preg_match('/X-Git-Revision: (.*?)\n/',$header,$xgitrev);
		$gitrev = trim($xgitrev[1]);
MatrixCrawler's avatar
MatrixCrawler committed
109
			
MatrixCrawler's avatar
MatrixCrawler committed
110 111 112
		preg_match('/X-Diaspora-Version: (.*?)\n/',$header,$xdver);
		$dverr = split("-",trim($xdver[1]));
		$diasporaVersion = $dverr[0];
MatrixCrawler's avatar
MatrixCrawler committed
113
			
MatrixCrawler's avatar
MatrixCrawler committed
114 115
		preg_match('/X-Runtime: (.*?)\n/',$outputssl,$xruntime);
		$runtime = isset($xruntime[1]) ? trim($xruntime[1]) : null;
MatrixCrawler's avatar
MatrixCrawler committed
116
			
MatrixCrawler's avatar
MatrixCrawler committed
117 118
		preg_match('/Server: (.*?)\n/',$outputssl,$xserver);
		$server = isset($xserver[1]) ? trim($xserver[1]) : null;
MatrixCrawler's avatar
MatrixCrawler committed
119
			
MatrixCrawler's avatar
MatrixCrawler committed
120 121 122 123 124 125
		preg_match('/Content-Encoding: (.*?)\n/',$outputssl,$xencoding);
		if ($xencoding) {
			$encoding = trim($xencoding[1]);
		} else {
			$encoding = null;
		}
126

MatrixCrawler's avatar
MatrixCrawler committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140
		if (DEBUG) {
			echo "GitUpdate: ".$gitdate."<br />";
			echo "GitRev: ".$gitrev."<br />";
			echo "Version code: ".$diasporaVersion."<br />";
			echo "Runtime: ".$runtime."<br />";
			echo "Server: ".$server."<br />";
			echo "Encoding: ".$encoding."<br />";
		}
		
	}
	
	public static function parseJSON($header, &$podName, &$registrationsOpen, &$totalUsers, &$activeUsersHalfyear, &$activeUsersMonthly, &$localPosts) {
		preg_match_all("/{(.*?)}/", $header, $JSONArray);
		$JSON = json_decode($JSONArray[0][0]);
141

MatrixCrawler's avatar
MatrixCrawler committed
142 143
		if ($JSON->registrations_open === true) {
			$registrationsOpen = 1;
MatrixCrawler's avatar
MatrixCrawler committed
144
		} else {
MatrixCrawler's avatar
MatrixCrawler committed
145
			$registrationsOpen = 0;
MatrixCrawler's avatar
MatrixCrawler committed
146 147
		}
		
MatrixCrawler's avatar
MatrixCrawler committed
148 149 150 151 152
		$podName = isset($JSON->name) ? $JSON->name : "null";
		$totalUsers = isset($JSON->total_users) ? $JSON->total_users : 0;
		$activeUsersHalfyear = isset($JSON->active_users_halfyear) ? $JSON->active_users_halfyear : 0;
		$activeUsersMonthly = isset($JSON->active_users_monthly) ? $JSON->active_users_monthly : 0;
		$localPosts = isset($JSON->local_posts) ? $JSON->local_posts : 0;
MatrixCrawler's avatar
MatrixCrawler committed
153
		
MatrixCrawler's avatar
MatrixCrawler committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
		if (DEBUG) {
			echo "Registrations Open: ".$registrationsOpen."<br />";
			echo "PodName: ".$podName."<br />";
			echo "Active user over half year: ".$activeUsersHalfyear."<br />";
			echo "Active user monthly: ".$activeUsersMonthly."<br />";
			echo "Local Posts: ".$localPosts."<br />";
		}	
	
	}
	
	public static function getMasterVersion() {
		//get master code version
		$masterVersionResult = Pull::getCurlResult("https://raw.github.com/diaspora/diaspora/master/config/defaults.yml");
		preg_match('/number: "(.*?)"/', $masterVersionResult, $version);

		if (DEBUG) {
			echo "MasterVersion: ".$masterVersion."<br>";
		} 
		
		return trim($version[1], '"');
	}
	
	public static function getPodList($domain, PDO $dbConnection) {
		if ($domain) {
			// Pull is requested for specific Domain
			$sql = $dbConnection->quote("SELECT domain,pingdomurl,score,datecreated FROM pods WHERE domain = ".$domain);
MatrixCrawler's avatar
MatrixCrawler committed
180
		} else {
MatrixCrawler's avatar
MatrixCrawler committed
181 182
			// General pull. Get all pods from Database
			$sql = $dbConnection->quote("SELECT domain,pingdomurl,score,datecreated,adminrating FROM pods");
MatrixCrawler's avatar
MatrixCrawler committed
183 184
		}
		
MatrixCrawler's avatar
MatrixCrawler committed
185
		$result = $dbConnection->query($sql);
MatrixCrawler's avatar
MatrixCrawler committed
186
		
MatrixCrawler's avatar
MatrixCrawler committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
		if (!$result) {
			if ($domain) {
				die("Error fetching SQL Result for Pod: ".$domain.". Error:" . $result->errorCode());
			} else {
				die("Error fetching SQL Result. Error: " . $result->errorCode());
			}
		} else {
			return $result;
		}
	}
	
	/**
	 * Cap the score at 20 and -20
	 * @param integer $score
	 */
	public static function capScore(&$score) {
MatrixCrawler's avatar
MatrixCrawler committed
203 204 205 206 207
		if ($score > 20) {
			$score = 20;
		} elseif ($score < -20) {
			$score = -20;
		}
MatrixCrawler's avatar
MatrixCrawler committed
208 209 210 211 212 213 214 215 216 217 218
	}
	
	/**
	 * Returns the IPv6 Address of the pod if there is any
	 * @param string $podurl
	 * @return string
	 */
	public static function getIPv6($podurl) {
		$command = escapeshellcmd('dig +nocmd '.$podurl.' aaaa +noall +short');
		return exec($command);
	}
MatrixCrawler's avatar
MatrixCrawler committed
219

MatrixCrawler's avatar
MatrixCrawler committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
	/**
	 * Returns the IPv4 Address of the pod, if there is any
	 * @param string $podurl
	 * @return string
	 */
	public static function getIPv4($podurl) {
		$command = escapeshellcmd('dig +nocmd '.$podurl.' a +noall +short');
		return exec($command);
	}
	
	/**
	 * Tries ti get a GeoIP based Location
	 * @param unknown $ipnum
	 * @param unknown $whois
	 * @param unknown $country
	 * @param unknown $city
	 * @param unknown $lat
	 * @param unknown $long
	 */
	public static function getGeoIPData($ipnum, &$whois, &$country, &$city, &$lat, &$long) {
MatrixCrawler's avatar
MatrixCrawler committed
240 241 242 243 244 245 246 247 248 249 250
		$geoip = Net_GeoIP::getInstance("GeoLiteCity.dat");
		try {
    		$location = $geoip->lookupLocation($ipnum);
			if ($debug) {
				echo "GEOIP: ".$location."<br>";
			}
		} catch (Exception $e) {
    		// 	Handle exception
		}
		
		$whois = "Country: ".$location->countryName."\n Lat:".$location->latitude." Long:".$location->longitude;
MatrixCrawler's avatar
MatrixCrawler committed
251 252 253 254 255 256 257 258 259 260
		$country = $location->countryName;
		$city = isset($location->city) ? iconv("UTF-8", "UTF-8//IGNORE", $location->city) : null;
		$lat = $location->latitude;
		$long = $location->longitude;
	}
	
	private static function getPingdomData($pingdomUrl, &$responsetime, &$months, &$uptime, &$live, &$score) {
		// Pod is monitored via pingdom
		$thismonth = "/".date("Y")."/".date("m");
		Pull::getCurlResultAndInfo($pingdomUrl.$thismonth,$pingdom,$info);
261

MatrixCrawler's avatar
MatrixCrawler committed
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
		if ($info['http_code'] == 200) {
		
			//response time
			preg_match_all('/<h3>Avg. resp. time this month<\/h3>
				        <p class="large">(.*?)</',$pingdom,$matcheach);
			$responsetime = $matcheach[1][0];
		
			//months monitored
			preg_match_all('/"historySelect">\s*(.*?)\s*<\/select/is',$pingdom,$matchhistory);
			$implodemonths = implode(" ", $matchhistory[1]);
		
			preg_match_all('/<option(.*?)/s',$implodemonths,$matchdates);
			$months = isset($matchdates[0])?count($matchdates[0]):0;
			//echo $matchdates[0];
			//uptime %
		
			preg_match_all('/<h3>Uptime this month<\/h3>\s*<p class="large">(.*?)%</',$pingdom,$matchper);
			$uptime = isset($matchper[1][0])?preg_replace("/,/", ".", $matchper[1][0]):0;
		
			if (strpos($pingdom,"class=\"up\"")) {
				$live="up";
			} elseif (strpos($pingdom,"class=\"down\"")) {
				$live="down";
			} elseif (strpos($pingdom,"class=\"paused\"")) {
				$live="paused";
MatrixCrawler's avatar
MatrixCrawler committed
287
			} else {
MatrixCrawler's avatar
MatrixCrawler committed
288
				$live="error";
MatrixCrawler's avatar
MatrixCrawler committed
289 290 291
				$score -= 2;
			}
		} else {
MatrixCrawler's avatar
MatrixCrawler committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
			//pingdom url is <> 200 so stats are gone, lower score
			$score -= 2;
		}
		
		if (DEBUG) {
			echo "Pingdom - Url: ".$pingdomUrl.$thismonth."<br />";
			echo "Pingdom code: ".$info['http_code']."<br />";
			echo "Responsetime: ".$responsetime."<br />";
			echo "Months: ".$months."<br />";
			echo "Live: ".$live."<br />";
			echo "Score: ".$score."<br />";
		}
		
	}
	
	private static function getUptimerobotData($pingdomUrl, &$responsetime, &$months, &$uptime, &$live) {
		//do uptimerobot API instead
		$uptimerobot = Pull::getCurlResult($pingdomUrl);
		$json_encap = "jsonUptimeRobotApi()";
		$up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap));
MatrixCrawler's avatar
MatrixCrawler committed
312
			
MatrixCrawler's avatar
MatrixCrawler committed
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
		$JSON = json_decode($up2);
		$responsetime = 'n/a';
		$uptime = $JSON->monitors->monitor{'0'}->alltimeuptimeratio;
		$diff = abs(strtotime(date('Y-m-d H:i:s')) - strtotime($dateadded));
		$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
		
		switch ($JSON->monitors->monitor{'0'}->status) {
			case 1:
				$live = "Paused";
				break;
			case 2:
				$live = "Up";
				break;
			case 8:
				$live = "Seems Down";
				break;
			case 9:
				$live = "Down";
				break;
MatrixCrawler's avatar
MatrixCrawler committed
332 333
		}
		
MatrixCrawler's avatar
MatrixCrawler committed
334 335 336 337 338
		if (DEBUG) {
			echo "UptimeRobot - Url: ".$pingdomUrl."<br />";
			echo "Responsetime: ".$responsetime."<br />";
			echo "Months: ".$months."<br />";
			echo "Live: ".$live."<br />";
MatrixCrawler's avatar
MatrixCrawler committed
339
		}
MatrixCrawler's avatar
MatrixCrawler committed
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
	}
	
	public static function getRobotData($pingdomUrl, &$responsetime, &$months, &$uptime, &$live, &$score) {
		$month = 0;
		$uptime = 0;
		
		if (strpos($pingdomUrl, "pingdom.com")) {
			Pull::getPingdomData($pingdomUrl, $responsetime, $months, $uptime, $live, $score);
		} else {
			Pull::getUptimerobotData($pingdomUrl, $responsetime, $months, $uptime, $live);
		}
	}
	
	public static function writeData(PDO $connection, $gitdate, $encoding, $secure, $hidden, $runtime, $gitrev, $ipnum, $ipv6, $months, $uptime, $live, $pingdomdate, $timenow, $responsetime, $score, $adminRating, $country, $city, $state, $lat, $long, $diasporaVersion, $whois, $userRating, $xdver, $masterVersion, $registrationsOpen, $totalUsers, $activeUsersHalfyear, $activeUsersMonthly, $localPosts, $podName, $domain) {
		
		$sql = "UPDATE pods SET Hgitdate=".$gitDate.", Hencoding=".$encoding.", secure=".$secure.", hidden=".$hidden.", Hruntime=".$runtime.", ";
		$sql .= "Hgitref=".$gitrev.", ip=".$ipnum.", ipv6=".$ipv6.", monthsmonitored=".$months.", uptimelast7=".$uptime.", status=".$live.", ";
		$sql .= "dateLaststats=".$pingdomdate.", dateUpdated=".$timenow.", responsetimelast7=".$responsetime.", score=".$score.", ";
		$sql .= "adminrating=".$adminRating.", country=".$country.", city=".$city.", state=".$state.", lat=".$lat.", long=".$long.", ";
		$sql .= "postalcode='', connection=".$diasporaVersion.", whois=".$whois.", userrating=".$userRating.", longversion=".$xdver.", ";
		$sql .= "shortversion=".$diasporaVersion.", masterversion=".$masterVersion.", signup=".$registrationsOpen.", total_users=".$totalUsers.", ";
		$sql .= "active_users_halfyear=".$activeUsersHalfyear.", active_users_monthly=".$activeUsersMonthly.", local_posts=".$localPosts.", ";
		$sql .= "name=".$podName;
		$sql .= "WHERE";
		$sql .= "domain=".$domain;
		
		$escapedSql = $connection->quote($sql); 
		
		if (!$escapedSql) {
			die("Error escaping SQL query: ".$sql);
		} else {
			$result = $connection->query($escapedSql);
			if (!$result) {
				die("Error executing SQL query: ". $result->errorCode());
			}
MatrixCrawler's avatar
MatrixCrawler committed
375
		}
MatrixCrawler's avatar
MatrixCrawler committed
376 377 378 379
	}
}

// Inititialize variables
MatrixCrawler's avatar
MatrixCrawler committed
380

MatrixCrawler's avatar
MatrixCrawler committed
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
$state 					= ""; // Seems to be always empty. Deprecated?
$pingdomdate 			= date('Y-m-d H:i:s'); // is always the current date
$timenow 				= date('Y-m-d H:i:s'); // is always the current date
$gitdate 				= "";
$encoding 				= "";
$secure 				= ""; 
$hidden 				= ""; 
$runtime 				= ""; 
$gitrev 				= ""; 
$ipnum 					= ""; 
$ipv6 					= ""; 
$months 				= ""; 
$uptime 				= ""; 
$live 					= ""; 
$pingdomdate 			= ""; 
$timenow 				= ""; 
$responsetime 			= ""; 
$score 					= ""; 
$adminRating 			= ""; 
$country 				= ""; 
$city 					= ""; 
$state 					= ""; 
$lat 					= ""; 
$long 					= ""; 
$diasporaVersion		= ""; 
$whois 					= ""; 
$userRating 			= ""; 
$xdver 					= ""; 
$registrationsOpen		= ""; 
$totalUsers 			= ""; 
$activeUsersHalfyear 	= "";
$activeUsersMonthly 	= ""; 
$localPosts 			= ""; 
$podName 				= ""; 
MatrixCrawler's avatar
MatrixCrawler committed
415

MatrixCrawler's avatar
MatrixCrawler committed
416 417 418 419 420 421
$masterVersion = Pull::getMasterVersion();
$dbh = Pull::getDatabaseConnection();

// Check if the pullrequest is made for a specific pod domain
$domain = isset($_GET['domain']) ? $_GET['domain'] : null;
$result = Pull::getPodList($domain, $dbh);
David Morley's avatar
David Morley committed
422

MatrixCrawler's avatar
MatrixCrawler committed
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
// Iterate over each Pod in the resultset
while ($row = $result->fetchAll()) {
	
	$podSecure = false;
	
	$domain = $row['domain'];
	$score = $row['score'];
	//$datecreated = $row['datecreated']; Not used
	$adminRating = $row['adminrating'];
	
	if (DEBUG) {
		echo("Pod: <b>".$domain."</b><br />");
	}
	// Get Ratings for Pod
	Pull::getRatings($adminRating, $userRating, $domain, $dbh);
	
	// Get Header from Pod
	if (!$header = Pull::getCurlResult("https://".$domain."/statistics.json")) {
		// No https connection possible, try http instead
		$header = Pull::getCurlResult("http://".$domain."/statistics.json");
	} else {
		// Got https connection. Pod seems to be secure
		$podSecure = true;
	}
	
	if (DEBUG) {
		if ($podSecure) {
			echo "Pod has SSL connection<br />";
		} else {
			echo "Pod has no SSL connection<br />";
		}
		echo "Pod Header: ".$header."<br />";
	}
	
	if ($header) {
		// Parse Header Data, if there is a header
		Pull::parseHeader($header, $gitdate, $gitrev, $xdver, $diasporaVersion, $runtime, $server, $encoding);
		Pull::parseJSON($header, $podName, $registrationsOpen, $totalUsers, $activeUsersHalfyear, $activeUsersMonthly, $localPosts);
		
		if (!$diasporaVersion) {
			// No Diaspora-Version identifier. might not be trustable?
			$score -= 2;
			if (DEBUG) {
				echo("No Diaspora Version-identifier. Reducing points.<br />");
			}	
		} else {
			$score++;
			if (DEBUG) {
				echo("Everything allright. Increasing points.<br />");
			}
		}
	} else {
		// No header, no connection
		$score--;
		if (DEBUG) {
			echo("No header. Reducing points.<br />");
		}
	}
	
	if ($score > 5) {
		$hidden = "no";
	} else {
		$hidden = "yes";
	}
	
	if (DEBUG) {
		echo "Hidden: ".$hidden;
	}
	
	Pull::capScore($score);
	$ip6num = Pull::getIPv6($domain);
	if ($ip6num == '') {
		$podHasIPv6 = "no";
	} else {
		$podHasIPv6 = "yes";
	}
	$ipnum = Pull::getIPv4($domain);
	Pull::getGeoIPData($ipnum, $whois, $country, $city, $lat, $long);
	Pull::getRobotData($row['pingdomurl'], $responsetime, $months, $uptime, $live, $score);
	Pull::writeData($dbh, $gitdate, $encoding, $secure, $hidden, $runtime, $gitrev, $ipnum, $ipv6, $months, $uptime, $live, $pingdomdate, $timenow, $responsetime, $score, $adminRating, $country, $city, $state, $lat, $long, $diasporaVersion, $whois, $userRating, $xdver, $masterVersion, $registrationsOpen, $totalUsers, $activeUsersHalfyear, $activeUsersMonthly, $localPosts, $podName, $domain);	
	
	if (DEBUG) {
		echo "<br />Score out of 20: ".$score."<br />";
		echo "Success <br />";
	}
	
} // end while	
unset($dbh);
511
?>