<?php
/*******************************************************/
//        - FireBase Administration
//           Developement Template -
// 
//        Copyright  2004-2005 Kevin Adolphe
//               All Rights Reserved !
//
//  This is the basic administartion template
//  used solely for speedier developement of
//  applications used in the FireBase Software
//  Content Management and Syndication system
//
//  This file is not to be uploaded with the core!
//
/******************************************************/

//
// Include our config page
//
	
require_once("firebase.conf.php");

//
// Grab our templates - read them into to the page variable
//
	
	$urlsrc =  ROOT . "/firebase_themes/" . THEME . "/general_site_header.tpl";
	$file = fopen($urlsrc, "r");
	$page = fread($file, 1024*1024);
	fclose($file);

	$urlsrc =  ROOT . "/firebase_themes/" . THEME . "/main.tpl";
	$file =   @fopen($urlsrc, "r");
	$page .= @fread($file, 1024*1024);
	@fclose($file);
	
	$urlsrc =  ROOT . "/firebase_themes/" . THEME . "/general_site_footer.tpl";
	$file =  @fopen($urlsrc, "r");
	$page .= @fread($file, 1024*1024);
	@fclose($file);

	
//
// Now create our list of things to replace within the page
//
	
	$id = (! empty($_REQUEST['id'])) ? $_REQUEST['id'] : null;

	$expl = explode("/", SELF);
	$sub =            $expl[count($expl)-2];
	$id =             $expl[count($expl)-1];

	$logo = "<a href='/'><img src=\"/firebase_themes/" . THEME . "/images/logo.gif\" border=\"0\" alt=\"Company Logo and Link Back To Main Site\"></a>";


	$dbi = new DBI(DB_URL);
	if(!$dbi->isConnected()){
		print "We could not gain access to the database!";
	}


	if($id =="")
	{
		$sub = urldecode(stripslashes($sub));
		$statement = "Select * from firebase_content where category=\"" . $sub . "\" and description='index'";
		
	}
	else
	{
		$id = urldecode(stripslashes($id));
		$statement = "Select * from firebase_content where title=\"" . $id . "\"";
		
	}


	$result = $dbi->query($statement);

	
	if($result== "NULL"){
	
	}
	elseif ($result->numRows() == 0)
	{
			$content_title = "Example Content";
			$description = "This is an example of what your content could look like...";
			$body = "Use your administration panel to begin adding content";

	$debug->debug('No user file found...application has run with the default news item');

	} else {

	
	$newsItem = "";
	while($row = $result->fetchRow())
		{
		$newsId = $row->id;
		$category = $row->category;
		$content_title = $row->title;
		$body = $row->body;
		$author = $row->author;
		$date_added = $row->date_added;
		$date_modified = $row->date_modified;
		$start_date = $row->start;
		$end_date = $row->end;
		$comments = $row->comments;
		$rating = $row->rating;
		
		$body = strip_tags($body,  $F_HTML_ALLOW);
		$body = eregi_replace("<p>&nbsp;</p>", "<br /><br />", $body);
		$body = str_replace("<br>", "<br />", $body);
		
		$category = strtoupper($category);
	

				
				}
			}

// Now parse the variables out of our template

require_once('template_vars/_tpl-var-list.php');

//
// Loop through the page replacing the key list with content
//

        while(list($k, $v) = each($list))
		{
			$page = str_replace("{" . $k . "}", $v, $page);
		}


//
// render our page
//
		print $page;

?>
