From 7a2e3b4354b495f7f46bc57dfde070ce7270bd25 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 3 Jun 2013 23:38:48 +0530 Subject: [ticket/11566] add interface for captcha Add basic captcha template while reporting post when the user is not a registered user. PHPBB3-11566 --- phpBB/report.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index c1172ec1d5..06fc086d4d 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -133,6 +133,13 @@ else } } +if ($config['enable_post_confirm'] && !$user->data['is_registered']) +{ + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_POST); +} + // Submit report? if ($submit && $reason_id) { @@ -224,6 +231,13 @@ display_reasons($reason_id); $page_title = ($pm_id) ? $user->lang['REPORT_MESSAGE'] : $user->lang['REPORT_POST']; +if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false)) +{ + $template->assign_vars(array( + 'CAPTCHA_TEMPLATE' => $captcha->get_template(), + )); +} + $template->assign_vars(array( 'S_REPORT_POST' => ($pm_id) ? false : true, 'REPORT_TEXT' => $report_text, -- cgit v1.2.1 From eafd0ae29f649213cf71b7575131b7f5555c4e67 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 10 Jun 2013 23:52:41 +0530 Subject: [ticket/11566] add error functionality add $error which stores the captcha error when captcha validation fails PHPBB3-11566 --- phpBB/report.php | 147 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 67 deletions(-) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index 06fc086d4d..7f6cd4a792 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -140,90 +140,101 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered']) $captcha->init(CONFIRM_POST); } +$error = array(); + // Submit report? if ($submit && $reason_id) { - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other')) + $vc_response = $captcha->validate(); + if ($vc_response) { - trigger_error('EMPTY_REPORT'); + $error[] = $vc_response; } - $sql_ary = array( - 'reason_id' => (int) $reason_id, - 'post_id' => $post_id, - 'pm_id' => $pm_id, - 'user_id' => (int) $user->data['user_id'], - 'user_notify' => (int) $user_notify, - 'report_closed' => 0, - 'report_time' => (int) time(), - 'report_text' => (string) $report_text - ); - - $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - $report_id = $db->sql_nextid(); - - if ($post_id) + if (!sizeof($error)) { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_reported = 1 - WHERE post_id = ' . $post_id; - $db->sql_query($sql); - - if (!$report_data['topic_reported']) + $sql = 'SELECT * + FROM ' . REPORTS_REASONS_TABLE . " + WHERE reason_id = $reason_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other')) { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_reported = 1 - WHERE topic_id = ' . $report_data['topic_id'] . ' - OR topic_moved_id = ' . $report_data['topic_id']; - $db->sql_query($sql); + trigger_error('EMPTY_REPORT'); } - $lang_return = $user->lang['RETURN_TOPIC']; - $lang_success = $user->lang['POST_REPORTED_SUCCESS']; - } - else - { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_reported = 1 - WHERE msg_id = ' . $pm_id; - $db->sql_query($sql); - $sql_ary = array( - 'msg_id' => $pm_id, - 'user_id' => ANONYMOUS, - 'author_id' => (int) $report_data['author_id'], - 'pm_deleted' => 0, - 'pm_new' => 0, - 'pm_unread' => 0, - 'pm_replied' => 0, - 'pm_marked' => 0, - 'pm_forwarded' => 0, - 'folder_id' => PRIVMSGS_INBOX, + 'reason_id' => (int) $reason_id, + 'post_id' => $post_id, + 'pm_id' => $pm_id, + 'user_id' => (int) $user->data['user_id'], + 'user_notify' => (int) $user_notify, + 'report_closed' => 0, + 'report_time' => (int) time(), + 'report_text' => (string) $report_text ); - $sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); + $report_id = $db->sql_nextid(); - $lang_return = $user->lang['RETURN_PM']; - $lang_success = $user->lang['PM_REPORTED_SUCCESS']; - } + if ($post_id) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_reported = 1 + WHERE post_id = ' . $post_id; + $db->sql_query($sql); - meta_refresh(3, $redirect_url); + if (!$report_data['topic_reported']) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_reported = 1 + WHERE topic_id = ' . $report_data['topic_id'] . ' + OR topic_moved_id = ' . $report_data['topic_id']; + $db->sql_query($sql); + } + + $lang_return = $user->lang['RETURN_TOPIC']; + $lang_success = $user->lang['POST_REPORTED_SUCCESS']; + } + else + { + $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' + SET message_reported = 1 + WHERE msg_id = ' . $pm_id; + $db->sql_query($sql); - $message = $lang_success . '

' . sprintf($lang_return, '', ''); - if ($return_forum_url) - { - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $sql_ary = array( + 'msg_id' => $pm_id, + 'user_id' => ANONYMOUS, + 'author_id' => (int) $report_data['author_id'], + 'pm_deleted' => 0, + 'pm_new' => 0, + 'pm_unread' => 0, + 'pm_replied' => 0, + 'pm_marked' => 0, + 'pm_forwarded' => 0, + 'folder_id' => PRIVMSGS_INBOX, + ); + + $sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + + $lang_return = $user->lang['RETURN_PM']; + $lang_success = $user->lang['PM_REPORTED_SUCCESS']; + } + + meta_refresh(3, $redirect_url); + + $message = $lang_success . '

' . sprintf($lang_return, '', ''); + if ($return_forum_url) + { + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + } + trigger_error($message); } - trigger_error($message); } // Generate the reasons @@ -231,14 +242,16 @@ display_reasons($reason_id); $page_title = ($pm_id) ? $user->lang['REPORT_MESSAGE'] : $user->lang['REPORT_POST']; -if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false)) +if ((isset($captcha) && $captcha->is_solved() === false)) { $template->assign_vars(array( + 'S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); } $template->assign_vars(array( + 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'S_REPORT_POST' => ($pm_id) ? false : true, 'REPORT_TEXT' => $report_text, 'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id . '&pm=' . $pm_id), -- cgit v1.2.1 From 2c240f8a7b36feab129336b7e36273cdb9798364 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Tue, 11 Jun 2013 00:09:14 +0530 Subject: [ticket/11566] display error instead of trigger_error When the error report is empty display error in the template instead of trigger_error PHPBB3-11566 --- phpBB/report.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index 7f6cd4a792..1ae0abcdc2 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -151,20 +151,20 @@ if ($submit && $reason_id) $error[] = $vc_response; } - if (!sizeof($error)) + $sql = 'SELECT * + FROM ' . REPORTS_REASONS_TABLE . " + WHERE reason_id = $reason_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other')) { - $sql = 'SELECT * - FROM ' . REPORTS_REASONS_TABLE . " - WHERE reason_id = $reason_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other')) - { - trigger_error('EMPTY_REPORT'); - } + $error[] = $user->lang('EMPTY_REPORT'); + } + if (!sizeof($error)) + { $sql_ary = array( 'reason_id' => (int) $reason_id, 'post_id' => $post_id, -- cgit v1.2.1 From c4fbed251db058d808823d2700c441383edc3e63 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Tue, 11 Jun 2013 00:20:26 +0530 Subject: [ticket/11566] add captcha reset and hidden fields If captcha is solved and some other error pops up, store the captcha in a hidden field. Reset captcha if reporting the post is successful PHPBB3-11566 --- phpBB/report.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index 1ae0abcdc2..b876b5c94f 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -141,6 +141,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered']) } $error = array(); +$s_hidden_fields = ''; // Submit report? if ($submit && $reason_id) @@ -165,6 +166,11 @@ if ($submit && $reason_id) if (!sizeof($error)) { + if (isset($captcha)) + { + $captcha->reset(); + } + $sql_ary = array( 'reason_id' => (int) $reason_id, 'post_id' => $post_id, @@ -235,6 +241,10 @@ if ($submit && $reason_id) } trigger_error($message); } + else if (isset($captcha) && $captcha->is_solved() !== false) + { + $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); + } } // Generate the reasons @@ -255,6 +265,7 @@ $template->assign_vars(array( 'S_REPORT_POST' => ($pm_id) ? false : true, 'REPORT_TEXT' => $report_text, 'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id . '&pm=' . $pm_id), + 'S_HIDDEN_FIELDS' => (sizeof($s_hidden_fields)) ? $s_hidden_fields : null, 'S_NOTIFY' => $user_notify, 'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false) -- cgit v1.2.1 From 88b5180aa11ba90f37d598737bb46a054382042f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 22 Jun 2013 03:54:21 +0530 Subject: [ticket/11566] Rename var to $visual_confirmation_response PHPBB3-11566 --- phpBB/report.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index b876b5c94f..4fecaf4046 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -146,10 +146,10 @@ $s_hidden_fields = ''; // Submit report? if ($submit && $reason_id) { - $vc_response = $captcha->validate(); - if ($vc_response) + $visual_confirmation_response = $captcha->validate(); + if ($visual_confirmation_response) { - $error[] = $vc_response; + $error[] = $visual_confirmation_response; } $sql = 'SELECT * -- cgit v1.2.1 From 4ad1d9aa6530ebe1d554909a978b9ee124377625 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 22 Jun 2013 04:07:21 +0530 Subject: [ticket/11566] Use the new constant CONFIRM_REPORT for captcha init PHPBB3-11566 --- phpBB/report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index 4fecaf4046..f89a18fa8e 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -137,7 +137,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_POST); + $captcha->init(CONFIRM_REPORT); } $error = array(); -- cgit v1.2.1 From d4645575fdf0b787721fb8c8a240d2bd01e784f2 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 1 Jul 2013 15:23:45 +0530 Subject: [ticket/11566] Remove extra pair of brackets from conditional statement PHPBB3-11566 --- phpBB/report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/report.php') diff --git a/phpBB/report.php b/phpBB/report.php index f89a18fa8e..c92ecdfdcc 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -252,7 +252,7 @@ display_reasons($reason_id); $page_title = ($pm_id) ? $user->lang['REPORT_MESSAGE'] : $user->lang['REPORT_POST']; -if ((isset($captcha) && $captcha->is_solved() === false)) +if (isset($captcha) && $captcha->is_solved() === false) { $template->assign_vars(array( 'S_CONFIRM_CODE' => true, -- cgit v1.2.1