Project

General

Profile

Download (5.64 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2
/*
3 9ba87997 Phil Davis
	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 5b237745 Scott Ullrich
*/
32
33 50797647 Scott Ullrich
/* BEGIN compatibility goo with HEAD */
34 9ba87997 Phil Davis
if (!function_exists("gettext")) {
35 50797647 Scott Ullrich
	function gettext($text) {
36
		return $text;
37
	}
38
}
39
40 9ba87997 Phil Davis
if (!function_exists("pfSenseHeader")) {
41 ab6738c7 Scott Ullrich
	/****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 9ba87997 Phil Davis
		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 50797647 Scott Ullrich
	}
71
}
72
/* END compatibility goo with HEAD */
73
74 005ac3ca Marcello Coutinho
/*fetch menu notices function*/
75 9ba87997 Phil Davis
if (!function_exists("get_menu_messages")) {
76
	function get_menu_messages() {
77 086cf944 Phil Davis
		global $g, $config;
78 84e94f82 marcelloc
		if (are_notices_pending()) {
79
			$notices = get_notices();
80 6c07db48 Phil Davis
			$requests = array();
81 005ac3ca Marcello Coutinho
82 84e94f82 marcelloc
			## Get Query Arguments from URL ###
83
			foreach ($_REQUEST as $key => $value) {
84 9ba87997 Phil Davis
				if ($key != "PHPSESSID") {
85 84e94f82 marcelloc
					$requests[] = $key.'='.$value;
86
				}
87 9ba87997 Phil Davis
			}
88
			if (is_array($requests)) {
89 84e94f82 marcelloc
				$request_string = implode("&", $requests);
90 9ba87997 Phil Davis
			}
91 005ac3ca Marcello Coutinho
92 9ba87997 Phil Davis
			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 5b28ed7a jim-p
					$noticemsg = strip_tags(preg_replace("/(\"|\'|\n|<.?\w+>)/i", "", $noticemsg));
102 9ba87997 Phil Davis
					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 086cf944 Phil Davis
				if (count($notices) == 1) {
116
					$msg= sprintf("%1$02d", count($notices)) . " " . gettext("unread notice");
117 9ba87997 Phil Davis
				} else {
118 086cf944 Phil Davis
					$msg= sprintf("%1$02d", count($notices)) . " " . gettext("unread notices");
119 9ba87997 Phil Davis
				}
120 086cf944 Phil Davis
				$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 84e94f82 marcelloc
			}
123 9ba87997 Phil Davis
		} else {
124 086cf944 Phil Davis
			$menu_messages = '<div id="hostname">';
125
			$menu_messages .= $config['system']['hostname'] . "." . $config['system']['domain'];
126
			$menu_messages .= '</div>';
127 84e94f82 marcelloc
		}
128 9ba87997 Phil Davis
		return ($menu_messages);
129
	}
130 84e94f82 marcelloc
}
131 9ba87997 Phil Davis
132
if (!function_exists("dom_title")) {
133 086cf944 Phil Davis
	function dom_title($title_msg, $width=NULL) {
134
		$width=preg_replace("/\D+/", "", $width);
135 9ba87997 Phil Davis
		if (!empty($width)) {
136 84e94f82 marcelloc
			$width=",'width',$width";
137 9ba87997 Phil Davis
		}
138
		if (!empty($title_msg)) {
139 086cf944 Phil Davis
			$title_msg=preg_replace("/\s+/", " ", $title_msg);
140
			$title_msg=preg_replace("/'/", "\'", $title_msg);
141 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);\"";
142
		}
143 0f89c125 marcelloc
	}
144 9ba87997 Phil Davis
}
145 5b237745 Scott Ullrich
/* include all configuration functions */
146 175b9149 Scott Ullrich
require_once("interfaces.inc");
147 ae3c9a62 Ermal Lu?i
require_once("gwlb.inc");
148 175b9149 Scott Ullrich
require_once("services.inc");
149
require_once("pfsense-utils.inc");
150 f7e3f9ac Scott Ullrich
require_once("certs.inc");
151 c8950940 Ermal Lu?i
require_once("system.inc");
152 175b9149 Scott Ullrich
require_once("vslb.inc");
153 5b237745 Scott Ullrich
154 6f3d2063 Renato Botelho
?>