'http://www.google.com/search?q=$1', 'w' => 'http://en.wikipedia.org/wiki/Special:Search?go=1&search=$1', '_default' => 'http://www.google.com/search?q=$1', )); SDVA($HandleActions, array('dtrt'=>'HandleDTRT')); function HandleDTRT($pagename, $auth="read") { global $DTRT_links; #will ask for password if needed $page = RetrieveAuthPage($pagename,$auth,1, READPAGE_CURRENT); if (preg_match_all("/^\\s*(\\S*)\\s*:[^\\S\n]+(\\S*)/m", $page['text'], $match, PREG_SET_ORDER)) { foreach($match as $m) { $tmp = explode(',', $m[1]); foreach($tmp as $key) $DTRT_links[$key] = $m[2]; } } list($k, $q) = explode(' ', urldecode(stripmagic($_GET['q'])), 2); if(!isset($DTRT_links[$k]) || $DTRT_links[$k] == 'null' || $DTRT_links[$k] == '' ) { $rxfound = 0; foreach ($DTRT_links as $rx=>$u) { if (!preg_match('/^\\/.*\\/i?$/', $rx)) continue; if (! preg_match($rx, $k)) continue; $rxfound = 1; $k = $rx; # no 'break', later defs override earlier ones } if(!$rxfound) { $k = '_default'; $q = stripmagic($_GET['q']); } } $where = $DTRT_links[$k]; if(strpos($where, 'function:')===0 ) { $func = str_replace('function:', "DTRT_", $where); if(! function_exists($func)) Abort("User function '$func' does not exist."); $url = $func($q); } else $url = str_replace('$1', urlencode($q), $where); if(!$url) Abort("Bad configuration, where='$where', key='$k'; query='$q'."); Redirect($pagename, $url); }