'/',
'Notandi:Birte' => '/user/Birte/',
'Kerfissíða:Guestbook' => '/guestbook/',
'Kerfissíða:Categories' => '/tag/',
);
return $fallbacks[$title];
}
function nsp_fnam ($title) {
$ret_url = '';
if (preg_match('/^Kerfissíða:Recentchanges/i', $title)) {
return '/recentchanges/';
}
elseif (preg_match('/Mynd:(.*\.jpg)/', $title, $matches)) {
$mynd = $matches[1];
$mynd = str_replace('__63__', '', $mynd); // ?
$mynd = str_replace('__33__', '', $mynd); // !
$ret_url = nsp_fnam_filecheck('mynd', $mynd, 0);
}
elseif (preg_match('/Mynd:(.*\.(?:mp3|pdf))/', $title, $matches)) {
$ret_url = nsp_fnam_filecheck('file', $matches[1], 0);
}
elseif (preg_match('/^Flokkur:([^\/]+)/', $title, $matches)) {
$ret_url = nsp_fnam_filecheck('tag', $matches[1], 1);
}
elseif (preg_match('/^Leikur_að_bókum:([^\/]+)/', $title, $matches)) {
$ret_url = nsp_fnam_filecheck('leikur_ad_bokum', $matches[1], 1);
}
elseif (preg_match('/^Hjálp:([^\/]+)/', $title, $matches)) {
$ret_url = nsp_fnam_filecheck('help', $matches[1], 1);
}
// Notandi:Birte handled by fallback.
// Kerfissíða:Guestbook and Kerfissíða:Categories handled by fallback.
return $ret_url;
}
function nsp_fnam_filecheck ($dirname, $file, $ishtml) {
$basedir = '/export/leikuradbokum';
if ($ishtml) {
$url = '/' . $dirname . '/' . $file . '/';
$fn = $basedir . $url . 'index.html';
}
else {
$url = '/' . $dirname . '/' . $file;
$fn = $basedir . $url;
}
if (file_exists($fn)) {
// echo("success! ret_url = $url
tried: url=$url, fn=$fn"); die;
return $url;
}
else {
// echo("FAIL! ret_url = $url
tried: url=$url, fn=$fn"); die;
return '';
}
}
?>