Project

General

Profile

Download (5.67 KB) Statistics
| Branch: | Tag: | Revision:
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
	pfSense_MODULE:	utils
33

    
34
*/
35

    
36
/* BEGIN compatibility goo with HEAD */
37
if (!function_exists("gettext")) {
38
	function gettext($text) {
39
		return $text;
40
	}
41
}
42

    
43
if (!function_exists("pfSenseHeader")) {
44
	/****f* pfsense-utils/pfSenseHeader
45
	 * NAME
46
	 *   pfSenseHeader
47
	 * INPUTS
48
	 *   none
49
	 * RESULT
50
	 *   Javascript header change or browser Location:
51
	 ******/
52
	function pfSenseHeader($text) {
53
		global $_SERVER;
54
		if (isAjax()) {
55
			if ($_SERVER['HTTPS'] == "on") {
56
				$protocol = "https";
57
			} else {
58
				$protocol = "http";
59
			}
60

    
61
			$port = ":{$_SERVER['SERVER_PORT']}";
62
			if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http") {
63
				$port = "";
64
			}
65
			if ($_SERVER['SERVER_PORT'] == "443" && $protocol == "https") {
66
				$port = "";
67
			}
68
			$complete_url = "{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}";
69
			echo "\ndocument.location.href = '{$complete_url}';\n";
70
		} else {
71
			header("Location: $text");
72
		}
73
	}
74
}
75
/* END compatibility goo with HEAD */
76

    
77
/*fetch menu notices function*/
78
if (!function_exists("get_menu_messages")) {
79
	function get_menu_messages() {
80
		global $g, $config;
81
		if (are_notices_pending()) {
82
			$notices = get_notices();
83
			$requests = array();
84

    
85
			## Get Query Arguments from URL ###
86
			foreach ($_REQUEST as $key => $value) {
87
				if ($key != "PHPSESSID") {
88
					$requests[] = $key.'='.$value;
89
				}
90
			}
91
			if (is_array($requests)) {
92
				$request_string = implode("&", $requests);
93
			}
94

    
95
			if (is_array($notices)) {
96
				$notice_msgs = "<table colspan=\'6\' id=\'notice_table\'>";
97
				$alert_style="style=\'color:#ffffff; filter:Glow(color=#ff0000, strength=12);\' ";
98
				$notice = "<a href=\'#\' onclick=notice_action(\'acknowledge\',\'all\');domTT_close(this); {$alert_style}>".gettext("Acknowledge All Notices")."</a>";
99
				$alert_link="title=\'".gettext("Click to Acknowledge")."\' {$alert_style}";
100
				$domtt_width=500;
101
				foreach ($notices as $key => $value) {
102
					$date = date("m-d-y H:i:s", $key);
103
					$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
104
					$noticemsg = strip_tags(preg_replace("/(\"|\'|\n|<.?\w+>)/i", "", $noticemsg));
105
					if ((strlen($noticemsg)* 8) > $domtt_width) {
106
						$domtt_width=(strlen($noticemsg) *8);
107
					}
108
					if ((strlen($noticemsg)* 8) > 900) {
109
						$domtt_width= 900;
110
					}
111
					$alert_action ="onclick=notice_action(\'acknowledge\',\'{$key}\');domTT_close(this);jQuery(this).parent().parent().remove();";
112
					$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>";
113
				}
114
				$notice_msgs .="</table>";
115

    
116
				$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');\"";
117
				$menu_messages="<div id='alerts'>\n";
118
				if (count($notices) == 1) {
119
					$msg= sprintf("%1$02d", count($notices)) . " " . gettext("unread notice");
120
				} else {
121
					$msg= sprintf("%1$02d", count($notices)) . " " . gettext("unread notices");
122
				}
123
				$menu_messages .= "<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n";
124
				$menu_messages .= "</div>\n";
125
			}
126
		} else {
127
			$menu_messages = '<div id="hostname">';
128
			$menu_messages .= $config['system']['hostname'] . "." . $config['system']['domain'];
129
			$menu_messages .= '</div>';
130
		}
131
		return ($menu_messages);
132
	}
133
}
134

    
135
if (!function_exists("dom_title")) {
136
	function dom_title($title_msg, $width=NULL) {
137
		$width=preg_replace("/\D+/", "", $width);
138
		if (!empty($width)) {
139
			$width=",'width',$width";
140
		}
141
		if (!empty($title_msg)) {
142
			$title_msg=preg_replace("/\s+/", " ", $title_msg);
143
			$title_msg=preg_replace("/'/", "\'", $title_msg);
144
			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);\"";
145
		}
146
	}
147
}
148
/* include all configuration functions */
149
require_once("interfaces.inc");
150
require_once("gwlb.inc");
151
require_once("services.inc");
152
require_once("pfsense-utils.inc");
153
require_once("certs.inc");
154
require_once("system.inc");
155
require_once("vslb.inc");
156

    
157
?>
(21-21/67)