/** * 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; }
$output->nav['copyright'] = $root . 'COPYING'; // title and headline $output->title[0] = 'infoschool'; $output->headline[0] = 'infoschool'; // navigation menu $output->menu['./'] = 'start'; $output->menu['calendar/'] = 'calendar'; $output->menu['supply/'] = 'supply schedule'; $output->menu['forum/'] = 'Forum'; $output->menu['files/'] = 'file exchange'; $output->menu['messages/'] = 'Messages'; // $output->menu['zensuren/'] = 'grades'; $output->menu['news/'] = 'News'; // $output->menu['benutzer/'] = 'users'; $output->menu['users/'] = 'Users'; if (isset($_SESSION['admin']) && $_SESSION['admin']) { $output->menu['statistics/'] = 'statistics'; } $output->menu['dokumentation/'] = 'help'; $output->menu['dokumentation/faq.php'] = 'faq'; $output->menu['about/'] = 'About'; // subdir of the software $webdir = Path::clean(Path::rm_last($_SERVER['SCRIPT_NAME']) . $root); // system-root for the user: http://server.domain.tld/foo/ $http_root = 'http://' . $_SERVER['SERVER_NAME'] . $webdir; // starts outstanding jobs $cron = new cron(); // $output->out_of_service = true; if (isset($_GET['oos'])) { $output->out_of_service = $_GET['oos']; }
function test_rm_last_file_not_dir() { $path = '/root/bla/func/'; $this->assertEquals('/root/bla/func/', Path::rm_last($path)); }