beautify q&a captcha a bit (only slightly)

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10116 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-09-07 11:57:58 +00:00
parent 5f244f64c6
commit 02b2cced5a
4 changed files with 54 additions and 54 deletions

View file

@ -27,12 +27,12 @@
</thead> </thead>
<tbody> <tbody>
<!-- BEGIN questions --> <!-- BEGIN questions -->
<!-- IF questions.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> <!-- 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: left;">{questions.QUESTION_TEXT}</td>
<td style="text-align: center;">{questions.QUESTION_LANG}</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> <td style="text-align: center;"><a href="{questions.U_EDIT}">{ICON_EDIT}</a>&nbsp;<a href="{questions.U_DELETE}">{ICON_DELETE}</a></td>
</tr> </tr>
<!-- END questions --> <!-- END questions -->
</tbody> </tbody>
@ -58,21 +58,21 @@
<form id="captcha_qa" method="post" action="{U_ACTION}"> <form id="captcha_qa" method="post" action="{U_ACTION}">
<fieldset> <fieldset>
<legend>{L_EDIT_QUESTION}</legend> <legend>{L_EDIT_QUESTION}</legend>
<dl> <dl>
<dt><label for="strict">{L_QUESTION_STRICT}:</label><br /><span>{L_QUESTION_STRICT_EXPLAIN}</span></dt> <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> <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> <label><input type="radio" class="radio" name="strict" value="0"<!-- IF not STRICT --> id="strict" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="lang_iso">{L_QUESTION_LANG}</label><br /><span>{L_QUESTION_LANG_EXPLAIN}</span></dt> <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> <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>
<dl> <dl>
<dt><label for="question_text">{L_QUESTION_TEXT}</label><br /><span>{L_QUESTION_TEXT_EXPLAIN}</span></dt> <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> <dd><input id="question_text" maxlength="255" size="60" name="question_text" type="text" value="{QUESTION_TEXT}" /></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="answers">{L_QUESTION_ANSWERS}</label><br /><span>{L_ANSWERS_EXPLAIN}</span></dt> <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> <dd><textarea id="answers" style="word-wrap: normal; overflow-x: scroll;" name="answers" rows="15" cols="800" >{ANSWERS}</textarea></dd>
</dl> </dl>

View file

@ -2,6 +2,6 @@
<dt><label for="answer">{L_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt> <dt><label for="answer">{L_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt>
<dd> <dd>
<input type="text" tabindex="10" name="answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" /> <input type="text" tabindex="10" name="answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" />
</dd> </dd>
</dl> </dl>

View file

@ -48,7 +48,7 @@ class phpbb_captcha_qa
{ {
global $config, $db, $user; global $config, $db, $user;
// load our language file // load our language file
$user->add_lang('captcha_qa'); $user->add_lang('captcha_qa');
// read input // read input
@ -62,7 +62,7 @@ class phpbb_captcha_qa
// try the user's lang first // try the user's lang first
$sql = 'SELECT question_id $sql = 'SELECT question_id
FROM ' . CAPTCHA_QUESTIONS_TABLE . " FROM ' . CAPTCHA_QUESTIONS_TABLE . "
WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'";
$result = $db->sql_query($sql, 3600); $result = $db->sql_query($sql, 3600);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
@ -78,7 +78,7 @@ class phpbb_captcha_qa
$sql = 'SELECT question_id $sql = 'SELECT question_id
FROM ' . CAPTCHA_QUESTIONS_TABLE . " FROM ' . CAPTCHA_QUESTIONS_TABLE . "
WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
$result = $db->sql_query($sql, 7200); $result = $db->sql_query($sql, 7200);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
@ -139,7 +139,7 @@ class phpbb_captcha_qa
$sql = 'SELECT COUNT(question_id) as count $sql = 'SELECT COUNT(question_id) as count
FROM ' . CAPTCHA_QUESTIONS_TABLE . " FROM ' . CAPTCHA_QUESTIONS_TABLE . "
WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -283,7 +283,7 @@ class phpbb_captcha_qa
function install() function install()
{ {
global $db, $phpbb_root_path, $phpEx; global $db, $phpbb_root_path, $phpEx;
if (!class_exists('phpbb_db_tools')) if (!class_exists('phpbb_db_tools'))
{ {
include("$phpbb_root_path/includes/db/db_tools.$phpEx"); include("$phpbb_root_path/includes/db/db_tools.$phpEx");
@ -294,41 +294,41 @@ class phpbb_captcha_qa
$schemas = array( $schemas = array(
CAPTCHA_QUESTIONS_TABLE => array ( CAPTCHA_QUESTIONS_TABLE => array (
'COLUMNS' => array( 'COLUMNS' => array(
'question_id' => array('UINT', Null, 'auto_increment'), 'question_id' => array('UINT', Null, 'auto_increment'),
'strict' => array('BOOL', 0), 'strict' => array('BOOL', 0),
'lang_id' => array('UINT', 0), 'lang_id' => array('UINT', 0),
'lang_iso' => array('VCHAR:30', ''), 'lang_iso' => array('VCHAR:30', ''),
'question_text' => array('TEXT_UNI', ''), 'question_text' => array('TEXT_UNI', ''),
), ),
'PRIMARY_KEY' => 'question_id', 'PRIMARY_KEY' => 'question_id',
'KEYS' => array( 'KEYS' => array(
'lang_iso' => array('INDEX', 'lang_iso'), 'lang_iso' => array('INDEX', 'lang_iso'),
), ),
), ),
CAPTCHA_ANSWERS_TABLE => array ( CAPTCHA_ANSWERS_TABLE => array (
'COLUMNS' => array( 'COLUMNS' => array(
'question_id' => array('UINT', 0), 'question_id' => array('UINT', 0),
'answer_text' => array('STEXT_UNI', ''), 'answer_text' => array('STEXT_UNI', ''),
), ),
'KEYS' => array( 'KEYS' => array(
'question_id' => array('INDEX', 'question_id'), 'question_id' => array('INDEX', 'question_id'),
), ),
), ),
CAPTCHA_QA_CONFIRM_TABLE => array ( CAPTCHA_QA_CONFIRM_TABLE => array (
'COLUMNS' => array( 'COLUMNS' => array(
'session_id' => array('CHAR:32', ''), 'session_id' => array('CHAR:32', ''),
'confirm_id' => array('CHAR:32', ''), 'confirm_id' => array('CHAR:32', ''),
'lang_iso' => array('VCHAR:30', ''), 'lang_iso' => array('VCHAR:30', ''),
'question_id' => array('UINT', 0), 'question_id' => array('UINT', 0),
'attempts' => array('UINT', 0), 'attempts' => array('UINT', 0),
'confirm_type' => array('USINT', 0), 'confirm_type' => array('USINT', 0),
), ),
'KEYS' => array( 'KEYS' => array(
'session_id' => array('INDEX', 'session_id'), 'session_id' => array('INDEX', 'session_id'),
'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')), 'lookup' => array('INDEX', array('confirm_id', 'session_id', 'lang_iso')),
), ),
'PRIMARY_KEY' => 'confirm_id', 'PRIMARY_KEY' => 'confirm_id',
), ),
); );
@ -415,7 +415,7 @@ class phpbb_captcha_qa
$sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . '
SET question_id = ' . (int) $this->question . " SET question_id = ' . (int) $this->question . "
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'"; AND session_id = '" . $db->sql_escape($user->session_id) . "'";
$db->sql_query($sql); $db->sql_query($sql);
@ -436,7 +436,7 @@ class phpbb_captcha_qa
$sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . '
SET question_id = ' . (int) $this->question . ", SET question_id = ' . (int) $this->question . ",
attempts = attempts + 1 attempts = attempts + 1
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'"; AND session_id = '" . $db->sql_escape($user->session_id) . "'";
$db->sql_query($sql); $db->sql_query($sql);
@ -451,7 +451,7 @@ class phpbb_captcha_qa
global $db, $user; global $db, $user;
$sql = 'SELECT con.question_id, attempts, question_text, strict $sql = 'SELECT con.question_id, attempts, question_text, strict
FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' con, ' . CAPTCHA_QUESTIONS_TABLE . " qes
WHERE con.question_id = qes.question_id WHERE con.question_id = qes.question_id
AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "' AND confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "'
@ -520,7 +520,7 @@ class phpbb_captcha_qa
} }
/** /**
* API function * API function
*/ */
function get_attempt_count() function get_attempt_count()
{ {
@ -528,7 +528,7 @@ class phpbb_captcha_qa
} }
/** /**
* API function * API function
*/ */
function reset() function reset()
{ {
@ -544,7 +544,7 @@ class phpbb_captcha_qa
} }
/** /**
* API function * API function
*/ */
function is_solved() function is_solved()
{ {
@ -815,7 +815,7 @@ class phpbb_captcha_qa
$langs = $this->get_languages(); $langs = $this->get_languages();
$question_ary = $data; $question_ary = $data;
$question_ary['lang_id'] = $langs[$data['lang_iso']]['id']; $question_ary['lang_id'] = $langs[$data['lang_iso']]['id'];
unset($question_ary['answers']); unset($question_ary['answers']);
@ -862,7 +862,7 @@ class phpbb_captcha_qa
foreach ($tables as $table) foreach ($tables as $table)
{ {
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE question_id = $question_id"; WHERE question_id = $question_id";
$db->sql_query($sql); $db->sql_query($sql);
} }

View file

@ -7,7 +7,7 @@
<!-- ENDIF --> <!-- ENDIF -->
<dl> <dl>
<dt><label>{QA_CONFIRM_QUESTION}</label>:<br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt> <dt><label>{QA_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt>
<dd> <dd>
<input type="text" tabindex="{$CAPTCHA_TAB_INDEX}" name="qa_answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" /> <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}" /> <input type="hidden" name="qa_confirm_id" id="qa_confirm_id" value="{QA_CONFIRM_ID}" />