Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 690

User Location and IP details Info Box

$
0
0
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');"

$url='https://api.ipify.org/';
$ip = file_get_contents($url);
$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>&nbsp; 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>&nbsp; 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>&nbsp; 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>&nbsp; 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>&nbsp; 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>&nbsp; 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 Big Grin

Viewing all articles
Browse latest Browse all 690

Trending Articles