From 56c8e341457ed2233483f09ba058772b53538bc3 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 27 Oct 2009 08:43:00 +0000 Subject: #53235 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10235 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 65 +++++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index c17cfa7bbe..095cc89aee 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -617,21 +617,28 @@ class phpbb_captcha_qa } else if ($question_id && $action == 'delete') { - if (confirm_box(true)) + if ($this->get_class_name() !== $config['captcha_plugin'] || !$this->acp_is_last($question_id)) { - $this->acp_delete_question($question_id); + if (confirm_box(true)) + { + $this->acp_delete_question($question_id); - trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); + trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'question_id' => $question_id, + 'action' => $action, + 'configure' => 1, + 'select_captcha' => $this->get_class_name(), + )) + ); + } } else { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'question_id' => $question_id, - 'action' => $action, - 'configure' => 1, - 'select_captcha' => $this->get_class_name(), - )) - ); + trigger_error($user->lang['QA_ERROR_MSG'] . adm_back_link($list_url), E_USER_WARNING); } } else @@ -711,7 +718,7 @@ class phpbb_captcha_qa } else if ($submit) { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url)); + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url), E_USER_WARNING); } } } @@ -789,11 +796,12 @@ class phpbb_captcha_qa */ function acp_get_question_input() { + $answers = request_var('answers', '', true); $question = array( 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), - 'answers' => explode("\n", request_var('answers', '', true)), + 'answers' => (strlen($answers)) ? explode("\n", $answers) : '', ); return $question; @@ -908,12 +916,12 @@ class phpbb_captcha_qa } if (!isset($langs[$question_data['lang_iso']]) || - !$question_data['question_text'] || - !sizeof($question_data['answers'])) + !strlen($question_data['question_text']) || + !sizeof($question_data['answers']) || + !is_array($question_data['answers'])) { return false; } - return true; } @@ -940,6 +948,33 @@ class phpbb_captcha_qa return $langs; } + + + + /** + * Grab a question and bring it into a format the editor understands + */ + function acp_is_last($question_id) + { + global $config, $db; + + if ($question_id) + { + $sql = 'SELECT question_id + FROM ' . CAPTCHA_QUESTIONS_TABLE . " + WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "' + AND question_id <> " . (int) $question_id; + $result = $db->sql_query_limit($sql, 1); + $question = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$question) + { + return true; + } + return false; + } + } } ?> \ No newline at end of file -- cgit v1.2.1 From b23f6c90ba64370bddfcaaabdc57e44505dfc422 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 27 Oct 2009 11:17:53 +0000 Subject: fix spaces/tabs git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10236 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 095cc89aee..a0654bba19 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -349,12 +349,12 @@ class phpbb_captcha_qa global $config, $db, $user; $error = ''; - + if (!sizeof($this->question_ids)) { return false; } - + if (!$this->confirm_id) { $error = $user->lang['CONFIRM_QUESTION_WRONG']; @@ -419,7 +419,7 @@ class phpbb_captcha_qa function reselect_question() { global $db, $user; - + if (!sizeof($this->question_ids)) { return false; @@ -464,7 +464,7 @@ class phpbb_captcha_qa function load_answer() { global $db, $user; - + if (!sizeof($this->question_ids)) { return false; @@ -948,10 +948,8 @@ class phpbb_captcha_qa return $langs; } - - - - /** + + /** * Grab a question and bring it into a format the editor understands */ function acp_is_last($question_id) @@ -963,7 +961,7 @@ class phpbb_captcha_qa $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "' - AND question_id <> " . (int) $question_id; + AND question_id <> " . (int) $question_id; $result = $db->sql_query_limit($sql, 1); $question = $db->sql_fetchrow($result); $db->sql_freeresult($result); -- cgit v1.2.1 From 44719bd041c99a824723bba2854de66d8ddeb4a9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 27 Oct 2009 12:27:46 +0000 Subject: #53235 - removing accidental commits git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10237 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 67 ++++++---------------- 1 file changed, 18 insertions(+), 49 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index a0654bba19..0b64f07ab3 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -53,7 +53,7 @@ class phpbb_captcha_qa // read input $this->confirm_id = request_var('qa_confirm_id', ''); - $this->answer = request_var('qa_answer', '', true); + $this->answer = utf8_normalize_nfc(request_var('qa_answer', '', true)); $this->type = (int) $type; $this->question_lang = $user->lang_name; @@ -349,12 +349,12 @@ class phpbb_captcha_qa global $config, $db, $user; $error = ''; - + if (!sizeof($this->question_ids)) { return false; } - + if (!$this->confirm_id) { $error = $user->lang['CONFIRM_QUESTION_WRONG']; @@ -419,7 +419,7 @@ class phpbb_captcha_qa function reselect_question() { global $db, $user; - + if (!sizeof($this->question_ids)) { return false; @@ -464,7 +464,7 @@ class phpbb_captcha_qa function load_answer() { global $db, $user; - + if (!sizeof($this->question_ids)) { return false; @@ -617,28 +617,21 @@ class phpbb_captcha_qa } else if ($question_id && $action == 'delete') { - if ($this->get_class_name() !== $config['captcha_plugin'] || !$this->acp_is_last($question_id)) + if (confirm_box(true)) { - if (confirm_box(true)) - { - $this->acp_delete_question($question_id); + $this->acp_delete_question($question_id); - trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'question_id' => $question_id, - 'action' => $action, - 'configure' => 1, - 'select_captcha' => $this->get_class_name(), - )) - ); - } + trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url)); } else { - trigger_error($user->lang['QA_ERROR_MSG'] . adm_back_link($list_url), E_USER_WARNING); + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'question_id' => $question_id, + 'action' => $action, + 'configure' => 1, + 'select_captcha' => $this->get_class_name(), + )) + ); } } else @@ -718,7 +711,7 @@ class phpbb_captcha_qa } else if ($submit) { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url), E_USER_WARNING); + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url)); } } } @@ -801,7 +794,7 @@ class phpbb_captcha_qa 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), - 'answers' => (strlen($answers)) ? explode("\n", $answers) : '', + 'answers' => (strlen($answers)) ? explode("\n", request_var('answers', '', true)) : '', ); return $question; @@ -922,6 +915,7 @@ class phpbb_captcha_qa { return false; } + return true; } @@ -948,31 +942,6 @@ class phpbb_captcha_qa return $langs; } - - /** - * Grab a question and bring it into a format the editor understands - */ - function acp_is_last($question_id) - { - global $config, $db; - - if ($question_id) - { - $sql = 'SELECT question_id - FROM ' . CAPTCHA_QUESTIONS_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "' - AND question_id <> " . (int) $question_id; - $result = $db->sql_query_limit($sql, 1); - $question = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$question) - { - return true; - } - return false; - } - } } ?> \ No newline at end of file -- cgit v1.2.1 From d53f9a22d61c3b63ff9b6fc8a653a63f18630356 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 27 Oct 2009 12:36:55 +0000 Subject: adding normalization - shouldn't change anything git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10238 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 0b64f07ab3..c078265971 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -502,7 +502,7 @@ class phpbb_captcha_qa { global $db; - $answer = ($this->question_strict) ? request_var('qa_answer', '', true) : utf8_clean_string(request_var('qa_answer', '', true)); + $answer = ($this->question_strict) ? utf8_normalize_nfc(request_var('qa_answer', '', true)) : utf8_clean_string(utf8_normalize_nfc(request_var('qa_answer', '', true))); $sql = 'SELECT answer_text FROM ' . CAPTCHA_ANSWERS_TABLE . ' @@ -789,7 +789,7 @@ class phpbb_captcha_qa */ function acp_get_question_input() { - $answers = request_var('answers', '', true); + $answers = utf8_normalize_nfc(request_var('answers', '', true)); $question = array( 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), -- cgit v1.2.1 From df5fa06035cd86f6441edcdecb5b18c0caba27f0 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 27 Oct 2009 13:54:03 +0000 Subject: ... and finally git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10239 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php') diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index c078265971..45811c5d26 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -794,7 +794,7 @@ class phpbb_captcha_qa 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), - 'answers' => (strlen($answers)) ? explode("\n", request_var('answers', '', true)) : '', + 'answers' => (strlen($answers)) ? explode("\n", $answers) : '', ); return $question; -- cgit v1.2.1