[jobberbase] r434 committed - enh: the admin can choose on which pages to enable reCAPTCHA - possibl...

32 views
Skip to first unread message

codesite...@google.com

unread,
Feb 18, 2010, 1:04:00 PM2/18/10
to jobbe...@googlegroups.com
Revision: 434
Author: putyp...@gmail.com
Date: Thu Feb 18 10:03:13 2010
Log: enh: the admin can choose on which pages to enable reCAPTCHA -
possible pages are post job, apply to job, contact
http://code.google.com/p/jobberbase/source/detail?r=434

Modified:
/trunk/db/jobberbase.sql
/trunk/public/_config/config.settings.php
/trunk/public/page_apply.php
/trunk/public/page_job.php
/trunk/public/page_page.php
/trunk/public/page_write.php

=======================================
--- /trunk/db/jobberbase.sql Thu Feb 18 09:29:28 2010
+++ /trunk/db/jobberbase.sql Thu Feb 18 10:03:13 2010
@@ -314,7 +314,10 @@
(38, 5, 'mailer_smtp_username', 'SMTP user name', 'User name (for example,
us...@example.com)', NULL, NULL, NULL, NULL, NULL),
(39, 5, 'mailer_smtp_password', 'SMTP password', 'Password', NULL, NULL,
NULL, NULL, NULL),
(40, 4, 'report_post_after', 'Report Post Delay', 'No of Minutes after
which a user is allowed to report same post after the previous report.',
NULL, NULL, NULL, 'not_empty|is_number', '10'),
-(41, 4, 'post_notify_on', 'When to send Mail?', 'Send mail only after this
number of reports on a post.', 'integer', NULL, NULL, 'not_empty', '2');
+(41, 4, 'post_notify_on', 'When to send Mail?', 'Send mail only after this
number of reports on a post.', 'integer', NULL, NULL, 'not_empty', '2'),
+(42, 4, 'captcha_enable_on_post_page', 'Enable ReCaptcha on post
page', 'Enable spam protection on the post a job
page.', 'boolean', 'radiobutton', 'no|yes', NULL, '0'),
+(43, 4, 'captcha_enable_on_apply_page', 'Enable ReCaptcha on apply
page', 'Enable spam protection on the apply to a job
page.', 'boolean', 'radiobutton', 'no|yes', NULL, '1'),
+(44, 4, 'captcha_enable_on_contact_page', 'Enable ReCaptcha on contact
page', 'Enable spam protection on the contact
page.', 'boolean', 'radiobutton', 'no|yes', NULL, '0');

--
-- Table structure for table `settings_categories`
=======================================
--- /trunk/public/_config/config.settings.php Mon Dec 14 09:22:31 2009
+++ /trunk/public/_config/config.settings.php Thu Feb 18 10:03:13 2010
@@ -36,6 +36,9 @@
define('CAPTCHA_PRIVATE_KEY', $settings['captcha_private_key']);
define('REPORT_POST_AGAIN_AFTER', $settings['report_post_after']);
define('REPORT_POST_NOTIFY_ON', $settings['post_notify_on']);
+define('ENABLE_CAPTCHA_ON_POST_PAGE',
$settings['captcha_enable_on_post_page']);
+define('ENABLE_CAPTCHA_ON_APPLY_PAGE',
$settings['captcha_enable_on_apply_page']);
+define('ENABLE_CAPTCHA_ON_CONTACT_PAGE',
$settings['captcha_enable_on_contact_page']);
// default language code, useful if you with to quickly switch between
translation files later
define('LANG_CODE', 'en');
?>
=======================================
--- /trunk/public/page_apply.php Fri Sep 11 10:54:36 2009
+++ /trunk/public/page_apply.php Thu Feb 18 10:03:13 2010
@@ -4,15 +4,18 @@
$GLOBALS[$variable] = $value;
}
$errors = array();
+
+ $captcha_enabled = ENABLE_RECAPTCHA && ENABLE_CAPTCHA_ON_APPLY_PAGE;

// validation
- if (ENABLE_RECAPTCHA)
+ if ($captcha_enabled)
{
$resp = recaptcha_check_answer(CAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) $errors['captcha'] =
$translations['captcha']['captcha_error'];
}
+
if ($apply_name == '')
{
$errors['apply_name'] = $translations['apply']['name_error'];
=======================================
--- /trunk/public/page_job.php Mon Nov 2 10:37:24 2009
+++ /trunk/public/page_job.php Thu Feb 18 10:03:13 2010
@@ -1,7 +1,14 @@
<?php
$sanitizer = new Sanitizer();
- $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));
- $smarty->assign('ENABLE_RECAPTCHA', ENABLE_RECAPTCHA);
+
+ $captcha_enabled = ENABLE_RECAPTCHA && ENABLE_CAPTCHA_ON_APPLY_PAGE;
+
+ $smarty->assign('ENABLE_RECAPTCHA', $captcha_enabled);
+
+ if($captcha_enabled)
+ {
+ $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));
+ }

$job_flag = false;
$count = 0;
=======================================
--- /trunk/public/page_page.php Sat Feb 13 06:13:34 2010
+++ /trunk/public/page_page.php Thu Feb 18 10:03:13 2010
@@ -1,56 +1,63 @@
<?php

-if ($_SERVER['REQUEST_METHOD'] == 'POST') {
-
- $_SESSION['contact_msg_sent'] = -1;
-
- $contact_name = strip_tags($_POST['contact_name']);
- $contact_email = $_POST['contact_email'];
- $contact_msg = strip_tags($_POST['contact_msg']);
-
- $errors = array();
-
- // validation
- if (ENABLE_RECAPTCHA)
- {
- $resp = recaptcha_check_answer(CAPTCHA_PRIVATE_KEY,
- $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"],
- $_POST["recaptcha_response_field"]);
- if (!$resp->is_valid) $errors['captcha'] =
$translations['captcha']['captcha_error'];
- }
-
- if ($contact_name == '')
- {
- $errors['contact_name'] = $translations['contact']['name_error'];
- }
- if ($contact_email == '' || !validate_email($contact_email))
- {
- $errors['contact_email'] = $translations['contact']['email_error'];
- }
- if ($contact_msg == '')
- {
- $errors['contact_msg'] = $translations['contact']['msg_error'];
- }
-
- if (count($errors) > 0)
- {
- $errors['contact_error'] = $translations['contact']['send_error'];
- $smarty->assign('errors', $errors);
- }
- else
- {
- $mailer = new Postman();
-
- if ($mailer->MailContact($contact_name, $contact_email, $contact_msg))
- {
- $_SESSION['contact_msg_sent'] = 1;
+ $captcha_enabled = ENABLE_RECAPTCHA && ENABLE_CAPTCHA_ON_CONTACT_PAGE;
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+
+ $_SESSION['contact_msg_sent'] = -1;
+
+ $contact_name = strip_tags($_POST['contact_name']);
+ $contact_email = $_POST['contact_email'];
+ $contact_msg = strip_tags($_POST['contact_msg']);
+
+ $errors = array();
+
+ // validation
+ if ($captcha_enabled)
+ {
+ $resp = recaptcha_check_answer(CAPTCHA_PRIVATE_KEY,
+ $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"],
+ $_POST["recaptcha_response_field"]);
+ if (!$resp->is_valid) $errors['captcha'] =
$translations['captcha']['captcha_error'];
+ }
+
+ if ($contact_name == '')
+ {
+ $errors['contact_name'] = $translations['contact']['name_error'];
+ }
+ if ($contact_email == '' || !validate_email($contact_email))
+ {
+ $errors['contact_email'] = $translations['contact']['email_error'];
+ }
+ if ($contact_msg == '')
+ {
+ $errors['contact_msg'] = $translations['contact']['msg_error'];
+ }
+
+ if (count($errors) > 0)
+ {
+ $errors['contact_error'] = $translations['contact']['send_error'];
+ $smarty->assign('errors', $errors);
+ }
+ else
+ {
+ $mailer = new Postman();
+
+ if ($mailer->MailContact($contact_name, $contact_email, $contact_msg))
+ {
+ $_SESSION['contact_msg_sent'] = 1;
+ }
+ }
+ }
+ $smarty->assign('page', $pageData);
+
+ if ($pageData['has_form'] == '1')
+ {
+ $smarty->assign('ENABLE_RECAPTCHA', $captcha_enabled);
+
+ if ($captcha_enabled)
+ {
+ $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));
}
}
-}
-$smarty->assign('page', $pageData);
-
-if ($pageData['has_form'] == '1')
-{
- $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));
- $smarty->assign('ENABLE_RECAPTCHA', ENABLE_RECAPTCHA);
-}
+?>
=======================================
--- /trunk/public/page_write.php Sat Feb 6 11:54:22 2010
+++ /trunk/public/page_write.php Thu Feb 18 10:03:13 2010
@@ -1,7 +1,13 @@
<?php

- $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));
- $smarty->assign('ENABLE_RECAPTCHA', ENABLE_RECAPTCHA);
+ $captcha_enabled = ENABLE_RECAPTCHA && ENABLE_CAPTCHA_ON_POST_PAGE;
+
+ $smarty->assign('ENABLE_RECAPTCHA', $captcha_enabled);
+
+ if ($captcha_enabled)
+ {
+ $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));
+ }

$later_edit = false;
if ($id != 0)
@@ -61,7 +67,7 @@
$_SESSION['referer'] = BASE_URL . 'post/';

// validation
- if (ENABLE_RECAPTCHA)
+ if ($captcha_enabled)
{
$resp = recaptcha_check_answer(CAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"],
@@ -155,7 +161,7 @@
$_SESSION['referer'] = BASE_URL . 'post/';

// validation
- if (ENABLE_RECAPTCHA)
+ if ($captcha_enabled)
{
$resp = recaptcha_check_answer(CAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"],

Reply all
Reply to author
Forward
0 new messages