2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
|
|
|
|
/*************************************************/
|
|
|
|
|
/* Main Include Library for Application Database */
|
|
|
|
|
/*************************************************/
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-12-23 01:09:20 +00:00
|
|
|
// get modules
|
2004-03-15 16:22:00 +00:00
|
|
|
require(BASE."include/"."config.php");
|
|
|
|
|
require(BASE."include/"."util.php");
|
|
|
|
|
require(BASE."include/"."user.php");
|
|
|
|
|
require(BASE."include/"."session.php");
|
|
|
|
|
require(BASE."include/"."menu.php");
|
|
|
|
|
require(BASE."include/"."html.php");
|
2004-12-29 18:43:30 +00:00
|
|
|
require(BASE."include/db.php");
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
// create arrays
|
|
|
|
|
$sidebar_func_list = array();
|
|
|
|
|
$help_list = array();
|
|
|
|
|
|
|
|
|
|
function apidb_help_add($desc, $id)
|
|
|
|
|
{
|
|
|
|
|
global $help_list;
|
|
|
|
|
$help_list[] = array($desc, $id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-23 01:09:20 +00:00
|
|
|
// return url with docroot prepended
|
2004-03-15 16:22:00 +00:00
|
|
|
function apidb_url($path)
|
|
|
|
|
{
|
2004-12-23 01:09:20 +00:00
|
|
|
return BASE.$path;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-23 01:09:20 +00:00
|
|
|
// return FULL url with docroot prepended
|
2004-03-15 16:22:00 +00:00
|
|
|
function apidb_fullurl($path = "")
|
|
|
|
|
{
|
2004-12-23 01:09:20 +00:00
|
|
|
return BASE.$path;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function apidb_fullpath($path)
|
|
|
|
|
{
|
2004-12-23 01:09:20 +00:00
|
|
|
return $_SERVER['DOCUMENT_ROOT'].BASE.$path;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* output the common apidb header
|
|
|
|
|
*/
|
|
|
|
|
function apidb_header($title = 0)
|
|
|
|
|
{
|
2005-01-10 22:54:04 +00:00
|
|
|
$realname = isset($_SESSION['current'])?$_SESSION['current']->realname:"";
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
// Set Page Title
|
|
|
|
|
$page_title = $title;
|
|
|
|
|
if ($title)
|
2004-12-12 03:51:51 +00:00
|
|
|
$title = " - $title";
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
// banner ad
|
|
|
|
|
include(BASE."include/"."banner.php");
|
|
|
|
|
$banner_ad = banner_display();
|
|
|
|
|
|
|
|
|
|
// Display Header
|
|
|
|
|
include(BASE."include/"."header.php");
|
|
|
|
|
|
|
|
|
|
// Display Sidebar
|
|
|
|
|
echo "<table width='100%' border=0 cellspacing=0 cellpadding=0>\n";
|
|
|
|
|
echo "<tr valign='top'>\n";
|
|
|
|
|
echo "<td width=150>\n";
|
|
|
|
|
apidb_sidebar();
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td width='100%'>\n";
|
|
|
|
|
|
2004-12-18 01:54:23 +00:00
|
|
|
echo html_frame_start($page_title, '100%');
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
// Display Status Messages
|
|
|
|
|
dumpmsgbuffer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* output the common apidb footer
|
|
|
|
|
*/
|
|
|
|
|
function apidb_footer()
|
|
|
|
|
{
|
|
|
|
|
echo html_frame_end();
|
|
|
|
|
|
|
|
|
|
//Close Sidebar and Content Well
|
2004-03-24 15:58:57 +00:00
|
|
|
echo "<br></td></tr></table>\n";
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
// Display Footer
|
2004-12-10 01:07:45 +00:00
|
|
|
if(!isset($header_disabled))
|
2004-03-15 16:22:00 +00:00
|
|
|
include(BASE."include/"."footer.php");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* output the sidebar, calls all functions registered with apidb_sidebar_add
|
|
|
|
|
*/
|
|
|
|
|
function apidb_sidebar()
|
|
|
|
|
{
|
|
|
|
|
global $sidebar_func_list;
|
|
|
|
|
|
|
|
|
|
//TURN on GLOBAL ADMIN MENU
|
|
|
|
|
if (havepriv("admin"))
|
|
|
|
|
{
|
2004-12-12 03:51:51 +00:00
|
|
|
include(BASE."include/"."sidebar_admin.php");
|
|
|
|
|
apidb_sidebar_add("global_admin_menu");
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Login Menu
|
|
|
|
|
include(BASE."include/"."sidebar_login.php");
|
|
|
|
|
apidb_sidebar_add("global_sidebar_login");
|
|
|
|
|
|
|
|
|
|
// Main Menu
|
|
|
|
|
include(BASE."include/"."sidebar.php");
|
|
|
|
|
apidb_sidebar_add("global_sidebar_menu");
|
|
|
|
|
|
|
|
|
|
//LOOP and display menus
|
|
|
|
|
for($i = 0; $i < sizeof($sidebar_func_list); $i++)
|
|
|
|
|
{
|
2004-12-12 03:51:51 +00:00
|
|
|
$func = $sidebar_func_list[$i];
|
|
|
|
|
$func();
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
|
|
|
|
* register a sidebar menu function
|
2004-03-15 16:22:00 +00:00
|
|
|
* the supplied function is called when the sidebar is built
|
|
|
|
|
*/
|
|
|
|
|
function apidb_sidebar_add($funcname)
|
|
|
|
|
{
|
|
|
|
|
global $sidebar_func_list;
|
|
|
|
|
array_unshift($sidebar_func_list, $funcname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function apidb_image($name)
|
|
|
|
|
{
|
2004-12-23 01:09:20 +00:00
|
|
|
return BASE."images/$name";
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2004-03-15 16:22:00 +00:00
|
|
|
* display an error page
|
|
|
|
|
*/
|
|
|
|
|
function errorpage($text = null, $message = null)
|
|
|
|
|
{
|
|
|
|
|
if (!$text) {
|
2004-12-12 03:51:51 +00:00
|
|
|
$text = "You must be logged in to perform that operation.";
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
apidb_header("Oops");
|
|
|
|
|
echo "<div align=center><font color=red><b>$text</b></font></div>\n";
|
|
|
|
|
echo "<p>$message</p>\n";
|
|
|
|
|
apidb_footer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2004-03-15 16:22:00 +00:00
|
|
|
* redirect to $url
|
|
|
|
|
*/
|
|
|
|
|
function redirect($url)
|
|
|
|
|
{
|
|
|
|
|
header("Location: ".$url);
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2004-03-15 16:22:00 +00:00
|
|
|
* redirect back to referer, or else to the main page
|
|
|
|
|
*/
|
|
|
|
|
function redirectref($url = null)
|
|
|
|
|
{
|
|
|
|
|
if(!$url)
|
2004-12-12 03:51:51 +00:00
|
|
|
$url = $_SERVER['HTTP_REFERER'];
|
2004-03-15 16:22:00 +00:00
|
|
|
if(!$url)
|
2004-12-12 03:51:51 +00:00
|
|
|
$url = apidb_fullurl();
|
2004-03-15 16:22:00 +00:00
|
|
|
redirect($url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2004-03-15 16:22:00 +00:00
|
|
|
* msgs will be displayed on the Next page view of the same user
|
|
|
|
|
*/
|
|
|
|
|
function addmsg($text, $color = "black")
|
|
|
|
|
{
|
|
|
|
|
if($color)
|
2004-12-12 03:51:51 +00:00
|
|
|
$text = "<font color='$color'> $text </font>\n";
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
$text = str_replace("'", "\\'", $text);
|
2005-01-11 00:26:05 +00:00
|
|
|
query_appdb("INSERT INTO sessionMessages VALUES (null, null, '".session_id()."', '$text')");
|
2004-03-15 16:22:00 +00:00
|
|
|
echo mysql_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2004-03-15 16:22:00 +00:00
|
|
|
* output msg_buffer and clear it.
|
|
|
|
|
*/
|
|
|
|
|
function dumpmsgbuffer()
|
|
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT * FROM sessionMessages WHERE sessionId = '".session_id()."'");
|
2004-03-15 16:22:00 +00:00
|
|
|
if(!$result)
|
2004-12-12 03:51:51 +00:00
|
|
|
return;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
while($r = mysql_fetch_object($result))
|
2004-12-12 03:51:51 +00:00
|
|
|
{
|
|
|
|
|
echo html_frame_start("","300","",5);
|
|
|
|
|
echo "<div align=center> $r->message </div>";
|
|
|
|
|
echo html_frame_end(" ");
|
2004-03-15 16:22:00 +00:00
|
|
|
echo "<br>\n";
|
2004-12-12 03:51:51 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-11 00:26:05 +00:00
|
|
|
query_appdb("DELETE FROM sessionMessages WHERE sessionId = '".session_id()."'");
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
2004-12-23 01:08:21 +00:00
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-12-13 03:50:02 +00:00
|
|
|
/*
|
|
|
|
|
* Start DB Connection
|
|
|
|
|
*/
|
|
|
|
|
opendb();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Init Session (stores user info and cart info in session)
|
|
|
|
|
*/
|
|
|
|
|
$session = new session("whq_appdb");
|
|
|
|
|
$session->register("current");
|
|
|
|
|
|
2004-12-18 01:56:08 +00:00
|
|
|
// if we are debugging we need to see all errors
|
|
|
|
|
if(debugging()) error_reporting(E_ALL ^ E_NOTICE);
|
2004-03-15 16:22:00 +00:00
|
|
|
?>
|