<?php 

require_once('scripts/sb_functions.php');
global $logged_in;
$logged_in = logged_in( true, true );
	
read_config();
sb_language( 'delete' );
		
// "CGI" Functions
if ( array_key_exists( 'no', $_POST ) || array_key_exists( 'yes', $_POST ) ) {
  if ( array_key_exists( 'no', $_POST ) ) {
    // User clicked the "Cancel" button
    redirect_to_url( 'index.php' );
  } else {
    if ( array_key_exists( 'yes', $_POST ) ) {
      // User clicked the "OK" button
      $ok = delete_entry( $_POST[ 'entry' ], $_POST[ 'path' ] );
      
      if ( $ok === true ) {	
	redirect_to_url( 'index.php' );
      }
    }
  }
}

html_header();


function page_content() {
  global $lang_string, $user_colors;
		
  if ( array_key_exists( "no", $_POST ) || array_key_exists( "yes", $_POST ) ) {
    // Check to see if we're posting data...
    global $ok;
    if ( $ok !== true ) {
      echo( $lang_string[ 'error' ] . $ok . '<p />' );
    }
    echo( '<a href="index.php">' . $lang_string[ 'home' ] . '</a><br /><br />' );
  } else {
  ?>
			
 <h2><?php echo( $lang_string[ 'title' ] ); ?></h2>
			<?php echo( $lang_string[ 'instructions' ] ); ?><p />
			
			<div class="hr"><hr /></div>
			
			<?php
				$blog_content = read_entry_from_file( 'content/'.$_GET[ 'y' ].'/'.$_GET[ 'm' ].'/'.$_GET[ 'entry' ] );
				echo( $blog_content );
			?>
			
			<div class="hr"><hr /></div>
			
			<form accept-charset="<?php echo( $lang_string[ 'html_charset' ] ); ?>,iso-8859-1,utf-8" action='delete.php' method="post">
				<input type="hidden" name="entry" value="<?php echo( $_GET[ 'entry' ] ); ?>">
				<input type="hidden" name="path" value="<?php echo( 'content/'.$_GET[ 'y' ].'/'.$_GET[ 'm' ].'/' ); ?>">
				<input type="submit" name="yes" value="<?php echo( $lang_string[ 'ok_btn' ] ); ?>" />
				<input type="submit" name="no" value="<?php echo( $lang_string[ 'cancel_btn' ] ); ?>" />
			</form>
			
			<?php 
		}
	}

theme_pagelayout();
html_footer();

?>
