count($matches)-1) { debug('routing',print_error('Routing failure','Trying to set request variable "'.$vars[$i].'" but ran out of matches (page='.$dest.')')); } else { $_REQUEST[$vars[$i]]=$matches[$i+1]; } } } while ($dest != null) { debug('routing','Routing to '.$dest); if (!is_file('pages/'.$dest.'.php')) { throw_exception('Routing to '.$dest.' but pages/'.$dest.'.php doesn\'t exist.'); } require_once('pages/'.$dest.'.php'); $dest=str_replace(array('/', '-'), '_', $dest); $initfunc='init_'.$dest; if (function_exists($initfunc)) { $value=$initfunc($S); if ($value === null) { break; } elseif (is_array($value)) { if (isset($value['dest'])) { $dest=$value['dest']; unset($value['dest']); $S=array_merge($S, $value); } else { $S=array_merge($S, $value); break; } } else { $dest=$value; } } else { debug('routing','No init function for '.$dest.'... continuing to body'); break; // require_once('include/header.php'); // die(print_error('Routing Failure', 'Init function undefined for '.$dest.'.')); } } if (!$S['notemplates']) { require_once('include/header.php'); } $bodyfunc='body_'.str_replace('/','_',$dest); if (function_exists($bodyfunc)) { $bodyresult=$bodyfunc($S); if ($bodyresult !== null) { require($bodyresult); } } else { if ($S['notemplates']) { debug('Routing', 'Body function missing for page '.$dest); } else { die(print_error('Routing failure', 'Body function missing for page '.$dest)); } } die; } } die(print_error('Routing Failure', 'You should never see this message. Please contact an administrator.')); ?>