| Server IP : 54.36.91.62 / Your IP : 216.73.217.94 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/c/o/o/coopiak/dansnotreville-fr/nice/plugins/system/tgeoip/field/ |
Upload File : |
<?php
/**
* @package EngageBox
* @version 6.1.3 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
// No direct access to this file
defined('_JEXEC') or die;
use NRFramework\User;
class JFormFieldTG_Lookup extends JFormField
{
/**
* GeoIP Class
*
* @var object
*/
private $geoIP;
/**
* Method to render the input field
*
* @return string
*/
public function getInput()
{
// JavaScript
$ajaxURL = JURI::base() . 'index.php?option=com_ajax&format=raw&plugin=tgeoip&task=get&' . JSession::getFormToken() . '=1';
JFactory::getDocument()->addScriptDeclaration('
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("click", function(e) {
var btn = e.target.closest(".tGeoIPtest button");
if (!btn) {
return;
}
e.preventDefault();
ip = document.querySelector(".tGeoIPtest input").value;
if (!ip) {
alert("Please enter a valid IP address");
return false;
}
var data = new FormData();
data.append("ip", ip);
fetch("' . $ajaxURL . '",
{
method: "POST",
body: data
})
.then(function(res){ return res.json(); })
.then(function(response){
if (response) {
if (response.continent) {
document.querySelector(".tGeoIPtest .continent").innerHTML = response.continent.names.en;
}
if (response.city) {
document.querySelector(".tGeoIPtest .city").innerHTML = response.city.names.en;
}
if (response.country) {
document.querySelector(".tGeoIPtest .country").innerHTML = response.country.names.en;
document.querySelector(".tGeoIPtest .country_code").innerHTML = response.country.iso_code;
}
document.querySelector(".tGeoIPtest .results").style.display = "block";
} else {
alert("Invalid IP address");
document.querySelector(".tGeoIPtest .results").style.display = "none";
}
})
return false;
})
});
');
// HTML
$ip = User::getIP();
return '<div class="tGeoIPtest">
<input class="form-control input-medium" type="text" value="' . $ip . '"/>
<button class="btn btn-outline-secondary">Lookup</button>
<ul class="results" style="margin-top:20px; display:none;">
<li>Continent: <span class="continent"></span></li>
<li>Country: <span class="country"></span></li>
<li>Country Code: <span class="country_code"></span></li>
<li>City: <span class="city"></span></li>
<ul>
</div>';
}
}