<?
/*
if (!(($_SERVER["REMOTE_ADDR"] == "69.135.241.202") || ($_SERVER["REMOTE_ADDR"] == "24.210.217.82")))
    die("updating!");
*/

// *** Check for Referrer Spam! ***
include_once "php/referrer-karma.php";
check_referrer();

// *** Include Secrets ***
include "php/secret.php";

// *** Include Persistant Link ***
include "php/pconnect.phps";

// *** Get Config from MySQL DB ***
include "php/get_config.phps";
if (!
get_config())
    die (
"Unable to Load Configuration Variables from Database");

// *** Include Functions ***
include "php/cms_functions.phps";

// *** Initialize Benchmark ***
$benchmark_time = new benchmark;



//if (member_info(current_member(), "handle") != "frikk") die("Sorry, I'm having some Technical Difficulties.  Frikk dot TK will be back up in just a few minutes, seriously!");



// *** Query String ***

// *** See if i should separate the query by , or / ***
// *** This a temporary solution until I can figure how to send vars through ajax, but not through the URL ***
//if (!strstr($_SERVER["REQUEST_URI"], "?ajax,"))
    
$exp = (strstr($_SERVER["QUERY_STRING"], '/')) ? "/" ",";
//else
//    $exp = ",";


$QUERY=explode($expurldecode($_SERVER["QUERY_STRING"]));

// *** Initialize Template ***
$tpl = new template();

// *** Load up the ajax scripts (Needs $QUERY) ***
include_once "php/ajax.phps";

// *** Load up custom scripts ***
include_once "custom/custom.php";

if (
substr_count($_SERVER["REQUEST_URI"], "?") > 1)
    die(
"Invalid Query.  You cannot have more than a single quotation mark (?) in the query string");

// *** Run Statistics Script & Update Login Info ***
do_stats();

// *** Load up the browser identifier ***
include_once "browser.phps";
$browser = new Browser();

// *** Include the google api script if we need it. This is sloppy ***
if ($QUERY[0] == "gmap"$google_api 
    
"<script src=\"http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAalWNR9kuA33Hbh6pZykwg" .
    
"BThVi8yJ2cNBIBd5HdGUIFFajGUqxTLLhi5ShGHply48osGgLvYrChyMg\" type=\"text/javascript\"></script>";
else 
$google_api "";

$tpl->template_set("{GOOGLEMAPS_API}"$google_api);

switch (
$QUERY[0]){
    case 
'home':
    case 
'':
        
header("Location: http://" $_SERVER['HTTP_HOST']
                     . 
dirname($_SERVER['PHP_SELF'])
                     . 
MAIN_URL);
        die();

        break;
    case 
'stats':
        
$tpl->template_set("{TITLE}""Stats for " date("m.d.y @ g:i a"));
        
$tpl->template_set("{STAT_UPTIME}""aa");
        
$tpl->template_set_content("{STAT_UPTIME} <br><br>{STAT_MEMORY_INFO}<br><br>{STAT_SERVER_INFO}");
        break;
        
    case 
'gmap':
        
$tpl->template_set("{TITLE}""GMAP of where my visitors are from");
        
$tpl->template_set_content(generate_gmap());
        break;

    case 
'rss':
        
//if (empty($QUERY[1])) die(MSG_INVALID_CONTENT);
        // *** Change the header accordingly ***

        
if (empty($QUERY[1]) || $QUERY[1] == "8")
        {
            
header("HTTP/1.1 307 Temporary Redirect");
              
header("Location: http://feeds.feedburner.com/FrikkDotTk-SoLongAndThanksForAllTheFish");
            die();
        }

        if (
$QUERY[1] == "fb"$feed_id 8;
        if (empty(
$feed_id)) $feed_id $QUERY[1];

        
header("Content-type: text/xml");
        
update_stats("rss_views");

        
$tpl->set_rss_feed(get_rss_feed($feed_id));
        break;

    case 
'media':
        if (!empty(
$QUERY[1]))
        {
            
$tpl->set_media($QUERY[1]);
            break;
        }

        
$tpl->template_set("{TITLE}""Media");
        
$tpl->template_set_content("Media Listing");
        break;

    case 
'admin':
        if (!
is_logged_in())
            die (
MSG_NOT_LOGGED_IN);
        if (
member_info(current_member(), "status") < STATUS_ADMIN)
            die (
MSG_NOT_ADMIN);
        break;

    case 
'prefs':
        
$hcontent "";
        if (!
is_logged_in())
            die(
MSG_NOT_LOGGED_IN);
        if (
$_SERVER["REQUEST_METHOD"] == "POST")
        {
            if (!
update_member_info(current_member(), "view_ads"$view_ads_checkbox))
            {
                
$hcontent .= "Error Saving Ad Settings<br>";
            } else {
                
$hcontent .= "Ad Settings Updated<br>";
            }
            if (!empty(
$password0) && !empty($password1) && !empty($password2))
            {
                if (
$password0 == base64_decode(member_info(current_member(), "password")))
                {
                    if(
$password1 == $password2)
                    {
                        
$member current_member();
                        if (!
update_member_info($member"password"base64_encode($password2)))
                        {
                            die(
"Sorry, unable to set password");
                        } else {
                            
$hcontent .= "Password Updated<br>";
                            
login ($member$password2);
                        
header("Location: http://" $_SERVER['HTTP_HOST']
                             . 
dirname($_SERVER['PHP_SELF'])
                             . 
MAIN_URL);

                        die();
                        }
                    } else {
                        
$hcontent .= "Passwords don't match<br>";
                    }
                } else {
                    
$hcontent .= "Wrong Password.<br>";
                }
            }
        }

        
$tpl->template_set("{TITLE}""Preferences");
        
$view_ads member_info(current_member(), "view_ads");
        
$content = array(
        
"{ADS_CHECKED}"=>    ($view_ads     "CHECKED" "")
        );
        
$hcontent .= $tpl->get_mini_tpl("prefs.tpl"$content);
        
$tpl->template_set_content($hcontent);
        break;

    case 
"post_comment":
        
$tpl->template_set("{TITLE}""posting comment");
        if (
$_SERVER["REQUEST_METHOD"] <> "POST")
            die (
MSG_NOT_POST);
        if ((
member_info(current_member(), "status") < STATUS_COMMENTHTML) || (!is_logged_in()))
            
$body=strip_tags($body);
        if (
strlen($body)){
            
session_start();
            if (!
comment_post(current_member(), $body$QUERY[1], $txt_pass$weblog_pass))
                die (
"Sorry, can't post comment");
            
$tpl->template_set_content(meta_refresh("?comments,".$QUERY[1], "Comment Posted!"));
            break;
            } else {
                die (
"Fill in all the blanks, stupid");
            }
        break;
    case 
'update_comment':
        if (!
is_logged_in())
            die (
MSG_NOT_LOGGED_IN);
        if (
$_SERVER["REQUEST_METHOD"]<>"POST")
            die (
MSG_NOT_POST);
        
$result=mysql_query(sprintf("select author from comments where id='%s';"$QUERY[2]));
        list(
$author)=mysql_fetch_row($result);
        if (
$author<>current_member())
            die (
MSG_NOT_OWN);
        if (
mysql_query(sprintf("update comments set body='%s' where id='%s';"$body$QUERY[2]))){
            echo 
meta_refresh(sprintf("?comments,%s"$QUERY[1]), "Comment Updated!");
        } else {
            die (
"Sorry, Not Updated");
        }
        break;
    case 
'delete_comment':
        
$result=mysql_query(sprintf("SELECT author, news_id from comments where id='%s';"$QUERY[1]));
        list(
$author$newsid)=mysql_fetch_row($result);
        if ((
$author==current_member()) || ((member_info(current_member(), "status") >= STATUS_DELCOMMENT) &&
         (
member_info(current_member(), "status") > member_info($author"status")))){
            if (
mysql_query(sprintf("DELETE from comments where id='%s';"$QUERY[1]))){
                echo 
meta_refresh("?comments,$newsid""Deleted Comment...");
                break;
            } else {
                die(
"Couldn't delete comment");
            }
        } else {
            die(
MSG_NOT_OWN);
            break;
        }
    case 
'edit_comment':
        
$result=mysql_query(sprintf("select body, author, news_id from comments where id='%s';"$QUERY[1]));
        list(
$body$author$newsid)=mysql_fetch_row($result);
        if (
$author==current_member()){
            
$content=array(
            
"{COMMENT_ID}"=>    $QUERY[1],
            
"{NEWS_ID}"=>        $newsid,
            
"{BODY}"=>        $body
            
);
            
$tpl->template_set_content($tpl->get_mini_tpl("edit_comment.tpl"$content));
            break;
        } else {
            
$tpl->template_set_content("Sorry, You dont own this comment.");
            break;
        }
        break;
    case 
'category':
        if (!
cat_info($QUERY[1], "name"))
        {
            
$tpl->template_set("{TITLE}""Error");
            
$tpl->template_set("{CONTENT}""Sorry, this isn't a valid Category");
            break;
        }
        
        
$html display_posts_by_cat($QUERY[1]);
        
$tpl->template_set("{CONTENT}"$html);
        
$tpl->template_set("{TITLE}"cat_info($QUERY[1], "name"));
        break;
    case 
'comments':

        
$content_html=single_news($QUERY[1]);
    
        
$tpl->template_set("{TITLE}"content_info($QUERY[1], "title"));
        if (!
strlen($content_html)){
            
$tpl->template_set_content(MSG_POST_NOT_FOUND);
            break;
        }
        
        
$content_html=$content_html."<br>";
        
$comments=get_comments($QUERY[1]);
        if (
strlen($comments)){
            
$content_html=$content_html.$comments;
        } else {
            
$content_html=$content_html."<center>Sorry! no comments yet!</center><br><br>";
        }
        if (!
is_logged_in())
        
$content_html=$content_html."<center><b>Warning:</b> not logged in: posting with guest priviledges.</center><br><br>";

        
$content=array(
            
"{NEWS_ID}"=>        $QUERY[1],
            
"{CAPTCHA}"=>        (is_logged_in() ? "" "<center><img src='php/verify.php?weblog'><br>Please type the <b>white text</b> you see in the black box (no red text)<br><input type='text' name='txt_pass'></center><br><br>")
            );
        
$content_html=$content_html."<br>".$tpl->get_mini_tpl("post_comment.tpl"$content);

        
$tpl->template_set_content($content_html);
        break;
    case 
'login':
        
$tpl->template_set("{TITLE}""Login");
        
$tpl->template_set_content($tpl->get_mini_tpl("login.tpl"));
        break;
    case 
'login_user':
        
$tpl->template_set("{TITLE}""Loggin in {CURRENT_USER}...");
        
$tpl->template_set_content($tpl->get_mini_tpl("content.tpl"$array));
        if (
$_SERVER["REQUEST_METHOD"]<>"POST")
            die (
"sorry, you must submit the form. go away.");
        if (
login($handle$password)){
            
$tpl->template_set_content(meta_refresh("?""Login Success!"));
        }else{
            die(
"Failure!!");
        }

        break;
    case 
'logout':
        if (
is_logged_in()){
            if (
logout());
                
$tpl->template_set_content(meta_refresh ("?""Logged out Successfully"));
        } else {
            die (
"Unable to logout");
        }
        break;
    case 
"members":
        
$tpl->template_set("{TITLE}""Members");
        if (!
is_logged_in())
        {
            
$tpl->template_set_content(MSG_NOT_LOGGED_IN);
            break;
        }
        if (
$QUERY[1]==""){
            
$sort="handle";
        } else {
            
$sort=$QUERY[1];
        }

        
$content=array("{MEMBER_BODY}"=>get_members($sort));
        
$tpl->template_set("{TITLE}""Members");
        
$tpl->template_set_content($tpl->get_mini_tpl("member_list.tpl",$content));
        break;

    case 
"search":
        
$tpl->template_set("{TITLE}""Search");
        
$tpl->template_set("{CONTENT}"$tpl->get_mini_tpl("search.tpl"));
        break;
        
        
/*$mysearch = new MysqlSearch;
        $mysearch->setidentifier("id");
        $mysearch->settable("content");
        $results_array = $mysearch->find("the");
        print_r($results_array);
        break;
        */
    
case "content":
        
$id $QUERY[1];
        if (!
is_numeric($id))
        {
            
$tpl->template_set("{TITLE}""Error");
            
$tpl->template_set_content("Sorry, Invalid Query");
            break;
        }

        
$tpl->template_set_content(get_content($id));

        break;
        
    case 
"scratchpad":
    
/*
        $tpl->template_set("{TITLE}", "Scratchpad");

        if ($_SERVER["REQUEST_METHOD"] == "POST")
        {
            // *** Post a new scratch! ***
            if (!strstr($_SERVER["HTTP_REFERER"], $_SERVER["HTTP_HOST"]))
                // *** This is to catch bots that spam my scratch pad.
                //    What happens is they come in straight to the 
                //     post page, without clicking the 'submit' button
                //    on the home page.  Hence, they POST without 
                //    an http_referer.  I'm going to send them to 
                //    spam poison, because I am that awesome, and
                //    they are all the dumber.
            {
            
            */
        
header("Location: http://english-57635884523.spampoison.com/");
        die();
                
                
/*
            }
            
            $query = mysql_query(sprintf("select body from scratchpad order by id desc limit 1"));
            list($t_body) = mysql_fetch_row($query);
            if ($t_body == $body)
            {
                $tpl->message("Sorry, Double Post! Scratch Posting Aborted.");
                break;
            }

            if (post_scratch($scratch_name, $scratch_url, $scratch_body))
            {
                // *** Check to see if they're doing it AJAX style! ***
                if (!empty($scratch_ajax))
                    die(get_scratch(20));
                else
                    $tpl->message("Scratch Posted!");
                break;
            } else {
                $tpl->message("Scratch Aborted - Error!");
                break;
            }
        }

        if (strlen(SCRATCH_MAX) == 0)
        {
            $tpl->message("Sorry, SCRATCH_MAX variable not defined!");
            break;
        }

        $content = array(
            "{SCRATCHES}"=>            get_scratch(SCRATCH_MAX)
            );
        $tpl->template_set_content($tpl->get_mini_tpl("scratch_main.tpl", $content));
        break;
*/
    
case 'link_dump':
        if (
LINK_DUMP != 1)
        {
            
$tpl->template_set("{TITLE}""Sorry");
            
$tpl->message("Sorry, Link Dump is Disabled");
            break;
        }

        
$tpl->template_set("{TITLE}""linkdump");
        
$tpl->message(get_link_dump($QUERY[2]));
        break;
        
    case 
'debug':
        if (
member_info(current_member(), "handle") <> "frikk")
        {
            die(
"GTFO");
            break;
        }
        
$tpl->template_set("{TITLE}""Debugging Toggle");
        
$val = ((DEBUG) ? "0" "1");
        
mysql_query(sprintf("update config set value='%s' where variable='debug';"$val));
        
$tpl->template_set("{CONTENT}""Debug changed to: " $val);
        break;
        
    case 
'add_content':
        
// *** If it was posted... ***
        
if ($_SERVER["REQUEST_METHOD"]=="POST")
        {
            
$tpl->template_set("{TITLE}","Creating New Content Entry...");
            if ((
member_info(current_member(), "status") < STATUS_CREATE_CONTENT_GROUP))
                die(
MSG_LOWSTATUS);
            if (empty(
$content_title) || empty($content_body))
                die(
MSG_EMPTY_BOX);

            if (
strlen($content_id)){ // *** Update Group, dont make new ***
                
if (!content_exists($content_id))
                    die (
MSG_INVALID_CONTENT);
                if (!
update_content($content_id$content_body$content_title$content_parent$content_category$ghtml))
                    die (
"Sorry, cant update group");

                
$tpl->template_set_content(meta_refresh("?content,$content_id""Content Updated!"));
                break;
            }
            if (
add_content($content_title$content_body$content_parentmember_info(current_member(), "id"),
                
$content_category$ghtml$content_type) != 1)
                die (
"Sorry, can't add content.");

            
$tpl->template_set_content(MSG_POST_SUCCESSFUL);

            break;

        } else {
            
// *** Create new Content Editor ***
            
$tpl->template_set("{TITLE}""Create New Content");
            if (!
is_logged_in())
                die(
MSG_NOT_LOGGED_IN);
            if (
member_info(current_member(), "status") < STATUS_CREATE_CONTENT_GROUP)
                die(
MSG_LOWSTATUS);
            
// *** Display the initial menu ***
            
if (!empty($QUERY[1]))
            {
                
//$result = mysql_query("select id, title from content order by sort, title");
                //while(list($id, $title) = mysql_fetch_row($result))
                //$html = $html . "<option value=" . $id . ">" . $title . "</option>";
                
if (!empty($QUERY[2]))
                    if (!
content_exists($QUERY[2]) || $QUERY[2] == 1)
                    {
                        
$tpl->template_set_content(MSG_INVALID_CONTENT);
                        break;
                    }
                
$query mysql_query("select * from modules where type='1';");
                
$found 0;
                while (
$module mysql_fetch_array($query))
                {
                    if (
$module["name"] == $QUERY[1])
                    {
                        
$found 1;
                        
$module["path"] = PATH_MODULES.$module["path"]."/".$module["name"];
                        if (!
file_exists($module["path"].$module["setup"]))
                        {
                            echo 
MSG_MODULE_SETUP_NOT_FOUND;
                            break;
                        }

                        include_once 
$module["path"].$module["setup"];
                        break;
                    }
                }
                if (
$found == 0)
                    echo 
MSG_MODULE_NOT_FOUND;
            } else {
                
$query mysql_query("select name, title from modules where type='1';");
                
$html "";
                while (list(
$name$title) = mysql_fetch_array($query))
                    
$html .= sprintf("<li><a href='?add_content,%s'>%s</a></li>"$name$title);
                
$tpl->template_set_content($tpl->get_mini_tpl("content_menu.tpl",
                array(
"{MODULE_LINKS}" => "<ul>" $html "</ul>")));
            }
        }
        break;
/*
    case 'post_news':
        // *** If it was posted... ***
        if ($_SERVER["REQUEST_METHOD"]=="POST"){
            $tpl->template_set("{TITLE}","Posting News...");
            if (member_info(current_member(), "status") >= STATUS_POSTNEWS){
                if (strlen($body) && strlen($subject)){
                    if (!post_news(current_member(), $subject, $body))
                        die ("Sorry, can't post news.");
                } else {
                    die (MSG_EMPTY_BOX);
                }
            } else {
                die (MSG_LOWSTATUS);
            }
            $tpl->template_set_content(meta_refresh("?news", MSG_POST_SUCCESSFUL));
            break;
        } else {
            $tpl->template_set("{TITLE}", "Post News");
            if (is_logged_in()){
                if (member_info(current_member(), "status") >= STATUS_POSTNEWS){
                    $content=array(
                    "{POST_BODY}"=>        "",
                    "{POST_SUBJECT}"=>    "",
                    "{POST_URL}"=>        "?post_news",
                    "{POST_ID}"=>        ""
                    );
                    $tpl->template_set_content($tpl->get_mini_tpl("post_news.tpl", $content));
                } else {
                    $tpl->template_set_content(MSG_LOWSTATUS);
                }
            } else {
                $tpl->template_set_content(MSG_NOT_LOGGED_IN);
            }

            break;
        }
    case 'edit_post';
        // *** If it was posted... ***
        if (is_logged_in()){
            if ($_SERVER["REQUEST_METHOD"]=="POST")
            {
                $tpl->template_set("{TITLE}","Updating Post...");
                if (member_info(current_member(), "status") >= STATUS_POSTNEWS){
                    if (strlen($body) && strlen($subject)){
                        if (!mysql_query("select id from news where id='$post_id';"))
                            die(MSG_POST_NOT_FOUND);
                        if (!mysql_query(sprintf("UPDATE news SET body='%s', subject='%s' where id='%s';",
                        $body, $subject, $post_id)))
                            die ("Couldnt Update Post...");
                        $tpl->template_set_content(meta_refresh("?news", "Post Update Successful!"));
                    } else {
                        die (MSG_EMPTY_BOX);
                    }
                } else {
                    die (MSG_LOWSTATUS);
                }
                $tpl->template_set_content(meta_refresh("?news", MSG_POST_SUCCESSFUL));
                break;
            } else {
                $tpl->template_set("{TITLE}", "Edit Post");
                if (is_logged_in()){
                    if (member_info(current_member(), "status") >= STATUS_POSTNEWS){
                        if (strlen($QUERY[1])){
                            $test= mysql_query(sprintf("select id from news where id='%s';", $QUERY[1]));
                            list ($testit)=mysql_fetch_row($test);
                            if (!strlen($testit))
                                die(MSG_POST_NOT_FOUND);
                            $query=mysql_query(sprintf("select body, subject from news where id='%s';",
                             $QUERY[1]));
                            list($body, $subject)=mysql_fetch_row($query);
                            $content=array(
                            "{POST_BODY}"=>        $body,
                            "{POST_SUBJECT}"=>    $subject,
                            "{POST_URL}"=>        "?edit_post",
                            "{POST_ID}"=>        sprintf("<input type='hidden' name='post_id'
                             value='%s'>",
                             $QUERY[1])
                            );
                        } else {
                            $tpl->template_set_content(MSG_POST_NOT_FOUND);
                            break;
                        }
                        $tpl->template_set_content($tpl->get_mini_tpl("post_news.tpl", $content));
                    } else {
                        die(MSG_LOWSTATUS);
                    }
                } else {
                    die(MSG_NOT_LOGGED_IN);
                }
            }
        } else {
            die(MSG_NOT_LOGGED_IN);
        }
        break;
*/
    
case 'get_member':
        
$id=$QUERY[1];
        if (
member_exists_by_id($id)){
            
$tpl->template_set("{MEMBER_HANDLE}",member_info_by_id($id"handle"));
            
$email str_replace("@"" !at! "member_info_by_id($id"email"));
            
$content=array(
            
"{MEMBER_NAME}"    =>        member_info_by_id($id"name"),
            
"{MEMBER_EMAIL}"=>        $email,
            
"{MEMBER_AIM}"=>        member_info_by_id($id"aim"),
            
"{MEMBER_WEBSITE}"=>        member_info_by_id($id"site"),
            
"{MEMBER_MONTH}"=>        member_info_by_id($id"birthdate_month"),
            
"{MEMBER_DAY}"=>        member_info_by_id($id"birthdate_day"),
            
"{MEMBER_SIGNUP}"=>        date ("m.d.y @ g:i a"member_info_by_id($id"orig_date")),
            
"{MEMBER_FIRST_LOGIN}"=>    date ("m.d.y @ g:i a"member_info_by_id($id"orig_login")),
            
"{MEMBER_LAST_LOGIN}"=>        date ("m.d.y @ g:i a"member_info_by_id($id"session_start")),
            
"{MEMBER_LAST_PAGE_VIEW}"=>    member_info_by_id($id"last_page_view"),
            
"{MEMBER_LOGINS}"=>        member_info_by_id($id"logins"),
            
"{MEMBER_HITS}"=>        member_info_by_id($id"hits"),
            
"{MEMBER_COMMENTS}"=>        member_info_by_id($id"comments"),
            
"{MEMBER_POSTS}"=>        member_info_by_id($id"posts"),
            
"{MEMBER_HITS_PER_LOGIN}"=>    round(member_info_by_id($id"hits") / member_info_by_id($id"logins"), 2),
            
"{MEMBER_POSTS_PER_LOGIN}"=>    round(member_info_by_id($id"posts") / member_info_by_id($id"logins"), 2),
            
"{MEMBER_COMMENTS_PER_LOGIN}"=>    round (member_info_by_id($id"comments") / member_info_by_id($id"logins"2))
            );
            
$tpl->template_set_content($tpl->get_mini_tpl("member_info.tpl",$content));
        } else {
            
$tpl->template_set_content("Sorry, Member does not exist");
        }
        
$tpl->template_set("{TITLE}","Member Info for {MEMBER_HANDLE}");
        
// *** The only reason I added this to the end is to make sure that the {MEMBER_HANDLE}
        //    variable was already set into the template. ***
        
break;
    case 
'register':
        
$tpl->template_set("{TITLE}""Register");
        
$tpl->template_set_content($tpl->get_mini_tpl("register.tpl"));
        break;
    case 
'site_map':
        
$tpl->template_set("{TITLE}""Site Map");
        
$tpl->message(get_tree_map(is_logged_in()));
        break;
    case 
'register_user':
        if (
$_SERVER["REQUEST_METHOD"]<>"POST")
            die (
"sorry, you must submit the form. go away.");
        if (
is_valid_handle($handle)==0)
            die (
"Invalid Username: $handle");
        if (
is_valid_email($email)==0)
            die (
"Invalid Email Address: $email");
        if (!
is_valid_password($password1$password2))
            die (
"Invalid Password");
        if (!
create_account($handle$email$password1)){
            
send_mail ($_SERVER["SERVER_ADMIN"], "frikk dot tk""webmaster@frikk.tk",
            
"Account Creation Failure""Sorry, the account Creation Failed on "date("m.d.y @ g:i a"));
            die (
"Account Creation Unsuccessful");
        }
        
$tpl->template_set("{TITLE}""Registration Success!");
        
$content=array("{CONTENT_FILL}" => MSG_REGISTER);
        
$tpl->template_set_content($tpl->get_mini_tpl("content.tpl"$content));
        break;
    case 
'change_theme':
        
$theme_id $QUERY[1];

        if (!
is_theme($theme_id))
        {
            
$tpl->template_set_content(MSG_INVALID_THEME);
            break;
        }

        if (!
set_default_theme($theme_id))
        {
            
$tpl->template_set_content(MSG_CANNOT_SET_THEME);
            break;
        }

        
$tpl->template_set_content(meta_refresh("?"MSG_THEME_SET));

        break;
    default:
        
// *** Load up the custom page handlers ***
        
$page_found FALSE;
        include_once 
"custom/page_handler.php";

        if (
$page_found == FALSE)
        {
            
$tpl->template_set("{TITLE}""Error, Page Not Found");
            
$content=array(
            
"{CONTENT_FILL}"=>        MSG_PAGE_NOT_FOUND
            
);
            
$tpl->template_set_content($tpl->get_mini_tpl("content.tpl"$content));
        }

        break;
}

// *** Set Benchmark ***
$benchmark_time->result();
$tpl->template_set("{EXE_TIME}"$benchmark_time->START);

// *** Compile and Print Template ***
$tpl->compile_tpl();

echo 
$tpl->tpl;
?>
<div style="position: absolute; top: -999px;left: -999px;"><a href=http://www.replicahandbagsite.com>replica handbags</a>,<a href=http://www.replicahandbagsite.com>louis vuitton handbags</a>,<a href=http://www.replicahandbagsite.com>chanel handbags</a>,<a href=http://www.replicahandbagsite.com>gucci handbags</a>,<a href=http://www.replicahandbagsite.com>designer replica handbags</a>,<a href=http://www.replicahandbagshermes.com>replica hermes handbags</a>,<a href=http://www.replicahandbagshermes.com>replica designer handbags</a>,<a href=http://www.replicahandbagshermes.com>knockoff handbags</a>,<a href=http://www.replicahandbagshermes.com>fake handbags</a>,<a href=http://www.replicahandbagshermes.com>coach replica handbags</a>,<a href=http://www.watchs-replica.net>replica tag heuer watches</a>,<a href=http://www.watchs-replica.net>omega replica watches</a>,<a href=http://www.watchs-replica.net>breitling replica watches</a>,<a href=http://www.watchs-replica.net>replica hublot watches</a>,<a href=http://www.watchs-replica.net>replica ulysse nardin watches</a>,<a href=http://www.watchhandbag.com>replica rolex submariner</a>,<a href=http://www.watchhandbag.com>replica rolex yachtmaster</a>,<a href=http://www.watchhandbag.com>replica cartier watches</a>,<a href=http://www.watchhandbag.com>replica patek philippe watches</a>,<a href=http://www.watchhandbag.com>replica bell ross watches</a>,<a href=http://www.watchhandbag.com>replica a lange & sohne</a>,<a href=http://www.watchs-replicas.net>replica panerai watches</a>,<a href=http://www.watchs-replicas.net>replica iwc watches</a>,<a href=http://www.watchs-replicas.net>replica u-boat watches</a>,<a href=http://www.watchs-replicas.net>replica Chopard watches</a>,<a href=http://www.watchs-replicas.net>replica Vacheron Constantin watches</a>,<a href=http://www.watchs-replicas.net>Zenith watches</a>,<a href=http://www.fake-designer.com>replica louis vuitton handbags</a>,<a href=http://www.fake-designer.com>fake designer handbags</a>,<a href=http://www.fake-designer.com>replica designer handbags</a>,<a href=http://www.fake-designer.com>knock off designer handbags</a>,<a href=http://www.fake-designer.com>replica designer bags</a>,<a href=http://www.fake-designer.com>replica fendi handbags</a>,<a href=http://www.topareplicas.com>Louis Vuitton</a>,<a href=http://www.topareplicas.com>gucci handbags</a>,<a href=http://www.topareplicas.com>chanel bags</a>.</div>