| Linux hosting5.siteguarding.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64 Path : /home/devsafetybis/j4412.dev.safetybis.com/administrator/components/com_geoprotection/ |
| Current File : /home/devsafetybis/j4412.dev.safetybis.com/administrator/components/com_geoprotection/script.php |
<?php
/**
* @package GEO Protection
* @copyright Copyright (C) 2020 SiteGuarding.com. All rights reserved.
* @GNU General Public License
*/
defined('_JEXEC') or die('Restricted access');
class com_geoprotectionInstallerScript
{
function install($parent)
{
jimport('joomla.installer.installer');
$src_plugins = dirname(__FILE__). DIRECTORY_SEPARATOR .'plugin';
$installer = new JInstaller;
$result = $installer->install($src_plugins);
$db = JFactory::getDBO();
$db->setQuery("UPDATE #__extensions SET enabled = '1' WHERE `element` = 'geoprotection' AND `type` = 'plugin'");
$db->execute();
$this->API_Request(1);
}
function uninstall($parent)
{
jimport('joomla.installer.installer');
$db = JFactory::getDBO();
$db->setQuery('SELECT `extension_id` FROM #__extensions WHERE `type` = "plugin" AND `element` = "geoprotection" AND `folder` = "system"');
$id = $db->loadResult();
if($id)
{
$installer = new JInstaller;
$result = $installer->uninstall('plugin', $id , 1);
}
$this->API_Request(3);
}
public function sendRequest($url, $request, $method = 'POST', $headers = false) {
if (is_array($request)) $request = http_build_query($request);
$method = strtoupper($method);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
switch($method) {
case 'POST':
case 'PATCH':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
break;
case 'DELETE':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
break;
}
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
if ($headers) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$ch_error = curl_error($ch);
if (!empty($ch_error)) {
return array('status' => 'error', 'reason' => $ch_error, 'report_url' => '');
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($method == 'DELETE') return $httpCode;
return @json_decode($response, true);
}
public function API_Request($type = '')
{
$plugin_code = 28;
$website_url = JURI::root();
$url = "https://www.siteguarding.com/ext/plugin_api/index.php";
$data = array(
'action' => 'inform',
'website_url' => $website_url,
'action_code' => $type,
'plugin_code' => $plugin_code,
);
$result = $this->sendRequest($url, $data);
}
}