503, 'wordpress.nintechnet.com/index.php' => 200, 'pro.nintechnet.com/index.php' => 200 ); foreach( $urls as $url => $res_code ) { // HTTP: // connect2site( $url, $res_code, 'http' ); // HTTPS: connect2site( $url, $res_code, 'https' ); } /* ================================================================== */ function connect2site( $url, $res_code, $proto ) { echo "Attempting to connect to {$url} ({$proto}): "; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ninja-connect {$version})" ); curl_setopt( $ch, CURLOPT_ENCODING, ''); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 ); curl_setopt( $ch, CURLOPT_TIMEOUT, 10 ); curl_setopt( $ch, CURLOPT_URL, "{$proto}://{$url}" ); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); if ( ( $content = curl_exec( $ch ) ) === FALSE ) { $CURL_ERR = curl_error( $ch ); $CURL_ERR_NUM = curl_errno( $ch ); echo "ERROR {$CURL_ERR_NUM}: {$CURL_ERR}\n"; @curl_close( $ch ); return; } $response = curl_getinfo( $ch ); curl_close( $ch ); if ( $response['http_code'] != $res_code ) { echo "ERROR: returned HTTP code is {$response['http_code']}, not {$res_code}\n"; return; } echo "OK\n"; } echo "\n\nNinjaFirewall (WP edition) connection test script v{$version}\n"; exit; /* ================================================================== */ // EOF