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