Project

General

Profile

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