<?php
	require_once('scripts/sb_functions.php');
	global $logged_in;
	$logged_in = logged_in( false, true );
	if ( !session_id() ) {
		session_start();
	}

	read_config();

//	require_once('languages/' . $blog_config[ 'blog_language' ] . '/strings.php');
	sb_language( 'contact' );

	$subject='Contact sent through ' . $blog_config[ 'blog_title' ];

////////////////////////////////////////////////////////////////////////////
// I don't like HTML mail ... this is the old style (commented out)
/*
	$body='<b>Name:</b> ' . $_POST[ 'name' ] . "<br />\n";
	$body=$body . '<b>Email:</b> ' . $_POST[ 'email' ] . "<br />\n";
	$body=$body . '<b>Subject:</b> ' . $_POST[ 'subject' ] . "<br />\n<br />\n";
	$body=$body . "<b>Comment:</b><br />\n";
	$body=$body . str_replace( chr(10), '<br />', $_POST[ 'comment' ] );
*/

////////////////////////////////////////////////////////////////////////////
// new: plain text!

	$body='Name: ' . $_POST[ 'name' ] . "\n";
	$body=$body . 'Email: ' . $_POST[ 'email' ] . "\n";
	$body=$body . 'Subject: ' . $_POST[ 'subject' ] . "\n\n";
	$body=$body . "Comment:\n";

	// Replace hard returns with '<br />' tags.
	$body=$body . $_POST[ 'comment' ] ;

	$ok=false;
	if ( $_POST[ 'capcha' ] == $_SESSION[ 'capcha_contact' ] ) {
		$ok=sb_mail( $_POST[ 'email' ], $blog_config[ 'blog_email' ], $subject, $body, false );
	}
	@session_unregister( 'capcha_contact' );

html_header();

	function page_content() {
		global $lang_string, $user_colors, $ok;

		if ( $ok ) {
			echo( $lang_string[ 'success' ] );
		}
		else {
			echo( $lang_string[ 'error' ] );
		}

		echo( '<a href="index.php">' . $lang_string[ 'home' ] . '</a><br /><br />' );
	}


theme_pagelayout();
html_footer();

?>
