1
|
<?php
|
2
|
/*
|
3
|
functions.inc
|
4
|
|
5
|
part of pfSense (https://www.pfsense.org)
|
6
|
Copyright (c) 2004-2016 Electric Sheep Fencing, LLC. All rights reserved.
|
7
|
|
8
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in
|
20
|
the documentation and/or other materials provided with the
|
21
|
distribution.
|
22
|
|
23
|
3. All advertising materials mentioning features or use of this software
|
24
|
must display the following acknowledgment:
|
25
|
"This product includes software developed by the pfSense Project
|
26
|
for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
27
|
|
28
|
4. The names "pfSense" and "pfSense Project" must not be used to
|
29
|
endorse or promote products derived from this software without
|
30
|
prior written permission. For written permission, please contact
|
31
|
coreteam@pfsense.org.
|
32
|
|
33
|
5. Products derived from this software may not be called "pfSense"
|
34
|
nor may "pfSense" appear in their names without prior written
|
35
|
permission of the Electric Sheep Fencing, LLC.
|
36
|
|
37
|
6. Redistributions of any form whatsoever must retain the following
|
38
|
acknowledgment:
|
39
|
|
40
|
"This product includes software developed by the pfSense Project
|
41
|
for use in the pfSense software distribution (http://www.pfsense.org/).
|
42
|
|
43
|
THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
44
|
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
45
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
46
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
47
|
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
48
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
49
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
50
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
51
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
52
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
53
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
54
|
OF THE POSSIBILITY OF SUCH DAMAGE.
|
55
|
*/
|
56
|
|
57
|
/* BEGIN compatibility goo with HEAD */
|
58
|
if (!function_exists("gettext")) {
|
59
|
function gettext($text) {
|
60
|
return $text;
|
61
|
}
|
62
|
}
|
63
|
|
64
|
if (!function_exists("pfSenseHeader")) {
|
65
|
/****f* pfsense-utils/pfSenseHeader
|
66
|
* NAME
|
67
|
* pfSenseHeader
|
68
|
* INPUTS
|
69
|
* none
|
70
|
* RESULT
|
71
|
* Javascript header change or browser Location:
|
72
|
******/
|
73
|
function pfSenseHeader($text) {
|
74
|
global $_SERVER;
|
75
|
if (isAjax()) {
|
76
|
if ($_SERVER['HTTPS'] == "on") {
|
77
|
$protocol = "https";
|
78
|
} else {
|
79
|
$protocol = "http";
|
80
|
}
|
81
|
|
82
|
$port = ":{$_SERVER['SERVER_PORT']}";
|
83
|
if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http") {
|
84
|
$port = "";
|
85
|
}
|
86
|
if ($_SERVER['SERVER_PORT'] == "443" && $protocol == "https") {
|
87
|
$port = "";
|
88
|
}
|
89
|
$complete_url = "{$protocol}://{$_SERVER['HTTP_HOST']}{$port}/{$text}";
|
90
|
echo "\ndocument.location.href = '{$complete_url}';\n";
|
91
|
} else {
|
92
|
header("Location: $text");
|
93
|
}
|
94
|
}
|
95
|
}
|
96
|
/* END compatibility goo with HEAD */
|
97
|
|
98
|
/*fetch menu notices function*/
|
99
|
if (!function_exists("get_menu_messages")) {
|
100
|
function get_menu_messages() {
|
101
|
global $g, $config;
|
102
|
if (are_notices_pending()) {
|
103
|
$notices = get_notices();
|
104
|
$requests = array();
|
105
|
|
106
|
## Get Query Arguments from URL ###
|
107
|
foreach ($_REQUEST as $key => $value) {
|
108
|
if ($key != "PHPSESSID") {
|
109
|
$requests[] = $key . '=' . $value;
|
110
|
}
|
111
|
}
|
112
|
if (is_array($requests)) {
|
113
|
$request_string = implode("&", $requests);
|
114
|
}
|
115
|
|
116
|
if (is_array($notices)) {
|
117
|
$notice_msgs = "<table colspan=\'6\' id=\'notice_table\'>";
|
118
|
$alert_style = "style=\'color:#ffffff; filter:Glow(color=#ff0000, strength=12);\' ";
|
119
|
$notice = "<a href=\'#\' onclick=notice_action(\'acknowledge\',\'all\');domTT_close(this); {$alert_style}>" . gettext("Acknowledge All Notices") . "</a>";
|
120
|
$alert_link = "title=\'" . gettext("Click to Acknowledge") . "\' {$alert_style}";
|
121
|
$domtt_width = 500;
|
122
|
foreach ($notices as $key => $value) {
|
123
|
$date = date("m-d-y H:i:s", $key);
|
124
|
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
|
125
|
$noticemsg = strip_tags(preg_replace("/(\"|\'|\n|<.?\w+>)/i", "", $noticemsg));
|
126
|
if ((strlen($noticemsg)* 8) > $domtt_width) {
|
127
|
$domtt_width = (strlen($noticemsg) *8);
|
128
|
}
|
129
|
if ((strlen($noticemsg)* 8) > 900) {
|
130
|
$domtt_width = 900;
|
131
|
}
|
132
|
$alert_action = "onclick=notice_action(\'acknowledge\',\'{$key}\');domTT_close(this);jQuery(this).parent().parent().remove();";
|
133
|
$notice_msgs .= "<tr><td style=\'vertical-align: top\' width=\'120\'><a href=\'#\' {$alert_link} {$alert_action}>{$date}</a></td><td style=\'vertical-align: top\'><a href=\'#\' {$alert_link} {$alert_action}>[ " . htmlspecialchars($noticemsg) . "]</a></td></tr>";
|
134
|
}
|
135
|
$notice_msgs .= "</table>";
|
136
|
|
137
|
$domtt = "onclick=\"domTT_activate(this, event, 'caption', '{$notice}','content', '<br />{$notice_msgs}', 'trail', false, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','width','{$domtt_width}','y',5,'type', 'sticky');\"";
|
138
|
$menu_messages = "<div id='alerts'>\n";
|
139
|
if (count($notices) == 1) {
|
140
|
$msg = sprintf("%1$02d", count($notices)) . " " . gettext("unread notice");
|
141
|
} else {
|
142
|
$msg = sprintf("%1$02d", count($notices)) . " " . gettext("unread notices");
|
143
|
}
|
144
|
$menu_messages .= "<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n";
|
145
|
$menu_messages .= "</div>\n";
|
146
|
}
|
147
|
} else {
|
148
|
$menu_messages = '<div id="hostname">';
|
149
|
$menu_messages .= $config['system']['hostname'] . "." . $config['system']['domain'];
|
150
|
$menu_messages .= '</div>';
|
151
|
}
|
152
|
return ($menu_messages);
|
153
|
}
|
154
|
}
|
155
|
|
156
|
if (!function_exists("dom_title")) {
|
157
|
function dom_title($title_msg, $width=NULL) {
|
158
|
$width = preg_replace("/\D+/", "", $width);
|
159
|
if (!empty($width)) {
|
160
|
$width = ",'width',$width";
|
161
|
}
|
162
|
if (!empty($title_msg)) {
|
163
|
$title_msg = preg_replace("/\s+/", " ", $title_msg);
|
164
|
$title_msg = preg_replace("/'/", "\'", $title_msg);
|
165
|
return "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 250, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle' $width);\"";
|
166
|
}
|
167
|
}
|
168
|
}
|
169
|
/* include all configuration functions */
|
170
|
require_once("interfaces.inc");
|
171
|
require_once("gwlb.inc");
|
172
|
require_once("services.inc");
|
173
|
require_once("pfsense-utils.inc");
|
174
|
require_once("certs.inc");
|
175
|
require_once("system.inc");
|
176
|
require_once("vslb.inc");
|
177
|
|
178
|
?>
|