<?php

session_start();

require_once('scripts/sb_functions.php');
global $logged_in;
$logged_in = logged_in( false, true );

read_config();
sb_language( 'index' );
	
		
// Verify information being passed
$temp_year = NULL;
if ( array_key_exists( 'y', $_REQUEST ) ) {
    if ( strpos( $_REQUEST[ 'y' ], array( '/', '.', '\\', '%' ) ) === false && 
	 strlen( $_REQUEST[ 'y' ] ) == 2 ) {
	$temp_year = $_REQUEST[ 'y' ];
    }
}
$temp_month = NULL;
if ( array_key_exists( 'm', $_REQUEST ) ) {
    if ( strpos( $_REQUEST[ 'm' ], array( '/', '.', '\\', '%' ) ) === false && 
	 strlen( $_REQUEST[ 'm' ] ) == 2 ) {
	$temp_month = $_REQUEST[ 'm' ];
    }
}
$temp_day = NULL;
if ( array_key_exists( 'd', $_REQUEST ) ) {
    if ( strpos( $_REQUEST[ 'd' ], array( '/', '.', '\\', '%' ) ) === false && 
	 strlen( $_REQUEST[ 'd' ] ) == 2 ) {
	$temp_day = $_REQUEST[ 'd' ];
    }
}
$temp_entry = NULL;
if ( array_key_exists( 'entry', $_REQUEST ) ) {
    if ( strpos( $_REQUEST[ 'entry' ], array( '/', '.', '\\', '%' ) ) === false && 
	 strlen( $_REQUEST[ 'entry' ] ) == 18 ) {
	$temp_entry = $_REQUEST[ 'entry' ];
    }
}
	
if ( !isset( $temp_year ) || !isset( $temp_month ) ) {
    // Set the $month, $year, $day globals...
    // get_latest_entry();
    global $day, $month, $year;
    $day = date('d');
    $year = date('y');
    $month = date('m'); 
} else {
    // Grab $year and $month from URL
    global $month, $year;
    $year = $temp_year;
    $month = $temp_month;
}
	
if ( isset( $temp_day ) ) {
    global $day;
    $day = $temp_day;
}
	
if ( isset( $temp_entry) ) {
    global $temp_entry;
    $entry = $temp_entry;
}
	
if ( array_key_exists( 'category', $_REQUEST ) ) {
    global $category;
    $category = $_REQUEST[ 'category' ];
}
	
global $lang_string, $sb_info, $blog_config, $pppb_info;
repeat_events($year,$month);


// print the HTML header
html_header('',false);



function page_content() {
   global $month, $year, $day, $category, $logged_in, $entry;		
   echo ( read_entries( $month, $year, $day, $logged_in, $entry, $category ) );
}


theme_pagelayout();
html_footer();

?>
