<?php function requireLogin() { global $currentuser; if ( $_SESSION['userid'] != 0 ) { return true; } else { header('Location: index.php'); exit(); } return; } // // This function outputs the HTML header along with adding a string // of text to the page title. // function includeHTMLHeader($headertext = "", ...$sheets) { global $currentuser; if ($headertext != "") $fullpagetitle = htmlspecialchars($headertext); $extrasheets = " <!-- Extra CSS included by the current page -->\n"; foreach ( $sheets as $sheet ) { $extrasheets .= " <link type='text/css' rel='stylesheet' href='css/{$sheet}'/>\n"; } require 'htmlheader.php'; } // // This function outputs the HTML footer along with adding script tags // for any script files passed to the function. These files are assumed // to be in the js/ folder. // function includeHTMLFooter(...$scripts) { require 'htmlfooter.php'; foreach ( $scripts as $script ) { echo "\n <script type='text/javascript' src='js/", trim($script), "'></script>\n"; } echo " </body>\n"; echo "</html>\n"; } // // This function will redirect to the home page if the current session // has a validated user (i.e. userid != 0). // function require_anonymous() { if ( $_SESSION['userid'] != 0 ) { header('Location: index.php'); exit(); } } // // A simple function to redirect a page while still in the header // function redirectPage($page = null) { if ( is_null($page) ) $page = "index.php"; header("Location: {$page}"); exit(); }