<?
// Renewal Code
$renewal_result = mysql_query("SELECT * FROM members");
while($renewal = mysql_fetch_object($renewal_result)){
																				
	$renew = $renewal->renew;

	if($renew <= date("z")){
		
		while($renew <= date("z")){
			$renew = $renew + 30;
		}
		
		if($renew > 365){
			$renew = $renew - 365;
		}
		
		$sql = "UPDATE members SET renew='$renew',used_bandwidth='0',cycle_views='0' WHERE member_id = '$renewal->member_id'";
		$result = mysql_query($sql);
	}
	else if(date("z") + 30 < $renew){
		
		$renew = $renew - 365;
		
		while($renew < date("z")){
			$renew = $renew + 30;
		}
		
		$sql = "UPDATE members SET renew='$renew',used_bandwidth='0',cycle_views='0' WHERE member_id = '$renewal->member_id'";
		$result = mysql_query($sql);
	}
}
?>