Created
July 3, 2016 02:07
-
-
Save 3D-I/6625b4172bbfa511b37224aff0e5e634 to your computer and use it in GitHub Desktop.
Used to debug IPCF cURL - 1.0.0-dev-v0002
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Usage: Download and unzip the file, upload it to your Board's root (i.e.: www.mydomain.com/phpBB3/) | |
* Point your browser to i.e.: www.mydomain.com/phpBB3/ipcfcurl.php - results will be on your screen | |
* @package - IPCF tests | |
* @copyright (c) 2016 3Di (Marco T.) 01-jul-2016 | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 | |
*/ | |
define('IN_PHPBB', true); | |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; | |
$phpEx = substr(strrchr(__FILE__, '.'), 1); | |
include($phpbb_root_path . 'common.' . $phpEx); | |
// Start session management | |
$user->session_begin(); | |
$auth->acl($user->data); | |
$user->ip = '212.233.111.121'; //russia | |
//$user->ip = '0.0.0.1'; //status = fail | |
//$user->ip = '127.0.0.1'; //false | |
/** | |
* Returns whether cURL is available | |
* | |
* @return bool | |
*/ | |
function is_curl() | |
{ | |
return function_exists('curl_version'); | |
} | |
$is_curl = is_curl(); | |
if ($is_curl) | |
{ | |
echo 'cURL is TRUE!';; | |
} | |
else | |
{ | |
echo 'cURL is FALSE!';; | |
} | |
/* Some code borrowed from david63's Cookie Policy ext */ | |
$curl_handle = curl_init(); | |
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); | |
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); | |
/** | |
* 16386 = countryCode,status fields, using magic numbers to save bandwidth | |
*/ | |
curl_setopt($curl_handle, CURLOPT_URL, 'http://ip-api.com/json/' . $user->ip . '?fields=16386'); | |
$ip_query = curl_exec($curl_handle); | |
curl_close($curl_handle); | |
var_dump($ip_query); | |
if (!empty($ip_query)) | |
{ | |
/* Creating an array from string */ | |
$ip_array = json_decode($ip_query, true); | |
if ($ip_array['status'] == 'success') | |
{ | |
echo 'success -> flag'; | |
} | |
else if ($ip_array['status'] != 'success') | |
{ | |
echo 'fail -> WO'; | |
} | |
} | |
else | |
{ | |
echo 'server outage -> WO'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment