first commit
This commit is contained in:
83
plugins/installer/jce/jce.php
Normal file
83
plugins/installer/jce/jce.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c)2016 - 2020 Ryan Demmer
|
||||
* @license GNU General Public License version 2, or later
|
||||
*/
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Handle commercial extension update authorization.
|
||||
*
|
||||
* @since 2.6
|
||||
*/
|
||||
class plgInstallerJce extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Handle adding credentials to package download request.
|
||||
*
|
||||
* @param string $url url from which package is going to be downloaded
|
||||
* @param array $headers headers to be sent along the download request (key => value format)
|
||||
*
|
||||
* @return bool true if credentials have been added to request or not our business, false otherwise (credentials not set by user)
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function onInstallerBeforePackageDownload(&$url, &$headers)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$uri = JUri::getInstance($url);
|
||||
$host = $uri->getHost();
|
||||
|
||||
if ($host !== 'www.joomlacontenteditor.net') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the subscription key
|
||||
JLoader::import('joomla.application.component.helper');
|
||||
$component = JComponentHelper::getComponent('com_jce');
|
||||
|
||||
// load plugin language for warning messages
|
||||
JFactory::getLanguage()->load('plg_installer_jce', JPATH_ADMINISTRATOR);
|
||||
|
||||
// check if the key has already been set via the dlid field
|
||||
$dlid = $uri->getVar('key', '');
|
||||
|
||||
// check the component params, fallback to the dlid
|
||||
$key = $component->params->get('updates_key', $dlid);
|
||||
|
||||
// if no key is set...
|
||||
if (empty($key)) {
|
||||
// if we are attempting to update JCE Pro, display a notice message
|
||||
if (strpos($url, 'pkg_jce_pro') !== false) {
|
||||
$app->enqueueMessage(JText::_('PLG_INSTALLER_JCE_KEY_WARNING'), 'notice');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Append the subscription key to the download URL
|
||||
$uri->setVar('key', $key);
|
||||
|
||||
// create the url string
|
||||
$url = $uri->toString();
|
||||
|
||||
// check validity of the key and display a message if it is invalid / expired
|
||||
try
|
||||
{
|
||||
$tmpUri = clone $uri;
|
||||
|
||||
$tmpUri->setVar('task', 'update.validate');
|
||||
$tmpUri->delVar('file');
|
||||
$tmpUrl = $tmpUri->toString();
|
||||
$response = JHttpFactory::getHttp()->get($tmpUrl, array());
|
||||
} catch (RuntimeException $exception) {}
|
||||
|
||||
// invalid key, display a notice message
|
||||
if (403 == $response->code) {
|
||||
$app->enqueueMessage(JText::_('PLG_INSTALLER_JCE_KEY_INVALID'), 'notice');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
19
plugins/installer/jce/jce.xml
Normal file
19
plugins/installer/jce/jce.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.8" type="plugin" group="installer" method="upgrade">
|
||||
<name>plg_installer_jce</name>
|
||||
<version>2.9.32</version>
|
||||
<creationDate>01-11-2022</creationDate>
|
||||
<author>Ryan Demmer</author>
|
||||
<authorEmail>info@joomlacontenteditor.net</authorEmail>
|
||||
<authorUrl>http://www.joomlacontenteditor.net</authorUrl>
|
||||
<copyright>Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved</copyright>
|
||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||
<description>PLG_INSTALLER_JCE_XML_DESCRIPTION</description>
|
||||
<files folder="plugins/installer/jce">
|
||||
<filename plugin="jce">jce.php</filename>
|
||||
</files>
|
||||
<languages folder="administrator/language/en-GB">
|
||||
<language tag="en-GB">en-GB.plg_installer_jce.ini</language>
|
||||
<language tag="en-GB">en-GB.plg_installer_jce.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
Reference in New Issue
Block a user