This repository was archived by the owner on Dec 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathListener.php
More file actions
82 lines (73 loc) · 2.32 KB
/
Listener.php
File metadata and controls
82 lines (73 loc) · 2.32 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
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
<?php
/*
* This file is part of a XenForo add-on.
*
* (c) Jeremy P <https://xenforo.com/community/members/jeremy-p.450/>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
namespace Jrahmy\DeferJs;
/**
* Provides static methods to extend the XenForo API.
*
* @author Jeremy P <https://xenforo.com/community/members/jeremy-p.450/>
*/
class Listener
{
/**
* Alters front controller output.
*
* @param \XenForo_FrontController $frontController The XenForo front controller
* @param string $output The view output
*/
public static function frontControllerPostView(\XenForo_FrontController $frontController, &$output)
{
// only run on public pages
if (!$frontController->getDependencies() instanceof
\XenForo_Dependencies_Public
) {
return;
}
// disable for attachment output (in case of HTML attachments)
if ($frontController->route()->getControllerName() ===
'XenForo_ControllerPublic_Attachment'
) {
return;
}
// only run on html pages
if (strpos($output, '<html') === false) {
return;
}
// chrome xss auditor blocks with deferred wysiwyg on post request
$wysiwyg = (strpos($output, 'redactor') or strpos($output, 'tinymce'));
if ($frontController->getRequest()->isPost() and $wysiwyg) {
return;
}
// get blacklist from backend
$blacklist = explode(
"\n",
str_replace(
"\r",
'',
trim(
\XenForo_Application::getOptions()->jrahmy_deferJs_blacklist
)
)
);
$deferrer = new Deferrer($output, $blacklist);
$output = $deferrer->defer();
}
/**
* Adds filesums to the XenForo File Health Check.
*
* @param \XenForo_ControllerAdmin_Abstract $controller The current admin controller
* @param array $hashes An array of filesums
*/
public static function fileHealthCheck(
\XenForo_ControllerAdmin_Abstract $controller,
array &$hashes
) {
$hashes += FileSums::getHashes();
}
}