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