Projet

Général

Profil

Télécharger (6,02 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / etc / inc / functions.inc @ 6f3d2063

1
<?php
2
/* $Id$ */
3
/*
4
    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

    
33
	pfSense_MODULE:	utils
34

    
35
*/
36

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

    
44
if(!function_exists("pfSenseHeader")) {
45
	/****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
	        global $_SERVER;
55
	        if (isAjax()) {
56
	                if ($_SERVER['HTTPS'] == "on")
57
	                        $protocol = "https";
58
	                else
59
	                        $protocol = "http";
60
	
61
	                $port = ":{$_SERVER['SERVER_PORT']}";
62
	                if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http")
63
	                        $port = "";
64
	                if ($_SERVER['SERVER_PORT'] == "443" && $protocol == "https")
65
	                        $port = "";
66
	                $complete_url = "{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}";
67
	                echo "\ndocument.location.href = '{$complete_url}';\n";
68
	        } else {
69
	                header("Location: $text");
70
	        }
71
	}
72
}
73
/* END compatibility goo with HEAD */
74

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

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

    
91
				if(is_array($notices)) {
92
					$notice_msgs = "<table colspan=\'6\' id=\'notice_table\'>";
93
					$alert_style="style=\'color:#ffffff; filter:Glow(color=#ff0000, strength=12);\' ";
94
					$notice = "<a href=\'#\' onclick=notice_action(\'acknowledge\',\'all\');domTT_close(this); {$alert_style}>".gettext("Acknowledge All Notices")."</a>";
95
					$alert_link="title=\'".gettext("Click to Acknowledge")."\' {$alert_style}";
96
					$domtt_width=500;
97
					foreach ($notices as $key => $value) {
98
						$date = date("m-d-y H:i:s", $key);
99
						$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
100
						$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
101
						if ((strlen($noticemsg)* 8) > $domtt_width)
102
							$domtt_width=(strlen($noticemsg) *8);
103
						if ((strlen($noticemsg)* 8) > 900)
104
							$domtt_width= 900;
105
						$alert_action ="onclick=notice_action(\'acknowledge\',\'{$key}\');domTT_close(this);jQuery(this).parent().parent().remove();";
106
						$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>";
107
						}
108
					$notice_msgs .="</table>";
109
						
110
					$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');\"";					
111
                    $menu_messages="<div id='alerts'>\n";
112
                    if(count($notices)==1)
113
                    	$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
114
                    else
115
                    	$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
116
                    $menu_messages.="<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n";
117
                    $menu_messages.="</div>\n";
118
                    }
119
			}
120
		else {
121
			$menu_messages='<div id="hostname">';
122
			$menu_messages.=$config['system']['hostname'] . "." . $config['system']['domain']; 
123
			$menu_messages.='</div>';
124
			}
125
		return ($menu_messages);
126
		}
127
}
128
				
129
if(!function_exists("dom_title")) {
130
	function dom_title($title_msg,$width=NULL){
131
		$width=preg_replace("/\D+/","",$width);
132
		if (!empty($width)){
133
			$width=",'width',$width";
134
			}
135
		if (!empty($title_msg)){
136
			$title_msg=preg_replace("/\s+/"," ",$title_msg);
137
	   	    $title_msg=preg_replace("/'/","\'",$title_msg);
138
			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);\"";
139
			}
140
		}
141
	}
142
/* include all configuration functions */
143
require_once("interfaces.inc");
144
require_once("gwlb.inc");
145
require_once("services.inc");
146
require_once("pfsense-utils.inc");
147
require_once("certs.inc");
148
require_once("system.inc");
149
require_once("vslb.inc");
150

    
151
?>
(21-21/68)