mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11566] add error functionality
add $error which stores the captcha error when captcha validation fails PHPBB3-11566
This commit is contained in:
parent
7a2e3b4354
commit
eafd0ae29f
1 changed files with 81 additions and 68 deletions
149
phpBB/report.php
149
phpBB/report.php
|
@ -140,90 +140,101 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'])
|
||||||
$captcha->init(CONFIRM_POST);
|
$captcha->init(CONFIRM_POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$error = array();
|
||||||
|
|
||||||
// Submit report?
|
// Submit report?
|
||||||
if ($submit && $reason_id)
|
if ($submit && $reason_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT *
|
$vc_response = $captcha->validate();
|
||||||
FROM ' . REPORTS_REASONS_TABLE . "
|
if ($vc_response)
|
||||||
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[] = $vc_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_ary = array(
|
if (!sizeof($error))
|
||||||
'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)
|
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE ' . POSTS_TABLE . '
|
$sql = 'SELECT *
|
||||||
SET post_reported = 1
|
FROM ' . REPORTS_REASONS_TABLE . "
|
||||||
WHERE post_id = ' . $post_id;
|
WHERE reason_id = $reason_id";
|
||||||
$db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (!$report_data['topic_reported'])
|
if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
trigger_error('EMPTY_REPORT');
|
||||||
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);
|
|
||||||
|
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'msg_id' => $pm_id,
|
'reason_id' => (int) $reason_id,
|
||||||
'user_id' => ANONYMOUS,
|
'post_id' => $post_id,
|
||||||
'author_id' => (int) $report_data['author_id'],
|
'pm_id' => $pm_id,
|
||||||
'pm_deleted' => 0,
|
'user_id' => (int) $user->data['user_id'],
|
||||||
'pm_new' => 0,
|
'user_notify' => (int) $user_notify,
|
||||||
'pm_unread' => 0,
|
'report_closed' => 0,
|
||||||
'pm_replied' => 0,
|
'report_time' => (int) time(),
|
||||||
'pm_marked' => 0,
|
'report_text' => (string) $report_text
|
||||||
'pm_forwarded' => 0,
|
|
||||||
'folder_id' => PRIVMSGS_INBOX,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$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);
|
$db->sql_query($sql);
|
||||||
|
$report_id = $db->sql_nextid();
|
||||||
|
|
||||||
$lang_return = $user->lang['RETURN_PM'];
|
if ($post_id)
|
||||||
$lang_success = $user->lang['PM_REPORTED_SUCCESS'];
|
{
|
||||||
|
$sql = 'UPDATE ' . POSTS_TABLE . '
|
||||||
|
SET post_reported = 1
|
||||||
|
WHERE post_id = ' . $post_id;
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
$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 . '<br /><br />' . sprintf($lang_return, '<a href="' . $redirect_url . '">', '</a>');
|
||||||
|
if ($return_forum_url)
|
||||||
|
{
|
||||||
|
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $return_forum_url . '">', '</a>');
|
||||||
|
}
|
||||||
|
trigger_error($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_refresh(3, $redirect_url);
|
|
||||||
|
|
||||||
$message = $lang_success . '<br /><br />' . sprintf($lang_return, '<a href="' . $redirect_url . '">', '</a>');
|
|
||||||
if ($return_forum_url)
|
|
||||||
{
|
|
||||||
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $return_forum_url . '">', '</a>');
|
|
||||||
}
|
|
||||||
trigger_error($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the reasons
|
// Generate the reasons
|
||||||
|
@ -231,14 +242,16 @@ display_reasons($reason_id);
|
||||||
|
|
||||||
$page_title = ($pm_id) ? $user->lang['REPORT_MESSAGE'] : $user->lang['REPORT_POST'];
|
$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(
|
$template->assign_vars(array(
|
||||||
|
'S_CONFIRM_CODE' => true,
|
||||||
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
|
'CAPTCHA_TEMPLATE' => $captcha->get_template(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
|
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
||||||
'S_REPORT_POST' => ($pm_id) ? false : true,
|
'S_REPORT_POST' => ($pm_id) ? false : true,
|
||||||
'REPORT_TEXT' => $report_text,
|
'REPORT_TEXT' => $report_text,
|
||||||
'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id . '&pm=' . $pm_id),
|
'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id . '&pm=' . $pm_id),
|
||||||
|
|
Loading…
Add table
Reference in a new issue