Version Description
Download this release
Release Info
Developer | Facens |
Plugin | iubenda Cookie Solution for GDPR |
Version | 1.14.0-beta4 |
Comparing to | |
See all releases |
Code changes from version 1.14.0-beta2 to 1.14.0-beta4
- css/admin.css +21 -128
- iubenda-cookie-class/iubenda.class.faster.php +0 -190
- iubenda-cookie-class/iubenda.class.php +0 -377
- iubenda-cookie-class/simple_html_dom.php +0 -1734
- iubenda-cookie-class/test.php +0 -118
- iubenda-cookie-class/usage.php +0 -59
- iubenda_cookie_solution.php +442 -354
- js/admin.js +16 -58
- languages/iubenda-cookie-law-solution.pot +85 -70
- readme.txt +10 -4
css/admin.css
CHANGED
@@ -3,150 +3,43 @@
|
|
3 |
|
4 |
width: 90%;
|
5 |
margin: 50px auto;
|
6 |
-
padding
|
|
|
7 |
|
8 |
border-radius: 2px;
|
9 |
background-color: #FFFFFF;
|
10 |
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1)
|
11 |
}
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
margin: 0 auto;
|
16 |
-
}
|
17 |
-
.iubenda-tab {
|
18 |
-
cursor: pointer;
|
19 |
-
|
20 |
-
display: inline-table;
|
21 |
-
padding: 10px 15px;
|
22 |
-
padding-top: 0;
|
23 |
-
margin-right: 10px;
|
24 |
-
|
25 |
-
background-color: #FFFFFF;
|
26 |
-
border-top: 2px solid #454545;
|
27 |
-
box-shadow: 0 -2px 3px 0 rgba(5, 5, 5, 0.2);
|
28 |
-
|
29 |
-
color: #454545
|
30 |
-
}
|
31 |
-
.iubenda-tab:before, .iubenda-tab::before {
|
32 |
-
content: "";
|
33 |
-
|
34 |
-
display: table;
|
35 |
-
margin: auto;
|
36 |
-
margin-bottom: 8px;
|
37 |
-
|
38 |
-
border-style: solid;
|
39 |
-
border-width: 5px 5px 0;
|
40 |
-
border-color: transparent transparent;
|
41 |
-
}
|
42 |
-
#iubenda-code-it, #iubenda-code-de, #iubenda-code-ru, #iubenda-code-es, #iubenda-code-pt-br, #iubenda-code-en, #iubenda-code-fr {
|
43 |
-
display: none;
|
44 |
-
|
45 |
-
width: 100%;
|
46 |
-
|
47 |
-
background-color: #FFFFFF;
|
48 |
-
box-shadow: 0 0 3px 0 rgba(5, 5, 5, 0.2);
|
49 |
-
}
|
50 |
-
#iubenda-information {
|
51 |
-
width: 100%;
|
52 |
-
padding-top: 25px;
|
53 |
-
padding-bottom: 25px;
|
54 |
-
|
55 |
-
|
56 |
-
text-indent: 20px;
|
57 |
-
|
58 |
-
background-color: #FFFFFF;
|
59 |
-
box-shadow: 0 0 3px 0 rgba(5, 5, 5, 0.2);
|
60 |
-
}
|
61 |
-
.iubenda-textarea {
|
62 |
-
display: block;
|
63 |
-
width: 95%; height: 300px;
|
64 |
-
margin: 20px auto;
|
65 |
-
|
66 |
-
overflow-y: scroll;
|
67 |
-
|
68 |
-
outline: none;
|
69 |
-
resize: vertical
|
70 |
-
}
|
71 |
-
.iubenda-textarea-single {
|
72 |
-
width: 100%;
|
73 |
-
box-shadow: 0 0 3px 0 rgba(5, 5, 5, 0.2);
|
74 |
-
}
|
75 |
-
[data-active-tab] {
|
76 |
-
border-color: #1FAD81;
|
77 |
-
|
78 |
-
color: #1FAD81
|
79 |
-
}
|
80 |
-
[data-active-tab]:before, [data-active-tab]::before {
|
81 |
-
border-color: #1FAD81 transparent
|
82 |
-
}
|
83 |
-
#iubenda-logo {
|
84 |
-
display: table;
|
85 |
}
|
86 |
.iubenda-link {
|
87 |
display: table;
|
88 |
-
margin:
|
89 |
-
}
|
90 |
-
#iubenda-save {
|
91 |
-
transition: background-color 300ms, box-shadow 300ms;
|
92 |
-
cursor: pointer;
|
93 |
-
|
94 |
-
display: table;
|
95 |
-
margin: 20px 0;
|
96 |
-
padding: 5px 10px;
|
97 |
-
|
98 |
-
background-color: #1FAD81;
|
99 |
-
border: none;
|
100 |
-
border-radius: 1px;
|
101 |
-
box-shadow: 0 0 3px 0 rgba(5, 5, 5, 0.2);
|
102 |
-
|
103 |
-
color: #FFFFFF
|
104 |
-
}
|
105 |
-
#iubenda-save:hover {
|
106 |
-
background-color: #199C71;
|
107 |
-
box-shadow: 0 0 4px 0 rgba(5, 5, 5, 0.5);
|
108 |
-
}
|
109 |
-
#iubenda-saved {
|
110 |
-
display: table;
|
111 |
-
margin: 10px 0;
|
112 |
-
width: 100%; height: 30px;
|
113 |
-
|
114 |
-
background-color: #199C71;
|
115 |
-
border-radius: 1px;
|
116 |
-
box-shadow: 0 0 3px 0 rgba(5, 5, 5, 0.2);
|
117 |
-
}
|
118 |
-
#iubenda-saved p {
|
119 |
-
display: table;
|
120 |
-
margin: 10px;
|
121 |
-
|
122 |
-
color: #FFFFFF
|
123 |
}
|
124 |
.iubenda-text {
|
125 |
-
|
126 |
-
width: 80%;
|
127 |
-
margin: 5px auto;
|
128 |
-
|
129 |
color: #434149
|
130 |
}
|
131 |
-
|
132 |
-
|
|
|
|
|
133 |
margin-top: 10px;
|
134 |
-
|
135 |
-
font-weight: bold;
|
136 |
}
|
137 |
-
|
138 |
-
display: inline-table;
|
139 |
margin-bottom: 10px;
|
140 |
}
|
141 |
-
#
|
142 |
-
|
|
|
|
|
143 |
}
|
144 |
-
#
|
145 |
-
margin-
|
146 |
}
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
margin-top: 0;
|
151 |
-
line-height: 1.2;
|
152 |
}
|
3 |
|
4 |
width: 90%;
|
5 |
margin: 50px auto;
|
6 |
+
padding: 50px 6%;
|
7 |
+
box-sizing: border-box;
|
8 |
|
9 |
border-radius: 2px;
|
10 |
background-color: #FFFFFF;
|
11 |
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1)
|
12 |
}
|
13 |
+
.iubenda-title {
|
14 |
+
margin-top: 10px;
|
15 |
+
font-weight: bold;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
.iubenda-link {
|
18 |
display: table;
|
19 |
+
margin: 0 auto 40px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
.iubenda-text {
|
22 |
+
margin: 10px auto;
|
|
|
|
|
|
|
23 |
color: #434149
|
24 |
}
|
25 |
+
#iubenda-tabs {
|
26 |
+
margin: 30px auto 20px;
|
27 |
+
}
|
28 |
+
#iub_parser_engine_container {
|
29 |
margin-top: 10px;
|
|
|
|
|
30 |
}
|
31 |
+
#iub_parser_engine_container > div:not(:last-child) {
|
|
|
32 |
margin-bottom: 10px;
|
33 |
}
|
34 |
+
#iubenda-tabs #contextual-help-back {
|
35 |
+
right: 0;
|
36 |
+
border-top: 1px solid #e1e1e1;
|
37 |
+
border-bottom: 1px solid #e1e1e1;
|
38 |
}
|
39 |
+
#iubenda-tabs .help-tab-content {
|
40 |
+
margin-right: 0;
|
41 |
}
|
42 |
+
#iubenda-tabs .help-tab-content textarea {
|
43 |
+
margin-top: 18px;
|
44 |
+
width: 100%;
|
|
|
|
|
45 |
}
|
iubenda-cookie-class/iubenda.class.faster.php
DELETED
@@ -1,190 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* iubenda.class.php
|
5 |
-
* version: 2.0.2
|
6 |
-
* codename: Faster
|
7 |
-
* @author: Copyright 2015 iubenda
|
8 |
-
* @license GNU/GPL
|
9 |
-
* This program is free software: you can redistribute it and/or modify
|
10 |
-
* it under the terms of the GNU General Public License as published by
|
11 |
-
* the Free Software Foundation, either version 3 of the License, or
|
12 |
-
* (at your option) any later version.
|
13 |
-
*
|
14 |
-
* This program is distributed in the hope that it will be useful,
|
15 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
-
* GNU General Public License for more details.
|
18 |
-
*
|
19 |
-
*
|
20 |
-
* You should have received a copy of the GNU General Public License
|
21 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
22 |
-
*/
|
23 |
-
|
24 |
-
class iubendaFaster
|
25 |
-
{
|
26 |
-
/*
|
27 |
-
Variables
|
28 |
-
*/
|
29 |
-
|
30 |
-
private $getBlack = array
|
31 |
-
(
|
32 |
-
array
|
33 |
-
(
|
34 |
-
/*
|
35 |
-
Domains
|
36 |
-
*/
|
37 |
-
|
38 |
-
"platform.twitter.com/widgets.js",
|
39 |
-
"apis.google.com/js/plusone.js",
|
40 |
-
"apis.google.com/js/platform.js",
|
41 |
-
"connect.facebook.net",
|
42 |
-
"www.youtube.com/iframe_api",
|
43 |
-
"pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
|
44 |
-
"sharethis.com/button/buttons.js",
|
45 |
-
"addthis.com/js/",
|
46 |
-
|
47 |
-
/*
|
48 |
-
JavaScript
|
49 |
-
*/
|
50 |
-
|
51 |
-
"window.adsbygoogle"
|
52 |
-
),
|
53 |
-
array
|
54 |
-
(
|
55 |
-
"youtube.com",
|
56 |
-
"platform.twitter.com",
|
57 |
-
"www.facebook.com/plugins/like.php",
|
58 |
-
"www.facebook.com/plugins/likebox.php",
|
59 |
-
"apis.google.com",
|
60 |
-
"www.google.com/maps/embed/",
|
61 |
-
"player.vimeo.com/video",
|
62 |
-
"maps.google.it/maps",
|
63 |
-
"www.google.com/maps/embed"
|
64 |
-
)
|
65 |
-
);
|
66 |
-
|
67 |
-
/**/
|
68 |
-
|
69 |
-
private $getBlank = "//cdn.iubenda.com/cookie_solution/empty.html";
|
70 |
-
|
71 |
-
private $getClass = array("_iub_cs_activate", "_iub_cs_activate-inline");
|
72 |
-
|
73 |
-
/*
|
74 |
-
Methods
|
75 |
-
*/
|
76 |
-
|
77 |
-
public function isBlack($offender, $blacklist)
|
78 |
-
{
|
79 |
-
/*
|
80 |
-
Check if a string is in the black list.
|
81 |
-
*/
|
82 |
-
|
83 |
-
if(empty($offender) || empty($blacklist)) {
|
84 |
-
|
85 |
-
return false;
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
/**/
|
90 |
-
|
91 |
-
foreach($blacklist as $black)
|
92 |
-
{
|
93 |
-
if(strpos($offender, $black) !== false) {
|
94 |
-
|
95 |
-
return true;
|
96 |
-
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
/**/
|
101 |
-
|
102 |
-
return false;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**/
|
106 |
-
|
107 |
-
public function isParse($offender)
|
108 |
-
{
|
109 |
-
/*
|
110 |
-
Parse the entrie document and search for black elements.
|
111 |
-
*/
|
112 |
-
|
113 |
-
libxml_use_internal_errors(true);
|
114 |
-
|
115 |
-
/**/
|
116 |
-
|
117 |
-
$src = "";
|
118 |
-
|
119 |
-
$blank = $this -> getBlank;
|
120 |
-
$class = $this -> getClass;
|
121 |
-
|
122 |
-
$list_1 = $this -> getBlack[0];
|
123 |
-
$list_2 = $this -> getBlack[1];
|
124 |
-
|
125 |
-
$document = new DOMDocument();
|
126 |
-
|
127 |
-
/**/
|
128 |
-
|
129 |
-
$document -> formatOutput = true;
|
130 |
-
$document -> preserveWhiteSpace = false;
|
131 |
-
|
132 |
-
/**/
|
133 |
-
|
134 |
-
$document -> loadHTML($offender);
|
135 |
-
|
136 |
-
/**/
|
137 |
-
|
138 |
-
$scripts = $document -> getElementsByTagName("script");
|
139 |
-
$iframes = $document -> getElementsByTagName("iframe");
|
140 |
-
|
141 |
-
/*
|
142 |
-
Parse the founded elements and check who is in black.
|
143 |
-
*/
|
144 |
-
|
145 |
-
foreach($scripts as $script)
|
146 |
-
{
|
147 |
-
$src = $script -> getAttribute("src");
|
148 |
-
|
149 |
-
/**/
|
150 |
-
|
151 |
-
if($this -> isBlack($src, $list_1))
|
152 |
-
{
|
153 |
-
$script -> setAttribute("type", "text/plain");
|
154 |
-
$script -> setAttribute("class", $script -> getAttribute("class")." ".$class[0]);
|
155 |
-
}
|
156 |
-
elseif($this -> isBlack($script -> nodeValue, $list_1))
|
157 |
-
{
|
158 |
-
$script -> setAttribute("type", "text/plain");
|
159 |
-
$script -> setAttribute("class", $script -> getAttribute("class")." ".$class[1]);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
foreach($iframes as $iframe) {
|
163 |
-
|
164 |
-
$src = $iframe -> getAttribute("src");
|
165 |
-
|
166 |
-
/**/
|
167 |
-
|
168 |
-
if($this -> isBlack($src, $list_2))
|
169 |
-
{
|
170 |
-
$iframe -> setAttribute("src", $blank);
|
171 |
-
$iframe -> setAttribute("suppressedsrc", $src);
|
172 |
-
$iframe -> setAttribute("class", $iframe -> getAttribute("class")." ".$class[0]);
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
/**/
|
177 |
-
|
178 |
-
$offender = $document -> saveHTML();
|
179 |
-
|
180 |
-
/**/
|
181 |
-
|
182 |
-
libxml_use_internal_errors(false);
|
183 |
-
|
184 |
-
/**/
|
185 |
-
|
186 |
-
return $offender;
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iubenda-cookie-class/iubenda.class.php
DELETED
@@ -1,377 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* iubenda.class.php
|
4 |
-
* version: 1.0.2
|
5 |
-
* @author: Copyright 2015 iubenda
|
6 |
-
* @license GNU/GPL
|
7 |
-
* This program is free software: you can redistribute it and/or modify
|
8 |
-
* it under the terms of the GNU General Public License as published by
|
9 |
-
* the Free Software Foundation, either version 3 of the License, or
|
10 |
-
* (at your option) any later version.
|
11 |
-
*
|
12 |
-
* This program is distributed in the hope that it will be useful,
|
13 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
-
* GNU General Public License for more details.
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* You should have received a copy of the GNU General Public License
|
19 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
-
*/
|
21 |
-
|
22 |
-
class iubendaPage {
|
23 |
-
|
24 |
-
const IUB_REGEX_PATTERN = '/<!--\s*IUB_COOKIE_POLICY_START\s*-->(.*?)<!--\s*IUB_COOKIE_POLICY_END\s*-->/sU';
|
25 |
-
|
26 |
-
public $auto_script_tags = array(
|
27 |
-
'platform.twitter.com/widgets.js',
|
28 |
-
'apis.google.com/js/plusone.js',
|
29 |
-
'apis.google.com/js/platform.js',
|
30 |
-
'connect.facebook.net',
|
31 |
-
'www.youtube.com/iframe_api',
|
32 |
-
'pagead2.googlesyndication.com/pagead/js/adsbygoogle.js',
|
33 |
-
'sharethis.com/button/buttons.js',
|
34 |
-
'addthis.com/js/',
|
35 |
-
'window.adsbygoogle'
|
36 |
-
);
|
37 |
-
|
38 |
-
public $auto_iframe_tags = array(
|
39 |
-
'youtube.com',
|
40 |
-
'platform.twitter.com',
|
41 |
-
'www.facebook.com/plugins/like.php',
|
42 |
-
'www.facebook.com/plugins/likebox.php',
|
43 |
-
'apis.google.com',
|
44 |
-
'www.google.com/maps/embed/',
|
45 |
-
'player.vimeo.com/video',
|
46 |
-
'maps.google.it/maps',
|
47 |
-
'www.google.com/maps/embed',
|
48 |
-
'window.adsbygoogle'
|
49 |
-
);
|
50 |
-
|
51 |
-
public $iub_comments_detected = array();
|
52 |
-
public $iframe_detected = array();
|
53 |
-
public $iframe_converted = array();
|
54 |
-
public $scripts_detected = array();
|
55 |
-
public $scripts_inline_detected = array();
|
56 |
-
public $scripts_inline_converted = array();
|
57 |
-
public $scripts_converted = array();
|
58 |
-
|
59 |
-
|
60 |
-
/*
|
61 |
-
construct: the whole HTML output of the page
|
62 |
-
*/
|
63 |
-
public function __construct($content_page){
|
64 |
-
$this->original_content_page = $content_page;
|
65 |
-
$this->content_page = $content_page;
|
66 |
-
}
|
67 |
-
|
68 |
-
/*
|
69 |
-
print iubenda banner, parameter: the script code of iubenda to print the banner
|
70 |
-
*/
|
71 |
-
public function print_banner($banner){
|
72 |
-
return $banner.= "\n
|
73 |
-
<script>
|
74 |
-
var iCallback = function(){};
|
75 |
-
|
76 |
-
if('callback' in _iub.csConfiguration) {
|
77 |
-
if('onConsentGiven' in _iub.csConfiguration.callback) iCallback = _iub.csConfiguration.callback.onConsentGiven;
|
78 |
-
|
79 |
-
_iub.csConfiguration.callback.onConsentGiven = function()
|
80 |
-
{
|
81 |
-
iCallback();
|
82 |
-
|
83 |
-
/*
|
84 |
-
* Separator
|
85 |
-
*/
|
86 |
-
|
87 |
-
jQuery('noscript._no_script_iub').each(function (a, b) { var el = jQuery(b); el.after(el.html()); });
|
88 |
-
};
|
89 |
-
};
|
90 |
-
</script>";
|
91 |
-
}
|
92 |
-
|
93 |
-
/*
|
94 |
-
Static, detect bot & crawler
|
95 |
-
*/
|
96 |
-
static function bot_detected() {
|
97 |
-
return (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider|google|yahoo/i', $_SERVER['HTTP_USER_AGENT']));
|
98 |
-
}
|
99 |
-
|
100 |
-
/*
|
101 |
-
Static, utility function: Return true if the user has already given consent on the page
|
102 |
-
*/
|
103 |
-
static function consent_given(){
|
104 |
-
foreach($_COOKIE as $key => $value){
|
105 |
-
if(Page::strpos_array($key, array('_iub_cs-s', '_iub_cs'))){
|
106 |
-
return true;
|
107 |
-
}
|
108 |
-
}
|
109 |
-
return false;
|
110 |
-
}
|
111 |
-
/*
|
112 |
-
Static, utility function: strpos for array
|
113 |
-
*/
|
114 |
-
static function strpos_array($haystack, $needle){
|
115 |
-
if(is_array($needle)){
|
116 |
-
foreach($needle as $need){
|
117 |
-
if(strpos($haystack, $need) !== false){
|
118 |
-
return true;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
}else{
|
122 |
-
if(strpos($haystack, $need) !== false) {
|
123 |
-
return true;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
|
130 |
-
/* Convert scripts, iframe and other code inside IUBENDAs comment in text/plain to not generate cookies */
|
131 |
-
public function create_tags($html){
|
132 |
-
|
133 |
-
$elements = $html->find("*");
|
134 |
-
$js = '';
|
135 |
-
|
136 |
-
if(is_array($elements)){
|
137 |
-
$count = count($elements);
|
138 |
-
for($j=0; $j<$count; $j++){
|
139 |
-
$e = $elements[$j];
|
140 |
-
switch($e->tag){
|
141 |
-
case 'script':
|
142 |
-
$class = $e->class;
|
143 |
-
$e->class = $class . ' _iub_cs_activate';
|
144 |
-
$e->type = 'text/plain';
|
145 |
-
$js.= $e->outertext;
|
146 |
-
break;
|
147 |
-
|
148 |
-
case 'iframe':
|
149 |
-
$new_src = "//cdn.iubenda.com/cookie_solution/empty.html";
|
150 |
-
$class = $e->class;
|
151 |
-
$e->suppressedsrc = $e->src;
|
152 |
-
$e->src = $new_src;
|
153 |
-
$e->class = $class . ' _iub_cs_activate';
|
154 |
-
$js.= $e->outertext;
|
155 |
-
break;
|
156 |
-
|
157 |
-
default:
|
158 |
-
$js = $html;
|
159 |
-
break;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
}
|
163 |
-
return $js;
|
164 |
-
}
|
165 |
-
|
166 |
-
/* Parse all IUBENDAs comment and convert the code inside with create_tags method */
|
167 |
-
public function parse_iubenda_comments(){
|
168 |
-
preg_match_all(self::IUB_REGEX_PATTERN, $this->content_page, $scripts);
|
169 |
-
if(is_array($scripts[1])){
|
170 |
-
$count = count($scripts[1]);
|
171 |
-
$js_scripts = array();
|
172 |
-
for($j=0; $j<$count; $j++){
|
173 |
-
$this->iub_comments_detected[] = $scripts[1][$j];
|
174 |
-
$html = str_get_html($scripts[1][$j], $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
175 |
-
$js_scripts[] = $this->create_tags($html);
|
176 |
-
}
|
177 |
-
|
178 |
-
if(is_array($scripts[1]) && is_array($js_scripts)){
|
179 |
-
if(count($scripts[1]) >= 1 && count($js_scripts) >= 1){
|
180 |
-
$this->content_page = strtr($this->content_page, array_combine($scripts[1], $js_scripts));
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
-
/* Parse automatically all the scripts in the page and converts it in text/plain
|
187 |
-
if src or the whole output has inside one of the elements in $auto_script_tags array */
|
188 |
-
public function parse_scripts(){
|
189 |
-
|
190 |
-
$html = str_get_html($this->content_page, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
191 |
-
if(is_object($html)){
|
192 |
-
$scripts = $html->find("script");
|
193 |
-
if(is_array($scripts)){
|
194 |
-
$count = count($scripts);
|
195 |
-
for($j=0; $j<$count; $j++){
|
196 |
-
$s = $scripts[$j];
|
197 |
-
if(!empty($s->innertext)){
|
198 |
-
$this->scripts_detected[] = $s->innertext;
|
199 |
-
if (Page::strpos_array($s->innertext, $this->auto_script_tags) !== false) {
|
200 |
-
$class = $s->class;
|
201 |
-
$s->class = $class . ' _iub_cs_activate-inline';
|
202 |
-
$s->type = 'text/plain';
|
203 |
-
$this->scripts_converted[] = $s->innertext;
|
204 |
-
}
|
205 |
-
}else{
|
206 |
-
$src = $s->src;
|
207 |
-
if($src){
|
208 |
-
$this->scripts_inline_detected[] = $src;
|
209 |
-
if (Page::strpos_array($src, $this->auto_script_tags) !== false) {
|
210 |
-
$class = $s->class;
|
211 |
-
$s->class = $class . ' _iub_cs_activate';
|
212 |
-
$s->type = 'text/plain';
|
213 |
-
$this->scripts_inline_converted[] = $src;
|
214 |
-
}
|
215 |
-
}
|
216 |
-
}
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
/*
|
221 |
-
* AdSense check by Peste Vasile Alexandru, AdSense here
|
222 |
-
*/
|
223 |
-
|
224 |
-
$ad_found = false;
|
225 |
-
|
226 |
-
while(preg_match("#google_ad_client =(.*?);#i", $html))
|
227 |
-
{
|
228 |
-
$ad_found = true;
|
229 |
-
$ad_client = null;
|
230 |
-
$ad_slot = null;
|
231 |
-
$ad_width = null;
|
232 |
-
$ad_height = null;
|
233 |
-
$ad_block = null;
|
234 |
-
|
235 |
-
/**/
|
236 |
-
|
237 |
-
preg_match("#google_ad_client =(.*?);#i", $html, $ad_client);
|
238 |
-
preg_match("#google_ad_slot =(.*?);#i", $html, $ad_slot);
|
239 |
-
preg_match("#google_ad_width =(.*?);#i", $html, $ad_width);
|
240 |
-
preg_match("#google_ad_height =(.*?);#i", $html, $ad_height);
|
241 |
-
|
242 |
-
/**/
|
243 |
-
|
244 |
-
$html = preg_replace("#google_ad_client =(.*?);#i", "", $html, 1);
|
245 |
-
$html = preg_replace("#google_ad_slot =(.*?);#i", "", $html, 1);
|
246 |
-
$html = preg_replace("#google_ad_width =(.*?);#i", "", $html, 1);
|
247 |
-
$html = preg_replace("#google_ad_height =(.*?);#i", "", $html, 1);
|
248 |
-
|
249 |
-
/**/
|
250 |
-
|
251 |
-
$ad_client = trim($ad_client[1]);
|
252 |
-
$ad_slot = trim($ad_slot[1]);
|
253 |
-
$ad_width = trim($ad_width[1]);
|
254 |
-
$ad_height = trim($ad_height[1]);
|
255 |
-
|
256 |
-
/**/
|
257 |
-
|
258 |
-
$ad_class = 'class="_iub_cs_activate_google_ads"';
|
259 |
-
$ad_style = 'style="width:'.$ad_width.'px; height:'.$ad_height.'px;"';
|
260 |
-
|
261 |
-
$ad_client = 'data-client='.$ad_client;
|
262 |
-
$ad_slot = 'data-slot='.$ad_slot;
|
263 |
-
$ad_width = 'data-width="'.$ad_width.'"';
|
264 |
-
$ad_height = 'data-height="'.$ad_height.'"';
|
265 |
-
|
266 |
-
/**/
|
267 |
-
|
268 |
-
$ad_block = "<div $ad_style $ad_class $ad_width $ad_height $ad_slot $ad_client></div>";
|
269 |
-
|
270 |
-
/**/
|
271 |
-
|
272 |
-
$html = preg_replace('#(<[^>]+) src="//pagead2.googlesyndication.com/pagead/show_ads.js"(.*?)</script>#i', $ad_block, $html, 1);
|
273 |
-
}
|
274 |
-
|
275 |
-
/**/
|
276 |
-
|
277 |
-
if($ad_found)
|
278 |
-
{
|
279 |
-
$adsense_callback =
|
280 |
-
"
|
281 |
-
<script>
|
282 |
-
function iubenda_adsense_unblock(){
|
283 |
-
var t = 1;
|
284 |
-
jQuery('._iub_cs_activate_google_ads').each(function() {
|
285 |
-
var banner = jQuery(this);
|
286 |
-
setTimeout(function(){
|
287 |
-
var client = banner.data('client');
|
288 |
-
var slot = banner.data('slot');
|
289 |
-
var width = banner.data('width');
|
290 |
-
var height = banner.data('height');
|
291 |
-
var adsense_script = '<scr'+'ipt>'
|
292 |
-
+ 'google_ad_client = ".chr(34)."'+client+'".chr(34).";'
|
293 |
-
+ 'google_ad_slot = '+slot+';'
|
294 |
-
+ 'google_ad_width = '+width+';'
|
295 |
-
+ 'google_ad_height = '+height+';'
|
296 |
-
+ '</scr'+'ipt>';
|
297 |
-
var script = document.createElement('script');
|
298 |
-
var ads = document.createElement('ads');
|
299 |
-
var w = document.write;
|
300 |
-
script.setAttribute('type', 'text/javascript');
|
301 |
-
script.setAttribute('src', 'http://pagead2.googlesyndication.com/pagead/show_ads.js');
|
302 |
-
document.write = (function(params) {
|
303 |
-
ads.innerHTML = params;
|
304 |
-
document.write = w;
|
305 |
-
});
|
306 |
-
banner.html(adsense_script).append(ads).append(script);
|
307 |
-
}, t);
|
308 |
-
t += 300;
|
309 |
-
});
|
310 |
-
}
|
311 |
-
if('callback' in _iub.csConfiguration) {
|
312 |
-
_iub.csConfiguration.callback.onConsentGiven = iubenda_adsense_unblock;
|
313 |
-
}
|
314 |
-
else
|
315 |
-
{
|
316 |
-
_iub.csConfiguration.callback = {};
|
317 |
-
|
318 |
-
_iub.csConfiguration.callback.onConsentGiven = iubenda_adsense_unblock;
|
319 |
-
}
|
320 |
-
</script>
|
321 |
-
";
|
322 |
-
|
323 |
-
$html = str_replace("</body>", $adsense_callback."</body>", $html);
|
324 |
-
}
|
325 |
-
|
326 |
-
/**/
|
327 |
-
|
328 |
-
$this->content_page = $html;
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
332 |
-
/* Parse automatically all the iframe in the page and change the src to suppressedsrc
|
333 |
-
if src has inside one of the elements in $auto_iframe_tags array */
|
334 |
-
public function parse_iframe(){
|
335 |
-
$html = str_get_html($this->content_page, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
336 |
-
if(is_object($html)){
|
337 |
-
$iframes = $html->find("iframe");
|
338 |
-
if(is_array($iframes)){
|
339 |
-
$count = count($iframes);
|
340 |
-
for($j=0; $j<$count; $j++){
|
341 |
-
$i = $iframes[$j];
|
342 |
-
$src = $i->src;
|
343 |
-
$this->iframe_detected[] = $src;
|
344 |
-
if (Page::strpos_array($src, $this->auto_iframe_tags) !== false){
|
345 |
-
$new_src = "//cdn.iubenda.com/cookie_solution/empty.html";
|
346 |
-
$class = $i->class;
|
347 |
-
$i->suppressedsrc = $src;
|
348 |
-
$i->src = $new_src;
|
349 |
-
$i->class = $class . ' _iub_cs_activate';
|
350 |
-
$this->iframe_converted[] = $src;
|
351 |
-
}
|
352 |
-
}
|
353 |
-
}
|
354 |
-
$this->content_page = $html;
|
355 |
-
}
|
356 |
-
}
|
357 |
-
|
358 |
-
/*
|
359 |
-
Call three methods to parse the page, iubendas comment, scripts + iframe
|
360 |
-
*/
|
361 |
-
public function parse()
|
362 |
-
{
|
363 |
-
$this->parse_iubenda_comments();
|
364 |
-
$this->parse_scripts();
|
365 |
-
$this->parse_iframe();
|
366 |
-
}
|
367 |
-
|
368 |
-
/*
|
369 |
-
Return the final page to output
|
370 |
-
*/
|
371 |
-
public function get_converted_page(){
|
372 |
-
return $this->content_page;
|
373 |
-
}
|
374 |
-
|
375 |
-
}
|
376 |
-
|
377 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iubenda-cookie-class/simple_html_dom.php
DELETED
@@ -1,1734 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Website: http://sourceforge.net/projects/simplehtmldom/
|
4 |
-
* Additional projects that may be used: http://sourceforge.net/projects/debugobject/
|
5 |
-
* Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
|
6 |
-
* Contributions by:
|
7 |
-
* Yousuke Kumakura (Attribute filters)
|
8 |
-
* Vadim Voituk (Negative indexes supports of "find" method)
|
9 |
-
* Antcs (Constructor with automatically load contents either text or file/url)
|
10 |
-
*
|
11 |
-
* all affected sections have comments starting with "PaperG"
|
12 |
-
*
|
13 |
-
* Paperg - Added case insensitive testing of the value of the selector.
|
14 |
-
* Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
|
15 |
-
* This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will not reflect the REAL position of the tag in the source,
|
16 |
-
* it will almost always be smaller by some amount.
|
17 |
-
* We use this to determine how far into the file the tag in question is. This "percentage will never be accurate as the $dom->size is the "real" number of bytes the dom was created from.
|
18 |
-
* but for most purposes, it's a really good estimation.
|
19 |
-
* Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
|
20 |
-
* Allow the user to tell us how much they trust the html.
|
21 |
-
* Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node.
|
22 |
-
* This allows for us to find tags based on the text they contain.
|
23 |
-
* Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
|
24 |
-
* Paperg: added parse_charset so that we know about the character set of the source document.
|
25 |
-
* NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
|
26 |
-
* last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
|
27 |
-
*
|
28 |
-
* Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that.
|
29 |
-
* PaperG (John Schlick) Added get_display_size for "IMG" tags.
|
30 |
-
*
|
31 |
-
* Licensed under The MIT License
|
32 |
-
* Redistributions of files must retain the above copyright notice.
|
33 |
-
*
|
34 |
-
* @author S.C. Chen <me578022@gmail.com>
|
35 |
-
* @author John Schlick
|
36 |
-
* @author Rus Carroll
|
37 |
-
* @version 1.5 ($Rev: 210 $)
|
38 |
-
* @package PlaceLocalInclude
|
39 |
-
* @subpackage simple_html_dom
|
40 |
-
*/
|
41 |
-
|
42 |
-
/**
|
43 |
-
* All of the Defines for the classes below.
|
44 |
-
* @author S.C. Chen <me578022@gmail.com>
|
45 |
-
*/
|
46 |
-
define('HDOM_TYPE_ELEMENT', 1);
|
47 |
-
define('HDOM_TYPE_COMMENT', 2);
|
48 |
-
define('HDOM_TYPE_TEXT', 3);
|
49 |
-
define('HDOM_TYPE_ENDTAG', 4);
|
50 |
-
define('HDOM_TYPE_ROOT', 5);
|
51 |
-
define('HDOM_TYPE_UNKNOWN', 6);
|
52 |
-
define('HDOM_QUOTE_DOUBLE', 0);
|
53 |
-
define('HDOM_QUOTE_SINGLE', 1);
|
54 |
-
define('HDOM_QUOTE_NO', 3);
|
55 |
-
define('HDOM_INFO_BEGIN', 0);
|
56 |
-
define('HDOM_INFO_END', 1);
|
57 |
-
define('HDOM_INFO_QUOTE', 2);
|
58 |
-
define('HDOM_INFO_SPACE', 3);
|
59 |
-
define('HDOM_INFO_TEXT', 4);
|
60 |
-
define('HDOM_INFO_INNER', 5);
|
61 |
-
define('HDOM_INFO_OUTER', 6);
|
62 |
-
define('HDOM_INFO_ENDSPACE',7);
|
63 |
-
// helper functions
|
64 |
-
// -----------------------------------------------------------------------------
|
65 |
-
// get html dom from file
|
66 |
-
// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
|
67 |
-
function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $stripRN=true)
|
68 |
-
{
|
69 |
-
// We DO force the tags to be terminated.
|
70 |
-
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $stripRN, $defaultBRText, $defaultSpanText);
|
71 |
-
// For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
|
72 |
-
$contents = file_get_contents($url, $use_include_path, $context, $offset);
|
73 |
-
// Paperg - use our own mechanism for getting the contents as we want to control the timeout.
|
74 |
-
//$contents = retrieve_url_contents($url);
|
75 |
-
if (empty($contents))
|
76 |
-
{
|
77 |
-
return false;
|
78 |
-
}
|
79 |
-
// The second parameter can force the selectors to all be lowercase.
|
80 |
-
$dom->load($contents, $lowercase, $stripRN);
|
81 |
-
return $dom;
|
82 |
-
}
|
83 |
-
|
84 |
-
// get html dom from string
|
85 |
-
function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $stripRN=true)
|
86 |
-
{
|
87 |
-
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $stripRN);
|
88 |
-
if (empty($str))
|
89 |
-
{
|
90 |
-
$dom->clear();
|
91 |
-
return false;
|
92 |
-
}
|
93 |
-
$dom->load($str, $lowercase, $stripRN);
|
94 |
-
return $dom;
|
95 |
-
}
|
96 |
-
|
97 |
-
// dump html dom tree
|
98 |
-
function dump_html_tree($node, $show_attr=true, $deep=0)
|
99 |
-
{
|
100 |
-
$node->dump($node);
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/**
|
105 |
-
* simple html dom node
|
106 |
-
* PaperG - added ability for "find" routine to lowercase the value of the selector.
|
107 |
-
* PaperG - added $tag_start to track the start position of the tag in the total byte index
|
108 |
-
*
|
109 |
-
* @package PlaceLocalInclude
|
110 |
-
*/
|
111 |
-
class simple_html_dom_node
|
112 |
-
{
|
113 |
-
public $nodetype = HDOM_TYPE_TEXT;
|
114 |
-
public $tag = 'text';
|
115 |
-
public $attr = array();
|
116 |
-
public $children = array();
|
117 |
-
public $nodes = array();
|
118 |
-
public $parent = null;
|
119 |
-
// The "info" array - see HDOM_INFO_... for what each element contains.
|
120 |
-
public $_ = array();
|
121 |
-
public $tag_start = 0;
|
122 |
-
private $dom = null;
|
123 |
-
|
124 |
-
function __construct($dom)
|
125 |
-
{
|
126 |
-
$this->dom = $dom;
|
127 |
-
$dom->nodes[] = $this;
|
128 |
-
}
|
129 |
-
|
130 |
-
function __destruct()
|
131 |
-
{
|
132 |
-
$this->clear();
|
133 |
-
}
|
134 |
-
|
135 |
-
function __toString()
|
136 |
-
{
|
137 |
-
return $this->outertext();
|
138 |
-
}
|
139 |
-
|
140 |
-
// clean up memory due to php5 circular references memory leak...
|
141 |
-
function clear()
|
142 |
-
{
|
143 |
-
$this->dom = null;
|
144 |
-
$this->nodes = null;
|
145 |
-
$this->parent = null;
|
146 |
-
$this->children = null;
|
147 |
-
}
|
148 |
-
|
149 |
-
// dump node's tree
|
150 |
-
function dump($show_attr=true, $deep=0)
|
151 |
-
{
|
152 |
-
$lead = str_repeat(' ', $deep);
|
153 |
-
|
154 |
-
echo $lead.$this->tag;
|
155 |
-
if ($show_attr && count($this->attr)>0)
|
156 |
-
{
|
157 |
-
echo '(';
|
158 |
-
foreach ($this->attr as $k=>$v)
|
159 |
-
echo "[$k]=>\"".$this->$k.'", ';
|
160 |
-
echo ')';
|
161 |
-
}
|
162 |
-
echo "\n";
|
163 |
-
|
164 |
-
if ($this->nodes)
|
165 |
-
{
|
166 |
-
foreach ($this->nodes as $c)
|
167 |
-
{
|
168 |
-
$c->dump($show_attr, $deep+1);
|
169 |
-
}
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
// Debugging function to dump a single dom node with a bunch of information about it.
|
175 |
-
function dump_node($echo=true)
|
176 |
-
{
|
177 |
-
|
178 |
-
$string = $this->tag;
|
179 |
-
if (count($this->attr)>0)
|
180 |
-
{
|
181 |
-
$string .= '(';
|
182 |
-
foreach ($this->attr as $k=>$v)
|
183 |
-
{
|
184 |
-
$string .= "[$k]=>\"".$this->$k.'", ';
|
185 |
-
}
|
186 |
-
$string .= ')';
|
187 |
-
}
|
188 |
-
if (count($this->_)>0)
|
189 |
-
{
|
190 |
-
$string .= ' $_ (';
|
191 |
-
foreach ($this->_ as $k=>$v)
|
192 |
-
{
|
193 |
-
if (is_array($v))
|
194 |
-
{
|
195 |
-
$string .= "[$k]=>(";
|
196 |
-
foreach ($v as $k2=>$v2)
|
197 |
-
{
|
198 |
-
$string .= "[$k2]=>\"".$v2.'", ';
|
199 |
-
}
|
200 |
-
$string .= ")";
|
201 |
-
} else {
|
202 |
-
$string .= "[$k]=>\"".$v.'", ';
|
203 |
-
}
|
204 |
-
}
|
205 |
-
$string .= ")";
|
206 |
-
}
|
207 |
-
|
208 |
-
if (isset($this->text))
|
209 |
-
{
|
210 |
-
$string .= " text: (" . $this->text . ")";
|
211 |
-
}
|
212 |
-
|
213 |
-
$string .= " HDOM_INNER_INFO: '";
|
214 |
-
if (isset($node->_[HDOM_INFO_INNER]))
|
215 |
-
{
|
216 |
-
$string .= $node->_[HDOM_INFO_INNER] . "'";
|
217 |
-
}
|
218 |
-
else
|
219 |
-
{
|
220 |
-
$string .= ' NULL ';
|
221 |
-
}
|
222 |
-
|
223 |
-
$string .= " children: " . count($this->children);
|
224 |
-
$string .= " nodes: " . count($this->nodes);
|
225 |
-
$string .= " tag_start: " . $this->tag_start;
|
226 |
-
$string .= "\n";
|
227 |
-
|
228 |
-
if ($echo)
|
229 |
-
{
|
230 |
-
echo $string;
|
231 |
-
return;
|
232 |
-
}
|
233 |
-
else
|
234 |
-
{
|
235 |
-
return $string;
|
236 |
-
}
|
237 |
-
}
|
238 |
-
|
239 |
-
// returns the parent of node
|
240 |
-
// If a node is passed in, it will reset the parent of the current node to that one.
|
241 |
-
function parent($parent=null)
|
242 |
-
{
|
243 |
-
// I am SURE that this doesn't work properly.
|
244 |
-
// It fails to unset the current node from it's current parents nodes or children list first.
|
245 |
-
if ($parent !== null)
|
246 |
-
{
|
247 |
-
$this->parent = $parent;
|
248 |
-
$this->parent->nodes[] = $this;
|
249 |
-
$this->parent->children[] = $this;
|
250 |
-
}
|
251 |
-
|
252 |
-
return $this->parent;
|
253 |
-
}
|
254 |
-
|
255 |
-
// verify that node has children
|
256 |
-
function has_child()
|
257 |
-
{
|
258 |
-
return !empty($this->children);
|
259 |
-
}
|
260 |
-
|
261 |
-
// returns children of node
|
262 |
-
function children($idx=-1)
|
263 |
-
{
|
264 |
-
if ($idx===-1)
|
265 |
-
{
|
266 |
-
return $this->children;
|
267 |
-
}
|
268 |
-
if (isset($this->children[$idx]))
|
269 |
-
{
|
270 |
-
return $this->children[$idx];
|
271 |
-
}
|
272 |
-
return null;
|
273 |
-
}
|
274 |
-
|
275 |
-
// returns the first child of node
|
276 |
-
function first_child()
|
277 |
-
{
|
278 |
-
if (count($this->children)>0)
|
279 |
-
{
|
280 |
-
return $this->children[0];
|
281 |
-
}
|
282 |
-
return null;
|
283 |
-
}
|
284 |
-
|
285 |
-
// returns the last child of node
|
286 |
-
function last_child()
|
287 |
-
{
|
288 |
-
if (($count=count($this->children))>0)
|
289 |
-
{
|
290 |
-
return $this->children[$count-1];
|
291 |
-
}
|
292 |
-
return null;
|
293 |
-
}
|
294 |
-
|
295 |
-
// returns the next sibling of node
|
296 |
-
function next_sibling()
|
297 |
-
{
|
298 |
-
if ($this->parent===null)
|
299 |
-
{
|
300 |
-
return null;
|
301 |
-
}
|
302 |
-
|
303 |
-
$idx = 0;
|
304 |
-
$count = count($this->parent->children);
|
305 |
-
while ($idx<$count && $this!==$this->parent->children[$idx])
|
306 |
-
{
|
307 |
-
++$idx;
|
308 |
-
}
|
309 |
-
if (++$idx>=$count)
|
310 |
-
{
|
311 |
-
return null;
|
312 |
-
}
|
313 |
-
return $this->parent->children[$idx];
|
314 |
-
}
|
315 |
-
|
316 |
-
// returns the previous sibling of node
|
317 |
-
function prev_sibling()
|
318 |
-
{
|
319 |
-
if ($this->parent===null) return null;
|
320 |
-
$idx = 0;
|
321 |
-
$count = count($this->parent->children);
|
322 |
-
while ($idx<$count && $this!==$this->parent->children[$idx])
|
323 |
-
++$idx;
|
324 |
-
if (--$idx<0) return null;
|
325 |
-
return $this->parent->children[$idx];
|
326 |
-
}
|
327 |
-
|
328 |
-
// function to locate a specific ancestor tag in the path to the root.
|
329 |
-
function find_ancestor_tag($tag)
|
330 |
-
{
|
331 |
-
global $debug_object;
|
332 |
-
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
|
333 |
-
|
334 |
-
// Start by including ourselves in the comparison.
|
335 |
-
$returnDom = $this;
|
336 |
-
|
337 |
-
while (!is_null($returnDom))
|
338 |
-
{
|
339 |
-
if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); }
|
340 |
-
|
341 |
-
if ($returnDom->tag == $tag)
|
342 |
-
{
|
343 |
-
break;
|
344 |
-
}
|
345 |
-
$returnDom = $returnDom->parent;
|
346 |
-
}
|
347 |
-
return $returnDom;
|
348 |
-
}
|
349 |
-
|
350 |
-
// get dom node's inner html
|
351 |
-
function innertext()
|
352 |
-
{
|
353 |
-
if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
|
354 |
-
if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
|
355 |
-
|
356 |
-
$ret = '';
|
357 |
-
foreach ($this->nodes as $n)
|
358 |
-
$ret .= $n->outertext();
|
359 |
-
return $ret;
|
360 |
-
}
|
361 |
-
|
362 |
-
// get dom node's outer text (with tag)
|
363 |
-
function outertext()
|
364 |
-
{
|
365 |
-
global $debug_object;
|
366 |
-
if (is_object($debug_object))
|
367 |
-
{
|
368 |
-
$text = '';
|
369 |
-
if ($this->tag == 'text')
|
370 |
-
{
|
371 |
-
if (!empty($this->text))
|
372 |
-
{
|
373 |
-
$text = " with text: " . $this->text;
|
374 |
-
}
|
375 |
-
}
|
376 |
-
$debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
|
377 |
-
}
|
378 |
-
|
379 |
-
if ($this->tag==='root') return $this->innertext();
|
380 |
-
|
381 |
-
// trigger callback
|
382 |
-
if ($this->dom && $this->dom->callback!==null)
|
383 |
-
{
|
384 |
-
call_user_func_array($this->dom->callback, array($this));
|
385 |
-
}
|
386 |
-
|
387 |
-
if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
|
388 |
-
if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
|
389 |
-
|
390 |
-
// render begin tag
|
391 |
-
if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]])
|
392 |
-
{
|
393 |
-
$ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
|
394 |
-
} else {
|
395 |
-
$ret = "";
|
396 |
-
}
|
397 |
-
|
398 |
-
// render inner text
|
399 |
-
if (isset($this->_[HDOM_INFO_INNER]))
|
400 |
-
{
|
401 |
-
// If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added.
|
402 |
-
if ($this->tag != "br")
|
403 |
-
{
|
404 |
-
$ret .= $this->_[HDOM_INFO_INNER];
|
405 |
-
}
|
406 |
-
} else {
|
407 |
-
if ($this->nodes)
|
408 |
-
{
|
409 |
-
foreach ($this->nodes as $n)
|
410 |
-
{
|
411 |
-
$ret .= $this->convert_text($n->outertext());
|
412 |
-
}
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
// render end tag
|
417 |
-
if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
|
418 |
-
$ret .= '</'.$this->tag.'>';
|
419 |
-
return $ret;
|
420 |
-
}
|
421 |
-
|
422 |
-
// get dom node's plain text
|
423 |
-
function text()
|
424 |
-
{
|
425 |
-
if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
|
426 |
-
switch ($this->nodetype)
|
427 |
-
{
|
428 |
-
case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
|
429 |
-
case HDOM_TYPE_COMMENT: return '';
|
430 |
-
case HDOM_TYPE_UNKNOWN: return '';
|
431 |
-
}
|
432 |
-
if (strcasecmp($this->tag, 'script')===0) return '';
|
433 |
-
if (strcasecmp($this->tag, 'style')===0) return '';
|
434 |
-
|
435 |
-
$ret = '';
|
436 |
-
// In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
|
437 |
-
// NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
|
438 |
-
// WHY is this happening?
|
439 |
-
if (!is_null($this->nodes))
|
440 |
-
{
|
441 |
-
foreach ($this->nodes as $n)
|
442 |
-
{
|
443 |
-
$ret .= $this->convert_text($n->text());
|
444 |
-
}
|
445 |
-
|
446 |
-
// If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
|
447 |
-
if ($this->tag == "span")
|
448 |
-
{
|
449 |
-
$ret .= $this->dom->default_span_text;
|
450 |
-
}
|
451 |
-
|
452 |
-
|
453 |
-
}
|
454 |
-
return $ret;
|
455 |
-
}
|
456 |
-
|
457 |
-
function xmltext()
|
458 |
-
{
|
459 |
-
$ret = $this->innertext();
|
460 |
-
$ret = str_ireplace('<![CDATA[', '', $ret);
|
461 |
-
$ret = str_replace(']]>', '', $ret);
|
462 |
-
return $ret;
|
463 |
-
}
|
464 |
-
|
465 |
-
// build node's text with tag
|
466 |
-
function makeup()
|
467 |
-
{
|
468 |
-
// text, comment, unknown
|
469 |
-
if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
|
470 |
-
|
471 |
-
$ret = '<'.$this->tag;
|
472 |
-
$i = -1;
|
473 |
-
|
474 |
-
foreach ($this->attr as $key=>$val)
|
475 |
-
{
|
476 |
-
++$i;
|
477 |
-
|
478 |
-
// skip removed attribute
|
479 |
-
if ($val===null || $val===false)
|
480 |
-
continue;
|
481 |
-
|
482 |
-
$ret .= $this->_[HDOM_INFO_SPACE][$i][0];
|
483 |
-
//no value attr: nowrap, checked selected...
|
484 |
-
if ($val===true)
|
485 |
-
$ret .= $key;
|
486 |
-
else {
|
487 |
-
switch ($this->_[HDOM_INFO_QUOTE][$i])
|
488 |
-
{
|
489 |
-
case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
|
490 |
-
case HDOM_QUOTE_SINGLE: $quote = '\''; break;
|
491 |
-
default: $quote = '';
|
492 |
-
}
|
493 |
-
$ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
|
494 |
-
}
|
495 |
-
}
|
496 |
-
$ret = $this->dom->restore_noise($ret);
|
497 |
-
return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
|
498 |
-
}
|
499 |
-
|
500 |
-
// find elements by css selector
|
501 |
-
//PaperG - added ability for find to lowercase the value of the selector.
|
502 |
-
function find($selector, $idx=null, $lowercase=false)
|
503 |
-
{
|
504 |
-
$selectors = $this->parse_selector($selector);
|
505 |
-
if (($count=count($selectors))===0) return array();
|
506 |
-
$found_keys = array();
|
507 |
-
|
508 |
-
// find each selector
|
509 |
-
for ($c=0; $c<$count; ++$c)
|
510 |
-
{
|
511 |
-
// The change on the below line was documented on the sourceforge code tracker id 2788009
|
512 |
-
// used to be: if (($levle=count($selectors[0]))===0) return array();
|
513 |
-
if (($levle=count($selectors[$c]))===0) return array();
|
514 |
-
if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
|
515 |
-
|
516 |
-
$head = array($this->_[HDOM_INFO_BEGIN]=>1);
|
517 |
-
|
518 |
-
// handle descendant selectors, no recursive!
|
519 |
-
for ($l=0; $l<$levle; ++$l)
|
520 |
-
{
|
521 |
-
$ret = array();
|
522 |
-
foreach ($head as $k=>$v)
|
523 |
-
{
|
524 |
-
$n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
|
525 |
-
//PaperG - Pass this optional parameter on to the seek function.
|
526 |
-
$n->seek($selectors[$c][$l], $ret, $lowercase);
|
527 |
-
}
|
528 |
-
$head = $ret;
|
529 |
-
}
|
530 |
-
|
531 |
-
foreach ($head as $k=>$v)
|
532 |
-
{
|
533 |
-
if (!isset($found_keys[$k]))
|
534 |
-
{
|
535 |
-
$found_keys[$k] = 1;
|
536 |
-
}
|
537 |
-
}
|
538 |
-
}
|
539 |
-
|
540 |
-
// sort keys
|
541 |
-
ksort($found_keys);
|
542 |
-
|
543 |
-
$found = array();
|
544 |
-
foreach ($found_keys as $k=>$v)
|
545 |
-
$found[] = $this->dom->nodes[$k];
|
546 |
-
|
547 |
-
// return nth-element or array
|
548 |
-
if (is_null($idx)) return $found;
|
549 |
-
else if ($idx<0) $idx = count($found) + $idx;
|
550 |
-
return (isset($found[$idx])) ? $found[$idx] : null;
|
551 |
-
}
|
552 |
-
|
553 |
-
// seek for given conditions
|
554 |
-
// PaperG - added parameter to allow for case insensitive testing of the value of a selector.
|
555 |
-
protected function seek($selector, &$ret, $lowercase=false)
|
556 |
-
{
|
557 |
-
global $debug_object;
|
558 |
-
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
|
559 |
-
|
560 |
-
list($tag, $key, $val, $exp, $no_key) = $selector;
|
561 |
-
|
562 |
-
// xpath index
|
563 |
-
if ($tag && $key && is_numeric($key))
|
564 |
-
{
|
565 |
-
$count = 0;
|
566 |
-
foreach ($this->children as $c)
|
567 |
-
{
|
568 |
-
if ($tag==='*' || $tag===$c->tag) {
|
569 |
-
if (++$count==$key) {
|
570 |
-
$ret[$c->_[HDOM_INFO_BEGIN]] = 1;
|
571 |
-
return;
|
572 |
-
}
|
573 |
-
}
|
574 |
-
}
|
575 |
-
return;
|
576 |
-
}
|
577 |
-
|
578 |
-
$end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
|
579 |
-
if ($end==0) {
|
580 |
-
$parent = $this->parent;
|
581 |
-
while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
|
582 |
-
$end -= 1;
|
583 |
-
$parent = $parent->parent;
|
584 |
-
}
|
585 |
-
$end += $parent->_[HDOM_INFO_END];
|
586 |
-
}
|
587 |
-
|
588 |
-
for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
|
589 |
-
$node = $this->dom->nodes[$i];
|
590 |
-
|
591 |
-
$pass = true;
|
592 |
-
|
593 |
-
if ($tag==='*' && !$key) {
|
594 |
-
if (in_array($node, $this->children, true))
|
595 |
-
$ret[$i] = 1;
|
596 |
-
continue;
|
597 |
-
}
|
598 |
-
|
599 |
-
// compare tag
|
600 |
-
if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
|
601 |
-
// compare key
|
602 |
-
if ($pass && $key) {
|
603 |
-
if ($no_key) {
|
604 |
-
if (isset($node->attr[$key])) $pass=false;
|
605 |
-
} else {
|
606 |
-
if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
|
607 |
-
}
|
608 |
-
}
|
609 |
-
// compare value
|
610 |
-
if ($pass && $key && $val && $val!=='*') {
|
611 |
-
// If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
|
612 |
-
if ($key == "plaintext") {
|
613 |
-
// $node->plaintext actually returns $node->text();
|
614 |
-
$nodeKeyValue = $node->text();
|
615 |
-
} else {
|
616 |
-
// this is a normal search, we want the value of that attribute of the tag.
|
617 |
-
$nodeKeyValue = $node->attr[$key];
|
618 |
-
}
|
619 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
|
620 |
-
|
621 |
-
//PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
|
622 |
-
if ($lowercase) {
|
623 |
-
$check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue));
|
624 |
-
} else {
|
625 |
-
$check = $this->match($exp, $val, $nodeKeyValue);
|
626 |
-
}
|
627 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));}
|
628 |
-
|
629 |
-
// handle multiple class
|
630 |
-
if (!$check && strcasecmp($key, 'class')===0) {
|
631 |
-
foreach (explode(' ',$node->attr[$key]) as $k) {
|
632 |
-
// Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
|
633 |
-
if (!empty($k)) {
|
634 |
-
if ($lowercase) {
|
635 |
-
$check = $this->match($exp, strtolower($val), strtolower($k));
|
636 |
-
} else {
|
637 |
-
$check = $this->match($exp, $val, $k);
|
638 |
-
}
|
639 |
-
if ($check) break;
|
640 |
-
}
|
641 |
-
}
|
642 |
-
}
|
643 |
-
if (!$check) $pass = false;
|
644 |
-
}
|
645 |
-
if ($pass) $ret[$i] = 1;
|
646 |
-
unset($node);
|
647 |
-
}
|
648 |
-
// It's passed by reference so this is actually what this function returns.
|
649 |
-
if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);}
|
650 |
-
}
|
651 |
-
|
652 |
-
protected function match($exp, $pattern, $value) {
|
653 |
-
global $debug_object;
|
654 |
-
if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
|
655 |
-
|
656 |
-
switch ($exp) {
|
657 |
-
case '=':
|
658 |
-
return ($value===$pattern);
|
659 |
-
case '!=':
|
660 |
-
return ($value!==$pattern);
|
661 |
-
case '^=':
|
662 |
-
return preg_match("/^".preg_quote($pattern,'/')."/", $value);
|
663 |
-
case '$=':
|
664 |
-
return preg_match("/".preg_quote($pattern,'/')."$/", $value);
|
665 |
-
case '*=':
|
666 |
-
if ($pattern[0]=='/') {
|
667 |
-
return preg_match($pattern, $value);
|
668 |
-
}
|
669 |
-
return preg_match("/".$pattern."/i", $value);
|
670 |
-
}
|
671 |
-
return false;
|
672 |
-
}
|
673 |
-
|
674 |
-
protected function parse_selector($selector_string) {
|
675 |
-
global $debug_object;
|
676 |
-
if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
|
677 |
-
|
678 |
-
// pattern of CSS selectors, modified from mootools
|
679 |
-
// Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does.
|
680 |
-
// Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check.
|
681 |
-
// Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
|
682 |
-
// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
|
683 |
-
// farther study is required to determine of this should be documented or removed.
|
684 |
-
// $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
|
685 |
-
$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
|
686 |
-
preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
|
687 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);}
|
688 |
-
|
689 |
-
$selectors = array();
|
690 |
-
$result = array();
|
691 |
-
//print_r($matches);
|
692 |
-
|
693 |
-
foreach ($matches as $m) {
|
694 |
-
$m[0] = trim($m[0]);
|
695 |
-
if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
|
696 |
-
// for browser generated xpath
|
697 |
-
if ($m[1]==='tbody') continue;
|
698 |
-
|
699 |
-
list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
|
700 |
-
if (!empty($m[2])) {$key='id'; $val=$m[2];}
|
701 |
-
if (!empty($m[3])) {$key='class'; $val=$m[3];}
|
702 |
-
if (!empty($m[4])) {$key=$m[4];}
|
703 |
-
if (!empty($m[5])) {$exp=$m[5];}
|
704 |
-
if (!empty($m[6])) {$val=$m[6];}
|
705 |
-
|
706 |
-
// convert to lowercase
|
707 |
-
if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
|
708 |
-
//elements that do NOT have the specified attribute
|
709 |
-
if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
|
710 |
-
|
711 |
-
$result[] = array($tag, $key, $val, $exp, $no_key);
|
712 |
-
if (trim($m[7])===',') {
|
713 |
-
$selectors[] = $result;
|
714 |
-
$result = array();
|
715 |
-
}
|
716 |
-
}
|
717 |
-
if (count($result)>0)
|
718 |
-
$selectors[] = $result;
|
719 |
-
return $selectors;
|
720 |
-
}
|
721 |
-
|
722 |
-
function __get($name)
|
723 |
-
{
|
724 |
-
if (isset($this->attr[$name]))
|
725 |
-
{
|
726 |
-
return $this->convert_text($this->attr[$name]);
|
727 |
-
}
|
728 |
-
switch ($name)
|
729 |
-
{
|
730 |
-
case 'outertext': return $this->outertext();
|
731 |
-
case 'innertext': return $this->innertext();
|
732 |
-
case 'plaintext': return $this->text();
|
733 |
-
case 'xmltext': return $this->xmltext();
|
734 |
-
default: return array_key_exists($name, $this->attr);
|
735 |
-
}
|
736 |
-
}
|
737 |
-
|
738 |
-
function __set($name, $value)
|
739 |
-
{
|
740 |
-
global $debug_object;
|
741 |
-
if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
|
742 |
-
|
743 |
-
switch ($name)
|
744 |
-
{
|
745 |
-
case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
|
746 |
-
case 'innertext':
|
747 |
-
if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
|
748 |
-
return $this->_[HDOM_INFO_INNER] = $value;
|
749 |
-
}
|
750 |
-
if (!isset($this->attr[$name]))
|
751 |
-
{
|
752 |
-
$this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
|
753 |
-
$this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
|
754 |
-
}
|
755 |
-
$this->attr[$name] = $value;
|
756 |
-
}
|
757 |
-
|
758 |
-
function __isset($name)
|
759 |
-
{
|
760 |
-
switch ($name)
|
761 |
-
{
|
762 |
-
case 'outertext': return true;
|
763 |
-
case 'innertext': return true;
|
764 |
-
case 'plaintext': return true;
|
765 |
-
}
|
766 |
-
//no value attr: nowrap, checked selected...
|
767 |
-
return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
|
768 |
-
}
|
769 |
-
|
770 |
-
function __unset($name) {
|
771 |
-
if (isset($this->attr[$name]))
|
772 |
-
unset($this->attr[$name]);
|
773 |
-
}
|
774 |
-
|
775 |
-
// PaperG - Function to convert the text from one character set to another if the two sets are not the same.
|
776 |
-
function convert_text($text)
|
777 |
-
{
|
778 |
-
global $debug_object;
|
779 |
-
if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
|
780 |
-
|
781 |
-
$converted_text = $text;
|
782 |
-
|
783 |
-
$sourceCharset = "";
|
784 |
-
$targetCharset = "";
|
785 |
-
|
786 |
-
if ($this->dom)
|
787 |
-
{
|
788 |
-
$sourceCharset = strtoupper($this->dom->_charset);
|
789 |
-
$targetCharset = strtoupper($this->dom->_target_charset);
|
790 |
-
}
|
791 |
-
if (is_object($debug_object)) {$debug_object->debug_log(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);}
|
792 |
-
|
793 |
-
if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0))
|
794 |
-
{
|
795 |
-
// Check if the reported encoding could have been incorrect and the text is actually already UTF-8
|
796 |
-
if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text)))
|
797 |
-
{
|
798 |
-
$converted_text = $text;
|
799 |
-
}
|
800 |
-
else
|
801 |
-
{
|
802 |
-
$converted_text = iconv($sourceCharset, $targetCharset, $text);
|
803 |
-
}
|
804 |
-
}
|
805 |
-
|
806 |
-
// Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output.
|
807 |
-
if ($targetCharset == 'UTF-8')
|
808 |
-
{
|
809 |
-
if (substr($converted_text, 0, 3) == "\xef\xbb\xbf")
|
810 |
-
{
|
811 |
-
$converted_text = substr($converted_text, 3);
|
812 |
-
}
|
813 |
-
if (substr($converted_text, -3) == "\xef\xbb\xbf")
|
814 |
-
{
|
815 |
-
$converted_text = substr($converted_text, 0, -3);
|
816 |
-
}
|
817 |
-
}
|
818 |
-
|
819 |
-
return $converted_text;
|
820 |
-
}
|
821 |
-
|
822 |
-
/**
|
823 |
-
* Returns true if $string is valid UTF-8 and false otherwise.
|
824 |
-
*
|
825 |
-
* @param mixed $str String to be tested
|
826 |
-
* @return boolean
|
827 |
-
*/
|
828 |
-
static function is_utf8($str)
|
829 |
-
{
|
830 |
-
$c=0; $b=0;
|
831 |
-
$bits=0;
|
832 |
-
$len=strlen($str);
|
833 |
-
for($i=0; $i<$len; $i++)
|
834 |
-
{
|
835 |
-
$c=ord($str[$i]);
|
836 |
-
if($c > 128)
|
837 |
-
{
|
838 |
-
if(($c >= 254)) return false;
|
839 |
-
elseif($c >= 252) $bits=6;
|
840 |
-
elseif($c >= 248) $bits=5;
|
841 |
-
elseif($c >= 240) $bits=4;
|
842 |
-
elseif($c >= 224) $bits=3;
|
843 |
-
elseif($c >= 192) $bits=2;
|
844 |
-
else return false;
|
845 |
-
if(($i+$bits) > $len) return false;
|
846 |
-
while($bits > 1)
|
847 |
-
{
|
848 |
-
$i++;
|
849 |
-
$b=ord($str[$i]);
|
850 |
-
if($b < 128 || $b > 191) return false;
|
851 |
-
$bits--;
|
852 |
-
}
|
853 |
-
}
|
854 |
-
}
|
855 |
-
return true;
|
856 |
-
}
|
857 |
-
/*
|
858 |
-
function is_utf8($string)
|
859 |
-
{
|
860 |
-
//this is buggy
|
861 |
-
return (utf8_encode(utf8_decode($string)) == $string);
|
862 |
-
}
|
863 |
-
*/
|
864 |
-
|
865 |
-
/**
|
866 |
-
* Function to try a few tricks to determine the displayed size of an img on the page.
|
867 |
-
* NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.
|
868 |
-
*
|
869 |
-
* @author John Schlick
|
870 |
-
* @version April 19 2012
|
871 |
-
* @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out.
|
872 |
-
*/
|
873 |
-
function get_display_size()
|
874 |
-
{
|
875 |
-
global $debug_object;
|
876 |
-
|
877 |
-
$width = -1;
|
878 |
-
$height = -1;
|
879 |
-
|
880 |
-
if ($this->tag !== 'img')
|
881 |
-
{
|
882 |
-
return false;
|
883 |
-
}
|
884 |
-
|
885 |
-
// See if there is aheight or width attribute in the tag itself.
|
886 |
-
if (isset($this->attr['width']))
|
887 |
-
{
|
888 |
-
$width = $this->attr['width'];
|
889 |
-
}
|
890 |
-
|
891 |
-
if (isset($this->attr['height']))
|
892 |
-
{
|
893 |
-
$height = $this->attr['height'];
|
894 |
-
}
|
895 |
-
|
896 |
-
// Now look for an inline style.
|
897 |
-
if (isset($this->attr['style']))
|
898 |
-
{
|
899 |
-
// Thanks to user gnarf from stackoverflow for this regular expression.
|
900 |
-
$attributes = array();
|
901 |
-
preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
|
902 |
-
foreach ($matches as $match) {
|
903 |
-
$attributes[$match[1]] = $match[2];
|
904 |
-
}
|
905 |
-
|
906 |
-
// If there is a width in the style attributes:
|
907 |
-
if (isset($attributes['width']) && $width == -1)
|
908 |
-
{
|
909 |
-
// check that the last two characters are px (pixels)
|
910 |
-
if (strtolower(substr($attributes['width'], -2)) == 'px')
|
911 |
-
{
|
912 |
-
$proposed_width = substr($attributes['width'], 0, -2);
|
913 |
-
// Now make sure that it's an integer and not something stupid.
|
914 |
-
if (filter_var($proposed_width, FILTER_VALIDATE_INT))
|
915 |
-
{
|
916 |
-
$width = $proposed_width;
|
917 |
-
}
|
918 |
-
}
|
919 |
-
}
|
920 |
-
|
921 |
-
// If there is a width in the style attributes:
|
922 |
-
if (isset($attributes['height']) && $height == -1)
|
923 |
-
{
|
924 |
-
// check that the last two characters are px (pixels)
|
925 |
-
if (strtolower(substr($attributes['height'], -2)) == 'px')
|
926 |
-
{
|
927 |
-
$proposed_height = substr($attributes['height'], 0, -2);
|
928 |
-
// Now make sure that it's an integer and not something stupid.
|
929 |
-
if (filter_var($proposed_height, FILTER_VALIDATE_INT))
|
930 |
-
{
|
931 |
-
$height = $proposed_height;
|
932 |
-
}
|
933 |
-
}
|
934 |
-
}
|
935 |
-
|
936 |
-
}
|
937 |
-
|
938 |
-
// Future enhancement:
|
939 |
-
// Look in the tag to see if there is a class or id specified that has a height or width attribute to it.
|
940 |
-
|
941 |
-
// Far future enhancement
|
942 |
-
// Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width
|
943 |
-
// Note that in this case, the class or id will have the img subselector for it to apply to the image.
|
944 |
-
|
945 |
-
// ridiculously far future development
|
946 |
-
// If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.
|
947 |
-
|
948 |
-
$result = array('height' => $height,
|
949 |
-
'width' => $width);
|
950 |
-
return $result;
|
951 |
-
}
|
952 |
-
|
953 |
-
// camel naming conventions
|
954 |
-
function getAllAttributes() {return $this->attr;}
|
955 |
-
function getAttribute($name) {return $this->__get($name);}
|
956 |
-
function setAttribute($name, $value) {$this->__set($name, $value);}
|
957 |
-
function hasAttribute($name) {return $this->__isset($name);}
|
958 |
-
function removeAttribute($name) {$this->__set($name, null);}
|
959 |
-
function getElementById($id) {return $this->find("#$id", 0);}
|
960 |
-
function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
|
961 |
-
function getElementByTagName($name) {return $this->find($name, 0);}
|
962 |
-
function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
|
963 |
-
function parentNode() {return $this->parent();}
|
964 |
-
function childNodes($idx=-1) {return $this->children($idx);}
|
965 |
-
function firstChild() {return $this->first_child();}
|
966 |
-
function lastChild() {return $this->last_child();}
|
967 |
-
function nextSibling() {return $this->next_sibling();}
|
968 |
-
function previousSibling() {return $this->prev_sibling();}
|
969 |
-
function hasChildNodes() {return $this->has_child();}
|
970 |
-
function nodeName() {return $this->tag;}
|
971 |
-
function appendChild($node) {$node->parent($this); return $node;}
|
972 |
-
|
973 |
-
}
|
974 |
-
|
975 |
-
/**
|
976 |
-
* simple html dom parser
|
977 |
-
* Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector.
|
978 |
-
* Paperg - change $size from protected to public so we can easily access it
|
979 |
-
* Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not. Default is to NOT trust it.
|
980 |
-
*
|
981 |
-
* @package PlaceLocalInclude
|
982 |
-
*/
|
983 |
-
class simple_html_dom
|
984 |
-
{
|
985 |
-
public $root = null;
|
986 |
-
public $nodes = array();
|
987 |
-
public $callback = null;
|
988 |
-
public $lowercase = false;
|
989 |
-
// Used to keep track of how large the text was when we started.
|
990 |
-
public $original_size;
|
991 |
-
public $size;
|
992 |
-
protected $pos;
|
993 |
-
protected $doc;
|
994 |
-
protected $char;
|
995 |
-
protected $cursor;
|
996 |
-
protected $parent;
|
997 |
-
protected $noise = array();
|
998 |
-
protected $token_blank = " \t\r\n";
|
999 |
-
protected $token_equal = ' =/>';
|
1000 |
-
protected $token_slash = " />\r\n\t";
|
1001 |
-
protected $token_attr = ' >';
|
1002 |
-
// Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
|
1003 |
-
public $_charset = '';
|
1004 |
-
public $_target_charset = '';
|
1005 |
-
protected $default_br_text = "";
|
1006 |
-
public $default_span_text = "";
|
1007 |
-
|
1008 |
-
// use isset instead of in_array, performance boost about 30%...
|
1009 |
-
protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
|
1010 |
-
protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
|
1011 |
-
// Known sourceforge issue #2977341
|
1012 |
-
// B tags that are not closed cause us to return everything to the end of the document.
|
1013 |
-
protected $optional_closing_tags = array(
|
1014 |
-
'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
|
1015 |
-
'th'=>array('th'=>1),
|
1016 |
-
'td'=>array('td'=>1),
|
1017 |
-
'li'=>array('li'=>1),
|
1018 |
-
'dt'=>array('dt'=>1, 'dd'=>1),
|
1019 |
-
'dd'=>array('dd'=>1, 'dt'=>1),
|
1020 |
-
'dl'=>array('dd'=>1, 'dt'=>1),
|
1021 |
-
'p'=>array('p'=>1),
|
1022 |
-
'nobr'=>array('nobr'=>1),
|
1023 |
-
'b'=>array('b'=>1),
|
1024 |
-
'option'=>array('option'=>1),
|
1025 |
-
);
|
1026 |
-
|
1027 |
-
function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $stripRN=true)
|
1028 |
-
{
|
1029 |
-
if ($str)
|
1030 |
-
{
|
1031 |
-
if (preg_match("/^http:\/\//i",$str) || is_file($str))
|
1032 |
-
{
|
1033 |
-
$this->load_file($str);
|
1034 |
-
}
|
1035 |
-
else
|
1036 |
-
{
|
1037 |
-
$this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
|
1038 |
-
}
|
1039 |
-
}
|
1040 |
-
// Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html.
|
1041 |
-
if (!$forceTagsClosed) {
|
1042 |
-
$this->optional_closing_array=array();
|
1043 |
-
}
|
1044 |
-
$this->_target_charset = 'UTF-8';
|
1045 |
-
}
|
1046 |
-
|
1047 |
-
function __destruct()
|
1048 |
-
{
|
1049 |
-
$this->clear();
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
// load html from string
|
1053 |
-
function load($str, $lowercase=true, $stripRN=true)
|
1054 |
-
{
|
1055 |
-
global $debug_object;
|
1056 |
-
|
1057 |
-
// prepare
|
1058 |
-
$this->prepare($str, $lowercase, $stripRN, '', '');
|
1059 |
-
// strip out cdata
|
1060 |
-
$this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
|
1061 |
-
// strip out comments
|
1062 |
-
$this->remove_noise("'<!--(.*?)-->'is");
|
1063 |
-
// Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
|
1064 |
-
// Script tags removal now preceeds style tag removal.
|
1065 |
-
// strip out <script> tags
|
1066 |
-
$this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
|
1067 |
-
$this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
|
1068 |
-
// strip out <style> tags
|
1069 |
-
$this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
|
1070 |
-
$this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
|
1071 |
-
// strip out preformatted tags
|
1072 |
-
$this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
|
1073 |
-
// strip out server side scripts
|
1074 |
-
$this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
|
1075 |
-
// strip smarty scripts
|
1076 |
-
$this->remove_noise("'(\{\w)(.*?)(\})'s", true);
|
1077 |
-
|
1078 |
-
// parsing
|
1079 |
-
while ($this->parse());
|
1080 |
-
// end
|
1081 |
-
$this->root->_[HDOM_INFO_END] = $this->cursor;
|
1082 |
-
$this->parse_charset();
|
1083 |
-
|
1084 |
-
// make load function chainable
|
1085 |
-
return $this;
|
1086 |
-
|
1087 |
-
}
|
1088 |
-
|
1089 |
-
// load html from file
|
1090 |
-
function load_file()
|
1091 |
-
{
|
1092 |
-
$args = func_get_args();
|
1093 |
-
$this->load(call_user_func_array('file_get_contents', $args), true);
|
1094 |
-
// Throw an error if we can't properly load the dom.
|
1095 |
-
if (($error=error_get_last())!==null) {
|
1096 |
-
$this->clear();
|
1097 |
-
return false;
|
1098 |
-
}
|
1099 |
-
}
|
1100 |
-
|
1101 |
-
// set callback function
|
1102 |
-
function set_callback($function_name)
|
1103 |
-
{
|
1104 |
-
$this->callback = $function_name;
|
1105 |
-
}
|
1106 |
-
|
1107 |
-
// remove callback function
|
1108 |
-
function remove_callback()
|
1109 |
-
{
|
1110 |
-
$this->callback = null;
|
1111 |
-
}
|
1112 |
-
|
1113 |
-
// save dom as string
|
1114 |
-
function save($filepath='')
|
1115 |
-
{
|
1116 |
-
$ret = $this->root->innertext();
|
1117 |
-
if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
|
1118 |
-
return $ret;
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
// find dom node by css selector
|
1122 |
-
// Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
|
1123 |
-
function find($selector, $idx=null, $lowercase=false)
|
1124 |
-
{
|
1125 |
-
return $this->root->find($selector, $idx, $lowercase);
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
// clean up memory due to php5 circular references memory leak...
|
1129 |
-
function clear()
|
1130 |
-
{
|
1131 |
-
foreach ($this->nodes as $n) {$n->clear(); $n = null;}
|
1132 |
-
// This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
|
1133 |
-
if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
|
1134 |
-
if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
|
1135 |
-
if (isset($this->root)) {$this->root->clear(); unset($this->root);}
|
1136 |
-
unset($this->doc);
|
1137 |
-
unset($this->noise);
|
1138 |
-
}
|
1139 |
-
|
1140 |
-
function dump($show_attr=true)
|
1141 |
-
{
|
1142 |
-
$this->root->dump($show_attr);
|
1143 |
-
}
|
1144 |
-
|
1145 |
-
// prepare HTML data and init everything
|
1146 |
-
protected function prepare($str, $lowercase=true, $stripRN=true)
|
1147 |
-
{
|
1148 |
-
$this->clear();
|
1149 |
-
|
1150 |
-
// set the length of content before we do anything to it.
|
1151 |
-
$this->size = strlen($str);
|
1152 |
-
// Save the original size of the html that we got in. It might be useful to someone.
|
1153 |
-
$this->original_size = $this->size;
|
1154 |
-
|
1155 |
-
//before we save the string as the doc... strip out the \r \n's if we are told to.
|
1156 |
-
$stripRN = false;
|
1157 |
-
|
1158 |
-
$this->doc = $str;
|
1159 |
-
$this->pos = 0;
|
1160 |
-
$this->cursor = 1;
|
1161 |
-
$this->noise = array();
|
1162 |
-
$this->nodes = array();
|
1163 |
-
$this->lowercase = $lowercase;
|
1164 |
-
$this->default_br_text = "\r\n";
|
1165 |
-
$this->default_span_text = " ";
|
1166 |
-
$this->root = new simple_html_dom_node($this);
|
1167 |
-
$this->root->tag = 'root';
|
1168 |
-
$this->root->_[HDOM_INFO_BEGIN] = -1;
|
1169 |
-
$this->root->nodetype = HDOM_TYPE_ROOT;
|
1170 |
-
$this->parent = $this->root;
|
1171 |
-
//if ($this->size>0) $this->char = $this->doc[0];
|
1172 |
-
}
|
1173 |
-
|
1174 |
-
// parse html content
|
1175 |
-
protected function parse()
|
1176 |
-
{
|
1177 |
-
if (($s = $this->copy_until_char('<'))==='')
|
1178 |
-
{
|
1179 |
-
return $this->read_tag();
|
1180 |
-
}
|
1181 |
-
|
1182 |
-
// text
|
1183 |
-
$node = new simple_html_dom_node($this);
|
1184 |
-
++$this->cursor;
|
1185 |
-
$node->_[HDOM_INFO_TEXT] = $s;
|
1186 |
-
$this->link_nodes($node, false);
|
1187 |
-
return true;
|
1188 |
-
}
|
1189 |
-
|
1190 |
-
// PAPERG - dkchou - added this to try to identify the character set of the page we have just parsed so we know better how to spit it out later.
|
1191 |
-
// NOTE: IF you provide a routine called get_last_retrieve_url_contents_content_type which returns the CURLINFO_CONTENT_TYPE from the last curl_exec
|
1192 |
-
// (or the content_type header from the last transfer), we will parse THAT, and if a charset is specified, we will use it over any other mechanism.
|
1193 |
-
protected function parse_charset()
|
1194 |
-
{
|
1195 |
-
global $debug_object;
|
1196 |
-
|
1197 |
-
$charset = null;
|
1198 |
-
|
1199 |
-
if (function_exists('get_last_retrieve_url_contents_content_type'))
|
1200 |
-
{
|
1201 |
-
$contentTypeHeader = get_last_retrieve_url_contents_content_type();
|
1202 |
-
$success = preg_match('/charset=(.+)/', $contentTypeHeader, $matches);
|
1203 |
-
if ($success)
|
1204 |
-
{
|
1205 |
-
$charset = $matches[1];
|
1206 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, 'header content-type found charset of: ' . $charset);}
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
}
|
1210 |
-
|
1211 |
-
if (empty($charset))
|
1212 |
-
{
|
1213 |
-
$el = $this->root->find('meta[http-equiv=Content-Type]',0, true);
|
1214 |
-
if (!empty($el))
|
1215 |
-
{
|
1216 |
-
$fullvalue = $el->content;
|
1217 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag found' . $fullvalue);}
|
1218 |
-
|
1219 |
-
if (!empty($fullvalue))
|
1220 |
-
{
|
1221 |
-
$success = preg_match('/charset=(.+)/i', $fullvalue, $matches);
|
1222 |
-
if ($success)
|
1223 |
-
{
|
1224 |
-
$charset = $matches[1];
|
1225 |
-
}
|
1226 |
-
else
|
1227 |
-
{
|
1228 |
-
// If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
|
1229 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');}
|
1230 |
-
$charset = 'ISO-8859-1';
|
1231 |
-
}
|
1232 |
-
}
|
1233 |
-
}
|
1234 |
-
}
|
1235 |
-
|
1236 |
-
// If we couldn't find a charset above, then lets try to detect one based on the text we got...
|
1237 |
-
if (empty($charset))
|
1238 |
-
{
|
1239 |
-
// Use this in case mb_detect_charset isn't installed/loaded on this machine.
|
1240 |
-
$charset = false;
|
1241 |
-
if (function_exists('mb_detect_encoding'))
|
1242 |
-
{
|
1243 |
-
// Have php try to detect the encoding from the text given to us.
|
1244 |
-
$charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) );
|
1245 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, 'mb_detect found: ' . $charset);}
|
1246 |
-
}
|
1247 |
-
|
1248 |
-
// and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
|
1249 |
-
if ($charset === false)
|
1250 |
-
{
|
1251 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, 'since mb_detect failed - using default of utf-8');}
|
1252 |
-
$charset = 'UTF-8';
|
1253 |
-
}
|
1254 |
-
}
|
1255 |
-
|
1256 |
-
// Since CP1252 is a superset, if we get one of it's subsets, we want it instead.
|
1257 |
-
if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1')))
|
1258 |
-
{
|
1259 |
-
if (is_object($debug_object)) {$debug_object->debug_log(2, 'replacing ' . $charset . ' with CP1252 as its a superset');}
|
1260 |
-
$charset = 'CP1252';
|
1261 |
-
}
|
1262 |
-
|
1263 |
-
if (is_object($debug_object)) {$debug_object->debug_log(1, 'EXIT - ' . $charset);}
|
1264 |
-
|
1265 |
-
return $this->_charset = $charset;
|
1266 |
-
}
|
1267 |
-
|
1268 |
-
// read tag info
|
1269 |
-
protected function read_tag()
|
1270 |
-
{
|
1271 |
-
if ($this->char!=='<')
|
1272 |
-
{
|
1273 |
-
$this->root->_[HDOM_INFO_END] = $this->cursor;
|
1274 |
-
return false;
|
1275 |
-
}
|
1276 |
-
$begin_tag_pos = $this->pos;
|
1277 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1278 |
-
|
1279 |
-
// end tag
|
1280 |
-
if ($this->char==='/')
|
1281 |
-
{
|
1282 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1283 |
-
// This represents the change in the simple_html_dom trunk from revision 180 to 181.
|
1284 |
-
// $this->skip($this->token_blank_t);
|
1285 |
-
$this->skip($this->token_blank);
|
1286 |
-
$tag = $this->copy_until_char('>');
|
1287 |
-
|
1288 |
-
// skip attributes in end tag
|
1289 |
-
if (($pos = strpos($tag, ' '))!==false)
|
1290 |
-
$tag = substr($tag, 0, $pos);
|
1291 |
-
|
1292 |
-
$parent_lower = strtolower($this->parent->tag);
|
1293 |
-
$tag_lower = strtolower($tag);
|
1294 |
-
|
1295 |
-
if ($parent_lower!==$tag_lower)
|
1296 |
-
{
|
1297 |
-
if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower]))
|
1298 |
-
{
|
1299 |
-
$this->parent->_[HDOM_INFO_END] = 0;
|
1300 |
-
$org_parent = $this->parent;
|
1301 |
-
|
1302 |
-
while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
|
1303 |
-
$this->parent = $this->parent->parent;
|
1304 |
-
|
1305 |
-
if (strtolower($this->parent->tag)!==$tag_lower) {
|
1306 |
-
$this->parent = $org_parent; // restore origonal parent
|
1307 |
-
if ($this->parent->parent) $this->parent = $this->parent->parent;
|
1308 |
-
$this->parent->_[HDOM_INFO_END] = $this->cursor;
|
1309 |
-
return $this->as_text_node($tag);
|
1310 |
-
}
|
1311 |
-
}
|
1312 |
-
else if (($this->parent->parent) && isset($this->block_tags[$tag_lower]))
|
1313 |
-
{
|
1314 |
-
$this->parent->_[HDOM_INFO_END] = 0;
|
1315 |
-
$org_parent = $this->parent;
|
1316 |
-
|
1317 |
-
while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
|
1318 |
-
$this->parent = $this->parent->parent;
|
1319 |
-
|
1320 |
-
if (strtolower($this->parent->tag)!==$tag_lower)
|
1321 |
-
{
|
1322 |
-
$this->parent = $org_parent; // restore origonal parent
|
1323 |
-
$this->parent->_[HDOM_INFO_END] = $this->cursor;
|
1324 |
-
return $this->as_text_node($tag);
|
1325 |
-
}
|
1326 |
-
}
|
1327 |
-
else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
|
1328 |
-
{
|
1329 |
-
$this->parent->_[HDOM_INFO_END] = 0;
|
1330 |
-
$this->parent = $this->parent->parent;
|
1331 |
-
}
|
1332 |
-
else
|
1333 |
-
return $this->as_text_node($tag);
|
1334 |
-
}
|
1335 |
-
|
1336 |
-
$this->parent->_[HDOM_INFO_END] = $this->cursor;
|
1337 |
-
if ($this->parent->parent) $this->parent = $this->parent->parent;
|
1338 |
-
|
1339 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1340 |
-
return true;
|
1341 |
-
}
|
1342 |
-
|
1343 |
-
$node = new simple_html_dom_node($this);
|
1344 |
-
$node->_[HDOM_INFO_BEGIN] = $this->cursor;
|
1345 |
-
++$this->cursor;
|
1346 |
-
$tag = $this->copy_until($this->token_slash);
|
1347 |
-
$node->tag_start = $begin_tag_pos;
|
1348 |
-
|
1349 |
-
// doctype, cdata & comments...
|
1350 |
-
if (isset($tag[0]) && $tag[0]==='!') {
|
1351 |
-
$node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
|
1352 |
-
|
1353 |
-
if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
|
1354 |
-
$node->nodetype = HDOM_TYPE_COMMENT;
|
1355 |
-
$node->tag = 'comment';
|
1356 |
-
} else {
|
1357 |
-
$node->nodetype = HDOM_TYPE_UNKNOWN;
|
1358 |
-
$node->tag = 'unknown';
|
1359 |
-
}
|
1360 |
-
if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
|
1361 |
-
$this->link_nodes($node, true);
|
1362 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1363 |
-
return true;
|
1364 |
-
}
|
1365 |
-
|
1366 |
-
// text
|
1367 |
-
if ($pos=strpos($tag, '<')!==false) {
|
1368 |
-
$tag = '<' . substr($tag, 0, -1);
|
1369 |
-
$node->_[HDOM_INFO_TEXT] = $tag;
|
1370 |
-
$this->link_nodes($node, false);
|
1371 |
-
$this->char = $this->doc[--$this->pos]; // prev
|
1372 |
-
return true;
|
1373 |
-
}
|
1374 |
-
|
1375 |
-
if (!preg_match("/^[\w-:]+$/", $tag)) {
|
1376 |
-
$node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
|
1377 |
-
if ($this->char==='<') {
|
1378 |
-
$this->link_nodes($node, false);
|
1379 |
-
return true;
|
1380 |
-
}
|
1381 |
-
|
1382 |
-
if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
|
1383 |
-
$this->link_nodes($node, false);
|
1384 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1385 |
-
return true;
|
1386 |
-
}
|
1387 |
-
|
1388 |
-
// begin tag
|
1389 |
-
$node->nodetype = HDOM_TYPE_ELEMENT;
|
1390 |
-
$tag_lower = strtolower($tag);
|
1391 |
-
$node->tag = ($this->lowercase) ? $tag_lower : $tag;
|
1392 |
-
|
1393 |
-
// handle optional closing tags
|
1394 |
-
if (isset($this->optional_closing_tags[$tag_lower]) )
|
1395 |
-
{
|
1396 |
-
while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)]))
|
1397 |
-
{
|
1398 |
-
$this->parent->_[HDOM_INFO_END] = 0;
|
1399 |
-
$this->parent = $this->parent->parent;
|
1400 |
-
}
|
1401 |
-
$node->parent = $this->parent;
|
1402 |
-
}
|
1403 |
-
|
1404 |
-
$guard = 0; // prevent infinity loop
|
1405 |
-
$space = array($this->copy_skip($this->token_blank), '', '');
|
1406 |
-
|
1407 |
-
// attributes
|
1408 |
-
do
|
1409 |
-
{
|
1410 |
-
if ($this->char!==null && $space[0]==='')
|
1411 |
-
{
|
1412 |
-
break;
|
1413 |
-
}
|
1414 |
-
$name = $this->copy_until($this->token_equal);
|
1415 |
-
if ($guard===$this->pos)
|
1416 |
-
{
|
1417 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1418 |
-
continue;
|
1419 |
-
}
|
1420 |
-
$guard = $this->pos;
|
1421 |
-
|
1422 |
-
// handle endless '<'
|
1423 |
-
if ($this->pos>=$this->size-1 && $this->char!=='>') {
|
1424 |
-
$node->nodetype = HDOM_TYPE_TEXT;
|
1425 |
-
$node->_[HDOM_INFO_END] = 0;
|
1426 |
-
$node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
|
1427 |
-
$node->tag = 'text';
|
1428 |
-
$this->link_nodes($node, false);
|
1429 |
-
return true;
|
1430 |
-
}
|
1431 |
-
|
1432 |
-
// handle mismatch '<'
|
1433 |
-
if ($this->doc[$this->pos-1]=='<') {
|
1434 |
-
$node->nodetype = HDOM_TYPE_TEXT;
|
1435 |
-
$node->tag = 'text';
|
1436 |
-
$node->attr = array();
|
1437 |
-
$node->_[HDOM_INFO_END] = 0;
|
1438 |
-
$node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
|
1439 |
-
$this->pos -= 2;
|
1440 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1441 |
-
$this->link_nodes($node, false);
|
1442 |
-
return true;
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
if ($name!=='/' && $name!=='') {
|
1446 |
-
$space[1] = $this->copy_skip($this->token_blank);
|
1447 |
-
$name = $this->restore_noise($name);
|
1448 |
-
if ($this->lowercase) $name = strtolower($name);
|
1449 |
-
if ($this->char==='=') {
|
1450 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1451 |
-
$this->parse_attr($node, $name, $space);
|
1452 |
-
}
|
1453 |
-
else {
|
1454 |
-
//no value attr: nowrap, checked selected...
|
1455 |
-
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
|
1456 |
-
$node->attr[$name] = true;
|
1457 |
-
if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
|
1458 |
-
}
|
1459 |
-
$node->_[HDOM_INFO_SPACE][] = $space;
|
1460 |
-
$space = array($this->copy_skip($this->token_blank), '', '');
|
1461 |
-
}
|
1462 |
-
else
|
1463 |
-
break;
|
1464 |
-
} while ($this->char!=='>' && $this->char!=='/');
|
1465 |
-
|
1466 |
-
$this->link_nodes($node, true);
|
1467 |
-
$node->_[HDOM_INFO_ENDSPACE] = $space[0];
|
1468 |
-
|
1469 |
-
// check self closing
|
1470 |
-
if ($this->copy_until_char_escape('>')==='/')
|
1471 |
-
{
|
1472 |
-
$node->_[HDOM_INFO_ENDSPACE] .= '/';
|
1473 |
-
$node->_[HDOM_INFO_END] = 0;
|
1474 |
-
}
|
1475 |
-
else
|
1476 |
-
{
|
1477 |
-
// reset parent
|
1478 |
-
if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
|
1479 |
-
}
|
1480 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1481 |
-
|
1482 |
-
// If it's a BR tag, we need to set it's text to the default text.
|
1483 |
-
// This way when we see it in plaintext, we can generate formatting that the user wants.
|
1484 |
-
// since a br tag never has sub nodes, this works well.
|
1485 |
-
if ($node->tag == "br")
|
1486 |
-
{
|
1487 |
-
$node->_[HDOM_INFO_INNER] = $this->default_br_text;
|
1488 |
-
}
|
1489 |
-
|
1490 |
-
return true;
|
1491 |
-
}
|
1492 |
-
|
1493 |
-
// parse attributes
|
1494 |
-
protected function parse_attr($node, $name, &$space)
|
1495 |
-
{
|
1496 |
-
// Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
|
1497 |
-
// If the attribute is already defined inside a tag, only pay atetntion to the first one as opposed to the last one.
|
1498 |
-
if (isset($node->attr[$name]))
|
1499 |
-
{
|
1500 |
-
return;
|
1501 |
-
}
|
1502 |
-
|
1503 |
-
$space[2] = $this->copy_skip($this->token_blank);
|
1504 |
-
switch ($this->char) {
|
1505 |
-
case '"':
|
1506 |
-
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
|
1507 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1508 |
-
$node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
|
1509 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1510 |
-
break;
|
1511 |
-
case '\'':
|
1512 |
-
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
|
1513 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1514 |
-
$node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
|
1515 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1516 |
-
break;
|
1517 |
-
default:
|
1518 |
-
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
|
1519 |
-
$node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
|
1520 |
-
}
|
1521 |
-
// PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
|
1522 |
-
$node->attr[$name] = str_replace("\r", "", $node->attr[$name]);
|
1523 |
-
$node->attr[$name] = str_replace("\n", "", $node->attr[$name]);
|
1524 |
-
// PaperG: If this is a "class" selector, lets get rid of the preceeding and trailing space since some people leave it in the multi class case.
|
1525 |
-
if ($name == "class") {
|
1526 |
-
$node->attr[$name] = trim($node->attr[$name]);
|
1527 |
-
}
|
1528 |
-
}
|
1529 |
-
|
1530 |
-
// link node's parent
|
1531 |
-
protected function link_nodes(&$node, $is_child)
|
1532 |
-
{
|
1533 |
-
$node->parent = $this->parent;
|
1534 |
-
$this->parent->nodes[] = $node;
|
1535 |
-
if ($is_child)
|
1536 |
-
{
|
1537 |
-
$this->parent->children[] = $node;
|
1538 |
-
}
|
1539 |
-
}
|
1540 |
-
|
1541 |
-
// as a text node
|
1542 |
-
protected function as_text_node($tag)
|
1543 |
-
{
|
1544 |
-
$node = new simple_html_dom_node($this);
|
1545 |
-
++$this->cursor;
|
1546 |
-
$node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
|
1547 |
-
$this->link_nodes($node, false);
|
1548 |
-
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1549 |
-
return true;
|
1550 |
-
}
|
1551 |
-
|
1552 |
-
protected function skip($chars)
|
1553 |
-
{
|
1554 |
-
$this->pos += strspn($this->doc, $chars, $this->pos);
|
1555 |
-
$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1556 |
-
}
|
1557 |
-
|
1558 |
-
protected function copy_skip($chars)
|
1559 |
-
{
|
1560 |
-
$pos = $this->pos;
|
1561 |
-
$len = strspn($this->doc, $chars, $pos);
|
1562 |
-
$this->pos += $len;
|
1563 |
-
$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1564 |
-
if ($len===0) return '';
|
1565 |
-
return substr($this->doc, $pos, $len);
|
1566 |
-
}
|
1567 |
-
|
1568 |
-
protected function copy_until($chars)
|
1569 |
-
{
|
1570 |
-
$pos = $this->pos;
|
1571 |
-
$len = strcspn($this->doc, $chars, $pos);
|
1572 |
-
$this->pos += $len;
|
1573 |
-
$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
1574 |
-
return substr($this->doc, $pos, $len);
|
1575 |
-
}
|
1576 |
-
|
1577 |
-
protected function copy_until_char($char)
|
1578 |
-
{
|
1579 |
-
if ($this->char===null) return '';
|
1580 |
-
|
1581 |
-
if (($pos = strpos($this->doc, $char, $this->pos))===false) {
|
1582 |
-
$ret = substr($this->doc, $this->pos, $this->size-$this->pos);
|
1583 |
-
$this->char = null;
|
1584 |
-
$this->pos = $this->size;
|
1585 |
-
return $ret;
|
1586 |
-
}
|
1587 |
-
|
1588 |
-
if ($pos===$this->pos) return '';
|
1589 |
-
$pos_old = $this->pos;
|
1590 |
-
$this->char = $this->doc[$pos];
|
1591 |
-
$this->pos = $pos;
|
1592 |
-
return substr($this->doc, $pos_old, $pos-$pos_old);
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
protected function copy_until_char_escape($char)
|
1596 |
-
{
|
1597 |
-
if ($this->char===null) return '';
|
1598 |
-
|
1599 |
-
$start = $this->pos;
|
1600 |
-
while (1)
|
1601 |
-
{
|
1602 |
-
if (($pos = strpos($this->doc, $char, $start))===false)
|
1603 |
-
{
|
1604 |
-
$ret = substr($this->doc, $this->pos, $this->size-$this->pos);
|
1605 |
-
$this->char = null;
|
1606 |
-
$this->pos = $this->size;
|
1607 |
-
return $ret;
|
1608 |
-
}
|
1609 |
-
|
1610 |
-
if ($pos===$this->pos) return '';
|
1611 |
-
|
1612 |
-
if ($this->doc[$pos-1]==='\\') {
|
1613 |
-
$start = $pos+1;
|
1614 |
-
continue;
|
1615 |
-
}
|
1616 |
-
|
1617 |
-
$pos_old = $this->pos;
|
1618 |
-
$this->char = $this->doc[$pos];
|
1619 |
-
$this->pos = $pos;
|
1620 |
-
return substr($this->doc, $pos_old, $pos-$pos_old);
|
1621 |
-
}
|
1622 |
-
}
|
1623 |
-
|
1624 |
-
// remove noise from html content
|
1625 |
-
// save the noise in the $this->noise array.
|
1626 |
-
protected function remove_noise($pattern, $remove_tag=false)
|
1627 |
-
{
|
1628 |
-
global $debug_object;
|
1629 |
-
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
|
1630 |
-
|
1631 |
-
$count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
|
1632 |
-
|
1633 |
-
for ($i=$count-1; $i>-1; --$i)
|
1634 |
-
{
|
1635 |
-
$key = '___noise___'.sprintf('% 5d', count($this->noise)+1000);
|
1636 |
-
if (is_object($debug_object)) { $debug_object->debug_log(2, 'key is: ' . $key); }
|
1637 |
-
$idx = ($remove_tag) ? 0 : 1;
|
1638 |
-
$this->noise[$key] = $matches[$i][$idx][0];
|
1639 |
-
$this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
|
1640 |
-
}
|
1641 |
-
|
1642 |
-
// reset the length of content
|
1643 |
-
|
1644 |
-
$this->size = strlen($this->doc);
|
1645 |
-
if ($this->size>0){
|
1646 |
-
if(is_string($this->doc)){
|
1647 |
-
$this->char = $this->doc[0];
|
1648 |
-
}
|
1649 |
-
}
|
1650 |
-
}
|
1651 |
-
|
1652 |
-
// restore noise to html content
|
1653 |
-
function restore_noise($text)
|
1654 |
-
{
|
1655 |
-
global $debug_object;
|
1656 |
-
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
|
1657 |
-
|
1658 |
-
while (($pos=strpos($text, '___noise___'))!==false)
|
1659 |
-
{
|
1660 |
-
// Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
|
1661 |
-
if (strlen($text) > $pos+15)
|
1662 |
-
{
|
1663 |
-
$key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15];
|
1664 |
-
if (is_object($debug_object)) { $debug_object->debug_log(2, 'located key of: ' . $key); }
|
1665 |
-
|
1666 |
-
if (isset($this->noise[$key]))
|
1667 |
-
{
|
1668 |
-
$text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16);
|
1669 |
-
}
|
1670 |
-
else
|
1671 |
-
{
|
1672 |
-
// do this to prevent an infinite loop.
|
1673 |
-
$text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16);
|
1674 |
-
}
|
1675 |
-
}
|
1676 |
-
else
|
1677 |
-
{
|
1678 |
-
// There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
|
1679 |
-
$text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11);
|
1680 |
-
}
|
1681 |
-
}
|
1682 |
-
return $text;
|
1683 |
-
}
|
1684 |
-
|
1685 |
-
// Sometimes we NEED one of the noise elements.
|
1686 |
-
function search_noise($text)
|
1687 |
-
{
|
1688 |
-
global $debug_object;
|
1689 |
-
if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
|
1690 |
-
|
1691 |
-
foreach($this->noise as $noiseElement)
|
1692 |
-
{
|
1693 |
-
if (strpos($noiseElement, $text)!==false)
|
1694 |
-
{
|
1695 |
-
return $noiseElement;
|
1696 |
-
}
|
1697 |
-
}
|
1698 |
-
}
|
1699 |
-
function __toString()
|
1700 |
-
{
|
1701 |
-
return $this->root->innertext();
|
1702 |
-
}
|
1703 |
-
|
1704 |
-
function __get($name)
|
1705 |
-
{
|
1706 |
-
switch ($name)
|
1707 |
-
{
|
1708 |
-
case 'outer text':
|
1709 |
-
return $this->root->innertext();
|
1710 |
-
case 'inner text':
|
1711 |
-
return $this->root->innertext();
|
1712 |
-
case 'plaintext':
|
1713 |
-
return $this->root->text();
|
1714 |
-
case 'charset':
|
1715 |
-
return $this->_charset;
|
1716 |
-
case 'target_charset':
|
1717 |
-
return $this->_target_charset;
|
1718 |
-
}
|
1719 |
-
}
|
1720 |
-
|
1721 |
-
// camel naming conventions
|
1722 |
-
function childNodes($idx=-1) {return $this->root->childNodes($idx);}
|
1723 |
-
function firstChild() {return $this->root->first_child();}
|
1724 |
-
function lastChild() {return $this->root->last_child();}
|
1725 |
-
function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();}
|
1726 |
-
function createTextNode($value) {return @end(str_get_html($value)->nodes);}
|
1727 |
-
function getElementById($id) {return $this->find("#$id", 0);}
|
1728 |
-
function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
|
1729 |
-
function getElementByTagName($name) {return $this->find($name, 0);}
|
1730 |
-
function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
|
1731 |
-
function loadFile() {$args = func_get_args();$this->load_file($args);}
|
1732 |
-
}
|
1733 |
-
|
1734 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iubenda-cookie-class/test.php
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* test.php
|
4 |
-
* @author: Copyright 2015 iubenda
|
5 |
-
* @license GNU/GPL
|
6 |
-
* This program is free software: you can redistribute it and/or modify
|
7 |
-
* it under the terms of the GNU General Public License as published by
|
8 |
-
* the Free Software Foundation, either version 3 of the License, or
|
9 |
-
* (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This program is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
-
* GNU General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU General Public License
|
17 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
-
*/
|
19 |
-
|
20 |
-
ini_set('max_execution_time', 300);
|
21 |
-
?>
|
22 |
-
|
23 |
-
<html>
|
24 |
-
<head>
|
25 |
-
<!-- Latest compiled and minified CSS -->
|
26 |
-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
|
27 |
-
|
28 |
-
<!-- Optional theme -->
|
29 |
-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
|
30 |
-
<style>
|
31 |
-
ul { margin: 0; padding: 0;}
|
32 |
-
ul li { list-style-type: none; }
|
33 |
-
</style>
|
34 |
-
</head>
|
35 |
-
<body>
|
36 |
-
<div class="container">
|
37 |
-
<div class="row">
|
38 |
-
<div class="col-md-12">
|
39 |
-
<h1>iubenda class test</h1>
|
40 |
-
<form action="" method="POST">
|
41 |
-
<strong>URL WEBSITE</strong><BR>
|
42 |
-
<input type="text" name="url">
|
43 |
-
<input type="submit" class="btn" value="Analyze">
|
44 |
-
</form>
|
45 |
-
</div>
|
46 |
-
|
47 |
-
<?php
|
48 |
-
|
49 |
-
$url = $_POST['url'];
|
50 |
-
if($url || $_GET['url']){
|
51 |
-
|
52 |
-
function print_stuff($array){
|
53 |
-
if(count($array)){
|
54 |
-
echo "<ul>";
|
55 |
-
foreach($array as $r){
|
56 |
-
echo "<li><pre><code>".htmlspecialchars($r)."</code></pre></li>";
|
57 |
-
}
|
58 |
-
echo "</ul>";
|
59 |
-
}else{
|
60 |
-
echo "<p>Nothing</p>";
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
echo '<div class="col-md-12" style="padding-bottom:150px;"><h2>RESULTS</H2>';
|
65 |
-
include_once 'iubenda.class.php';
|
66 |
-
include_once 'simple_html_dom.php';
|
67 |
-
|
68 |
-
if($_GET['url']){
|
69 |
-
$content = file_get_contents('A');
|
70 |
-
}else{
|
71 |
-
$content = file_get_contents($url);
|
72 |
-
}
|
73 |
-
|
74 |
-
$page = new Page($content);
|
75 |
-
$page->parse();
|
76 |
-
|
77 |
-
$iub_comments_detected = count($page->iub_comments_detected);
|
78 |
-
$scripts_detected = count($page->scripts_detected);
|
79 |
-
$iframe_detected = count($page->iframe_detected);
|
80 |
-
$iframe_converted = count($page->iframe_converted);
|
81 |
-
$script_inline_converted = count($page->scripts_inline_converted);
|
82 |
-
$script_converted = count($page->scripts_converted);
|
83 |
-
|
84 |
-
echo "<p>Iubenda comments detected: $iub_comments_detected<br>Iubenda automatic stuff<br>Iframe detected: $iframe_detected<br>Iframe autoconverted: $iframe_converted<br>Scripts detected: $scripts_detected<br>Inline scripts autoconverted: $script_inline_converted<br>Scripts autoconverted: $script_converted</p>";
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
echo "<H3>DETAILS</H3>";
|
91 |
-
|
92 |
-
echo "<H4>iubenda comments stuff</h4>";
|
93 |
-
print_stuff($page->iub_comments_detected);
|
94 |
-
|
95 |
-
echo "<H4>Script detected</h4>";
|
96 |
-
print_stuff($page->scripts_detected);
|
97 |
-
echo "<H4>Script converted</h4>";
|
98 |
-
print_stuff($page->scripts_converted);
|
99 |
-
echo "<H4>Script inline converted</h4>";
|
100 |
-
print_stuff($page->scripts_inline_converted);
|
101 |
-
|
102 |
-
echo "<H4>Iframe detected</h4>";
|
103 |
-
print_stuff($page->iframe_detected);
|
104 |
-
echo "<H4>Iframe converted</h4>";
|
105 |
-
print_stuff($page->iframe_converted);
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
echo "</div>";
|
110 |
-
|
111 |
-
|
112 |
-
}
|
113 |
-
?>
|
114 |
-
</div>
|
115 |
-
</div>
|
116 |
-
|
117 |
-
</body>
|
118 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iubenda-cookie-class/usage.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* usage.php
|
4 |
-
* @author: Copyright 2015 iubenda
|
5 |
-
* @license GNU/GPL
|
6 |
-
* This program is free software: you can redistribute it and/or modify
|
7 |
-
* it under the terms of the GNU General Public License as published by
|
8 |
-
* the Free Software Foundation, either version 3 of the License, or
|
9 |
-
* (at your option) any later version.
|
10 |
-
*
|
11 |
-
* This program is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
-
* GNU General Public License for more details.
|
15 |
-
*
|
16 |
-
* You should have received a copy of the GNU General Public License
|
17 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
-
*/
|
19 |
-
|
20 |
-
// the "$html" parameter must contain the content of the web page with the iubenda JavaScript banner/policy included
|
21 |
-
|
22 |
-
function iubenda_system($html)
|
23 |
-
{
|
24 |
-
if(empty($html)) return;
|
25 |
-
|
26 |
-
/*
|
27 |
-
* Separator
|
28 |
-
*/
|
29 |
-
|
30 |
-
if(!function_exists("file_get_html")) {
|
31 |
-
require_once("simple_html_dom.php");
|
32 |
-
}
|
33 |
-
|
34 |
-
require_once("iubenda.class.php");
|
35 |
-
|
36 |
-
/*
|
37 |
-
* Separator
|
38 |
-
*/
|
39 |
-
|
40 |
-
if(!Page::consent_given() && !Page::bot_detected()) {
|
41 |
-
$page = new Page($html);
|
42 |
-
$page->parse();
|
43 |
-
$html = $page->get_converted_page();
|
44 |
-
}
|
45 |
-
|
46 |
-
/* Finished */
|
47 |
-
|
48 |
-
return $html;
|
49 |
-
}
|
50 |
-
|
51 |
-
/*
|
52 |
-
*
|
53 |
-
* Example:
|
54 |
-
*
|
55 |
-
* echo iubenda_system("<html> ...content... </html>");
|
56 |
-
*
|
57 |
-
*/
|
58 |
-
|
59 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iubenda_cookie_solution.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: https://www.iubenda.com
|
5 |
* Description: Iubenda Cookie Solution permette di gestire tutti gli aspetti della cookie law su WP.
|
6 |
* Author: iubenda
|
7 |
-
* Version: 1.14.0-
|
8 |
* Text Domain: iubenda-cookie-law-solution
|
9 |
* Author URI: https://www.iubenda.com
|
10 |
*/
|
@@ -15,7 +15,6 @@ if ( ! defined( 'ABSPATH' ) )
|
|
15 |
|
16 |
// define contants
|
17 |
define( 'IUB_DEBUG', 0 );
|
18 |
-
define( 'IUB_REGEX_PATTERN', "/<!--IUB_COOKIE_POLICY_START-->(.*)<!--IUB_COOKIE_POLICY_END-->/sU" );
|
19 |
|
20 |
// set plugin instance
|
21 |
$iubenda_cookie_law_solution = new iubenda_Cookie_Law_Solution();
|
@@ -30,37 +29,87 @@ class iubenda_Cookie_Law_Solution {
|
|
30 |
|
31 |
public $options;
|
32 |
public $defaults = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
);
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
35 |
/**
|
36 |
-
*
|
37 |
*/
|
38 |
public function __construct() {
|
39 |
-
|
40 |
-
|
41 |
|
42 |
// settings
|
43 |
-
$this->options = array_merge( $this->defaults, get_option( 'iubenda_cookie_law_solution', $this->defaults ) );
|
44 |
|
45 |
// actions
|
|
|
|
|
46 |
add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
|
|
|
|
|
47 |
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
48 |
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
49 |
add_action( 'after_setup_theme', array( $this, 'register_shortcode' ) );
|
50 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
|
|
51 |
add_action( 'wp_head', array( $this, 'wp_head' ), 99 );
|
52 |
-
add_action( '
|
53 |
add_action( 'shutdown', array( $this, 'output_end' ), 100 );
|
54 |
}
|
55 |
-
|
56 |
/**
|
57 |
* Initialize plugin.
|
|
|
|
|
58 |
*/
|
59 |
public function init() {
|
60 |
|
61 |
-
// check WPML
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
// load Simple HTML DOM if needed
|
@@ -72,14 +121,92 @@ class iubenda_Cookie_Law_Solution {
|
|
72 |
require_once( dirname( __FILE__ ) . '/lib/iubenda.class.faster.php' );
|
73 |
require_once( dirname( __FILE__ ) . '/lib/iubenda.class.php' );
|
74 |
}
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
/**
|
77 |
* Register shortcode function.
|
78 |
*/
|
79 |
public function register_shortcode() {
|
80 |
add_shortcode( 'iub-cookie-policy', array( $this, 'shortcode' ) );
|
81 |
}
|
82 |
-
|
83 |
/**
|
84 |
* Handle shortcode function.
|
85 |
*
|
@@ -96,16 +223,16 @@ class iubenda_Cookie_Law_Solution {
|
|
96 |
*/
|
97 |
public function admin_menu_options() {
|
98 |
add_menu_page(
|
99 |
-
|
100 |
}
|
101 |
-
|
102 |
/**
|
103 |
* Load textdomain.
|
104 |
*/
|
105 |
public function load_textdomain() {
|
106 |
load_plugin_textdomain( 'iubenda-cookie-law-solution', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
107 |
}
|
108 |
-
|
109 |
/**
|
110 |
* Load admin scripts and styles.
|
111 |
*
|
@@ -113,82 +240,86 @@ class iubenda_Cookie_Law_Solution {
|
|
113 |
* @return void
|
114 |
*/
|
115 |
public function admin_enqueue_scripts( $page ) {
|
116 |
-
|
117 |
if ( $page !== 'toplevel_page_iubenda-cookie-law-solution' )
|
118 |
return;
|
119 |
|
120 |
wp_enqueue_script(
|
121 |
-
|
122 |
);
|
123 |
|
124 |
wp_enqueue_style( 'iubenda-admin', plugins_url( 'css/admin.css', __FILE__ ) );
|
125 |
}
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
/**
|
128 |
* Add wp_head content.
|
129 |
*
|
130 |
* @return mixed
|
131 |
*/
|
132 |
public function wp_head() {
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
if ( ! get_option( "default_iubendaparse" ) ) {
|
143 |
-
update_option( "default_iubendaparse", true );
|
144 |
-
update_option( "iubenda_parse", true );
|
145 |
-
}
|
146 |
-
if ( ! get_option( "default_parser_engine" ) ) {
|
147 |
-
update_option( "default_parser_engine", true );
|
148 |
-
update_option( "parser_engine", "default" );
|
149 |
}
|
150 |
-
|
151 |
// check content type
|
152 |
-
$this->
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
-
|
160 |
-
|
161 |
-
if ( $_POST ||
|
162 |
return;
|
163 |
}
|
164 |
-
|
165 |
// initial head output
|
166 |
$iubenda_code = "";
|
167 |
-
|
168 |
-
if (
|
169 |
-
$
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
if ( strpos( $wpml_old, 'lang: "' . $iubenda_language ) !== false ) {
|
175 |
-
$language_tag = $iubenda_language;
|
176 |
-
|
177 |
-
break;
|
178 |
-
}
|
179 |
}
|
180 |
-
|
181 |
-
update_option( "iubenda-code-$language_tag", $wpml_old );
|
182 |
-
update_option( 'iubenda-code-default', $wpml_old );
|
183 |
-
update_option( 'iub_code', false );
|
184 |
-
}
|
185 |
-
|
186 |
-
if ( defined( 'IUBENDA_WPML' ) && get_option( 'iubenda-code-' . ICL_LANGUAGE_CODE ) ) {
|
187 |
-
$iubenda_code .= get_option( 'iubenda-code-' . ICL_LANGUAGE_CODE );
|
188 |
} else {
|
189 |
-
$iubenda_code .=
|
190 |
}
|
191 |
-
|
192 |
$iubenda_code .= "\n
|
193 |
<script>
|
194 |
var iCallback = function() {};
|
@@ -207,28 +338,32 @@ class iubenda_Cookie_Law_Solution {
|
|
207 |
}
|
208 |
}
|
209 |
</script>";
|
210 |
-
|
211 |
echo $iubenda_code;
|
212 |
}
|
213 |
-
|
214 |
/**
|
215 |
* Initialize html output.
|
216 |
*
|
217 |
* @return void
|
218 |
*/
|
219 |
public function output_start() {
|
220 |
-
|
|
|
|
|
221 |
}
|
222 |
-
|
223 |
/**
|
224 |
* Finish html output.
|
225 |
*
|
226 |
* @return void
|
227 |
*/
|
228 |
public function output_end() {
|
229 |
-
|
|
|
|
|
230 |
}
|
231 |
-
|
232 |
/**
|
233 |
* Handle final html output.
|
234 |
*
|
@@ -237,341 +372,294 @@ class iubenda_Cookie_Law_Solution {
|
|
237 |
*/
|
238 |
public function output_callback( $output ) {
|
239 |
// break on ajax, xmlrpc or iub_no_parse request
|
240 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
241 |
return $output;
|
242 |
}
|
243 |
-
|
244 |
// break on admin side
|
245 |
-
if ( is_admin() )
|
246 |
return $output;
|
247 |
-
|
|
|
248 |
// break for logged in users?
|
249 |
/* if ( is_user_logged_in() ) {
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
// break on rss feed
|
255 |
-
if (
|
256 |
-
|
257 |
-
return $output;
|
258 |
-
}
|
259 |
}
|
260 |
-
|
261 |
if ( strpos( $output, "<html" ) === false ) {
|
262 |
return $output;
|
263 |
} elseif ( strpos( $output, "<html" ) > 200 ) {
|
264 |
return $output;
|
265 |
}
|
266 |
-
|
267 |
// check whether to run parser or not
|
268 |
-
if (
|
269 |
-
|
270 |
-
|
271 |
-
|| iubendaPage::bot_detected()
|
272 |
-
|| $_POST
|
273 |
-
|| defined( 'IUBENDA_NO_HTML' )
|
274 |
-
|| ( get_option( 'iubenda_output_filter' ) && ob_get_level() > 1 ) ) {
|
275 |
-
|
276 |
return $output;
|
277 |
}
|
278 |
-
|
279 |
$startime = microtime( true );
|
280 |
-
|
281 |
// experimental class
|
282 |
-
if (
|
283 |
$faster = new iubendaFaster;
|
284 |
-
|
285 |
// render output
|
286 |
$output = $faster->isParse( mb_convert_encoding( $output, 'HTML-ENTITIES', 'UTF-8' ) );
|
287 |
-
|
288 |
// append signature
|
289 |
$output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
|
290 |
-
|
291 |
} else {
|
292 |
$page = new iubendaPage( $output );
|
293 |
$page->parse();
|
294 |
-
|
295 |
// render output
|
296 |
$output = $page->get_converted_page();
|
297 |
-
|
298 |
// append signature
|
299 |
$output .= '<!-- Parsed with iubenda default class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
|
300 |
}
|
301 |
-
|
302 |
return apply_filters( 'iubenda_final_output', $output );
|
303 |
}
|
304 |
|
305 |
/**
|
306 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
*
|
308 |
-
* @return
|
309 |
*/
|
310 |
-
public function
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
|
|
323 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
}
|
325 |
}
|
326 |
|
327 |
/**
|
328 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
*
|
330 |
* @return void
|
331 |
*/
|
332 |
-
public function
|
333 |
-
if ( ! current_user_can( 'manage_options' ) )
|
334 |
-
|
335 |
-
}
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
$
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
$language_tag = $iubenda_language;
|
345 |
-
|
346 |
-
break;
|
347 |
-
}
|
348 |
-
}
|
349 |
-
|
350 |
-
update_option( "iubenda-code-$language_tag", $wpml_old );
|
351 |
-
update_option( "iubenda-code-default", $wpml_old );
|
352 |
-
update_option( "iub_code", false );
|
353 |
-
}
|
354 |
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
} else {
|
366 |
-
update_option( "iubenda_ctype", false );
|
367 |
-
}
|
368 |
-
if ( ! empty( $_POST['iubenda_parse'] ) ) {
|
369 |
-
update_option( "iubenda_parse", true );
|
370 |
-
} else {
|
371 |
-
update_option( "iubenda_parse", false );
|
372 |
-
}
|
373 |
-
if ( ! empty( $_POST['iubenda_output_filter'] ) ) {
|
374 |
-
update_option( "iubenda_output_filter", true );
|
375 |
-
} else {
|
376 |
-
update_option( "iubenda_output_filter", false );
|
377 |
-
}
|
378 |
-
if ( ! empty( $_POST['iubenda_output_feed'] ) ) {
|
379 |
-
update_option( "iubenda_output_feed", true );
|
380 |
} else {
|
381 |
-
|
382 |
}
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
if ( ! get_option( "default_skip_parsing" ) ) {
|
395 |
-
update_option( "default_skip_parsing", true );
|
396 |
-
update_option( "skip_parsing", "skip" );
|
397 |
-
}
|
398 |
-
if ( ! get_option( "default_parser_engine" ) ) {
|
399 |
-
update_option( "default_parser_engine", true );
|
400 |
-
update_option( "parser_engine", "default" );
|
401 |
-
}
|
402 |
-
if ( ! get_option( "default_iubendactype" ) ) {
|
403 |
-
update_option( "default_iubendactype", true );
|
404 |
-
update_option( "iubenda_ctype", true );
|
405 |
-
}
|
406 |
-
if ( ! get_option( "default_iubendaparse" ) ) {
|
407 |
-
update_option( "default_iubendaparse", true );
|
408 |
-
update_option( "iubenda_parse", true );
|
409 |
-
}
|
410 |
-
if ( ! get_option( "default_iubenda_output_feed" ) ) {
|
411 |
-
update_option( "default_iubenda_output_feed", true );
|
412 |
-
update_option( "iubenda_output_feed", true );
|
413 |
-
}
|
414 |
-
|
415 |
-
/**/
|
416 |
-
|
417 |
-
if ( $_POST ) {
|
418 |
-
foreach ( $iubenda_language as $iub_check ) {
|
419 |
-
if ( ! empty( $_POST["iubenda-code-$iub_check"] ) ) {
|
420 |
-
update_option( "iubenda-code-$iub_check", stripslashes( $_POST["iubenda-code-$iub_check"] ) );
|
421 |
}
|
422 |
}
|
|
|
423 |
}
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
if ( get_option( "parser_engine" ) == "default" )
|
448 |
-
$parser_engine_default = 'checked="true"';
|
449 |
-
if ( get_option( "parser_engine" ) == "new" )
|
450 |
-
$parser_engine_new = 'checked="true"';
|
451 |
-
|
452 |
-
/**/
|
453 |
-
|
454 |
-
echo '
|
455 |
-
<div id="iubenda-view">
|
456 |
-
|
457 |
-
<a class="iubenda-link" href="http://iubenda.com"><img id="iubenda-logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAAAdCAMAAAB8M6mmAAAAhFBMVEUAAAA0O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0I0O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr3/////G69+35tdTw5/U8Ofx+vdiyKd+0rep4c/i9e8otIeN17/AB1g0AAAAHnRSTlMAEBAgIDAwQEBQUGBwcICAkJCgoLCwwMDQ0ODg8PCQCZ0FAAACrklEQVR4Xr2V63LbIBCFF1OZKBCiKAohlK7kXHt5//cruyDjjFTX42l9fnhh1+yHGB0EAJu7kXS/gUto8zRmPV2Edz/OergA7ctYtV0DCKPPBCgrF7kb4rzs3incrCzpEd05LKEDolqkb4nzNr1RuF1UB8TzcE1E/CPu+7Rbxwnozn06Eddw25H0wr9XsJQh3Flyazh4HGd9hRWpf4zbfptx15fAwR53dRHcWHFSkQDKoOJ05w5M1NjBdXpvFU0WW9TlHidN73rbVtz7844PU7mIiADQOkyaccIjqQOW6DHQ/3yTxiYg2pQhqVIfMPYDYiwZHdF3gdpk3K/XadoVH6hCgbbivMcsyzSPhntiFBAcbcOj6xI/QKl7UYynciOTj9YWJ/z8scfBjIOKQ68ADC2n8+oKNc37FHuqp7xMsQGuRzHvV1U/tMVQVwm0O4oLIg+4v0CkKXNiChZxEMVmbQrN/tBjweVdygXu7g84B3N/D6AxWhYdY8ZZgDroM6QaQUfGiwXu8Tiu5UyP0e3VLHERccUIqseCuzkVJzjjMEDVAtfgCk4HdLrgbk/FQcHhMZxa4hqPLg0WuKcTce1fcPITTvMbtoIbj+MaHvWIAxQFuXqYuuLYMKH08xQeTsVpbqRrPx1h9VVxFcd+6w77PX7G+dmtC5zDILK90XAl2nUjoD7A2fJUzRK3AYCBLzc5JCwqIarNTdmHxaRg7YBR5Gl3iJOx8EyKVkjFuxO8qhky7nV6m79ALXdDLyhGxXdf0EJYjO1s9yLFN2TZjgiIngaaSt4FjPla55AWc5o+dx/P0zQ9fzCOT5EfMBU19+nygl5CkeVEaCo6gOfI76AKuewwWgnQ0NRJcNwVxirGgdSGOlkFs5SxLZFrwppaXUoZ6qD1PFWSQ8p9wl3D/9ZvoAF23RgFj1kAAAAASUVORK5CYII="/></a>
|
458 |
-
|
459 |
-
<p class="iubenda-text">
|
460 |
-
' . __( "This plugin is the easiest and most comprehensive way to adapt your WordPress site to the European cookie law. Upon your user's first visit, the plugin will take care of collecting their consent, of blocking the most popular among the scripts that install cookies and subsequently reactivate these scripts as soon as consent is provided. The basic settings include obtaining consent by a simple scroll action (the most effective method) and script reactivation without refreshing the page.", 'iubenda-cookie-law-solution' ) . '
|
461 |
-
<span class="iubenda-title">' . __( "Would you like to know more about the cookie law?", 'iubenda-cookie-law-solution' ) . '</span>
|
462 |
-
' . sprintf( __( "Read our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">complete guide to the cookie law.</a>", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/soluzione-cookie-law" ) . '
|
463 |
-
<span class="iubenda-title">' . __( "What is the full functionality of the plugin?", 'iubenda-cookie-law-solution' ) . '</span>
|
464 |
-
' . sprintf( __( "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">plugin page.</a>", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/810" ) . '
|
465 |
-
<span class="iubenda-title">' . __( "Enter the iubenda code for the Cookie Solution below.", 'iubenda-cookie-law-solution' ) . '</span>
|
466 |
-
' . sprintf( __( "In order to run the plugin, you need to enter the iubenda code that activates the cookie law banner and the cookie policy in the form below. This code can be generated on www.iubenda.com, following <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">this guide.</a>", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/680" ) . '
|
467 |
-
</p>
|
468 |
-
|
469 |
-
<form id="iubenda-tabs" method="post" action="' . str_replace( '%7E', '~', $_SERVER['REQUEST_URI'] ) . '">';
|
470 |
-
|
471 |
-
if ( $_POST )
|
472 |
-
echo '<div id="iubenda-saved"><p>' . __( 'Settings applied successfully', 'iubenda-cookie-law-solution' ). '</p></div>';
|
473 |
-
|
474 |
-
if ( defined( "IUBENDA_WPML" ) ) {
|
475 |
-
|
476 |
-
$languages = icl_get_languages( 'skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str' );
|
477 |
-
|
478 |
-
foreach ( $languages as $language => $value ) {
|
479 |
-
|
480 |
-
echo
|
481 |
-
'
|
482 |
-
<div class="iubenda-tab iubenda-code-' . $language . '" onclick="iubendaGetLanguage(' . chr( 39 ) . $language . chr( 39 ) . ')" data-iubenda-button>'
|
483 |
-
. $value["translated_name"] . '
|
484 |
-
</div>
|
485 |
-
';
|
486 |
-
}
|
487 |
-
|
488 |
-
foreach ( $languages as $language => $value ) {
|
489 |
-
echo
|
490 |
-
'
|
491 |
-
<div id="iubenda-code-' . $language . '">
|
492 |
-
<textarea class="iubenda-textarea" name="iubenda-code-' . $language . '">' . stripslashes( get_option( "iubenda-code-" . $language ) ) . '</textarea>
|
493 |
-
</div>
|
494 |
-
';
|
495 |
-
}
|
496 |
-
|
497 |
-
echo
|
498 |
-
'
|
499 |
-
<div id="iubenda-information">' . __( 'Select a language to correctly pair it with your script', 'iubenda-cookie-law-solution' ) . '</div>
|
500 |
-
';
|
501 |
-
} else {
|
502 |
-
echo '<textarea class="iubenda-textarea iubenda-textarea-single" name="iubenda-code-default">' . stripslashes( get_option( "iubenda-code-default" ) ) . '</textarea>';
|
503 |
-
}
|
504 |
-
|
505 |
-
echo '
|
506 |
-
<div class="iubenda-checkbox-options">
|
507 |
-
|
508 |
-
<p>
|
509 |
-
<label>
|
510 |
-
<input id="parser_type" type="checkbox" name="iubenda_parse" value="enabled" ' . $checked_parse . '>
|
511 |
-
<span>
|
512 |
-
' . __( "Automatically blocks scripts detected by the plugin", 'iubenda-cookie-law-solution' ) . '<br />
|
513 |
-
(' . sprintf( __( "see <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">our documentation</a> for the list of detected scripts.", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/810" ) . ')
|
514 |
-
</span>
|
515 |
-
</label>
|
516 |
-
</p>
|
517 |
-
|
518 |
-
<div id="iubenda_parse_child">
|
519 |
-
<p id="parser_engine">
|
520 |
-
' . __( "Parsing engine", 'iubenda-cookie-law-solution' ) . ':<br>
|
521 |
-
<label><input type="radio" name="parser_engine" value="default" ' . $parser_engine_default . '>' . __( "Default", 'iubenda-cookie-law-solution' ) . '</label>
|
522 |
-
<label><input type="radio" name="parser_engine" value="new" ' . $parser_engine_new . '>' . __( "Experimental (enhances performance)", 'iubenda-cookie-law-solution' ) . '</label>
|
523 |
-
</p>
|
524 |
-
<p id="par_skip_parsing">
|
525 |
-
<label>
|
526 |
-
<input type="checkbox" name="skip_parsing" value="skip" ' . $checked . '>
|
527 |
-
<span>
|
528 |
-
' . __( "Leaves scripts untouched on the page if the user has already given consent", 'iubenda-cookie-law-solution' ) . '<br />
|
529 |
-
(' . __( "improves performance, highly recommended, to be deactivated only if your site uses a caching system", 'iubenda-cookie-law-solution' ) . ')
|
530 |
-
</span>
|
531 |
-
</label>
|
532 |
-
</p>
|
533 |
-
<p id="par_iubenda_output_filter">
|
534 |
-
<label>
|
535 |
-
<input type="checkbox" name="iubenda_output_filter" value="enabled" ' . $checked_output_filter . '>
|
536 |
-
<span>
|
537 |
-
' . __( "Applies special optimizations in cases with faulty output", 'iubenda-cookie-law-solution' ) . '<br />
|
538 |
-
(' . __( "only select this option if you had performance problems or if you notice that the blocking of code is run several times", 'iubenda-cookie-law-solution' ) . ')
|
539 |
-
</span>
|
540 |
-
</label>
|
541 |
-
</p>
|
542 |
-
|
543 |
-
<hr />
|
544 |
-
</div> <!-- /iubenda_parse_child -->
|
545 |
-
|
546 |
-
<p>
|
547 |
-
<label>
|
548 |
-
<input type="checkbox" name="iubenda_ctype" value="enabled" ' . $checked_ctype . '>
|
549 |
-
<span>
|
550 |
-
' . __( 'Restrict the plugin to run only for requests that have "Content-type: text / html" (recommended)', 'iubenda-cookie-law-solution' ) . '
|
551 |
-
</span>
|
552 |
-
</label>
|
553 |
-
</p>
|
554 |
-
<p>
|
555 |
-
<label>
|
556 |
-
<input type="checkbox" name="iubenda_output_feed" value="enabled" ' . $checked_output_feed . '>
|
557 |
-
<span>
|
558 |
-
' . __( 'Do not run the plugin inside the RSS feed (recommended)', 'iubenda-cookie-law-solution' ) . '
|
559 |
-
</span>
|
560 |
-
</label>
|
561 |
-
</p>
|
562 |
-
<p>
|
563 |
-
<input type="submit" value="' . __( 'Save' ) . '" class="button button-primary">
|
564 |
-
</p>
|
565 |
-
</div> <!-- /iubenda-checkbox-options -->
|
566 |
-
</form>
|
567 |
<p class="iubenda-text">
|
568 |
-
<span class="iubenda-title">' . __(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
' . sprintf( __( "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">support forum.</a>", 'iubenda-cookie-law-solution' ), "https://support.iubenda.com/forums/314835-general/suggestions/9670701-discussion-regarding-the-iubenda-cookie-law-soluti" ) . '
|
570 |
</p>
|
571 |
<p class="iubenda-text">
|
572 |
-
<span class="iubenda-title">' . __( 'Want to try a beta version of this plugin with the latest features?', 'iubenda-cookie-law-solution' ) . '</span
|
573 |
' . sprintf( __( "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">documentation pages</a> and follow the instructions to install a beta version.", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/810" ) . '
|
574 |
-
</p>
|
575 |
-
|
|
|
|
|
|
|
|
|
576 |
}
|
|
|
577 |
}
|
4 |
* Plugin URI: https://www.iubenda.com
|
5 |
* Description: Iubenda Cookie Solution permette di gestire tutti gli aspetti della cookie law su WP.
|
6 |
* Author: iubenda
|
7 |
+
* Version: 1.14.0-beta4
|
8 |
* Text Domain: iubenda-cookie-law-solution
|
9 |
* Author URI: https://www.iubenda.com
|
10 |
*/
|
15 |
|
16 |
// define contants
|
17 |
define( 'IUB_DEBUG', 0 );
|
|
|
18 |
|
19 |
// set plugin instance
|
20 |
$iubenda_cookie_law_solution = new iubenda_Cookie_Law_Solution();
|
29 |
|
30 |
public $options;
|
31 |
public $defaults = array(
|
32 |
+
'parse' => false, // iubenda_parse
|
33 |
+
'skip_parsing' => true, // skip_parsing
|
34 |
+
'ctype' => true, // iubenda_ctype
|
35 |
+
'parse' => false, // iubenda_parse
|
36 |
+
'parser_engine' => 'default', // parser_engine
|
37 |
+
'output_feed' => true, // iubenda_output_feed
|
38 |
+
'code_default' => false, // iubenda-code-default,
|
39 |
);
|
40 |
+
public $version = '1.14.0';
|
41 |
+
public $no_html = false;
|
42 |
+
public $multilang = false;
|
43 |
+
public $languages = array();
|
44 |
+
public $lang_default = '';
|
45 |
+
|
46 |
/**
|
47 |
+
* Class constructor.
|
48 |
*/
|
49 |
public function __construct() {
|
50 |
+
register_activation_hook( __FILE__, array( $this, 'activation' ) );
|
51 |
+
register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
|
52 |
|
53 |
// settings
|
54 |
+
$this->options = array_merge( $this->defaults, (array) get_option( 'iubenda_cookie_law_solution', $this->defaults ) );
|
55 |
|
56 |
// actions
|
57 |
+
add_action( 'admin_init', array( $this, 'register_options' ) );
|
58 |
+
add_action( 'admin_init', array( $this, 'update_plugin' ), 9 );
|
59 |
add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
|
60 |
+
add_action( 'admin_notices', array( $this, 'settings_errors' ) );
|
61 |
+
// add_action( 'admin_menu', array( $this, 'save_options' ), 9 );
|
62 |
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
63 |
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
64 |
add_action( 'after_setup_theme', array( $this, 'register_shortcode' ) );
|
65 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
66 |
+
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
|
67 |
add_action( 'wp_head', array( $this, 'wp_head' ), 99 );
|
68 |
+
add_action( 'template_redirect', array( $this, 'output_start' ), 0 );
|
69 |
add_action( 'shutdown', array( $this, 'output_end' ), 100 );
|
70 |
}
|
71 |
+
|
72 |
/**
|
73 |
* Initialize plugin.
|
74 |
+
*
|
75 |
+
* @return void
|
76 |
*/
|
77 |
public function init() {
|
78 |
|
79 |
+
// check if WPML or Polylang is active
|
80 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
81 |
+
|
82 |
+
// Polylang support
|
83 |
+
if ( is_plugin_active( 'polylang/polylang.php' ) && function_exists( 'PLL' ) ) {
|
84 |
+
$this->multilang = true;
|
85 |
+
|
86 |
+
// get registered languages
|
87 |
+
$registered_languages = PLL()->model->get_languages_list();
|
88 |
+
|
89 |
+
if ( ! empty( $registered_languages ) ) {
|
90 |
+
foreach ( $registered_languages as $language )
|
91 |
+
$this->languages[$language->slug] = $language->name;
|
92 |
+
}
|
93 |
+
|
94 |
+
// get default language
|
95 |
+
$this->lang_default = pll_default_language();
|
96 |
+
|
97 |
+
// WPML support
|
98 |
+
} elseif ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && class_exists( 'SitePress' ) ) {
|
99 |
+
$this->multilang = true;
|
100 |
+
|
101 |
+
global $sitepress;
|
102 |
+
|
103 |
+
// get registered languages
|
104 |
+
$registered_languages = icl_get_languages();
|
105 |
+
|
106 |
+
if ( ! empty( $registered_languages ) ) {
|
107 |
+
foreach ( $registered_languages as $language )
|
108 |
+
$this->languages[$language['code']] = $language['display_name'];
|
109 |
+
}
|
110 |
+
|
111 |
+
// get default language
|
112 |
+
$this->lang_default = $sitepress->get_default_language();
|
113 |
}
|
114 |
|
115 |
// load Simple HTML DOM if needed
|
121 |
require_once( dirname( __FILE__ ) . '/lib/iubenda.class.faster.php' );
|
122 |
require_once( dirname( __FILE__ ) . '/lib/iubenda.class.php' );
|
123 |
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Plugin activation.
|
127 |
+
*
|
128 |
+
* @return void
|
129 |
+
*/
|
130 |
+
public function activation() {
|
131 |
+
add_option( 'iubenda_cookie_law_solution', $this->options, '', 'no' );
|
132 |
+
add_option( 'iubenda_cookie_law_version', $this->version, '', 'no' );
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Plugin deactivation.
|
137 |
+
*
|
138 |
+
* @return void
|
139 |
+
*/
|
140 |
+
public function deactivation() {
|
141 |
+
// remove options from database?
|
142 |
+
// delete_option( 'iubenda_cookie_law_solution' );
|
143 |
+
// delete_option( 'iubenda_cookie_law_version' );
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Plugin options migration for versions < 1.14.0
|
148 |
+
*
|
149 |
+
* @return void
|
150 |
+
*/
|
151 |
+
public function update_plugin() {
|
152 |
+
if ( ! current_user_can( 'install_plugins' ) )
|
153 |
+
return;
|
154 |
+
|
155 |
+
$db_version = get_option( 'iubenda_cookie_law_version' );
|
156 |
+
$db_version = ! $db_version ? '1.13.0' : $db_version;
|
157 |
+
|
158 |
+
if ( $db_version != false ) {
|
159 |
+
if ( version_compare( $db_version, '1.14.0', '<' ) ) {
|
160 |
+
$options = array();
|
161 |
+
|
162 |
+
$old_new = array(
|
163 |
+
'iubenda_parse' => 'parse',
|
164 |
+
'skip_parsing' => 'skip_parsing',
|
165 |
+
'iubenda_ctype' => 'ctype',
|
166 |
+
'iubenda_parse' => 'parse',
|
167 |
+
'parser_engine' => 'parser_engine',
|
168 |
+
'iubenda_output_feed' => 'output_feed',
|
169 |
+
'iubenda-code-default' => 'code_default',
|
170 |
+
'default_skip_parsing' => '',
|
171 |
+
'default_iubendactype' => '',
|
172 |
+
'default_iubendaparse' => '',
|
173 |
+
'default_parser_engine' => '',
|
174 |
+
'iub_code' => '',
|
175 |
+
);
|
176 |
+
|
177 |
+
foreach ( $old_new as $old => $new ) {
|
178 |
+
if ( $new ) {
|
179 |
+
$options[$new] = get_option( $old );
|
180 |
+
}
|
181 |
+
delete_option( $old );
|
182 |
+
}
|
183 |
+
|
184 |
+
// multilang support
|
185 |
+
if ( ! empty( $this->languages ) ) {
|
186 |
+
foreach ( $this->languages as $lang ) {
|
187 |
+
$code = get_option( 'iubenda-code-' . $lang );
|
188 |
+
|
189 |
+
if ( ! empty( $code ) ) {
|
190 |
+
$options['code_' . $lang] = $code;
|
191 |
+
|
192 |
+
delete_option( 'iubenda-code-' . $lang );
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
add_option( 'iubenda_cookie_law_solution', $options, '', 'no' );
|
198 |
+
add_option( 'iubenda_cookie_law_version', $this->version, '', 'no' );
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
/**
|
204 |
* Register shortcode function.
|
205 |
*/
|
206 |
public function register_shortcode() {
|
207 |
add_shortcode( 'iub-cookie-policy', array( $this, 'shortcode' ) );
|
208 |
}
|
209 |
+
|
210 |
/**
|
211 |
* Handle shortcode function.
|
212 |
*
|
223 |
*/
|
224 |
public function admin_menu_options() {
|
225 |
add_menu_page(
|
226 |
+
'iubenda', 'iubenda', apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ), 'iubenda-cookie-law-solution', array( $this, 'options_page' ), 'none' );
|
227 |
}
|
228 |
+
|
229 |
/**
|
230 |
* Load textdomain.
|
231 |
*/
|
232 |
public function load_textdomain() {
|
233 |
load_plugin_textdomain( 'iubenda-cookie-law-solution', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
234 |
}
|
235 |
+
|
236 |
/**
|
237 |
* Load admin scripts and styles.
|
238 |
*
|
240 |
* @return void
|
241 |
*/
|
242 |
public function admin_enqueue_scripts( $page ) {
|
|
|
243 |
if ( $page !== 'toplevel_page_iubenda-cookie-law-solution' )
|
244 |
return;
|
245 |
|
246 |
wp_enqueue_script(
|
247 |
+
'iubenda-admin', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' )
|
248 |
);
|
249 |
|
250 |
wp_enqueue_style( 'iubenda-admin', plugins_url( 'css/admin.css', __FILE__ ) );
|
251 |
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Load admin style inline, for menu icon only.
|
255 |
+
*
|
256 |
+
* @return mixed
|
257 |
+
*/
|
258 |
+
public function admin_print_styles() {
|
259 |
+
echo '
|
260 |
+
<style>
|
261 |
+
a.toplevel_page_iubenda-cookie-law-solution .wp-menu-image {
|
262 |
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDkuNDE4IiBoZWlnaHQ9IjI3My4wMTgiIHZpZXdCb3g9IjAgMCAxMDkuNDE4IDI3My4wMTgiPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBmaWxsPSIjRkZGIiBkPSJNMTA5LjQxOCA1NC41M0MxMDkuNDE4IDI0LjQwNCA4NC45MzYgMCA1NC43MDggMCAyNC40ODYgMCAwIDI0LjQwNCAwIDU0LjUzYzAgMTQuNzY1IDUuOSAyOC4xNCAxNS40ODcgMzcuOTUzTDQuMTI0IDI3My4wMThoMTAzLjg3TDk2LjQ3NyA4OS43MzJjOC4wODYtOS41MDQgMTIuOTQtMjEuNzgyIDEyLjk0LTM1LjIwMnptLTY1LjM2LTkuOTAzQzQ3LjAwNyA0MS42OCA1MC42MyA0MC4yIDU0LjkzIDQwLjJjNC4yIDAgNy43NzMgMS40OCAxMC43MjUgNC40MjcgMi45NDggMi45NDggNC40MjQgNi41MjIgNC40MjQgMTAuNzI0IDAgNC4xOTctMS40NzYgNy43OTUtNC40MjQgMTAuNzk1LTIuOTUyIDMtNi41MjQgNC40OTgtMTAuNzI0IDQuNDk4LTQuMTk4IDAtNy44LTEuNDk4LTEwLjc5Ny00LjQ5OC0zLTMtNC41LTYuNi00LjUtMTAuNzk0LS4wMDItNC4yIDEuNDczLTcuNzc0IDQuNDI2LTEwLjcyM3ptNDQuMTY1IDIwOC44M0gyMS40ODZ2LTUuNDAyYzYuNyAwIDExLjItLjY0NiAxMy40OTgtMS45NDYgMi4yOTgtMS4yOTUgNC4xMjUtMy40NSA1LjQ3NS02LjQ0NyAxLjM0Ni0zIDIuMDIzLTguNzQ3IDIuMDIzLTE3LjI0N3YtNTIuOTQzYzAtMTQuODk4LS40NTMtMjQuNTQtMS4zNTItMjguOTQ0LS42OTgtMy4xOTYtMS43OTctNS40Mi0zLjMtNi42Ny0xLjQ5NS0xLjI1LTMuNTQ4LTEuODc0LTYuMTQ3LTEuODc0LTIuNzk4IDAtNi4yLjc1LTEwLjE5NyAyLjI1bC0yLjEwMi01LjQgNDEuMzk0LTE2Ljc5N2g2LjZ2MTEwLjM3N2MwIDguNTk4LjYyNCAxNC4zMiAxLjg3NSAxNy4xNyAxLjI1IDIuODQ4IDMuMDk2IDQuOTc0IDUuNTQ4IDYuMzc0IDIuNDUgMS40MDMgNi45MjYgMi4wOTcgMTMuNDIzIDIuMDk3djUuNHoiLz48L3N2Zz4=);
|
263 |
+
background-position: center center;
|
264 |
+
background-repeat: no-repeat;
|
265 |
+
background-size: 7px auto;
|
266 |
+
}
|
267 |
+
</style>
|
268 |
+
';
|
269 |
+
}
|
270 |
+
|
271 |
/**
|
272 |
* Add wp_head content.
|
273 |
*
|
274 |
* @return mixed
|
275 |
*/
|
276 |
public function wp_head() {
|
277 |
+
/* check if user is logged in, then disable the banner.
|
278 |
+
if ( is_user_logged_in() ) {
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
*/
|
282 |
+
|
283 |
+
// break on admin side
|
284 |
+
if ( is_admin() ) {
|
285 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
}
|
287 |
+
|
288 |
// check content type
|
289 |
+
if ( (bool) $this->options['ctype'] == true ) {
|
290 |
+
$iub_headers = headers_list();
|
291 |
+
$destroy = true;
|
292 |
+
|
293 |
+
foreach ( $iub_headers as $h ) {
|
294 |
+
if ( strpos( $h, "Content-Type: text/html" ) !== false || strpos( $h, "Content-type: text/html" ) !== false ) {
|
295 |
+
$destroy = false;
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
if ( $destroy ) {
|
300 |
+
$this->no_html = true;
|
301 |
+
}
|
302 |
}
|
303 |
+
|
304 |
+
// is post or not html content type?
|
305 |
+
if ( $_POST || $this->no_html ) {
|
306 |
return;
|
307 |
}
|
308 |
+
|
309 |
// initial head output
|
310 |
$iubenda_code = "";
|
311 |
+
|
312 |
+
if ( $this->multilang === true && defined( 'ICL_LANGUAGE_CODE' ) && isset( $this->options['code_' . ICL_LANGUAGE_CODE] ) ) {
|
313 |
+
$iubenda_code .= $this->options['code_' . ICL_LANGUAGE_CODE];
|
314 |
+
|
315 |
+
// no code for current language, use default
|
316 |
+
if ( ! $iubenda_code ) {
|
317 |
+
$iubenda_code .= $this->options['code_default'];
|
|
|
|
|
|
|
|
|
|
|
318 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
} else {
|
320 |
+
$iubenda_code .= $this->options['code_default'];
|
321 |
}
|
322 |
+
|
323 |
$iubenda_code .= "\n
|
324 |
<script>
|
325 |
var iCallback = function() {};
|
338 |
}
|
339 |
}
|
340 |
</script>";
|
341 |
+
|
342 |
echo $iubenda_code;
|
343 |
}
|
344 |
+
|
345 |
/**
|
346 |
* Initialize html output.
|
347 |
*
|
348 |
* @return void
|
349 |
*/
|
350 |
public function output_start() {
|
351 |
+
if ( ! is_admin() ) {
|
352 |
+
ob_start( array( $this, 'output_callback' ) );
|
353 |
+
}
|
354 |
}
|
355 |
+
|
356 |
/**
|
357 |
* Finish html output.
|
358 |
*
|
359 |
* @return void
|
360 |
*/
|
361 |
public function output_end() {
|
362 |
+
if ( ! is_admin() && ob_get_level() ) {
|
363 |
+
ob_end_flush();
|
364 |
+
}
|
365 |
}
|
366 |
+
|
367 |
/**
|
368 |
* Handle final html output.
|
369 |
*
|
372 |
*/
|
373 |
public function output_callback( $output ) {
|
374 |
// break on ajax, xmlrpc or iub_no_parse request
|
375 |
+
if (
|
376 |
+
( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
|
377 |
+
|| ( defined( 'DOING_AJAX' ) && DOING_AJAX )
|
378 |
+
|| isset( $_SERVER["HTTP_X_REQUESTED_WITH"] )
|
379 |
+
|| isset( $_GET['iub_no_parse'] )
|
380 |
+
) {
|
381 |
return $output;
|
382 |
}
|
383 |
+
|
384 |
// break on admin side
|
385 |
+
if ( is_admin() ) {
|
386 |
return $output;
|
387 |
+
}
|
388 |
+
|
389 |
// break for logged in users?
|
390 |
/* if ( is_user_logged_in() ) {
|
391 |
+
return $output;
|
392 |
+
}
|
393 |
+
*/
|
394 |
+
|
395 |
// break on rss feed
|
396 |
+
if ( is_feed() && $this->options['output_feed'] ) {
|
397 |
+
return $output;
|
|
|
|
|
398 |
}
|
399 |
+
|
400 |
if ( strpos( $output, "<html" ) === false ) {
|
401 |
return $output;
|
402 |
} elseif ( strpos( $output, "<html" ) > 200 ) {
|
403 |
return $output;
|
404 |
}
|
405 |
+
|
406 |
// check whether to run parser or not
|
407 |
+
if (
|
408 |
+
! $this->options['parse'] || ( iubendaPage::consent_given() && $this->options['skip_parsing'] ) || iubendaPage::bot_detected() || $_POST || $this->no_html ) {
|
409 |
+
|
|
|
|
|
|
|
|
|
|
|
410 |
return $output;
|
411 |
}
|
412 |
+
|
413 |
$startime = microtime( true );
|
414 |
+
|
415 |
// experimental class
|
416 |
+
if ( $this->options['parser_engine'] == 'new' ) {
|
417 |
$faster = new iubendaFaster;
|
418 |
+
|
419 |
// render output
|
420 |
$output = $faster->isParse( mb_convert_encoding( $output, 'HTML-ENTITIES', 'UTF-8' ) );
|
421 |
+
|
422 |
// append signature
|
423 |
$output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
|
424 |
+
// default class
|
425 |
} else {
|
426 |
$page = new iubendaPage( $output );
|
427 |
$page->parse();
|
428 |
+
|
429 |
// render output
|
430 |
$output = $page->get_converted_page();
|
431 |
+
|
432 |
// append signature
|
433 |
$output .= '<!-- Parsed with iubenda default class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
|
434 |
}
|
435 |
+
|
436 |
return apply_filters( 'iubenda_final_output', $output );
|
437 |
}
|
438 |
|
439 |
/**
|
440 |
+
* Register plugin options.
|
441 |
+
*/
|
442 |
+
public function register_options() {
|
443 |
+
register_setting( 'iubenda_cookie_law_solution', 'iubenda_cookie_law_solution', array( $this, 'save_options' ) );
|
444 |
+
|
445 |
+
add_settings_section( 'iubenda_cookie_law_solution', '', '', 'iubenda_cookie_law_solution' );
|
446 |
+
add_settings_field( 'iub_code', __( 'Code', 'iubenda-cookie-law-solution' ), array( $this, 'iub_code' ), 'iubenda_cookie_law_solution', 'iubenda_cookie_law_solution' );
|
447 |
+
add_settings_field( 'iub_parse', __( 'Scripts blocking', 'iubenda-cookie-law-solution' ), array( $this, 'iub_parse' ), 'iubenda_cookie_law_solution', 'iubenda_cookie_law_solution' );
|
448 |
+
add_settings_field( 'iub_ctype', __( 'Content type', 'iubenda-cookie-law-solution' ), array( $this, 'iub_ctype' ), 'iubenda_cookie_law_solution', 'iubenda_cookie_law_solution' );
|
449 |
+
add_settings_field( 'iub_output_feed', __( 'RSS feed', 'iubenda-cookie-law-solution' ), array( $this, 'iub_output_feed' ), 'iubenda_cookie_law_solution', 'iubenda_cookie_law_solution' );
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Display errors and notices.
|
454 |
+
*/
|
455 |
+
public function settings_errors() {
|
456 |
+
settings_errors( 'iub_settings_errors' );
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Code option.
|
461 |
*
|
462 |
+
* @return mixed
|
463 |
*/
|
464 |
+
public function iub_code() {
|
465 |
+
// multilang support
|
466 |
+
if ( $this->multilang && ! empty( $this->languages ) ) {
|
467 |
+
echo '
|
468 |
+
<div id="contextual-help-wrap" class="hidden" tabindex="-1" style="display: block;">
|
469 |
+
<div id="contextual-help-back"></div>
|
470 |
+
<div id="contextual-help-columns">
|
471 |
+
<div class="contextual-help-tabs">
|
472 |
+
<ul>';
|
473 |
+
foreach ( $this->languages as $lang_id => $lang_name ) {
|
474 |
+
echo '
|
475 |
+
<li id="tab-link-overview" class="' . ( $this->lang_default == $lang_id ? 'active' : '' ) . '">
|
476 |
+
<a href="#tab-panel-' . $lang_id . '" aria-controls="tab-panel-' . $lang_id . '">' . $lang_name . '</a>
|
477 |
+
</li>';
|
478 |
}
|
479 |
+
echo '
|
480 |
+
</ul>
|
481 |
+
</div>
|
482 |
+
|
483 |
+
<div class="contextual-help-tabs-wrap">';
|
484 |
+
foreach ( $this->languages as $lang_id => $lang_name ) {
|
485 |
+
// get code for the language
|
486 |
+
$code = ! empty( $this->options['code_' . $lang_id] ) ? html_entity_decode( trim( wp_kses( $this->options['code_' . $lang_id], array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) ) ) : '';
|
487 |
+
// handle default, if empty
|
488 |
+
$code = empty( $code ) && $lang_id == $this->lang_default ? html_entity_decode( trim( wp_kses( $this->options['code_default'], array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) ) ) : $code;
|
489 |
+
|
490 |
+
echo '
|
491 |
+
<div id="tab-panel-' . $lang_id . '" class="help-tab-content' . ( $this->lang_default == $lang_id ? ' active' : '' ) . '">
|
492 |
+
<textarea name="iubenda_cookie_law_solution[code_' . $lang_id . ']" class="large-text" cols="50" rows="10">' . $code . '</textarea>
|
493 |
+
<p class="description">' . sprintf( __( 'Enter the iubenda code for %s.', 'iubenda-cookie-law-solution' ), $lang_name ) . '</p>
|
494 |
+
</div>';
|
495 |
+
}
|
496 |
+
echo '
|
497 |
+
</div>
|
498 |
+
</div>
|
499 |
+
</div>';
|
500 |
+
} else {
|
501 |
+
echo '
|
502 |
+
<div id="iub_code_default">
|
503 |
+
<textarea name="iubenda_cookie_law_solution[code_default]" class="large-text" cols="50" rows="10">' . html_entity_decode( trim( wp_kses( $this->options['code_default'], array( 'script' => array( 'type' => array() ) ) ) ) ) . '</textarea>
|
504 |
+
<p class="description">' . __( 'Enter the iubenda code.', 'iubenda-cookie-law-solution' ) . '</p>
|
505 |
+
</div>';
|
506 |
}
|
507 |
}
|
508 |
|
509 |
/**
|
510 |
+
* Parsing option.
|
511 |
+
*
|
512 |
+
* @return mixed
|
513 |
+
*/
|
514 |
+
public function iub_parse() {
|
515 |
+
echo '
|
516 |
+
<div id="iub_parse_container">
|
517 |
+
<label><input id="iub_parse" type="checkbox" name="iubenda_cookie_law_solution[parse]" value="1" ' . checked( true, (bool) $this->options['parse'], false ) . '/>' . __( 'Automatically block scripts detected by the plugin.', 'iubenda-cookie-law-solution' ) . '</label>
|
518 |
+
<p class="description">' . '(' . sprintf( __( "see <a href=\"%s\" target=\"_blank\">our documentation</a> for the list of detected scripts.", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/810" ) . ')' . '</p>
|
519 |
+
<div id="iub_parser_engine_container"' . ( $this->options['parse'] === false ? ' style="display: none;"' : '' ) . '>
|
520 |
+
<div>
|
521 |
+
<label><input id="iub_parser_engine-default" type="radio" name="iubenda_cookie_law_solution[parser_engine]" value="default" ' . checked( 'default', $this->options['parser_engine'], false ) . ' />' . __( 'Default', 'iubenda-cookie-law-solution' ) . '</label>
|
522 |
+
<label><input id="iub_parser_engine-new" type="radio" name="iubenda_cookie_law_solution[parser_engine]" value="new" ' . checked( 'new', $this->options['parser_engine'], false ) . ' />' . __( 'Experimental', 'iubenda-cookie-law-solution' ) . '</label>
|
523 |
+
<p class="description">' . __( 'Select parsing engine.', 'iubenda-cookie-law-solution' ) . '</p>
|
524 |
+
</div>
|
525 |
+
<div>
|
526 |
+
<label><input id="iub_skip_parsing" type="checkbox" name="iubenda_cookie_law_solution[skip_parsing]" value="1" ' . checked( true, (bool) $this->options['skip_parsing'], false ) . '/>' . __( 'Leave scripts untouched on the page if the user has already given consent', 'iubenda-cookie-law-solution' ) . '</label>
|
527 |
+
<p class="description">(' . __( "improves performance, highly recommended, to be deactivated only if your site uses a caching system", 'iubenda-cookie-law-solution' ) . ')</p>
|
528 |
+
</div>
|
529 |
+
</div>
|
530 |
+
</div>';
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Ctype option.
|
535 |
+
*
|
536 |
+
* @return mixed
|
537 |
+
*/
|
538 |
+
public function iub_ctype() {
|
539 |
+
echo '
|
540 |
+
<div id="iub_ctype_container">
|
541 |
+
<label><input id="iub_ctype" type="checkbox" name="iubenda_cookie_law_solution[ctype]" value="1" ' . checked( true, (bool) $this->options['ctype'], false ) . '/>' . __( 'Restrict the plugin to run only for requests that have "Content-type: text / html" (recommended)', 'iubenda-cookie-law-solution' ) . '</label>
|
542 |
+
</div>';
|
543 |
+
}
|
544 |
+
|
545 |
+
/**
|
546 |
+
* RSS feed option.
|
547 |
+
*
|
548 |
+
* @return mixed
|
549 |
+
*/
|
550 |
+
public function iub_output_feed() {
|
551 |
+
echo '
|
552 |
+
<div id="iub_output_feed_container">
|
553 |
+
<label><input id="iub_ctype" type="checkbox" name="iubenda_cookie_law_solution[output_feed]" value="1" ' . checked( true, (bool) $this->options['output_feed'], false ) . '/>' . __( 'Do not run the plugin inside the RSS feed (recommended)', 'iubenda-cookie-law-solution' ) . '</label>
|
554 |
+
</div>';
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Save options.
|
559 |
*
|
560 |
* @return void
|
561 |
*/
|
562 |
+
public function save_options( $input ) {
|
563 |
+
if ( ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ) ) )
|
564 |
+
return;
|
|
|
565 |
|
566 |
+
// save options
|
567 |
+
if ( isset( $_POST['save_iubenda_options'] ) ) {
|
568 |
+
$input['parse'] = (bool) isset( $input['parse'] );
|
569 |
+
$input['parser_engine'] = isset( $input['parser_engine'] ) && in_array( $input['parser_engine'], array( 'default', 'new' ) ) ? $input['parser_engine'] : $this->defaults['parser_engine'];
|
570 |
+
$input['skip_parsing'] = (bool) isset( $input['skip_parsing'] );
|
571 |
+
$input['ctype'] = (bool) isset( $input['ctype'] );
|
572 |
+
$input['output_feed'] = (bool) isset( $input['output_feed'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
|
574 |
+
// multilang support
|
575 |
+
if ( $this->multilang && ! empty( $this->languages ) ) {
|
576 |
+
foreach ( $this->languages as $lang_id => $lang_name ) {
|
577 |
+
$input['code_' . $lang_id] = ! empty( $input['code_' . $lang_id] ) ? wp_kses( $input['code_' . $lang_id], array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) : '';
|
578 |
+
|
579 |
+
// handle default lang too
|
580 |
+
if ( $lang_id == $this->lang_default ) {
|
581 |
+
$input['code_default'] = ! empty( $input['code_' . $lang_id] ) ? wp_kses( $input['code_' . $lang_id], array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) : $this->options['code_default'];
|
582 |
+
}
|
583 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
} else {
|
585 |
+
$input['code_default'] = ! empty( $input['code_default'] ) ? wp_kses( $input['code_default'], array( 'script' => array( 'type' => array(), 'src' => array(), 'charset' => array(), 'async' => array() ) ) ) : '';
|
586 |
}
|
587 |
+
|
588 |
+
add_settings_error( 'iub_settings_errors', 'iub_settings_updated', __( 'Settings saved.', 'iubenda-cookie-law-solution' ), 'updated' );
|
589 |
+
// reset options
|
590 |
+
} elseif ( isset( $_POST['reset_iubenda_options'] ) ) {
|
591 |
+
$input = $this->defaults;
|
592 |
+
|
593 |
+
// multilang support
|
594 |
+
if ( $this->multilang && ! empty( $this->languages ) ) {
|
595 |
+
foreach ( $this->languages as $lang_id => $lang_name ) {
|
596 |
+
$input['code_' . $lang_id] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
}
|
598 |
}
|
599 |
+
add_settings_error( 'iub_settings_errors', 'iub_settings_restored', __( 'Settings restored to defaults.', 'iubenda-cookie-law-solution' ), 'updated' );
|
600 |
}
|
601 |
+
|
602 |
+
return $input;
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Load admin options page.
|
607 |
+
*
|
608 |
+
* @return void
|
609 |
+
*/
|
610 |
+
public function options_page() {
|
611 |
+
;
|
612 |
+
|
613 |
+
if ( ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ) ) ) {
|
614 |
+
wp_die( __( "You don't have permission to access this page.", 'iubenda-cookie-law-solution' ) );
|
615 |
+
}
|
616 |
+
?>
|
617 |
+
<div class="wrap">
|
618 |
+
<div id="iubenda-view">
|
619 |
+
<?php echo '
|
620 |
+
<a class="iubenda-link" href="http://iubenda.com"><img id="iubenda-logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAAAdCAMAAAB8M6mmAAAAhFBMVEUAAAA0O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0I0O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr380O0Ibr3/////G69+35tdTw5/U8Ofx+vdiyKd+0rep4c/i9e8otIeN17/AB1g0AAAAHnRSTlMAEBAgIDAwQEBQUGBwcICAkJCgoLCwwMDQ0ODg8PCQCZ0FAAACrklEQVR4Xr2V63LbIBCFF1OZKBCiKAohlK7kXHt5//cruyDjjFTX42l9fnhh1+yHGB0EAJu7kXS/gUto8zRmPV2Edz/OergA7ctYtV0DCKPPBCgrF7kb4rzs3incrCzpEd05LKEDolqkb4nzNr1RuF1UB8TzcE1E/CPu+7Rbxwnozn06Eddw25H0wr9XsJQh3Flyazh4HGd9hRWpf4zbfptx15fAwR53dRHcWHFSkQDKoOJ05w5M1NjBdXpvFU0WW9TlHidN73rbVtz7844PU7mIiADQOkyaccIjqQOW6DHQ/3yTxiYg2pQhqVIfMPYDYiwZHdF3gdpk3K/XadoVH6hCgbbivMcsyzSPhntiFBAcbcOj6xI/QKl7UYynciOTj9YWJ/z8scfBjIOKQ68ADC2n8+oKNc37FHuqp7xMsQGuRzHvV1U/tMVQVwm0O4oLIg+4v0CkKXNiChZxEMVmbQrN/tBjweVdygXu7g84B3N/D6AxWhYdY8ZZgDroM6QaQUfGiwXu8Tiu5UyP0e3VLHERccUIqseCuzkVJzjjMEDVAtfgCk4HdLrgbk/FQcHhMZxa4hqPLg0WuKcTce1fcPITTvMbtoIbj+MaHvWIAxQFuXqYuuLYMKH08xQeTsVpbqRrPx1h9VVxFcd+6w77PX7G+dmtC5zDILK90XAl2nUjoD7A2fJUzRK3AYCBLzc5JCwqIarNTdmHxaRg7YBR5Gl3iJOx8EyKVkjFuxO8qhky7nV6m79ALXdDLyhGxXdf0EJYjO1s9yLFN2TZjgiIngaaSt4FjPla55AWc5o+dx/P0zQ9fzCOT5EfMBU19+nygl5CkeVEaCo6gOfI76AKuewwWgnQ0NRJcNwVxirGgdSGOlkFs5SxLZFrwppaXUoZ6qD1PFWSQ8p9wl3D/9ZvoAF23RgFj1kAAAAASUVORK5CYII="/></a>
|
621 |
+
<p class="iubenda-text">
|
622 |
+
' . __( "This plugin is the easiest and most comprehensive way to adapt your WordPress site to the European cookie law. Upon your user's first visit, the plugin will take care of collecting their consent, of blocking the most popular among the scripts that install cookies and subsequently reactivate these scripts as soon as consent is provided. The basic settings include obtaining consent by a simple scroll action (the most effective method) and script reactivation without refreshing the page.", 'iubenda-cookie-law-solution' ) . '
|
623 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
624 |
<p class="iubenda-text">
|
625 |
+
<span class="iubenda-title">' . __( "Would you like to know more about the cookie law?", 'iubenda-cookie-law-solution' ) . '</span><br />
|
626 |
+
' . sprintf( __( "Read our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">complete guide to the cookie law.</a>", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/soluzione-cookie-law" ) . '
|
627 |
+
</p>
|
628 |
+
<p class="iubenda-text">
|
629 |
+
<span class="iubenda-title">' . __( "What is the full functionality of the plugin?", 'iubenda-cookie-law-solution' ) . '</span><br />
|
630 |
+
' . sprintf( __( "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">plugin page.</a>", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/810" ) . '
|
631 |
+
</p>
|
632 |
+
<p class="iubenda-text">
|
633 |
+
<span class="iubenda-title">' . __( "Enter the iubenda code for the Cookie Solution below.", 'iubenda-cookie-law-solution' ) . '</span><br />
|
634 |
+
' . sprintf( __( "In order to run the plugin, you need to enter the iubenda code that activates the cookie law banner and the cookie policy in the form below. This code can be generated on www.iubenda.com, following <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">this guide.</a>", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/680" ) . '
|
635 |
+
</p>';
|
636 |
+
?>
|
637 |
+
<form id="iubenda-tabs" action="options.php" method="post">
|
638 |
+
<?php
|
639 |
+
settings_fields( 'iubenda_cookie_law_solution' );
|
640 |
+
do_settings_sections( 'iubenda_cookie_law_solution' );
|
641 |
+
|
642 |
+
echo ' <p class="submit">';
|
643 |
+
submit_button( '', 'primary', 'save_iubenda_options', false );
|
644 |
+
echo ' ';
|
645 |
+
submit_button( __( 'Reset to defaults', 'iubenda-cookie-law-solution' ), 'secondary', 'reset_iubenda_options', false );
|
646 |
+
echo ' </p>';
|
647 |
+
?>
|
648 |
+
</form>
|
649 |
+
<?php echo '
|
650 |
+
<p class="iubenda-text">
|
651 |
+
<span class="iubenda-title">' . __( 'Need support for this plugin?', 'iubenda-cookie-law-solution' ) . '</span><br />
|
652 |
' . sprintf( __( "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">support forum.</a>", 'iubenda-cookie-law-solution' ), "https://support.iubenda.com/forums/314835-general/suggestions/9670701-discussion-regarding-the-iubenda-cookie-law-soluti" ) . '
|
653 |
</p>
|
654 |
<p class="iubenda-text">
|
655 |
+
<span class="iubenda-title">' . __( 'Want to try a beta version of this plugin with the latest features?', 'iubenda-cookie-law-solution' ) . '</span><br />
|
656 |
' . sprintf( __( "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">documentation pages</a> and follow the instructions to install a beta version.", 'iubenda-cookie-law-solution' ), "https://www.iubenda.com/it/help/posts/810" ) . '
|
657 |
+
</p>';
|
658 |
+
?>
|
659 |
+
</div>
|
660 |
+
<div class="clear"></div>
|
661 |
+
</div>
|
662 |
+
<?php
|
663 |
}
|
664 |
+
|
665 |
}
|
js/admin.js
CHANGED
@@ -1,63 +1,21 @@
|
|
1 |
( function ( $ ) {
|
2 |
|
3 |
$( document ).ready( function () {
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
} );
|
6 |
|
7 |
-
} )( jQuery );
|
8 |
-
|
9 |
-
function iubendaGetLanguage( str ) {
|
10 |
-
var languages = [ "it", "de", "en", "es", "pt-br", "ru", "fr" ];
|
11 |
-
|
12 |
-
for ( var i = 0; i < languages.length; i++ ) {
|
13 |
-
var tab = document.getElementById( "iubenda-code-" + languages[i] );
|
14 |
-
|
15 |
-
var active_tab = document.querySelector( ".iubenda-code-" + languages[i] );
|
16 |
-
|
17 |
-
if ( active_tab )
|
18 |
-
active_tab.removeAttribute( "data-active-tab" );
|
19 |
-
|
20 |
-
if ( tab )
|
21 |
-
tab.style.display = "none";
|
22 |
-
}
|
23 |
-
|
24 |
-
var tab = document.getElementById( "iubenda-code-" + str );
|
25 |
-
var active_tab = document.querySelector( ".iubenda-code-" + str );
|
26 |
-
|
27 |
-
if ( tab )
|
28 |
-
tab.style.display = "table";
|
29 |
-
if ( active_tab )
|
30 |
-
active_tab.setAttribute( "data-active-tab", "" );
|
31 |
-
|
32 |
-
document.getElementById( "iubenda-information" ).style.display = "none";
|
33 |
-
}
|
34 |
-
|
35 |
-
window.addEventListener(
|
36 |
-
"DOMContentLoaded", function () {
|
37 |
-
var firstTab = document.querySelector( "[data-iubenda-button]" );
|
38 |
-
|
39 |
-
if ( firstTab )
|
40 |
-
jQuery( firstTab ).trigger( "click" );
|
41 |
-
|
42 |
-
var engine = document.getElementById( "parser_type" );
|
43 |
-
|
44 |
-
engine.onchange = function () {
|
45 |
-
if ( this.checked ) {
|
46 |
-
document.getElementById( "iubenda_parse_child" ).style.display = "block";
|
47 |
-
} else {
|
48 |
-
document.getElementById( "iubenda_parse_child" ).style.display = "none";
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
jQuery( engine ).trigger( "change" );
|
53 |
-
}
|
54 |
-
);
|
55 |
-
|
56 |
-
setTimeout(
|
57 |
-
function () {
|
58 |
-
var x = document.getElementById( "iubenda-saved" );
|
59 |
-
|
60 |
-
if ( x )
|
61 |
-
x.style.display = "none";
|
62 |
-
}, 3000
|
63 |
-
);
|
1 |
( function ( $ ) {
|
2 |
|
3 |
$( document ).ready( function () {
|
4 |
+
|
5 |
+
// read more option
|
6 |
+
$( '#iub_parse' ).change( function () {
|
7 |
+
if ( $( this ).is(':checked') ) {
|
8 |
+
$( '#iub_parser_engine_container' ).slideDown( 'fast' );
|
9 |
+
} else {
|
10 |
+
$( '#iub_parser_engine_container' ).slideUp( 'fast' );
|
11 |
+
}
|
12 |
+
} );
|
13 |
+
|
14 |
+
// move notices
|
15 |
+
var errors = $( '.settings-error' ).detach();
|
16 |
+
|
17 |
+
$( '.iubenda-link' ).after( errors );
|
18 |
+
|
19 |
} );
|
20 |
|
21 |
+
} )( jQuery );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/iubenda-cookie-law-solution.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: Iubenda Cookie Solution\n"
|
5 |
-
"POT-Creation-Date: 2016-
|
6 |
"PO-Revision-Date: 2015-08-12 10:36+0200\n"
|
7 |
"Last-Translator: \n"
|
8 |
"Language-Team: \n"
|
@@ -16,138 +16,153 @@ msgstr ""
|
|
16 |
"X-Poedit-KeywordsList: __\n"
|
17 |
"X-Poedit-SearchPath-0: .\n"
|
18 |
|
19 |
-
#: iubenda_cookie_solution.php:
|
20 |
-
msgid "
|
21 |
msgstr ""
|
22 |
|
23 |
-
#: iubenda_cookie_solution.php:
|
24 |
-
msgid ""
|
25 |
-
"This plugin is the easiest and most comprehensive way to adapt your "
|
26 |
-
"WordPress site to the European cookie law. Upon your user's first visit, "
|
27 |
-
"the plugin will take care of collecting their consent, of blocking the most "
|
28 |
-
"popular among the scripts that install cookies and subsequently reactivate "
|
29 |
-
"these scripts as soon as consent is provided. The basic settings include "
|
30 |
-
"obtaining consent by a simple scroll action (the most effective method) and "
|
31 |
-
"script reactivation without refreshing the page."
|
32 |
msgstr ""
|
33 |
|
34 |
-
#: iubenda_cookie_solution.php:
|
35 |
-
msgid "
|
36 |
msgstr ""
|
37 |
|
38 |
-
#: iubenda_cookie_solution.php:
|
|
|
|
|
|
|
|
|
39 |
#, php-format
|
40 |
-
msgid ""
|
41 |
-
"Read our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">complete "
|
42 |
-
"guide to the cookie law.</a>"
|
43 |
msgstr ""
|
44 |
|
45 |
-
#: iubenda_cookie_solution.php:
|
46 |
-
msgid "
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: iubenda_cookie_solution.php:
|
|
|
|
|
|
|
|
|
50 |
#, php-format
|
51 |
msgid ""
|
52 |
-
"
|
53 |
-
"
|
54 |
msgstr ""
|
55 |
|
56 |
-
#: iubenda_cookie_solution.php:
|
57 |
-
msgid "
|
58 |
msgstr ""
|
59 |
|
60 |
-
#: iubenda_cookie_solution.php:
|
61 |
-
|
62 |
-
msgid ""
|
63 |
-
"In order to run the plugin, you need to enter the iubenda code that "
|
64 |
-
"activates the cookie law banner and the cookie policy in the form below. "
|
65 |
-
"This code can be generated on www.iubenda.com, following <a href=\"%s\" "
|
66 |
-
"class=\"iubenda-url\" target=\"_blank\">this guide.</a>"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: iubenda_cookie_solution.php:
|
70 |
-
msgid "
|
71 |
msgstr ""
|
72 |
|
73 |
-
#: iubenda_cookie_solution.php:
|
74 |
-
msgid "
|
|
|
75 |
msgstr ""
|
76 |
|
77 |
-
#: iubenda_cookie_solution.php:
|
78 |
-
msgid "
|
|
|
|
|
79 |
msgstr ""
|
80 |
|
81 |
-
#: iubenda_cookie_solution.php:
|
82 |
-
#, php-format
|
83 |
msgid ""
|
84 |
-
"
|
85 |
-
"
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: iubenda_cookie_solution.php:
|
89 |
-
msgid "
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: iubenda_cookie_solution.php:
|
93 |
-
msgid "
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: iubenda_cookie_solution.php:
|
97 |
-
msgid "
|
98 |
msgstr ""
|
99 |
|
100 |
-
#: iubenda_cookie_solution.php:
|
101 |
-
msgid ""
|
102 |
-
"Leave scripts untouched on the page if the user has already given consent"
|
103 |
msgstr ""
|
104 |
|
105 |
-
#: iubenda_cookie_solution.php:
|
106 |
msgid ""
|
107 |
-
"
|
108 |
-
"site
|
|
|
|
|
|
|
|
|
|
|
109 |
msgstr ""
|
110 |
|
111 |
-
#: iubenda_cookie_solution.php:
|
112 |
-
msgid "
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: iubenda_cookie_solution.php:
|
|
|
116 |
msgid ""
|
117 |
-
"
|
118 |
-
"
|
|
|
|
|
|
|
|
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: iubenda_cookie_solution.php:
|
|
|
122 |
msgid ""
|
123 |
-
"
|
124 |
-
"
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: iubenda_cookie_solution.php:
|
128 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: iubenda_cookie_solution.php:
|
132 |
-
msgid "
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: iubenda_cookie_solution.php:
|
136 |
msgid "Need support for this plugin?"
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: iubenda_cookie_solution.php:
|
140 |
#, php-format
|
141 |
msgid ""
|
142 |
"Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">support "
|
143 |
"forum.</a>"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: iubenda_cookie_solution.php:
|
147 |
msgid "Want to try a beta version of this plugin with the latest features?"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: iubenda_cookie_solution.php:
|
151 |
#, php-format
|
152 |
msgid ""
|
153 |
"Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank"
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: Iubenda Cookie Solution\n"
|
5 |
+
"POT-Creation-Date: 2016-12-07 16:26+0100\n"
|
6 |
"PO-Revision-Date: 2015-08-12 10:36+0200\n"
|
7 |
"Last-Translator: \n"
|
8 |
"Language-Team: \n"
|
16 |
"X-Poedit-KeywordsList: __\n"
|
17 |
"X-Poedit-SearchPath-0: .\n"
|
18 |
|
19 |
+
#: iubenda_cookie_solution.php:446
|
20 |
+
msgid "Code"
|
21 |
msgstr ""
|
22 |
|
23 |
+
#: iubenda_cookie_solution.php:447
|
24 |
+
msgid "Scripts blocking"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
msgstr ""
|
26 |
|
27 |
+
#: iubenda_cookie_solution.php:448
|
28 |
+
msgid "Content type"
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: iubenda_cookie_solution.php:449
|
32 |
+
msgid "RSS feed"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: iubenda_cookie_solution.php:493
|
36 |
#, php-format
|
37 |
+
msgid "Enter the iubenda code for %s."
|
|
|
|
|
38 |
msgstr ""
|
39 |
|
40 |
+
#: iubenda_cookie_solution.php:504
|
41 |
+
msgid "Enter the iubenda code."
|
42 |
msgstr ""
|
43 |
|
44 |
+
#: iubenda_cookie_solution.php:517
|
45 |
+
msgid "Automatically block scripts detected by the plugin."
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: iubenda_cookie_solution.php:518
|
49 |
#, php-format
|
50 |
msgid ""
|
51 |
+
"see <a href=\"%s\" target=\"_blank\">our documentation</a> for the list of "
|
52 |
+
"detected scripts."
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: iubenda_cookie_solution.php:521
|
56 |
+
msgid "Default"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: iubenda_cookie_solution.php:522
|
60 |
+
msgid "Experimental"
|
|
|
|
|
|
|
|
|
|
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: iubenda_cookie_solution.php:523
|
64 |
+
msgid "Select parsing engine."
|
65 |
msgstr ""
|
66 |
|
67 |
+
#: iubenda_cookie_solution.php:526
|
68 |
+
msgid ""
|
69 |
+
"Leave scripts untouched on the page if the user has already given consent"
|
70 |
msgstr ""
|
71 |
|
72 |
+
#: iubenda_cookie_solution.php:527
|
73 |
+
msgid ""
|
74 |
+
"improves performance, highly recommended, to be deactivated only if your "
|
75 |
+
"site uses a caching system"
|
76 |
msgstr ""
|
77 |
|
78 |
+
#: iubenda_cookie_solution.php:541
|
|
|
79 |
msgid ""
|
80 |
+
"Restrict the plugin to run only for requests that have \"Content-type: "
|
81 |
+
"text / html\" (recommended)"
|
82 |
msgstr ""
|
83 |
|
84 |
+
#: iubenda_cookie_solution.php:553
|
85 |
+
msgid "Do not run the plugin inside the RSS feed (recommended)"
|
86 |
msgstr ""
|
87 |
|
88 |
+
#: iubenda_cookie_solution.php:583
|
89 |
+
msgid "Settings saved."
|
90 |
msgstr ""
|
91 |
|
92 |
+
#: iubenda_cookie_solution.php:594
|
93 |
+
msgid "Settings restored to defaults."
|
94 |
msgstr ""
|
95 |
|
96 |
+
#: iubenda_cookie_solution.php:609
|
97 |
+
msgid "You don't have permission to access this page."
|
|
|
98 |
msgstr ""
|
99 |
|
100 |
+
#: iubenda_cookie_solution.php:617
|
101 |
msgid ""
|
102 |
+
"This plugin is the easiest and most comprehensive way to adapt your "
|
103 |
+
"WordPress site to the European cookie law. Upon your user's first visit, "
|
104 |
+
"the plugin will take care of collecting their consent, of blocking the most "
|
105 |
+
"popular among the scripts that install cookies and subsequently reactivate "
|
106 |
+
"these scripts as soon as consent is provided. The basic settings include "
|
107 |
+
"obtaining consent by a simple scroll action (the most effective method) and "
|
108 |
+
"script reactivation without refreshing the page."
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: iubenda_cookie_solution.php:620
|
112 |
+
msgid "Would you like to know more about the cookie law?"
|
113 |
msgstr ""
|
114 |
|
115 |
+
#: iubenda_cookie_solution.php:621
|
116 |
+
#, php-format
|
117 |
msgid ""
|
118 |
+
"Read our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">complete "
|
119 |
+
"guide to the cookie law.</a>"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: iubenda_cookie_solution.php:624
|
123 |
+
msgid "What is the full functionality of the plugin?"
|
124 |
msgstr ""
|
125 |
|
126 |
+
#: iubenda_cookie_solution.php:625
|
127 |
+
#, php-format
|
128 |
msgid ""
|
129 |
+
"Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">plugin "
|
130 |
+
"page.</a>"
|
131 |
msgstr ""
|
132 |
|
133 |
+
#: iubenda_cookie_solution.php:628
|
134 |
+
msgid "Enter the iubenda code for the Cookie Solution below."
|
135 |
+
msgstr ""
|
136 |
+
|
137 |
+
#: iubenda_cookie_solution.php:629
|
138 |
+
#, php-format
|
139 |
+
msgid ""
|
140 |
+
"In order to run the plugin, you need to enter the iubenda code that "
|
141 |
+
"activates the cookie law banner and the cookie policy in the form below. "
|
142 |
+
"This code can be generated on www.iubenda.com, following <a href=\"%s\" "
|
143 |
+
"class=\"iubenda-url\" target=\"_blank\">this guide.</a>"
|
144 |
msgstr ""
|
145 |
|
146 |
+
#: iubenda_cookie_solution.php:640
|
147 |
+
msgid "Reset to defaults"
|
148 |
msgstr ""
|
149 |
|
150 |
+
#: iubenda_cookie_solution.php:646
|
151 |
msgid "Need support for this plugin?"
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: iubenda_cookie_solution.php:647
|
155 |
#, php-format
|
156 |
msgid ""
|
157 |
"Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">support "
|
158 |
"forum.</a>"
|
159 |
msgstr ""
|
160 |
|
161 |
+
#: iubenda_cookie_solution.php:650
|
162 |
msgid "Want to try a beta version of this plugin with the latest features?"
|
163 |
msgstr ""
|
164 |
|
165 |
+
#: iubenda_cookie_solution.php:651
|
166 |
#, php-format
|
167 |
msgid ""
|
168 |
"Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank"
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
=== Plugin Name ===
|
2 |
Contributors: iubenda
|
3 |
Donate link:
|
4 |
Tags: cookies, cookie law, cookie policy, cookie banner, cookie block, privacy policy, cookie consent, privacy
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.
|
7 |
Stable tag: 1.11.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -323,7 +323,7 @@ How does this plugin work with a Facebook button, for example?
|
|
323 |
var js, fjs = d.getElementsByTagName(s)[0];
|
324 |
if (d.getElementById(id)) return;
|
325 |
js = d.createElement(s); js.id = id;
|
326 |
-
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1
|
327 |
fjs.parentNode.insertBefore(js, fjs);
|
328 |
}(document, 'script', 'facebook-jssdk'));
|
329 |
</script>
|
@@ -358,7 +358,7 @@ Per esempio in un plugin Facebook dovrai fare come segue:
|
|
358 |
var js, fjs = d.getElementsByTagName(s)[0];
|
359 |
if (d.getElementById(id)) return;
|
360 |
js = d.createElement(s); js.id = id;
|
361 |
-
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1
|
362 |
fjs.parentNode.insertBefore(js, fjs);
|
363 |
}(document, 'script', 'facebook-jssdk'));
|
364 |
</script>
|
@@ -382,3 +382,9 @@ In caso di proseguimento della navigazione, le preferenze dei tuoi utenti circa
|
|
382 |
|
383 |
* Il modo migliore per aiutarci è quello di fornire quante più informazioni possibili, compreso l'uso di wp_debug https://codex.wordpress.org/Debugging_in_WordPress.
|
384 |
* Saremo molto contenti di ricevere feedback qui: http://support.iubenda.com/forums/314835-general/suggestions/9670701-discussion-regarding-the-iubenda-cookie-law-soluti
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
Contributors: iubenda
|
3 |
Donate link:
|
4 |
Tags: cookies, cookie law, cookie policy, cookie banner, cookie block, privacy policy, cookie consent, privacy
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.7
|
7 |
Stable tag: 1.11.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
323 |
var js, fjs = d.getElementsByTagName(s)[0];
|
324 |
if (d.getElementById(id)) return;
|
325 |
js = d.createElement(s); js.id = id;
|
326 |
+
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=808061959224601";
|
327 |
fjs.parentNode.insertBefore(js, fjs);
|
328 |
}(document, 'script', 'facebook-jssdk'));
|
329 |
</script>
|
358 |
var js, fjs = d.getElementsByTagName(s)[0];
|
359 |
if (d.getElementById(id)) return;
|
360 |
js = d.createElement(s); js.id = id;
|
361 |
+
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=808061959224601";
|
362 |
fjs.parentNode.insertBefore(js, fjs);
|
363 |
}(document, 'script', 'facebook-jssdk'));
|
364 |
</script>
|
382 |
|
383 |
* Il modo migliore per aiutarci è quello di fornire quante più informazioni possibili, compreso l'uso di wp_debug https://codex.wordpress.org/Debugging_in_WordPress.
|
384 |
* Saremo molto contenti di ricevere feedback qui: http://support.iubenda.com/forums/314835-general/suggestions/9670701-discussion-regarding-the-iubenda-cookie-law-soluti
|
385 |
+
|
386 |
+
= 1.11.1 =
|
387 |
+
* New: Created a new option that disables the plugin on RSS feeds
|
388 |
+
* New: Improved the control that checks if the request content type is HTML
|
389 |
+
* Fixed an issue with the banner script
|
390 |
+
* Fixed a series of conflicts with UTF-8 special characters caused by the experimental parsing engine
|