forked from brianteeman/haraka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
haraka.php
132 lines (117 loc) · 3.31 KB
/
haraka.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* @package haraka
* @author Brian Teeman
* @copyright (C) 2016 - Brian Teeman
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
defined('_JEXEC') or die;
/**
* Haraka Plugin by Brian Teeman
*
* @since 1.0.0
*/
class plgSystemHaraka extends JPlugin
{
/**
* Application object.
*
* @var JApplicationCms
* @since 1.0.0
*/
protected $app;
/**
* Load plugin language files automatically
*
* @var boolean
* @since 1.0.0
*/
protected $autoloadLanguage = true;
/**
* Redirect variable
*
* @var boolean
* @since 1.0.0
*/
private $redirect = false;
/**
* Display the Haraka
*
* @return void
*
* @since 1.0.0
*/
private function displayHaraka()
{
$display_haraka = false;
$secret = trim($this->params->get('secret', ''));
$whitelist = trim($this->params->get('whitelist', ''));
if ($secret)
{
$storedSecret = $this->app->getUserState($this->_name . '.secret', 0);
if ($storedSecret === $secret)
{
$display_haraka = true;
}
else
{
$this->app->setUserState($this->_name . '.secret', 0);
$secretRequest = $this->app->getUserStateFromRequest($this->_name . '.secret', $secret, 0);
if ($secretRequest == 1)
{
$this->app->setUserState($this->_name . '.secret', $secret);
$display_haraka = true;
}
}
}
if (!$display_haraka && $whitelist)
{
$ip_whitelist = preg_split('/\s*\n\s*/', $whitelist);
$display_haraka = in_array($this->app->input->server->get('REMOTE_ADDR'), $ip_whitelist);
}
if (!$display_haraka)
{
$bgimage_url = JUri::base() . 'media/plg_haraka/images/' . $this->params->get('bgimage', 'comingsoon.jpg');
$caption = $this->params->get('caption', '');
$countdown = $this->params->get('countdown', 1);
$countdown_date = $this->params->get('countdown_date', '');
$fonts = $this->params->get('fonts', 'Roboto+Slab|Roboto');
$font = explode("|", $fonts);
$fontcss = str_replace('+',' ', $font);
$text = $this->params->get('text', '<p>' . JText::_('PLG_SYSTEM_HARAKA_COMING_SOON') . '</p>');
$theme = $this->params->get('theme', 'light');
$uri = JUri::getInstance();
// Meta
$meta_desc = $this->params->get('meta_desc', $this->app->get('MetaDesc'));
$meta_keys = $this->params->get('meta_keys', $this->app->get('MetaKeys'));
$title = $this->params->get('title', $this->app->get('sitename'));
$robots = $this->params->get('robots', $this->app->get('robots'));
// Social Media
$facebook = $this->params->get('facebook', '');
$facebook_url = 'https://facebook.com/' . $facebook;
$instagram = $this->params->get('instagram', '');
$instagram_url = 'https://instagram.com/' . $instagram;
$twitter = $this->params->get('twitter', '');
$twitter_url = 'https://twitter.com/' . $twitter;
$youtube = $this->params->get('youtube', '');
$youtube_url = 'https://youtube.com/' . $youtube;
$path = JPluginHelper::getLayoutPath('system', 'haraka');
include $path;
$this->app->close();
}
}
/**
* Listener for the `onAfterInitialise` event
*
* @return void
*
* @since 1.0.0
*/
public function onAfterInitialise()
{
if ($this->app->isSite())
{
$this->displayHaraka();
}
}
}