function vplan_single($pi = '')
{
    global $output;
    if ($_GET['key'] != 'kmyxl09') {
        $output->secure();
    }
    $user_pi = '0';
    if (isset($_GET['d'])) {
        $user_pi = $_GET['d'];
    }
    if (strlen($pi) == 0) {
        $pi = $user_pi;
    }
    (int) $pi;
    $vplan = get_vplan($pi);
    $vars = vplan2html_single($vplan['text']);
    $vars['%url%'] = sessionurl('single.php?d=' . $pi);
    $vars['%titel%'] = 'Vertretungsplan';
    echo FileReader::readFile('single.html', $vars);
}
 function format_menuitem($url, $caption, $level, $dir = false)
 {
     $url = Path::linkto($GLOBALS['root'] . $url);
     $caption = output::mask($caption);
     $m = array('menu_spacer' => array(), 'menu_entry' => array(), 'menu_dir' => array(), 'menu_url' => $url, 'menu_caption' => array(), 'menu_caption_this' => array());
     for ($i = 0; $i < $level; $i++) {
         $m['menu_spacer'][] = array();
     }
     if ($dir) {
         $m['menu_dir'][] = array();
     } else {
         $m['menu_entry'][] = array();
     }
     $document_root = $_SERVER['DOCUMENT_ROOT'];
     if (substr($document_root, -1) == '/') {
         $document_root = substr($document_root, 0, -1);
     }
     $a = Path::absolute($url);
     $b = sessionurl($a);
     $c = $document_root . $_SERVER['REQUEST_URI'];
     if ($a == $c || $b == $c) {
         $m['menu_caption_this'][0]['menu_caption'] = $caption;
     } else {
         $m['menu_caption'][0]['menu_caption'] = $caption;
     }
     return $m;
 }
/**
 * Wandelt eine relative URL in eine absolute um und modifiziert den
 * HTTP-Header(Location). Kehrt nicht zurück.
 * @param $path Pfad zur aufzurufenden Webseite
 * @param $arg GET-Argumente (?x=23&y=42)
 * @param $ilink HTML-interner Link (#foo)
 * @return never, Funktion terminiert die Ausführung und kehrt nicht zurück.
 */
function redirect($path = '', $arg = array(), $ilink = '')
{
    $protocol = 'http://';
    $host = $_SERVER['HTTP_HOST'];
    $file = $_SERVER['PHP_SELF'];
    $pos = strpos($path, '://');
    if ($pos) {
        $pos += 3;
        $protocol = substr($path, 0, $pos);
        $path = substr($path, $pos);
        $pos = strpos($path, '/');
        $host = substr($path, 0, $pos);
        $path = substr($path, $pos);
    }
    if (!$path) {
        $path = $file;
    }
    if (substr($path, 0, 1) != '/') {
        $path = Path::rm_last($file) . $path;
    }
    $path = Path::clean($path);
    if (strstr($path, '#')) {
        list($path, $internal_link) = explode('#', $path);
        if ($ilink == false) {
            $ilink = $internal_link;
        }
    }
    if (is_array($arg) && sizeof($arg) > 0) {
        if (strstr($path, '?')) {
            $z = '&';
        } else {
            $z = '?';
        }
        foreach ($arg as $n => $v) {
            $path .= $z . $n . '=' . $v;
            $z = '&';
        }
    }
    $path = sessionurl($path);
    if ($ilink && substr($_SERVER['HTTP_USER_AGENT'], 0, 5) != 'Opera') {
        $path .= '#' . $ilink;
    }
    if (substr($path, 0, 7) != $protocol) {
        $path = $protocol . $host . $path;
    }
    header('Location:' . $path);
    exit;
}