2021-07-23, 04:50 AM
(This post was last modified: 2021-07-23, 04:09 PM by venomgrills. Edited 1 time in total.)
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]
So first of all go to you index.php file and add this code before "$plugins->run_hooks('index_end');"
Now Go to acp > template and style > index template and add this code wherever you want this box to be displayed:
And You are done!!! Please reply for any suggestions or queries!!
Warm Regards,
Venom
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]
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"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_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;
}
else
{
$ip = $remote;
}
return $ip;
}
$ip = getUserIP();
$ch = curl_init('http://ipwhois.app/json/'.$ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($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;">
<tbody>
<tr>
<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>
</span></td>
</tr>
<tr>
<td class="trow1" width="100%"><font color="white"><i class="fas fa-server" aria-hidden="true"></i> Your IP:</font></td>
<td class="trow1" width="100%"><font color="white">{$ip}</font></td>
</tr>
<tr>
<td class="trow1" width="100%"><font color="white"><i class="fas fa-globe-africa" aria-hidden="true"></i> Your Country Code:</font></td>
<td class="trow1" width="100%"><font color="white">{$cc}</font></td>
</tr>
<tr>
<td class="trow1" width="100%"><font color="white"><i class="fas fa-user-clock" aria-hidden="true"></i> Your Timezone:</font></td>
<td class="trow1" width="100%"><font color="white">{$tz}</font></td>
</tr>
<tr>
<td class="trow1" width="100%"><font color="white"><i class="fas fa-server" aria-hidden="true"></i> Your Region:</font></td>
<td class="trow1" width="100%"><font color="white">{$region}</font></td>
</tr>
<tr>
<td class="trow1" width="100%"><font color="white"><i class="fas fa-city" aria-hidden="true"></i> Your City:</font></td>
<td class="trow1" width="100%"><font color="white">{$city}</font></td>
</tr>
<tr>
<td class="trow1" width="100%"><font color="white"><i class="fas fa-money-bill-wave" aria-hidden="true"></i> Your Currency:</font></td>
<td class="trow1" width="100%"><font color="white">{$money}</font></td>
</tr>
</tbody>
</table>
And You are done!!! Please reply for any suggestions or queries!!
Warm Regards,
Venom