Index: trunk/wb/modules/form/view.php
===================================================================
--- trunk/wb/modules/form/view.php	(revision 249)
+++ trunk/wb/modules/form/view.php	(revision 250)
@@ -269,7 +269,7 @@
 	if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */
 		if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){
 			// Check for a mismatch
-			if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR !$_POST['captcha'] == $_SESSION['captcha']) {
+			if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) {
 				$captcha_error = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
 			}
 		} else {
Index: trunk/wb/modules/form/save_settings.php
===================================================================
--- trunk/wb/modules/form/save_settings.php	(revision 249)
+++ trunk/wb/modules/form/save_settings.php	(revision 250)
@@ -41,7 +41,11 @@
 $field_loop = $admin->add_slashes($_POST['field_loop']);
 $footer = $admin->add_slashes($_POST['footer']);
 $email_to = $admin->add_slashes($_POST['email_to']);
-$use_captcha = $_POST['use_captcha'];
+if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) {
+	$use_captcha = $_POST['use_captcha'];
+} else {
+	$use_captcha = false;
+}
 if($_POST['email_from_field'] == '') {
 	$email_from = $admin->add_slashes($_POST['email_from']);
 } else {
Index: trunk/wb/modules/news/comment_page.php
===================================================================
--- trunk/wb/modules/news/comment_page.php	(revision 249)
+++ trunk/wb/modules/news/comment_page.php	(revision 250)
@@ -27,15 +27,48 @@
 if(!defined('WB_URL')) { header('Location: ../index.php'); }
 	
 // Get comments page template details from db
-$query_settings = $database->query("SELECT comments_page FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '".SECTION_ID."'");
+$query_settings = $database->query("SELECT comments_page,use_captcha FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '".SECTION_ID."'");
 if($query_settings->numRows() == 0) {
 	header('Location: '.WB_URL.'/pages/');
 } else {
 	$settings = $query_settings->fetchRow();
 	// Print comments page
-	$vars = array('[POST_TITLE]', '[ACTION_URL]');
-	$values = array(POST_TITLE, WB_URL.'/modules/news/submit_comment.php?page_id='.PAGE_ID.'&section_id='.SECTION_ID.'&post_id='.POST_ID);
-	echo str_replace($vars, $values, ($settings['comments_page']));
+	echo str_replace('[POST_TITLE]', POST_TITLE, ($settings['comments_page']));
+	?>
+	<form name="comment" action="<?php echo WB_URL.'/modules/news/submit_comment.php?page_id='.PAGE_ID.'&section_id='.SECTION_ID.'&post_id='.POST_ID; ?>" method="post">
+	<?php echo $TEXT['TITLE']; ?>:
+	<br />
+	<input type="text" name="title" maxlength="255" style="width: 90%;"<?php if(isset($_SESSION['comment_title'])) { echo ' value="'.$_SESSION['comment_title'].'"'; unset($_SESSION['comment_title']); } ?> />
+	<br /><br />
+	<?php echo $TEXT['COMMENT']; ?>:
+	<br />
+	<textarea name="comment" style="width: 90%; height: 150px;"><?php if(isset($_SESSION['comment_body'])) { echo $_SESSION['comment_body']; unset($_SESSION['comment_body']); } ?></textarea>
+	<br /><br />
+	<?php
+	if(isset($_SESSION['captcha_error'])) {
+		echo '<font color="#FF0000">'.$_SESSION['captcha_error'].'</font><br />';
+		unset($_SESSION['captcha_error']);
+	}
+	// Captcha
+	if($settings['use_captcha']) {
+	$_SESSION['captcha'] = '';
+	for($i = 0; $i < 5; $i++) {
+		$_SESSION['captcha'] .= rand(0,9);
+	}
+	?>
+	<table cellpadding="2" cellspacing="0" border="0">
+	<tr>
+	<td><?php echo $TEXT['VERIFICATION']; ?>:</td>
+	<td><img src="<?php echo WB_URL; ?>/include/captcha.php" alt="Captcha" /></td>
+	<td><input type="text" name="captcha" maxlength="5" /></td>
+	</tr></table>
+	<br />
+	<?php
+	}
+	?>
+	<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?> <?php echo $TEXT['COMMENT']; ?>" />
+	</form>	
+	<?php
 }
 
 ?>
\ No newline at end of file
Index: trunk/wb/modules/news/install.php
===================================================================
--- trunk/wb/modules/news/install.php	(revision 249)
+++ trunk/wb/modules/news/install.php	(revision 250)
@@ -38,7 +38,7 @@
 					 . '`content_short` TEXT NOT NULL,'
 					 . '`content_long` TEXT NOT NULL,'
 					 . '`commenting` VARCHAR(7) NOT NULL,'
-		   	    . '`posted_when` INT NOT NULL ,'
+		   	    	 . '`posted_when` INT NOT NULL ,'
 					 . '`posted_by` INT NOT NULL ,'
 					 . 'PRIMARY KEY (post_id)'
                 . ' )';
@@ -86,6 +86,7 @@
 					 . '`comments_page` TEXT NOT NULL,'
 					 . '`commenting` VARCHAR(7) NOT NULL,'
 					 . '`resize` INT NOT NULL,'
+					 . ' `use_captcha` INT NOT NULL,'
 					 . 'PRIMARY KEY (section_id)'
                 . ' )';
 	$database->query($mod_news);
Index: trunk/wb/modules/news/modify_settings.php
===================================================================
--- trunk/wb/modules/news/modify_settings.php	(revision 249)
+++ trunk/wb/modules/news/modify_settings.php	(revision 250)
@@ -106,7 +106,16 @@
 </tr>
 <?php if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ ?>
 <tr>
+	<td class="setting_name"><?php echo $TEXT['CAPTCHA_VERIFICATION']; ?>:</td>
 	<td>
+		<input type="radio" name="use_captcha" id="use_captcha_true" value="1"<?php if($fetch_content['use_captcha'] == true) { echo ' checked'; } ?> />
+		<label for="use_captcha_true"><?php echo $TEXT['ENABLED']; ?></label>
+		<input type="radio" name="use_captcha" id="use_captcha_false" value="0"<?php if($fetch_content['use_captcha'] == false) { echo ' checked'; } ?> />
+		<label for="use_captcha_false"><?php echo $TEXT['DISABLED']; ?></label>
+	</td>
+</tr>
+<tr>
+	<td>
 		<?php echo $TEXT['RESIZE_IMAGE_TO']; ?>:
 	</td>
 	<td>
Index: trunk/wb/modules/news/save_settings.php
===================================================================
--- trunk/wb/modules/news/save_settings.php	(revision 249)
+++ trunk/wb/modules/news/save_settings.php	(revision 250)
@@ -45,12 +45,14 @@
 $posts_per_page = $_POST['posts_per_page'];
 if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) {
 	$resize = $_POST['resize'];
+	$use_captcha = $_POST['use_captcha'];
 } else {
 	$resize = '';
+	$use_captcha = false;
 }
 
 // Update settings
-$database->query("UPDATE ".TABLE_PREFIX."mod_news_settings SET header = '$header', post_loop = '$post_loop', footer = '$footer', posts_per_page = '$posts_per_page', post_header = '$post_header', post_footer = '$post_footer', comments_header = '$comments_header', comments_loop = '$comments_loop', comments_footer = '$comments_footer', comments_page = '$comments_page', commenting = '$commenting', resize = '$resize' WHERE section_id = '$section_id'");
+$database->query("UPDATE ".TABLE_PREFIX."mod_news_settings SET header = '$header', post_loop = '$post_loop', footer = '$footer', posts_per_page = '$posts_per_page', post_header = '$post_header', post_footer = '$post_footer', comments_header = '$comments_header', comments_loop = '$comments_loop', comments_footer = '$comments_footer', comments_page = '$comments_page', commenting = '$commenting', resize = '$resize', use_captcha = '$use_captcha' WHERE section_id = '$section_id'");
 
 // Check if there is a db error, otherwise say successful
 if($database->is_error()) {
Index: trunk/wb/modules/news/submit_comment.php
===================================================================
--- trunk/wb/modules/news/submit_comment.php	(revision 249)
+++ trunk/wb/modules/news/submit_comment.php	(revision 250)
@@ -26,9 +26,31 @@
 // Include config file
 require('../../config.php');
 
+require_once(WB_PATH.'/framework/class.wb.php');
+$wb = new wb;
+
 // Check if we should show the form or add a comment
 if(is_numeric($_GET['page_id']) AND is_numeric($_GET['section_id']) AND isset($_GET['post_id']) AND is_numeric($_GET['post_id']) AND isset($_POST['comment']) AND $_POST['comment'] != '') {
 	
+	// Check captcha
+	if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */
+		if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){
+			// Check for a mismatch
+			if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) {
+				$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
+				$_SESSION['comment_title'] = $_POST['title'];
+				$_SESSION['comment_body'] = $_POST['comment'];
+				exit(header('Location: '.WB_URL.'/modules/news/comment.php?id='.$_GET['post_id']));
+			}
+		} else {
+			$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
+			$_SESSION['comment_title'] = $_POST['title'];
+			$_SESSION['comment_body'] = $_POST['comment'];
+			exit(header('Location: '.WB_URL.'/modules/news/comment.php?id='.$_GET['post_id']));
+		}
+	}
+	if(isset($_SESSION['catpcha'])) { unset($_SESSION['captcha']); }
+	
 	// Insert the comment into db
 	$page_id = $_GET['page_id'];
 	$section_id = $_GET['section_id'];
Index: trunk/wb/modules/news/add.php
===================================================================
--- trunk/wb/modules/news/add.php	(revision 249)
+++ trunk/wb/modules/news/add.php	(revision 250)
@@ -87,19 +87,9 @@
 <br /><a href=\"[ADD_COMMENT_URL]\">Add Comment</a>';
 $comments_page = '<h1>Comment</h1>
 <h2>[POST_TITLE]</h2>
-<br />
-<form name=\"comment\" action=\"[ACTION_URL]\" method=\"post\">
-Title:
-<br />
-<input type=\"text\" name=\"title\" maxlength=\"255\" style=\"width: 90%;\" />
-<br /><br />
-Comment:
-<br />
-<textarea name=\"comment\" style=\"width: 90%; height: 150px;\"></textarea>
-<br /><br />
-<input type=\"submit\" name=\"submit\" value=\"Add Comment\" />';
+<br />';
 $commenting = 'none';
-
-$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id,header,post_loop,footer,post_header,post_footer,comments_header,comments_loop,comments_footer,comments_page,commenting) VALUES ('$section_id','$page_id','$header','$post_loop','$footer','$post_header','$post_footer','$comments_header','$comments_loop','$comments_footer','$comments_page','$commenting')");
+$use_captcha = true;
+$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id,header,post_loop,footer,post_header,post_footer,comments_header,comments_loop,comments_footer,comments_page,commenting,use_captcha) VALUES ('$section_id','$page_id','$header','$post_loop','$footer','$post_header','$post_footer','$comments_header','$comments_loop','$comments_footer','$comments_page','$commenting','$use_captcha')");
 
 ?>
\ No newline at end of file
Index: trunk/wb/framework/initialize.php
===================================================================
--- trunk/wb/framework/initialize.php	(revision 249)
+++ trunk/wb/framework/initialize.php	(revision 250)
@@ -23,8 +23,8 @@
 
 */
  
-if (file_exists(WB_PATH.'/framework/class.database.php'))
-{
+if (file_exists(WB_PATH.'/framework/class.database.php')) {
+	
 	require_once(WB_PATH.'/framework/class.database.php');
 		
 	// Create database class
@@ -100,4 +100,4 @@
 		
 }
 
-?>
+?>
\ No newline at end of file
