<?php
error_reporting(E_ERROR);
//////////////////////////////////////////////////////////////////////////////////
// Kreative News
// Designed and Built by: Ben Kuskopf
// Copyright Kreative Studios 2002-2003
// You can modify the script files as much as you like
// How ever the copyright and powered by notice must appear on pages using knews.
// Last Modified: Marth 4th 2003
// To Do: Nothing at the moment
/////////////////////////////////////////////////////////////////////////////////


/* ------------------------------------- */
// I'm just going to clean this up a little, to give you an
// idea what I would have done.

// I'd abstract this, but thats okay.
$dbl = @mysql_pconnect($hn,$un,$pw) or die ('<html><body><h1>Database not 
available - please try later</h1></body></html>'."\n");

mysql_select_db($db);

if (isset($_GET['Temp']))
    $Temp = $_GET['Temp']; 
else 
    $Temp = 'Header';

$tableName = $tprefix.'settings';
$query = "SELECT setvalue FROM $tableName WHERE setname='%s'";
$valuesToGet = array( 
        "abpath",
        "hlimit",
        "smilies",
        "bbcode",
        "httppath",
        );

foreach ($valuesToGet as $value)
{
    $sqlnv = mysql_query_e(sprintf($query, $value));
    if ($sqlnv && $row = mysql_fetch_array($sqlnv))
    {
        $abpath = $row['setvalue'];	
    }
}

require ($abpath . "/functions.php");

if ($Temp == "Header" || $Temp == "Footer")
{
    $tableName = $tprefix.'templates';
    if ($Temp == "Header")
    {
        $id = 9;
    }
    else
    {
        $id=10;
    }

    $sqlnv = mysql_query_e("SELECT template FROM $tableName WHERE id='$id'");
    if ($sqlnv && $row = mysql_fetch_array($sqlnv))
    {
        $template = $row['template'];	
    }
$template = str_replace('%', '$', $template);
    
    echo "<!-- Start header Template -->\n\n";
    ob_start(); eval('?>' . $headertemp); $headertemp = ob_get_contents(); ob_end_clean();
	echo $headertemp;
    echo "\n\n<!-- End header Template -->\n\n";
    mysql_close();
}
?>