LinkProvider/functions.php
2018-10-03 11:59:53 -04:00

76 lines
2.5 KiB
PHP
Executable File

<?php
//
// 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();
}
//
// 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 header along with adding a string
// of text to the page title. This is for pages without side navigation.
//
function includeHTMLHeaderBasic($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-basic.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 "<script type='text/javascript' src='js/", trim($script), "'></script>\n";
}
echo " </body>\n";
echo " </html>\n";
}
//
// 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. This is for pages without side navigation.
//
function includeHTMLFooterBasic(...$scripts) {
require 'htmlfooter-basic.php';
foreach ( $scripts as $script ) {
echo "<script type='text/javascript' src='js/", trim($script), "'></script>\n";
}
echo " </body>\n";
echo " </html>\n";
}
function isValidIPAddress($address) {
$octets = explode(".", $address);
if ( count($octets) != 4 ) return false;
foreach ( $octets as $octet ) {
if ( !is_numeric($octet) || ($octet < 0) || ($octet > 255) ) return false;
}
return true;
}