Server : LiteSpeed System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : alsaif ( 1057) PHP Version : 7.4.33 Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/alsaif/domains/alsaif.group/public_html/plugins/system/tgeoip/ |
<?php
/**
* @package Convert Forms
* @version 4.3.3 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2024 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Language\Text;
class plgSystemTGeoIP extends CMSPlugin
{
/**
* Joomla Application Object
*
* @var object
*/
protected $app;
/**
* Auto load plugin language
*
* @var boolean
*/
protected $autoloadLanguage = true;
/**
* GeoIP Class
*
* @var object
*/
private $geoIP;
/**
* Load GeoIP Classes
*
* @return void
*/
private function loadGeoIP()
{
$path = JPATH_PLUGINS . '/system/tgeoip';
if (!class_exists('TGeoIP'))
{
if (@file_exists($path . '/helper/tgeoip.php'))
{
if (@include_once($path . '/vendor/autoload.php'))
{
@include_once $path . '/helper/tgeoip.php';
}
}
}
$this->geoIP = new TGeoIP();
}
/**
* Listens to AJAX requests on ?option=com_ajax&format=raw&plugin=tgeoip
*
* @return void
*/
public function onAjaxTgeoip()
{
Session::checkToken('request') or die('Invalid Token');
// Only in admin
if (!$this->app->isClient('administrator'))
{
return;
}
$this->loadGeoIP();
$task = $this->app->input->get('task', 'update');
$this->geoIP->setKey($this->app->input->get('license_key', ''));
switch ($task)
{
// Update database and redirect
case 'update-red':
$result = $this->geoIP->updateDatabase();
if ($result === true)
{
$msg = Text::_('PLG_SYSTEM_TGEOIP_DATABASE_UPDATED');
$msgType = 'message';
} else
{
$msgType = 'error';
$msg = $result;
}
$return = base64_decode($this->app->input->get->getBase64('return', null));
$this->app->enqueueMessage($msg, $msgType);
$this->app->redirect($return);
break;
// Update database
case 'update':
echo $this->geoIP->updateDatabase();
break;
// IP Lookup
case 'get':
$ip = $this->app->input->get('ip');
echo json_encode($this->geoIP->setIP($ip)->getRecord());
break;
}
}
}