function __construct($db)
 {
     $this->db = $db;
     $this->request_cache = array();
     $this->params_cache = array();
     $this->params_cache['game_data_version'] = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'GAME_INFO', 'DATA_VERSION');
     $this->params_cache['game_name'] = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'GAME_INFO', 'NAME');
     $this->params_cache['client_build'] = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'CLIENT', 'BUILD');
     $this->params_cache['client_version'] = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'CLIENT', 'VERSION');
     $this->params_cache['api_version'] = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'API', 'VERSION');
     $url_base = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'URL_BASE');
     $hmac_key = PgrmConfigDAO::getConfigProperty($this->db, 'value1', 'TOKENS', 'HMAC_KEY');
     $proxies = ProxyDAO::getActiveProxies($this->db);
     $this->ws = new WarOfnationsWS($this->db, $proxies, $url_base, $hmac_key);
 }
<?php

require_once dirname(__FILE__) . '/classes/data/DatabaseFactory.class.php';
require_once dirname(__FILE__) . '/classes/data/Proxy.class.php';
$debug = false;
// This is the page that that we're going to request going through the proxy
$testpage = "http://gcand.gree-apps.net/hc//index.php/json_gateway";
$checktext = "Json_gateway?svc=";
// This loads all the proxies from the file into an array
$db = DatabaseFactory::getDatabase();
//$proxies = ProxyDAO::getActiveProxies($db);
// Test each of our proxies 10 times
for ($i = 0; $i < 10; $i++) {
    // Reload the proxy list each time through in case we've deactivated something - this will speed up testing.
    $proxies = ProxyDAO::getActiveProxies($db);
    // Here we loop through each cell of the array with the proxies in them testing each one until we get to the end of the array
    foreach ($proxies as $proxy) {
        // Concatenate the proxy string
        $proxy_str = "{$proxy['ip_address']}:{$proxy['port']}";
        // This script utilizes cURL which is library you can read more about
        //using curl in my intro tutorials
        // starting curl and setting the page to get
        $ch = curl_init($testpage);
        // sets the proxy to go through
        curl_setopt($ch, CURLOPT_PROXY, $proxy_str);
        if ($proxy['type'] == 'SOCKS') {
            curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);