[For 1.8] User Location and IP details Info Box
Heya Guys!
This is my first tutorial so just don't judge me please.
Recently I started learning php and made some small codes to work with mybb.So here I will share you the tutorial of a side box where user can see his IP and it's basic details like location, country code, timezone, currency, region etc.Something like this:

[url=https://imgbb.com/][/url][Image: User-Info-Display-box.png]

So first of all go to you index.php file and add this code before "$plugins->run_hooks('index_end');"

function getUserIP()
    // Get real visitor IP behind CloudFlare network
    if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
        $ip = $client;
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
        $ip = $forward;
        $ip = $remote;

    return $ip;

$ip = getUserIP();

$ch = curl_init('http://ipwhois.app/json/'.$ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);

// Decode JSON response
$ipwhois_result = json_decode($json, true);

// Country code output, field "country_code"
$cc = $ipwhois_result['country_code'];
$isp = $ipwhois_result['isp'];
$tz = $ipwhois_result['timezone'];
$money = $ipwhois_result['currency'];
$region = $ipwhois_result['region'];
$city = $ipwhois_result['city'];

Now Go to acp > template and style > index template and add this code wherever you want this box to be displayed:

<table border="0" cellspacing="0" cellpadding="5" class="tborder" style="width: 100%; float: right; margin-bottom: 10px;">
		<td class="thead" colspan="5" width="100%" style="background: #47CB14; color: #fff; background-image: url(https://venomgrills.com/images/dvz_bg.png); background-size: cover;">
	<span style="padding: 4px 10px; background: rgba(0,0,0,0.13); border-radius: 2px;">
    <strong>Your Info</strong>
			<td class="trow1" width="100%"><font color="white"><i class="fas fa-server" aria-hidden="true"></i>&nbsp; Your IP:</font></td>
			<td class="trow1" width="100%"><font color="white">{$ip}</font></td>
			<td class="trow1" width="100%"><font color="white"><i class="fas fa-globe-africa" aria-hidden="true"></i>&nbsp; Your Country Code:</font></td>
			<td class="trow1" width="100%"><font color="white">{$cc}</font></td>
			<td class="trow1" width="100%"><font color="white"><i class="fas fa-user-clock" aria-hidden="true"></i>&nbsp; Your Timezone:</font></td>
			<td class="trow1" width="100%"><font color="white">{$tz}</font></td>
			<td class="trow1" width="100%"><font color="white"><i class="fas fa-server" aria-hidden="true"></i>&nbsp; Your Region:</font></td>
			<td class="trow1" width="100%"><font color="white">{$region}</font></td>
			<td class="trow1" width="100%"><font color="white"><i class="fas fa-city" aria-hidden="true"></i>&nbsp; Your City:</font></td>
			<td class="trow1" width="100%"><font color="white">{$city}</font></td>
			<td class="trow1" width="100%"><font color="white"><i class="fas fa-money-bill-wave" aria-hidden="true"></i>&nbsp; Your Currency:</font></td>
			<td class="trow1" width="100%"><font color="white">{$money}</font></td>

And You are done!!! Please reply for any suggestions or queries!!

Warm Regards,
Venom Big Grin

Forum Jump:

Users browsing this thread: 1 Guest(s)