Project

General

Profile

« Previous | Next » 

Revision ddd54e83

Added by Pi Ba about 8 years ago

auth_check, move the cmp_page_matches() to its own file so it can be shared by both auth_check.inc and priv.inc

View differences:

src/etc/inc/priv.inc
24 24
 */
25 25

  
26 26
require_once("priv.defs.inc");
27
require_once("auth_func.inc");
27 28

  
28 29
/* Load and process custom privs. */
29 30
function get_priv_files($directory) {
......
89 90
	uksort($privs, "cmp_privkeys");
90 91
}
91 92

  
92
function cmp_page_matches($page, & $matches, $fullwc = true) {
93

  
94
//	$dbg_matches = implode(",", $matches);
95
//	log_error("debug: checking page {$page} match with {$dbg_matches}");
96

  
97
	if (!is_array($matches)) {
98
		return false;
99
	}
100

  
101
	/* skip any leading fwdslash */
102
	$test = strpos($page, "/");
103
	if ($test !== false && $test == 0) {
104
		$page = substr($page, 1);
105
	}
106

  
107
	/* look for a match */
108
	foreach ($matches as $match) {
109

  
110
		/* possibly ignore full wildcard match */
111
		if (!$fullwc && !strcmp($match , "*")) {
112
			continue;
113
		}
114

  
115
		/* compare exact or wildcard match */
116
		$match = str_replace(array(".", "*", "?"), array("\.", ".*", "\?"), $match);
117
		$result = preg_match("@^/{$match}$@", "/{$page}");
118

  
119
		if ($result) {
120
			return true;
121
		}
122
	}
123

  
124
	return false;
125
}
126

  
127 93
function map_page_privname($page) {
128 94
	global $priv_list;
129 95

  

Also available in: Unified diff