website/parts/library.inc
Jeff Teunissen fc3ce061c3 Rename most of the _parts_ .php files too (not the preamble though)
Fix plans, from too much over- and under-quoting.
2007-03-22 05:54:08 +00:00

128 lines
2.5 KiB
PHP

<?
// helpful constants
if (!defined( '_COLORS_' )) {
define ('_COLORS_', 1);
define ('black', "black");
define ('white', "white");
define ('thisURL', $_SERVER['SCRIPT_NAME']);
if (!$currPage)
$currPage = 'none';
if (!$theme && date ('m') == 12)
$theme = "christmas";
if (!$theme)
$theme = "quakeforge";
switch ($theme) {
case "christmas":
define ('bgColor', black);
define ('tableHeadColor', '#7f000c');
define ('tableBgColor', black);
define ('featureHeadColor', '#7f000c');
define ('featureBgColor', '#083008');
break;
default:
define ('bgColor', black);
define ('tableHeadColor', '#737b9c');
define ('tableBgColor', black);
define ('featureHeadColor', '#737b9c');
define ('featureBgColor', '#262633');
}
}
if (!defined ('_SQLCONSTS_')) {
define ('_SQLCONSTS_', 1);
require siteHome . '/../etc/sql.conf';
}
if (!defined ('_ARRAY_')) { // Treat array handler special
require siteHome . "/lib/array.inc";
}
if (!defined ('_LIBFUNCS_')) {
define ('_LIBFUNCS_', 1);
/*
reqIfNeeded
Require a library module if it hasn't already been.
*/
function reqIfNeeded ($libNames)
{
global $has, $needs;
$libs = explode(' ', $libNames);
for ($i = 0 ; $i < count ($libs) ; $i++ ) {
$lib = $libs[$i];
if ((inArray ($libs[$i], $needs)) && (!inArray ($libs[$i], $has))) {
include siteHome . "/lib/$libs[$i].inc";
}
}
}
/*
have
Tell the library that module X is loaded
*/
function have ($libName)
{
global $has;
addToArray ($libName, $has);
}
/*
need
Load module X if it hasn't been already, taking care to retain the
integrity of the $needs array.
*/
function need ($libNames)
{
global $needs;
$libs = explode(' ', $libNames);
for ($i = 0 ; $i < count ($libs) ; $i++ ) {
addToArray ($libs[$i], $needs);
}
reqIfNeeded ($libNames);
}
function bailout ($str)
{
if (strlen ($str))
echo $str;
die;
}
function stripAllSlashes (&$var)
{
if (is_array ($var)) {
foreach (array_keys ($var) as $key) {
if (is_array($var[$key])) {
stripAllSlashes ($var[$key]);
} else {
$var[$key] = stripSlashes ($var[$key]);
}
}
} else {
$var = stripSlashes ($var);
}
}
if (true && get_magic_quotes_gpc()) { // unquote $_GET, $_POST, $_COOKIE
stripAllSlashes ($_GET);
stripAllSlashes ($_POST);
stripAllSlashes ($_COOKIE);
stripAllSlashes ($_REQUEST);
}
} // !_LIBFUNCS_
?>