Revision 250
Added by ryan almost 19 years ago
trunk/wb/modules/form/view.php | ||
---|---|---|
269 | 269 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ |
270 | 270 |
if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){ |
271 | 271 |
// Check for a mismatch |
272 |
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR !$_POST['captcha'] == $_SESSION['captcha']) {
|
|
272 |
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) {
|
|
273 | 273 |
$captcha_error = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA']; |
274 | 274 |
} |
275 | 275 |
} else { |
trunk/wb/modules/form/save_settings.php | ||
---|---|---|
41 | 41 |
$field_loop = $admin->add_slashes($_POST['field_loop']); |
42 | 42 |
$footer = $admin->add_slashes($_POST['footer']); |
43 | 43 |
$email_to = $admin->add_slashes($_POST['email_to']); |
44 |
$use_captcha = $_POST['use_captcha']; |
|
44 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { |
|
45 |
$use_captcha = $_POST['use_captcha']; |
|
46 |
} else { |
|
47 |
$use_captcha = false; |
|
48 |
} |
|
45 | 49 |
if($_POST['email_from_field'] == '') { |
46 | 50 |
$email_from = $admin->add_slashes($_POST['email_from']); |
47 | 51 |
} else { |
trunk/wb/modules/news/comment_page.php | ||
---|---|---|
27 | 27 |
if(!defined('WB_URL')) { header('Location: ../index.php'); } |
28 | 28 |
|
29 | 29 |
// Get comments page template details from db |
30 |
$query_settings = $database->query("SELECT comments_page FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '".SECTION_ID."'"); |
|
30 |
$query_settings = $database->query("SELECT comments_page,use_captcha FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '".SECTION_ID."'");
|
|
31 | 31 |
if($query_settings->numRows() == 0) { |
32 | 32 |
header('Location: '.WB_URL.'/pages/'); |
33 | 33 |
} else { |
34 | 34 |
$settings = $query_settings->fetchRow(); |
35 | 35 |
// Print comments page |
36 |
$vars = array('[POST_TITLE]', '[ACTION_URL]'); |
|
37 |
$values = array(POST_TITLE, WB_URL.'/modules/news/submit_comment.php?page_id='.PAGE_ID.'§ion_id='.SECTION_ID.'&post_id='.POST_ID); |
|
38 |
echo str_replace($vars, $values, ($settings['comments_page'])); |
|
36 |
echo str_replace('[POST_TITLE]', POST_TITLE, ($settings['comments_page'])); |
|
37 |
?> |
|
38 |
<form name="comment" action="<?php echo WB_URL.'/modules/news/submit_comment.php?page_id='.PAGE_ID.'§ion_id='.SECTION_ID.'&post_id='.POST_ID; ?>" method="post"> |
|
39 |
<?php echo $TEXT['TITLE']; ?>: |
|
40 |
<br /> |
|
41 |
<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']); } ?> /> |
|
42 |
<br /><br /> |
|
43 |
<?php echo $TEXT['COMMENT']; ?>: |
|
44 |
<br /> |
|
45 |
<textarea name="comment" style="width: 90%; height: 150px;"><?php if(isset($_SESSION['comment_body'])) { echo $_SESSION['comment_body']; unset($_SESSION['comment_body']); } ?></textarea> |
|
46 |
<br /><br /> |
|
47 |
<?php |
|
48 |
if(isset($_SESSION['captcha_error'])) { |
|
49 |
echo '<font color="#FF0000">'.$_SESSION['captcha_error'].'</font><br />'; |
|
50 |
unset($_SESSION['captcha_error']); |
|
51 |
} |
|
52 |
// Captcha |
|
53 |
if($settings['use_captcha']) { |
|
54 |
$_SESSION['captcha'] = ''; |
|
55 |
for($i = 0; $i < 5; $i++) { |
|
56 |
$_SESSION['captcha'] .= rand(0,9); |
|
57 |
} |
|
58 |
?> |
|
59 |
<table cellpadding="2" cellspacing="0" border="0"> |
|
60 |
<tr> |
|
61 |
<td><?php echo $TEXT['VERIFICATION']; ?>:</td> |
|
62 |
<td><img src="<?php echo WB_URL; ?>/include/captcha.php" alt="Captcha" /></td> |
|
63 |
<td><input type="text" name="captcha" maxlength="5" /></td> |
|
64 |
</tr></table> |
|
65 |
<br /> |
|
66 |
<?php |
|
67 |
} |
|
68 |
?> |
|
69 |
<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?> <?php echo $TEXT['COMMENT']; ?>" /> |
|
70 |
</form> |
|
71 |
<?php |
|
39 | 72 |
} |
40 | 73 |
|
41 | 74 |
?> |
trunk/wb/modules/news/install.php | ||
---|---|---|
38 | 38 |
. '`content_short` TEXT NOT NULL,' |
39 | 39 |
. '`content_long` TEXT NOT NULL,' |
40 | 40 |
. '`commenting` VARCHAR(7) NOT NULL,' |
41 |
. '`posted_when` INT NOT NULL ,' |
|
41 |
. '`posted_when` INT NOT NULL ,'
|
|
42 | 42 |
. '`posted_by` INT NOT NULL ,' |
43 | 43 |
. 'PRIMARY KEY (post_id)' |
44 | 44 |
. ' )'; |
... | ... | |
86 | 86 |
. '`comments_page` TEXT NOT NULL,' |
87 | 87 |
. '`commenting` VARCHAR(7) NOT NULL,' |
88 | 88 |
. '`resize` INT NOT NULL,' |
89 |
. ' `use_captcha` INT NOT NULL,' |
|
89 | 90 |
. 'PRIMARY KEY (section_id)' |
90 | 91 |
. ' )'; |
91 | 92 |
$database->query($mod_news); |
trunk/wb/modules/news/modify_settings.php | ||
---|---|---|
106 | 106 |
</tr> |
107 | 107 |
<?php if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ ?> |
108 | 108 |
<tr> |
109 |
<td class="setting_name"><?php echo $TEXT['CAPTCHA_VERIFICATION']; ?>:</td> |
|
109 | 110 |
<td> |
111 |
<input type="radio" name="use_captcha" id="use_captcha_true" value="1"<?php if($fetch_content['use_captcha'] == true) { echo ' checked'; } ?> /> |
|
112 |
<label for="use_captcha_true"><?php echo $TEXT['ENABLED']; ?></label> |
|
113 |
<input type="radio" name="use_captcha" id="use_captcha_false" value="0"<?php if($fetch_content['use_captcha'] == false) { echo ' checked'; } ?> /> |
|
114 |
<label for="use_captcha_false"><?php echo $TEXT['DISABLED']; ?></label> |
|
115 |
</td> |
|
116 |
</tr> |
|
117 |
<tr> |
|
118 |
<td> |
|
110 | 119 |
<?php echo $TEXT['RESIZE_IMAGE_TO']; ?>: |
111 | 120 |
</td> |
112 | 121 |
<td> |
trunk/wb/modules/news/save_settings.php | ||
---|---|---|
45 | 45 |
$posts_per_page = $_POST['posts_per_page']; |
46 | 46 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { |
47 | 47 |
$resize = $_POST['resize']; |
48 |
$use_captcha = $_POST['use_captcha']; |
|
48 | 49 |
} else { |
49 | 50 |
$resize = ''; |
51 |
$use_captcha = false; |
|
50 | 52 |
} |
51 | 53 |
|
52 | 54 |
// Update settings |
53 |
$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'"); |
|
55 |
$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'");
|
|
54 | 56 |
|
55 | 57 |
// Check if there is a db error, otherwise say successful |
56 | 58 |
if($database->is_error()) { |
trunk/wb/modules/news/submit_comment.php | ||
---|---|---|
26 | 26 |
// Include config file |
27 | 27 |
require('../../config.php'); |
28 | 28 |
|
29 |
require_once(WB_PATH.'/framework/class.wb.php'); |
|
30 |
$wb = new wb; |
|
31 |
|
|
29 | 32 |
// Check if we should show the form or add a comment |
30 | 33 |
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'] != '') { |
31 | 34 |
|
35 |
// Check captcha |
|
36 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ |
|
37 |
if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){ |
|
38 |
// Check for a mismatch |
|
39 |
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) { |
|
40 |
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA']; |
|
41 |
$_SESSION['comment_title'] = $_POST['title']; |
|
42 |
$_SESSION['comment_body'] = $_POST['comment']; |
|
43 |
exit(header('Location: '.WB_URL.'/modules/news/comment.php?id='.$_GET['post_id'])); |
|
44 |
} |
|
45 |
} else { |
|
46 |
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA']; |
|
47 |
$_SESSION['comment_title'] = $_POST['title']; |
|
48 |
$_SESSION['comment_body'] = $_POST['comment']; |
|
49 |
exit(header('Location: '.WB_URL.'/modules/news/comment.php?id='.$_GET['post_id'])); |
|
50 |
} |
|
51 |
} |
|
52 |
if(isset($_SESSION['catpcha'])) { unset($_SESSION['captcha']); } |
|
53 |
|
|
32 | 54 |
// Insert the comment into db |
33 | 55 |
$page_id = $_GET['page_id']; |
34 | 56 |
$section_id = $_GET['section_id']; |
trunk/wb/modules/news/add.php | ||
---|---|---|
87 | 87 |
<br /><a href=\"[ADD_COMMENT_URL]\">Add Comment</a>'; |
88 | 88 |
$comments_page = '<h1>Comment</h1> |
89 | 89 |
<h2>[POST_TITLE]</h2> |
90 |
<br /> |
|
91 |
<form name=\"comment\" action=\"[ACTION_URL]\" method=\"post\"> |
|
92 |
Title: |
|
93 |
<br /> |
|
94 |
<input type=\"text\" name=\"title\" maxlength=\"255\" style=\"width: 90%;\" /> |
|
95 |
<br /><br /> |
|
96 |
Comment: |
|
97 |
<br /> |
|
98 |
<textarea name=\"comment\" style=\"width: 90%; height: 150px;\"></textarea> |
|
99 |
<br /><br /> |
|
100 |
<input type=\"submit\" name=\"submit\" value=\"Add Comment\" />'; |
|
90 |
<br />'; |
|
101 | 91 |
$commenting = 'none'; |
102 |
|
|
103 |
$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')");
|
|
92 |
$use_captcha = true; |
|
93 |
$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')");
|
|
104 | 94 |
|
105 | 95 |
?> |
trunk/wb/framework/initialize.php | ||
---|---|---|
23 | 23 |
|
24 | 24 |
*/ |
25 | 25 |
|
26 |
if (file_exists(WB_PATH.'/framework/class.database.php')) |
|
27 |
{ |
|
26 |
if (file_exists(WB_PATH.'/framework/class.database.php')) {
|
|
27 |
|
|
28 | 28 |
require_once(WB_PATH.'/framework/class.database.php'); |
29 | 29 |
|
30 | 30 |
// Create database class |
... | ... | |
100 | 100 |
|
101 | 101 |
} |
102 | 102 |
|
103 |
?> |
|
103 |
?> |
Also available in: Unified diff
Added Captcha to News module