summaryrefslogtreecommitdiff
path: root/inc/auth.php
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-09-23 18:12:06 +0200
committerchris <chris@jalakai.co.uk>2006-09-23 18:12:06 +0200
commita424cd8e52ec6e1e860e19467c8cea23871f611f (patch)
treebf30c7939bc4bcc56d5d0432bd7cf7e1ee1730c5 /inc/auth.php
parent720307d9ce09c85c3b6037fed985128b2bd860a4 (diff)
downloadrpg-a424cd8e52ec6e1e860e19467c8cea23871f611f.tar.gz
rpg-a424cd8e52ec6e1e860e19467c8cea23871f611f.tar.bz2
add authname memory cache
actions which concern multiple pages (e.g. search, backlinks, recents) end up repeatedly encoding the current user's name and groups. This change caches the results of the encoding allowing them to be reused. darcs-hash:20060923161206-9b6ab-a3ec8f1c2ec284d84b9ff85cba1e56165b2967a7.gz
Diffstat (limited to 'inc/auth.php')
-rw-r--r--inc/auth.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/inc/auth.php b/inc/auth.php
index db53a4c19..63f84e141 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -380,13 +380,20 @@ function auth_aclcheck($id,$user,$groups){
* @see rawurldecode()
*/
function auth_nameencode($name,$skip_group=false){
- if($skip_group && $name{0} =='@'){
- return '@'.preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e',
- "'%'.dechex(ord('\\1'))",substr($name,1));
- }else{
- return preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e',
- "'%'.dechex(ord('\\1'))",$name);
+ global $cache_authname;
+ $cache =& $cache_authname;
+
+ if (!isset($cache[$name][$skip_group])) {
+ if($skip_group && $name{0} =='@'){
+ $cache[$name][$skip_group] = '@'.preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e',
+ "'%'.dechex(ord('\\1'))",substr($name,1));
+ }else{
+ $cache[$name][$skip_group] = preg_replace('/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/e',
+ "'%'.dechex(ord('\\1'))",$name);
+ }
}
+
+ return $cache[$name][$skip_group];
}
/**