monthlyarchive.php
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/* ======================================================
# Monthly Archive - Joomla! Component v4.3.3 (PRO version)
# -------------------------------------------------------
# For Joomla! 3.x
# Author: Yiannis Christodoulou (yiannis@web357.eu)
# Copyright (©) 2009-2018 Web357. All rights reserved.
# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
# Website: https://www.web357.eu/
# Demo: http://demo.web357.eu/?item=monthlyarchive
# Support: support@web357.eu
# Last modified: 09 Feb 2018, 13:55:18
========================================================= */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class plgSystemMonthlyarchive extends JPlugin
{
public function onInstallerBeforePackageDownload(&$url, &$headers)
{
$uri = JUri::getInstance($url);
// I don't care about download URLs not coming from our site
$host = $uri->getHost();
if ($host != 'downloads.web357.eu'):
return true;
endif;
// fetch download id from extension parameters
JLoader::import('joomla.application.component.helper');
$component = JComponentHelper::getComponent('com_monthlyarchive');
$download_id = $component->params->get('download_id', '');
// Append the Download ID to the download URL
if (!empty($download_id)):
$current_url = JURI::getInstance()->toString();
$parse = parse_url($current_url);
$domain = isset($parse['host']) ? $parse['host'] : 'domain.com';
$uri->setVar('liveupdate', 'true');
$uri->setVar('domain', $domain);
$uri->setVar('dlid', $download_id);
$url = $uri->toString();
endif;
return true;
}
}