<pre>
<?php
require ("../../../configuration.php");
require_once('config_update.php');
require_once('functions.php');

$db = mysqli_connect($db_host,$db_username,$db_password);
mysqli_select_db($db, $db_name);

$query = mysqli_query($db, "SELECT * FROM `tbldomains` WHERE `expirydate` = '0000-00-00' AND `registrar` = 'hyperhosting'");

while($myrow = mysqli_fetch_assoc($query)){

$domain = explode(".",$myrow["domain"]);

	$params["HYP_action"] = "checknameserver";
	$params["tld"] = $domain[1];
	$params["sld"] = $domain[0];

	$ret_data = postdata($params);	
	$linkdown   = 'Connection refused';
	$pos = strpos($ret_data, $linkdown);
	
	// Note our use of ===.  Simply == would not work as expected
	// because the position of 'a' was the 0th (first) character.
	if($domain[1] == "gr"){
	$resdata = json_decode($ret_data, true);
	
	}elseif($domain[1] == "eu"){
	
	$splited = explode("{",$ret_data);
	$resdata = json_decode("{".$splited[1], true);
	}
	$values["error"] = $resdata["error"];
	$values["ns1"] = $resdata["ns1"];
	$values["ns2"] = $resdata["ns2"];
	$values["ns3"] = $resdata["ns3"];
	$values["ns4"] = $resdata["ns4"];
	$values["expdate"] = $resdata["expdate"];
	$values["regdate"] = $resdata["regdate"];

	if(!$pos && ($resdata["expdate"] != "--" || $resdata["expdate"] != "0000-00-00"))
	{
		mysqli_query($db, "UPDATE `tbldomains` SET `registrationdate` = '".$resdata["regdate"]."', `expirydate` = '".$resdata["expdate"]."',
					`nextduedate` = '".$resdata["expdate"]."', `nextinvoicedate` = '".$resdata["expdate"]."', `status` = 'Active' WHERE `domain` = '".$myrow["domain"]."'");
	}
}
?>
Domain Sync Completed.
</pre>