Project

General

Profile

Download (1.84 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * auth_func.inc
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7
 * Copyright (c) 2005-2006 Bill Marquette <bill.marquette@gmail.com>
8
 * Copyright (c) 2006 Paul Taylor <paultaylor@winn-dixie.com>.
9
 * Copyright (c) 2008 Shrew Soft Inc
10
 * Copyright (c) 2003-2006 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
/*
27
 * Function put in seperate file to avoid processing priv.inc which is cpu intensive
28
 * cmp_page_matches is used by both auth_check.inc and priv.inc which is used by guiconfig.inc
29
 */
30

    
31
function cmp_page_matches($page, & $matches, $fullwc = true) {
32

    
33
//	$dbg_matches = implode(",", $matches);
34
//	log_error("debug: checking page {$page} match with {$dbg_matches}");
35

    
36
	if (!is_array($matches)) {
37
		return false;
38
	}
39

    
40
	/* skip any leading fwdslash */
41
	$test = strpos($page, "/");
42
	if ($test !== false && $test == 0) {
43
		$page = substr($page, 1);
44
	}
45

    
46
	/* look for a match */
47
	foreach ($matches as $match) {
48

    
49
		/* possibly ignore full wildcard match */
50
		if (!$fullwc && !strcmp($match , "*")) {
51
			continue;
52
		}
53

    
54
		/* compare exact or wildcard match */
55
		$match = str_replace(array(".", "*", "?"), array("\.", ".*", "\?"), $match);
56
		$result = preg_match("@^/{$match}$@", "/{$page}");
57

    
58
		if ($result) {
59
			return true;
60
		}
61
	}
62

    
63
	return false;
64
}
(3-3/54)