<?php 

require_once('scripts/sb_functions.php');
global $logged_in;

$logged_in = logged_in( false, true );
	
read_config();	
sb_language( 'login' );
	
$ok = check_password( sb_stripslashes( $_POST[ 'user' ] ), 
		      sb_stripslashes( $_POST[ 'pass' ] ) );

$logged_in = $ok;

if ( $ok === true ) {
  redirect_to_url( 'index.php' );
}


// this is new in pppBLOG:
// check if this is a registered user

global $signed_in;
$ok = check_user_password( sb_stripslashes( $_POST[ 'user' ] ), 
			   sb_stripslashes( $_POST[ 'pass' ] ) );


$signed_in = $ok;

if ( $ok === true ) {
  redirect_to_url( 'index.php' );
}


html_header('',false);
	
function page_content() {
    global $lang_string, $user_colors, $ok;
    sb_language( 'login' );
		
    if ( $ok === true ) {
	echo( $lang_string[ 'success' ] );
    } else {
	echo( $lang_string[ 'wrong_password' ] );
    }
		
    echo( '<a href="index.php">' . $lang_string[ 'home' ] . '</a><br />' );
		
    $upgrade_count = move_all_comment_files( true, true );
    if ( $upgrade_count > 0 ) {
	echo( '<div class="hr"><hr /></div><br />' );
	echo( $lang_string[ 'upgrade' ] );
	$str = str_replace ( '%n', $upgrade_count, $lang_string[ 'upgrade_count' ] );
	echo( $str . "<br /><br />" );
	echo( "<a href=\"upgrade.php\">" . $lang_string[ 'upgrade_url' ] ."</a><br />" );
    }
}
theme_pagelayout();
html_footer();
?>
