<?php

srand((double)microtime()*1000000);

if ($admin == 1 OR $admin == 2)
{
    include_once ("../inc/inc_connect.php");
}
else
{
    include_once ("inc/inc_connect.php");
}

if (isset($gfcookie[1]))
{
    //check for pass
    $result=mysql_query("SELECT * FROM $userstable WHERE strName = '$gfcookie[1]'");
    $num_rows = mysql_num_rows( $result );
    while ( $a_row = mysql_fetch_object( $result ) )
    {
        if ($gfcookie[2] != "$a_row->strEmail")
        {
            header("Location: login.php");
            exit;
        }
    }
}

$result=mysql_query("SELECT * FROM $admintable");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $titletype = "$a_row->strTitle";
    $font = "$a_row->strFont";
    $fontsize = "$a_row->strFontSize";
    $fontpoint = "$a_row->strFontPoint";
    $fontcolor = "$a_row->strFontColor";
    $ratecolor = "$a_row->strRateColor";
    $swearcolor = "$a_row->strSwearColor";
    $bgcolour = "$a_row->strBGColor";
    $fgcolour = "$a_row->strFGColor";
    $afgcolour = "$a_row->strAFGColor";
    $bordercolor = "$a_row->strBorderColor";
    $flink = "$a_row->strFLink";
    $vlink = "$a_row->strVLink";
    $alink = "$a_row->strALink";
    $boxedquotes = "$a_row->strBoxedQuotes";
    $quotebackcolor = "$a_row->strQuoteBackColor";
    $quotefontcolor = "$a_row->strQuoteFontColor";
    $postwidth = "$a_row->strPostWidth";
    $sigseperator = "$a_row->strSigSeperator";
    $stars2 = "$a_row->strStars2";
    $stars3 = "$a_row->strStars3";
    $stars4 = "$a_row->strStars4";
    $stars5 = "$a_row->strStars5";
    $showposts = "$a_row->strShowPosts";
    $showpostid = "$a_row->strShowPostId";
    $showmodlevel = "$a_row->strShowModLevel";
    $showstars = "$a_row->strShowStars";
    $showavatars = "$a_row->strShowAvatars";
    $showlocation = "$a_row->strShowLocation";
    $showseconds = "$a_row->strShowSeconds";
    $show24hour = "$a_row->strShow24Hour";
    $timeoffset = "$a_row->strTimeOffset";
    $showpmicon = "$a_row->strShowPmIcon";
    $showwwwicon = "$a_row->strShowWwwIcon";
    $showprofile1 = "$a_row->strShowProfile1";
    $showprofile2 = "$a_row->strShowProfile2";
    $showprofile3 = "$a_row->strShowProfile3";
    $showprofile4 = "$a_row->strShowProfile4";
    $showeditinfo = "$a_row->strShowEditInfo";
    $editinfocolour = "GREEN";
    $showteleporter = "$a_row->strTeleporter";
    $adlevel1 = "$a_row->strAdLevel1";
    $adlevel2 = "$a_row->strAdLevel2";
    $adlevel3 = "$a_row->strAdLevel3";
    $adlevel4 = "$a_row->strAdLevel4";
    $adlevel5 = "$a_row->strAdLevel5";
    $adlevel6 = "$a_row->strAdLevel6";
    $adlevel7 = "$a_row->strAdLevel7";
    $showquotes = "$a_row->strShowQuotes";
    $linkrandomquotes = "$a_row->strLinkRandomQuotes";
    $timermorning = "$a_row->strTimerMorning";
    $timernoon = "$a_row->strTimerAfternoon";
    $timerevening = "$a_row->strTimerEvening";
    $allowgalleryupload = "$a_row->strAllowGalleryUpload";
    $galleryrate = "$a_row->strGalleryRate";
    $maximagewidth = "$a_row->strMaxImageWidth";
    $usemainforthumb = "$a_row->strUseMainForThumb";
    $thumbsperrow = "$a_row->strThumbsPerRow";
    $softedit = "$a_row->strSoftEdit";
    $softdelete = "$a_row->strSoftDelete";
    $showlogin = "$a_row->strShowLogin";
    $showtime = "$a_row->strShowTime";
    $showdate = "$a_row->strShowDate";
    $keyboardnavigation = "$a_row->strKeyboardNavigation";
    $statistictracking = "$a_row->strStatisticTracking";
    $adminnewpage = "$a_row->strAdminNewPage";
    $errorreport = "$a_row->strErrorReport";
    $useob = "$a_row->strUseOb";
    $fixmagicquotes = "$a_row->strFixMagicQuotes";
    $metadescription = "Grim Forum 5: $a_row->strMetaDescription";
    $metakeywords = "Grim, Forum, 5, $a_row->strMetaKeyWords";
    $storeprofileemail = "$a_row->strStoreProfileEmail";
    $emailfrom = "$a_row->strEmailFrom";
    $showlastposttime = "$a_row->strShowLastPostTime";
    $showmoderators = "$a_row->strShowModerators";
    $showsecondicon = "$a_row->strShowSecondIcon";
    $gallerycomments = "$a_row->strGalleryComments";
    $allowgallerycommentformatting = "$a_row->strAllowGalleryCommentFormatting";
    $postit = "$a_row->strPostIt";
    $usecalendar = "$a_row->strUseCalendar";
    $backimage = "$a_row->strBackImage";
    $usespellcheck = "$a_row->strSpellCheck";
    $topicsperpage = "$a_row->strTopicsPerPage";
    $membersperpage = "$a_row->strMembersPerPage";
    $postsperpage = "$a_row->strPostsPerPage";
    $allowavatarupload = "$a_row->strAllowAvatarUpload";
    $postsforhottopic = "$a_row->strPostsForHotTopic";
}

$fontsizea = $fontsize - 1;
$fontsizeb = $fontsize + 1;
$fontsizec = $fontsize + 3;
$bordercolorlight = $bordercolor;
$bordercolordark = $bordercolor;
$postsforhottopic -= 1;


$result=mysql_query("SELECT * FROM $userstable WHERE strName = '$gfcookie[1]'");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $keynav = $a_row->intKeyNav;
}
if ($keynav == 1 AND $keyboardnavigation == 1)
{
    $keyboardnavigation = 1;
}
else
{
    $keyboardnavigation = 0;
}

if ($fontsizea < 1)
{
    $fontsizea = 1;
}

if ( substr("$fontpoint", -2) != "pt")
{
    $fontpoint = $fontpoint."pt";
}

//figure subscribed topics...
if (isset($gfcookie[1]))
{
    //forum subscription
    $result=mysql_query("SELECT * FROM $userstable WHERE strName = '$gfcookie[1]'");
    $num_rows = mysql_num_rows( $result );
    while ( $a_row = mysql_fetch_object( $result ) )
    {
        $nosub = explode("***", $a_row->strSubscribedForums);
    }
    $subcount = count($nosub);
}



/* If you are having trouble then uncomment the lines below to reset the forum to it's default values. */


// $fontsize = "2";
// $fontsizea = "1";
// $fontsizeb = "3";
// $fontsizec = "5";
// $font = "Arial";
// $fontpoint = "10pt";
// $fontcolor = "Black";
// $ratecolor = "Red";
// $swearcolor = "RED";
// $bgcolour = "#EFF3F7";
// $fgcolour = "#BCCDDE";
// $afgcolour = "#DCEDFE";
// $bordercolor = "#111111";
// $bordercolorlight = "#111111";
// $bordercolordark = "#111111";
// $flink = "#111111";
// $vlink = "#111111";
// $alink = "#111111";

// $titletype = "1";

// $boxedquotes = "1";
// $quotebackcolor = "#8080FF";
// $quotefontcolor = "WHITE";

// $postwidth = "90%";
// $sigseperator = "-------------------------------------";
// $stars1 = "5";
// $stars2 = "10";
// $stars3 = "15";
// $stars4 = "20";
// $stars5 = "25";
// $showposts = "1";
// $showpostid = "1";
// $showmodlevel = "1";
// $showstars = "1";
// $showavatars = "1";
// $showlocation = "1";
// $showseconds = "0";
// $show24hour = "0";
// $timeoffset = "0";
// $showpmicon = "1";
// $showwwwicon = "1";
// $showprofile1 = "0";
// $showprofile2 = "0";
// $showprofile3 = "0";
// $showprofile4 = "1";
// $showeditinfo = "1";
// $editinfocolour = "GREEN";
// $showteleporter = "1";

// $adlevel1 = "Forum Minion";
// $adlevel2 = "Forum Watcher";
// $adlevel3 = "Forum Elder";
// $adlevel4 = "Forum Guardian";
// $adlevel5 = "High Forum Guardian";
// $adlevel6 = "Forum Overlord";
// $adlevel7 = "He who must not be named";

// $showquotes = "1";
// $linkrandomquotes = "1";
// $timermorning = "Morning (1am-9am)";
// $timernoon = "Afternoon (9am-5pm)";
// $timerevening = "Evening (5pm-1am)";

// $allowgalleryupload = "1";
// $galleryrate = "1";
// $maximagewidth = "975";
// $usemainforthumb = "1";
// $thumbsperrow = "5";
// $gallerycomments = 1;
// $allowgallerycommentformatting = 1;

// $softedit = "1";
// $softdelete = "0";

// $showlogin = "1";
// $showtime = "1";   // Iiiiiiiiiiiiiiiiiiiit's Showtime! :o)
// $showdate = "1";

// $keyboardnavigation = "0";

// $statistictracking = "2";

// $adminnewpage = "0";

// $errorreport = "2";
// $useob = "0";
// $fixmagicquotes = "0";
// $metadescription = "The GF5 Test Forum";
// $metakeywords = "Testing, PHP, Code, Build";

// $storeprofileemail = "1";
// $emailfrom = "grimforum@hsmx.com";

// $showlastposttime = 0;
// $showmoderators = 0;
// $showsecondicon = 0;

// $postit = 1;

// $usecalendar = 1;

// $usespellcheck = 1;

// $topicsperpage = 50;
// $postsperpage = 0;
// $membersperpage = 100;


//Error Reporting Level

if ($errorreport == 0)
{
    error_reporting(0);
}

if ($errorreport == 1)
{
    error_reporting  (E_ERROR | E_WARNING | E_PARSE);
}

if ($errorreport == 2)
{
    error_reporting (E_ALL ^ E_NOTICE);
}

if ($errorreport == 3)
{
    error_reporting (E_ALL);
}

//fix magic slashes...

if ($fixmagicquotes == 1)
{
    ini_set("magic_quotes_runtime", 0);
}


if ($useob == 1)
{
    ob_start("ob_gzhandler");
}
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;

function highlight($sword, $haystack){
return preg_replace('|('.quotemeta($sword).')|iU',
                    '<a style="color: black; background-color: #66FF66">\\1</a>', $haystack);
}

?>