<?php
ob_start();
error_reporting(E_ERROR | E_PARSE);
ini_set('display_errors', '1');
require_once '../../includes/functions.php';
chkSession();
$values = array();
if($user_id_2 == 1 || $user_level_2 == 'superadmin' || $user_level_2 == 'developer'){
}else{
	echo "<script> swal({ title: 'Error!' , text: 'Sorry, you dont have permission to access this page.', button: false, closeOnClickOutside: false, icon: 'error' })  </script>";
	$db->RedirectToURL($db->base_url());
	exit;
}
    $key = strip_tags(trim($_GET['key']));
    
    $server = $db->sql_query("SELECT server_ip, status FROM server_list");
	while($server_row= $db->sql_fetchrow($server ))
	{
		$server_ip = $server_row['server_ip'];
		$server_status = $server_row['status'];
		
		$fp = fsockopen($server_ip, 80, $errno, $errstr, 20);
		
		if($fp)
		{
			$chk_premium_parser = '1';
		}else{
		    if($server_status == '99'){
		        $chk_premium_parser = '99';
		    }elseif($server_status == '98'){
		        $chk_premium_parser = '98';
		    }else{
		        $chk_premium_parser = '0';
		    }
		}
		
		$db->sql_query("UPDATE server_list SET status = '".$chk_premium_parser."' WHERE server_ip = '".$server_ip."'");
		
		fclose($fp);
	}
    
?>