Project

General

Profile

Download (5.17 KB) Statistics
| Branch: | Tag: | Revision:
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
 * Licensed under the Apache License, Version 2.0 (the "License");
14
 * you may not use this file except in compliance with the License.
15
 * You may obtain a copy of the License at
16
 *
17
 * http://www.apache.org/licenses/LICENSE-2.0
18
 *
19
 * Unless required by applicable law or agreed to in writing, software
20
 * distributed under the License is distributed on an "AS IS" BASIS,
21
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
 * See the License for the specific language governing permissions and
23
 * limitations under the License.
24
 */
25

    
26
/* BEGIN compatibility goo with HEAD */
27
if (!function_exists("gettext")) {
28
	function gettext($text) {
29
		return $text;
30
	}
31
}
32

    
33
if (!function_exists("pfSenseHeader")) {
34
	/****f* pfsense-utils/pfSenseHeader
35
	 * NAME
36
	 *   pfSenseHeader
37
	 * INPUTS
38
	 *   none
39
	 * RESULT
40
	 *   Javascript header change or browser Location:
41
	 ******/
42
	function pfSenseHeader($text) {
43
		global $_SERVER;
44
		if (isAjax()) {
45
			if ($_SERVER['HTTPS'] == "on") {
46
				$protocol = "https";
47
			} else {
48
				$protocol = "http";
49
			}
50

    
51
			$port = ":{$_SERVER['SERVER_PORT']}";
52
			if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http") {
53
				$port = "";
54
			}
55
			if ($_SERVER['SERVER_PORT'] == "443" && $protocol == "https") {
56
				$port = "";
57
			}
58
			$complete_url = "{$protocol}://{$_SERVER['HTTP_HOST']}{$port}/{$text}";
59
			echo "\ndocument.location.href = '{$complete_url}';\n";
60
		} else {
61
			header("Location: $text");
62
		}
63
	}
64
}
65
/* END compatibility goo with HEAD */
66

    
67
/*fetch menu notices function*/
68
if (!function_exists("get_menu_messages")) {
69
	function get_menu_messages() {
70
		global $g, $config;
71
		if (are_notices_pending()) {
72
			$notices = get_notices();
73
			$requests = array();
74

    
75
			## Get Query Arguments from URL ###
76
			foreach ($_REQUEST as $key => $value) {
77
				if ($key != "PHPSESSID") {
78
					$requests[] = $key . '=' . $value;
79
				}
80
			}
81
			if (is_array($requests)) {
82
				$request_string = implode("&", $requests);
83
			}
84

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

    
106
				$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');\"";
107
				$menu_messages = "<div id='alerts'>\n";
108
				if (count($notices) == 1) {
109
					$msg = sprintf("%1$02d", count($notices)) . " " . gettext("unread notice");
110
				} else {
111
					$msg = sprintf("%1$02d", count($notices)) . " " . gettext("unread notices");
112
				}
113
				$menu_messages .= "<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n";
114
				$menu_messages .= "</div>\n";
115
			}
116
		} else {
117
			$menu_messages = '<div id="hostname">';
118
			$menu_messages .= $config['system']['hostname'] . "." . $config['system']['domain'];
119
			$menu_messages .= '</div>';
120
		}
121
		return ($menu_messages);
122
	}
123
}
124

    
125
if (!function_exists("dom_title")) {
126
	function dom_title($title_msg, $width=NULL) {
127
		$width = preg_replace("/\D+/", "", $width);
128
		if (!empty($width)) {
129
			$width = ",'width',$width";
130
		}
131
		if (!empty($title_msg)) {
132
			$title_msg = preg_replace("/\s+/", " ", $title_msg);
133
			$title_msg = preg_replace("/'/", "\'", $title_msg);
134
			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);\"";
135
		}
136
	}
137
}
138
/* include all configuration functions */
139
require_once("interfaces.inc");
140
require_once("gwlb.inc");
141
require_once("services.inc");
142
require_once("pfsense-utils.inc");
143
require_once("certs.inc");
144
require_once("system.inc");
145
require_once("vslb.inc");
146

    
147
?>
(14-14/51)