Author: acydburn Date: Mon Sep 7 12:57:58 2009 New Revision: 10116 Log: beautify q&a captcha a bit (only slightly) Modified: branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp.html branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp_demo.html branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php branches/phpBB-3_0_0/phpBB/styles/prosilver/template/captcha_qa.html Modified: branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp.html (original) --- branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp.html Mon Sep 7 12:57:58 2009 *************** *** 27,38 **** </thead> <tbody> <!-- BEGIN questions --> ! <!-- IF questions.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> ! <td style="text-align: left;">{questions.QUESTION_TEXT}</td> <td style="text-align: center;">{questions.QUESTION_LANG}</td> ! <td style="text-align: center;"><a href="{questions.U_EDIT}">{ICON_EDIT}</a><a href="{questions.U_DELETE}">{ICON_DELETE}</a></td> </tr> <!-- END questions --> </tbody> --- 27,38 ---- </thead> <tbody> <!-- BEGIN questions --> ! <!-- IF questions.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> ! <td style="text-align: left;">{questions.QUESTION_TEXT}</td> <td style="text-align: center;">{questions.QUESTION_LANG}</td> ! <td style="text-align: center;"><a href="{questions.U_EDIT}">{ICON_EDIT}</a> <a href="{questions.U_DELETE}">{ICON_DELETE}</a></td> </tr> <!-- END questions --> </tbody> *************** *** 58,78 **** <form id="captcha_qa" method="post" action="{U_ACTION}"> <fieldset> <legend>{L_EDIT_QUESTION}</legend> ! <dl> <dt><label for="strict">{L_QUESTION_STRICT}:</label><br /><span>{L_QUESTION_STRICT_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="strict" value="1"<!-- IF STRICT --> id="strict" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="strict" value="0"<!-- IF not STRICT --> id="strict" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> ! ! <dl> <dt><label for="lang_iso">{L_QUESTION_LANG}</label><br /><span>{L_QUESTION_LANG_EXPLAIN}</span></dt> <dd><select id="lang_iso" name="lang_iso"><!-- BEGIN langs --><option value="{langs.ISO}" <!-- IF langs.ISO == LANG_ISO --> selected="selected" <!-- ENDIF -->>{langs.NAME}</option><!-- END langs --></select></dd> </dl> ! <dl> <dt><label for="question_text">{L_QUESTION_TEXT}</label><br /><span>{L_QUESTION_TEXT_EXPLAIN}</span></dt> <dd><input id="question_text" maxlength="255" size="60" name="question_text" type="text" value="{QUESTION_TEXT}" /></dd> </dl> ! <dl> <dt><label for="answers">{L_QUESTION_ANSWERS}</label><br /><span>{L_ANSWERS_EXPLAIN}</span></dt> <dd><textarea id="answers" style="word-wrap: normal; overflow-x: scroll;" name="answers" rows="15" cols="800" >{ANSWERS}</textarea></dd> </dl> --- 58,78 ---- <form id="captcha_qa" method="post" action="{U_ACTION}"> <fieldset> <legend>{L_EDIT_QUESTION}</legend> ! <dl> <dt><label for="strict">{L_QUESTION_STRICT}:</label><br /><span>{L_QUESTION_STRICT_EXPLAIN}</span></dt> <dd><label><input type="radio" class="radio" name="strict" value="1"<!-- IF STRICT --> id="strict" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="strict" value="0"<!-- IF not STRICT --> id="strict" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> ! ! <dl> <dt><label for="lang_iso">{L_QUESTION_LANG}</label><br /><span>{L_QUESTION_LANG_EXPLAIN}</span></dt> <dd><select id="lang_iso" name="lang_iso"><!-- BEGIN langs --><option value="{langs.ISO}" <!-- IF langs.ISO == LANG_ISO --> selected="selected" <!-- ENDIF -->>{langs.NAME}</option><!-- END langs --></select></dd> </dl> ! <dl> <dt><label for="question_text">{L_QUESTION_TEXT}</label><br /><span>{L_QUESTION_TEXT_EXPLAIN}</span></dt> <dd><input id="question_text" maxlength="255" size="60" name="question_text" type="text" value="{QUESTION_TEXT}" /></dd> </dl> ! <dl> <dt><label for="answers">{L_QUESTION_ANSWERS}</label><br /><span>{L_ANSWERS_EXPLAIN}</span></dt> <dd><textarea id="answers" style="word-wrap: normal; overflow-x: scroll;" name="answers" rows="15" cols="800" >{ANSWERS}</textarea></dd> </dl> Modified: branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp_demo.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp_demo.html (original) --- branches/phpBB-3_0_0/phpBB/adm/style/captcha_qa_acp_demo.html Mon Sep 7 12:57:58 2009 *************** *** 2,7 **** <dt><label for="answer">{L_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt> <dd> ! <input type="text" tabindex="10" name="answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" /> </dd> </dl> --- 2,7 ---- <dt><label for="answer">{L_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt> <dd> ! <input type="text" tabindex="10" name="answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" /> </dd> </dl> Modified: branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php (original) --- branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php Mon Sep 7 12:57:58 2009 *************** *** 48,54 **** { global $config, $db, $user; ! // load our language file $user->add_lang('captcha_qa'); // read input --- 48,54 ---- { global $config, $db, $user; ! // load our language file $user->add_lang('captcha_qa'); // read input *************** *** 62,68 **** // try the user's lang first $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " ! WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) --- 62,68 ---- // try the user's lang first $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " ! WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; $result = $db->sql_query($sql, 3600); while ($row = $db->sql_fetchrow($result)) *************** *** 78,84 **** $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " ! WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql, 7200); while ($row = $db->sql_fetchrow($result)) --- 78,84 ---- $sql = 'SELECT question_id FROM ' . CAPTCHA_QUESTIONS_TABLE . " ! WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql, 7200); while ($row = $db->sql_fetchrow($result)) *************** *** 139,145 **** $sql = 'SELECT COUNT(question_id) as count FROM ' . CAPTCHA_QUESTIONS_TABLE . " ! WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); --- 139,145 ---- $sql = 'SELECT COUNT(question_id) as count FROM ' . CAPTCHA_QUESTIONS_TABLE . " ! WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); *************** *** 283,289 **** function install() { global $db, $phpbb_root_path, $phpEx; ! if (!class_exists('phpbb_db_tools')) { include("$phpbb_root_path/includes/db/db_tools.$phpEx"); --- 283,289 ---- function install() { global $db, $phpbb_root_path, $phpEx; ! if (!class_exists('phpbb_db_tools')) { include("$phpbb_root_path/includes/db/db_tools.$phpEx"); *************** *** 294,334 **** $schemas = array( CAPTCHA_QUESTIONS_TABLE => array ( ! 'COLUMNS' => array( ! 'question_id' => array('UINT', Null, 'auto_increment'), ! 'strict' => array('BOOL', 0), ! 'lang_id' => array('UINT', 0), ! 'lang_iso' => array('VCHAR:30', ''), ! 'question_text' => array('TEXT_UNI', ''), ! ), ! 'PRIMARY_KEY' => 'question_id', ! 'KEYS' => array( ! 'lang_iso' => array('INDEX', 'lang_iso'), ! ), ), CAPTCHA_ANSWERS_TABLE => array ( ! 'COLUMNS' => array( ! 'question_id' => array('UINT', 0), ! 'answer_text' => array('STEXT_UNI', ''), ! ), ! 'KEYS' => array( ! 'question_id' => array('INDEX', 'question_id'), ! ), ), CAPTCHA_QA_CONFIRM_TABLE => array ( ! 'COLUMNS' => array( ! 'session_id' => array('CHAR:32', ''), ! 'confirm_id' => array('CHAR:32', ''), ! 'lang_iso' => array('VCHAR:30', ''), ! 'question_id' => array('UINT', 0), ! 'attempts' => array('UINT', 0), ! 'confirm_type' => array('USINT', 0), ! ), ! 'KEYS' => array( ! 'session_id' => array('INDEX', 'session_id'), ! 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), ! ), ! 'PRIMARY_KEY' => 'confirm_id', ), ); --- 294,334 ---- $schemas = array( CAPTCHA_QUESTIONS_TABLE => array ( ! 'COLUMNS' => array( ! 'question_id' => array('UINT', Null, 'auto_increment'), ! 'strict' => array('BOOL', 0), ! 'lang_id' => array('UINT', 0), ! 'lang_iso' => array('VCHAR:30', ''), ! 'question_text' => array('TEXT_UNI', ''), ! ), ! 'PRIMARY_KEY' => 'question_id', ! 'KEYS' => array( ! 'lang_iso' => array('INDEX', 'lang_iso'), ! ), ), CAPTCHA_ANSWERS_TABLE => array ( ! 'COLUMNS' => array( ! 'question_id' => array('UINT', 0), ! 'answer_text' => array('STEXT_UNI', ''), ! ), ! 'KEYS' => array( ! 'question_id' => array('INDEX', 'question_id'), ! ), ), CAPTCHA_QA_CONFIRM_TABLE => array ( ! 'COLUMNS' => array( ! 'session_id' => array('CHAR:32', ''), ! 'confirm_id' => array('CHAR:32', ''), ! 'lang_iso' => array('VCHAR:30', ''), ! 'question_id' => array('UINT', 0), ! 'attempts' => array('UINT', 0), ! 'confirm_type' => array('USINT', 0), ! ), ! 'KEYS' => array( ! 'session_id' => array('INDEX', 'session_id'), ! 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), ! ), ! 'PRIMARY_KEY' => 'confirm_id', ), ); *************** *** 415,421 **** $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET question_id = ' . (int) $this->question . " ! WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); --- 415,421 ---- $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET question_id = ' . (int) $this->question . " ! WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); *************** *** 436,442 **** $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET question_id = ' . (int) $this->question . ", attempts = attempts + 1 ! WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); --- 436,442 ---- $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET question_id = ' . (int) $this->question . ", attempts = attempts + 1 ! WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'"; $db->sql_query($sql); *************** *** 451,457 **** global $db, $user; $sql = 'SELECT con.question_id, attempts, question_text, strict ! FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes WHERE con.question_id = qes.question_id AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' --- 451,457 ---- global $db, $user; $sql = 'SELECT con.question_id, attempts, question_text, strict ! FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes WHERE con.question_id = qes.question_id AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' *************** *** 520,526 **** } /** ! * API function */ function get_attempt_count() { --- 520,526 ---- } /** ! * API function */ function get_attempt_count() { *************** *** 528,534 **** } /** ! * API function */ function reset() { --- 528,534 ---- } /** ! * API function */ function reset() { *************** *** 544,550 **** } /** ! * API function */ function is_solved() { --- 544,550 ---- } /** ! * API function */ function is_solved() { *************** *** 815,821 **** $langs = $this->get_languages(); $question_ary = $data; ! $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; unset($question_ary['answers']); --- 815,821 ---- $langs = $this->get_languages(); $question_ary = $data; ! $question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; unset($question_ary['answers']); *************** *** 862,868 **** foreach ($tables as $table) { ! $sql = "DELETE FROM $table WHERE question_id = $question_id"; $db->sql_query($sql); } --- 862,868 ---- foreach ($tables as $table) { ! $sql = "DELETE FROM $table WHERE question_id = $question_id"; $db->sql_query($sql); } Modified: branches/phpBB-3_0_0/phpBB/styles/prosilver/template/captcha_qa.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/styles/prosilver/template/captcha_qa.html (original) --- branches/phpBB-3_0_0/phpBB/styles/prosilver/template/captcha_qa.html Mon Sep 7 12:57:58 2009 *************** *** 7,13 **** <!-- ENDIF --> <dl> ! <dt><label>{QA_CONFIRM_QUESTION}</label>:<br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt> <dd> <input type="text" tabindex="{$CAPTCHA_TAB_INDEX}" name="qa_answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" /> <input type="hidden" name="qa_confirm_id" id="qa_confirm_id" value="{QA_CONFIRM_ID}" /> --- 7,13 ---- <!-- ENDIF --> <dl> ! <dt><label>{QA_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt> <dd> <input type="text" tabindex="{$CAPTCHA_TAB_INDEX}" name="qa_answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" /> <input type="hidden" name="qa_confirm_id" id="qa_confirm_id" value="{QA_CONFIRM_ID}" /> |