|
From: Henry S. <kel...@ph...> - 2009-08-14 10:00:48
|
Author: Kellanved
Date: Fri Aug 14 11:00:30 2009
New Revision: 9975
Log:
#49675 #49655 - ATTENTION: small captcha API change
Modified:
branches/phpBB-3_0_0/phpBB/adm/style/acp_captcha.html
branches/phpBB-3_0_0/phpBB/includes/acp/acp_captcha.php
branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/captcha_abstract.php
branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
Modified: branches/phpBB-3_0_0/phpBB/adm/style/acp_captcha.html
==============================================================================
*** branches/phpBB-3_0_0/phpBB/adm/style/acp_captcha.html (original)
--- branches/phpBB-3_0_0/phpBB/adm/style/acp_captcha.html Fri Aug 14 11:00:30 2009
***************
*** 39,48 ****
--- 39,50 ----
<dt><label for="captcha_select">{L_CAPTCHA_SELECT}:</label><br /><span>{L_CAPTCHA_SELECT_EXPLAIN}</span></dt>
<dd><select id="captcha_select" name="select_captcha" onchange="(document.getElementById('acp_captcha')).submit()" >{CAPTCHA_SELECT}</select></dd>
</dl>
+ <!-- IF S_CAPTCHA_HAS_CONFIG -->
<dl>
<dt><label for="configure">{L_CAPTCHA_CONFIGURE}:</label><br /><span>{L_CAPTCHA_CONFIGURE_EXPLAIN}</span></dt>
<dd><input class="button2" type="submit" id="configure" name="configure" value="{L_CONFIGURE}" /></dd>
</dl>
+ <!-- ENDIF -->
</fieldset>
<!-- IF CAPTCHA_PREVIEW_TPL -->
Modified: branches/phpBB-3_0_0/phpBB/includes/acp/acp_captcha.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/acp/acp_captcha.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/acp/acp_captcha.php Fri Aug 14 11:00:30 2009
***************
*** 67,73 ****
if ($submit && check_form_key($form_key))
{
- $config_vars = array_keys($config_vars);
foreach ($config_vars as $config_var => $options)
{
set_config($config_var, request_var($config_var, $options['default']));
--- 67,72 ----
***************
*** 122,127 ****
--- 121,127 ----
$template->assign_vars(array(
'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id),
+ 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(),
'CAPTCHA_SELECT' => $captcha_select,
));
}
Modified: branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/captcha_abstract.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/captcha_abstract.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/captcha_abstract.php Fri Aug 14 11:00:30 2009
***************
*** 362,367 ****
--- 362,375 ----
return (bool) $this->solved;
}
+ /**
+ * API function
+ */
+ function has_config()
+ {
+ return false;
+ }
+
}
?>
\ No newline at end of file
Modified: branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php Fri Aug 14 11:00:30 2009
***************
*** 73,78 ****
--- 73,86 ----
return can_load_dll('gd');
}
+ /**
+ * API function
+ */
+ function has_config()
+ {
+ return true;
+ }
+
function get_name()
{
return 'CAPTCHA_GD';
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 Fri Aug 14 11:00:30 2009
***************
*** 17,25 ****
}
global $table_prefix;
! define('QUESTIONS_TABLE', $table_prefix . 'captcha_questions');
! define('ANSWERS_TABLE', $table_prefix . 'captcha_answers');
! define('QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm');
--- 17,25 ----
}
global $table_prefix;
! define('CAPTCHA_QUESTIONS_TABLE', $table_prefix . 'captcha_questions');
! define('CAPTCHA_ANSWERS_TABLE', $table_prefix . 'captcha_answers');
! define('CAPTCHA_QA_CONFIRM_TABLE', $table_prefix . 'qa_confirm');
***************
*** 59,65 ****
$this->question_lang = $user->data['user_lang'];
// we need all defined questions - shouldn't be too many, so we can just grab them
// try the user's lang first
! $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($user->data['user_lang']) . '\'';
$result = $db->sql_query($sql, 3600);
while ($row = $db->sql_fetchrow($result))
{
--- 59,65 ----
$this->question_lang = $user->data['user_lang'];
// we need all defined questions - shouldn't be too many, so we can just grab them
// 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))
{
***************
*** 70,76 ****
if (!sizeof($this->question_ids))
{
$this->question_lang = $config['default_lang'];
! $sql = 'SELECT question_id FROM ' . QUESTIONS_TABLE . ' WHERE lang_iso = \'' . $db->sql_escape($config['default_lang']) . '\'';
$result = $db->sql_query($sql, 7200);
while ($row = $db->sql_fetchrow($result))
{
--- 70,76 ----
if (!sizeof($this->question_ids))
{
$this->question_lang = $config['default_lang'];
! $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))
{
***************
*** 108,114 ****
include("$phpbb_root_path/includes/db/db_tools.$phpEx");
}
$db_tool = new phpbb_db_tools($db);
! return $db_tool->sql_table_exists(QUESTIONS_TABLE);
}
/**
--- 108,114 ----
include("$phpbb_root_path/includes/db/db_tools.$phpEx");
}
$db_tool = new phpbb_db_tools($db);
! return $db_tool->sql_table_exists(CAPTCHA_QUESTIONS_TABLE);
}
/**
***************
*** 125,137 ****
{
return false;
}
! $sql = 'SELECT COUNT(question_id) as count FROM ' . 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);
return ((bool) $row['count']);
}
/**
* API function
*/
--- 125,147 ----
{
return false;
}
! $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);
return ((bool) $row['count']);
}
+
+ /**
+ * API function
+ */
+ function has_config()
+ {
+ return true;
+ }
+
+
/**
* API function
*/
***************
*** 219,225 ****
global $db, $config;
$sql = 'SELECT DISTINCT c.session_id
! FROM ' . QA_CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
WHERE s.session_id IS NULL' .
((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type);
--- 229,235 ----
global $db, $config;
$sql = 'SELECT DISTINCT c.session_id
! FROM ' . CAPTCHA_QA_CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
WHERE s.session_id IS NULL' .
((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type);
***************
*** 236,242 ****
if (sizeof($sql_in))
{
! $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . '
WHERE ' . $db->sql_in_set('session_id', $sql_in);
$db->sql_query($sql);
}
--- 246,252 ----
if (sizeof($sql_in))
{
! $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . '
WHERE ' . $db->sql_in_set('session_id', $sql_in);
$db->sql_query($sql);
}
***************
*** 264,273 ****
include("$phpbb_root_path/includes/db/db_tools.$phpEx");
}
$db_tool = new phpbb_db_tools($db);
! $tables = array(QUESTIONS_TABLE, ANSWERS_TABLE, QA_CONFIRM_TABLE);
$schemas = array(
! QUESTIONS_TABLE => array (
'COLUMNS' => array(
'question_id' => array('UINT', Null, 'auto_increment'),
'strict' => array('BOOL', 0),
--- 274,283 ----
include("$phpbb_root_path/includes/db/db_tools.$phpEx");
}
$db_tool = new phpbb_db_tools($db);
! $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE, CAPTCHA_QA_CONFIRM_TABLE);
$schemas = array(
! CAPTCHA_QUESTIONS_TABLE => array (
'COLUMNS' => array(
'question_id' => array('UINT', Null, 'auto_increment'),
'strict' => array('BOOL', 0),
***************
*** 280,286 ****
'lang_iso' => array('INDEX', 'lang_iso'),
),
),
! ANSWERS_TABLE => array (
'COLUMNS' => array(
'question_id' => array('UINT', 0),
'answer_text' => array('STEXT_UNI', ''),
--- 290,296 ----
'lang_iso' => array('INDEX', 'lang_iso'),
),
),
! CAPTCHA_ANSWERS_TABLE => array (
'COLUMNS' => array(
'question_id' => array('UINT', 0),
'answer_text' => array('STEXT_UNI', ''),
***************
*** 289,295 ****
'question_id' => array('INDEX', 'question_id'),
),
),
! QA_CONFIRM_TABLE => array (
'COLUMNS' => array(
'session_id' => array('CHAR:32', ''),
'confirm_id' => array('CHAR:32', ''),
--- 299,305 ----
'question_id' => array('INDEX', 'question_id'),
),
),
! CAPTCHA_QA_CONFIRM_TABLE => array (
'COLUMNS' => array(
'session_id' => array('CHAR:32', ''),
'confirm_id' => array('CHAR:32', ''),
***************
*** 363,369 ****
$this->confirm_id = md5(unique_id($user->ip));
$this->question = (int) array_rand($this->question_ids);
! $sql = 'INSERT INTO ' . QA_CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'confirm_id' => (string) $this->confirm_id,
'session_id' => (string) $user->session_id,
'lang_iso' => (string) $this->question_lang,
--- 373,379 ----
$this->confirm_id = md5(unique_id($user->ip));
$this->question = (int) array_rand($this->question_ids);
! $sql = 'INSERT INTO ' . CAPTCHA_QA_CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'confirm_id' => (string) $this->confirm_id,
'session_id' => (string) $user->session_id,
'lang_iso' => (string) $this->question_lang,
***************
*** 386,392 ****
$this->solved = 0;
// compute $seed % 0x7fffffff
! $sql = 'UPDATE ' . QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'question' => (int) $this->question,)) . '
WHERE
confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\'
--- 396,402 ----
$this->solved = 0;
// compute $seed % 0x7fffffff
! $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'question' => (int) $this->question,)) . '
WHERE
confirm_id = \'' . $db->sql_escape($this->confirm_id) . '\'
***************
*** 407,413 ****
$this->solved = 0;
// compute $seed % 0x7fffffff
! $sql = 'UPDATE ' . QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'question_id' => (int) $this->question)) . ',
attempts = attempts + 1
WHERE
--- 417,423 ----
$this->solved = 0;
// compute $seed % 0x7fffffff
! $sql = 'UPDATE ' . CAPTCHA_QA_CONFIRM_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'question_id' => (int) $this->question)) . ',
attempts = attempts + 1
WHERE
***************
*** 425,431 ****
global $db, $user;
$sql = 'SELECT con.question_id, attempts, question_text, strict
! FROM ' . QA_CONFIRM_TABLE . ' con, ' . 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) . "'
--- 435,441 ----
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) . "'
***************
*** 457,463 ****
$answer = ($this->question_strict) ? request_var('qa_answer', '', true) : utf8_clean_string(request_var('qa_answer', '', true));
$sql = 'SELECT answer_text
! FROM ' . ANSWERS_TABLE . '
WHERE question_id = ' . (int) $this->question;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
--- 467,473 ----
$answer = ($this->question_strict) ? request_var('qa_answer', '', true) : utf8_clean_string(request_var('qa_answer', '', true));
$sql = 'SELECT answer_text
! FROM ' . CAPTCHA_ANSWERS_TABLE . '
WHERE question_id = ' . (int) $this->question;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
***************
*** 480,486 ****
{
global $db, $user;
! $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_type = " . $this->type;
--- 490,496 ----
{
global $db, $user;
! $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_type = " . $this->type;
***************
*** 502,508 ****
{
global $db, $user;
! $sql = 'DELETE FROM ' . QA_CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_type = " . (int) $this->type;
$db->sql_query($sql);
--- 512,518 ----
{
global $db, $user;
! $sql = 'DELETE FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_type = " . (int) $this->type;
$db->sql_query($sql);
***************
*** 666,672 ****
{
global $db, $template;
! $sql = 'SELECT * FROM ' . QUESTIONS_TABLE . ' WHERE 1';
$result = $db->sql_query($sql);
$template->assign_vars(array(
'S_LIST' => true,
--- 676,682 ----
{
global $db, $template;
! $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE 1';
$result = $db->sql_query($sql);
$template->assign_vars(array(
'S_LIST' => true,
***************
*** 697,703 ****
if ($question_id)
{
! $sql = 'SELECT * FROM ' . QUESTIONS_TABLE . ' WHERE question_id = ' . $question_id;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
--- 707,713 ----
if ($question_id)
{
! $sql = 'SELECT * FROM ' . CAPTCHA_QUESTIONS_TABLE . ' WHERE question_id = ' . $question_id;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
***************
*** 709,715 ****
return false;
}
$question['answers'] = array();
! $sql = 'SELECT * FROM ' . ANSWERS_TABLE . ' WHERE question_id = ' . $question_id;
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
--- 719,725 ----
return false;
}
$question['answers'] = array();
! $sql = 'SELECT * FROM ' . CAPTCHA_ANSWERS_TABLE . ' WHERE question_id = ' . $question_id;
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
***************
*** 748,760 ****
global $db;
// easier to delete all answers than to figure out which to update
! $sql = "DELETE FROM " . ANSWERS_TABLE . " WHERE question_id = $question_id";
$db->sql_query($sql);
$langs = $this->get_languages();
$question_ary = $data;
$question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id'];
unset($question_ary['answers']);
! $sql = "UPDATE " . QUESTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $question_ary) . "
WHERE question_id = $question_id";
$db->sql_query($sql);
$this->acp_insert_answers($data, $question_id);
--- 758,770 ----
global $db;
// easier to delete all answers than to figure out which to update
! $sql = "DELETE FROM " . CAPTCHA_ANSWERS_TABLE . " WHERE question_id = $question_id";
$db->sql_query($sql);
$langs = $this->get_languages();
$question_ary = $data;
$question_ary['lang_id'] = $langs[$question_ary['lang_iso']]['id'];
unset($question_ary['answers']);
! $sql = "UPDATE " . CAPTCHA_QUESTIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $question_ary) . "
WHERE question_id = $question_id";
$db->sql_query($sql);
$this->acp_insert_answers($data, $question_id);
***************
*** 773,779 ****
$question_ary['lang_id'] = $langs[$data['lang_iso']]['id'];
unset($question_ary['answers']);
! $sql = "INSERT INTO " . QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary);
$db->sql_query($sql);
$question_id = $db->sql_nextid();
$this->acp_insert_answers($data, $question_id);
--- 783,789 ----
$question_ary['lang_id'] = $langs[$data['lang_iso']]['id'];
unset($question_ary['answers']);
! $sql = "INSERT INTO " . CAPTCHA_QUESTIONS_TABLE . $db->sql_build_array('INSERT', $question_ary);
$db->sql_query($sql);
$question_id = $db->sql_nextid();
$this->acp_insert_answers($data, $question_id);
***************
*** 793,799 ****
'question_id' => $question_id,
'answer_text' => $answer,
);
! $sql = "INSERT INTO " . ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary);
$db->sql_query($sql);
}
}
--- 803,809 ----
'question_id' => $question_id,
'answer_text' => $answer,
);
! $sql = "INSERT INTO " . CAPTCHA_ANSWERS_TABLE . $db->sql_build_array('INSERT', $answer_ary);
$db->sql_query($sql);
}
}
***************
*** 806,812 ****
{
global $db;
! $tables = array(QUESTIONS_TABLE, ANSWERS_TABLE);
foreach($tables as $table)
{
$sql = "DELETE FROM $table WHERE question_id = $question_id";
--- 816,822 ----
{
global $db;
! $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE);
foreach($tables as $table)
{
$sql = "DELETE FROM $table WHERE question_id = $question_id";
Modified: branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php Fri Aug 14 11:00:30 2009
***************
*** 54,59 ****
--- 54,67 ----
$user->add_lang('captcha_recaptcha');
return (isset($config['recaptcha_pubkey']) && !empty($config['recaptcha_pubkey']));
}
+
+ /**
+ * API function
+ */
+ function has_config()
+ {
+ return true;
+ }
function get_name()
{
|