mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-04 14:47:52 +02:00
marge
git-svn-id: file:///svn/phpbb/trunk@8696 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d8f2c4a1c4
commit
1b67e80422
@ -690,7 +690,29 @@ $sql = 'UPDATE ' . SOME_TABLE . '
|
||||
$db->sql_query($sql);
|
||||
</pre></div>
|
||||
|
||||
<p>The <code>$db->sql_build_array()</code> function supports the following modes: <code>INSERT</code> (example above), <code>INSERT_SELECT</code> (building query for <code>INSERT INTO table (...) SELECT value, column ...</code> statements), <code>MULTI_INSERT</code> (for returning extended inserts), <code>UPDATE</code> (example above) and <code>SELECT</code> (for building WHERE statement [AND logic]).</p>
|
||||
<p>The <code>$db->sql_build_array()</code> function supports the following modes: <code>INSERT</code> (example above), <code>INSERT_SELECT</code> (building query for <code>INSERT INTO table (...) SELECT value, column ...</code> statements), <code>UPDATE</code> (example above) and <code>SELECT</code> (for building WHERE statement [AND logic]).</p>
|
||||
|
||||
<h4>sql_multi_insert():</h4>
|
||||
|
||||
<p>If you want to insert multiple statements at once, please use the separate <code>sql_multi_insert()</code> method. An example:</p>
|
||||
|
||||
<div class="codebox"><pre>
|
||||
$sql_ary = array();
|
||||
|
||||
$sql_ary[] = array(
|
||||
'somedata' => $my_string_1,
|
||||
'otherdata' => $an_int_1,
|
||||
'moredata' => $another_int_1,
|
||||
);
|
||||
|
||||
$sql_ary[] = array(
|
||||
'somedata' => $my_string_2,
|
||||
'otherdata' => $an_int_2,
|
||||
'moredata' => $another_int_2,
|
||||
);
|
||||
|
||||
$db->sql_multi_insert(SOME_TABLE, $sql_ary);
|
||||
</pre></div>
|
||||
|
||||
<h4>sql_in_set():</h4>
|
||||
|
||||
@ -2201,6 +2223,13 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
|
||||
|
||||
<div class="content">
|
||||
|
||||
<h3>Revision 8596+</h3>
|
||||
|
||||
<ul>
|
||||
<li>Removed sql_build_array('MULTI_INSERT'... statements.</li>
|
||||
<li>Added sql_multi_insert() explanation.</li>
|
||||
</ul>
|
||||
|
||||
<h3>Revision 1.31</h3>
|
||||
|
||||
<ul>
|
||||
|
@ -34,7 +34,7 @@ class dbal
|
||||
var $query_hold = '';
|
||||
var $html_hold = '';
|
||||
var $sql_report = '';
|
||||
|
||||
|
||||
var $persistency = false;
|
||||
var $user = '';
|
||||
var $server = '';
|
||||
@ -47,7 +47,7 @@ class dbal
|
||||
var $sql_error_sql = '';
|
||||
// Holding the error information - only populated if sql_error_triggered is set
|
||||
var $sql_error_returned = array();
|
||||
|
||||
|
||||
// Holding transaction count
|
||||
var $transactions = 0;
|
||||
|
||||
@ -146,7 +146,7 @@ class dbal
|
||||
{
|
||||
$this->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
|
||||
return $this->_sql_close();
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ class dbal
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ class dbal
|
||||
* Build sql statement from array for insert/update/select statements
|
||||
*
|
||||
* Idea for this from Ikonboard
|
||||
* Possible query values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT
|
||||
* Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT
|
||||
*
|
||||
*/
|
||||
function sql_build_array($query, $assoc_ary = false)
|
||||
@ -336,24 +336,7 @@ class dbal
|
||||
}
|
||||
else if ($query == 'MULTI_INSERT')
|
||||
{
|
||||
$ary = array();
|
||||
foreach ($assoc_ary as $id => $sql_ary)
|
||||
{
|
||||
// If by accident the sql array is only one-dimensional we build a normal insert statement
|
||||
if (!is_array($sql_ary))
|
||||
{
|
||||
return $this->sql_build_array('INSERT', $assoc_ary);
|
||||
}
|
||||
|
||||
$values = array();
|
||||
foreach ($sql_ary as $key => $var)
|
||||
{
|
||||
$values[] = $this->_sql_validate_value($var);
|
||||
}
|
||||
$ary[] = '(' . implode(', ', $values) . ')';
|
||||
}
|
||||
|
||||
$query = ' (' . implode(', ', array_keys($assoc_ary[0])) . ') VALUES ' . implode(', ', $ary);
|
||||
trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR);
|
||||
}
|
||||
else if ($query == 'UPDATE' || $query == 'SELECT')
|
||||
{
|
||||
@ -438,7 +421,25 @@ class dbal
|
||||
|
||||
if ($this->multi_insert)
|
||||
{
|
||||
$this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('MULTI_INSERT', $sql_ary));
|
||||
$ary = array();
|
||||
foreach ($sql_ary as $id => $_sql_ary)
|
||||
{
|
||||
// If by accident the sql array is only one-dimensional we build a normal insert statement
|
||||
if (!is_array($_sql_ary))
|
||||
{
|
||||
$query = $this->sql_build_array('INSERT', $sql_ary);
|
||||
break;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
foreach ($_sql_ary as $key => $var)
|
||||
{
|
||||
$values[] = $this->_sql_validate_value($var);
|
||||
}
|
||||
$ary[] = '(' . implode(', ', $values) . ')';
|
||||
}
|
||||
|
||||
$this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -703,7 +704,7 @@ class dbal
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
' . $this->html_hold . '
|
||||
|
||||
<p style="text-align: center;">
|
||||
@ -731,24 +732,24 @@ class dbal
|
||||
case 'start':
|
||||
$this->query_hold = $query;
|
||||
$this->html_hold = '';
|
||||
|
||||
|
||||
$this->_sql_report($mode, $query);
|
||||
|
||||
$this->curtime = explode(' ', microtime());
|
||||
$this->curtime = $this->curtime[0] + $this->curtime[1];
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'add_select_row':
|
||||
|
||||
$html_table = func_get_arg(2);
|
||||
$row = func_get_arg(3);
|
||||
|
||||
|
||||
if (!$html_table && sizeof($row))
|
||||
{
|
||||
$html_table = true;
|
||||
$this->html_hold .= '<table cellspacing="1"><tr>';
|
||||
|
||||
|
||||
foreach (array_keys($row) as $val)
|
||||
{
|
||||
$this->html_hold .= '<th>' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '</th>';
|
||||
@ -764,7 +765,7 @@ class dbal
|
||||
$this->html_hold .= '<td class="' . $class . '">' . (($val) ? $val : ' ') . '</td>';
|
||||
}
|
||||
$this->html_hold .= '</tr>';
|
||||
|
||||
|
||||
return $html_table;
|
||||
|
||||
break;
|
||||
@ -795,7 +796,7 @@ class dbal
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
|
||||
$this->_sql_report($mode, $query);
|
||||
|
||||
break;
|
||||
|
@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Code from pear.php.net, Text_Diff-0.2.1 (beta) package
|
||||
* Code from pear.php.net, Text_Diff-1.0.0 package
|
||||
* http://pear.php.net/package/Text_Diff/
|
||||
*
|
||||
* Modified by phpBB Group to meet our coding standards
|
||||
@ -26,6 +26,9 @@ if (!defined('IN_PHPBB'))
|
||||
* General API for generating and formatting diffs - the differences between
|
||||
* two sequences of strings.
|
||||
*
|
||||
* Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
|
||||
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
|
||||
*
|
||||
* @package diff
|
||||
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
|
||||
*/
|
||||
@ -45,7 +48,7 @@ class diff
|
||||
*/
|
||||
function __construct(&$from_content, &$to_content, $preserve_cr = true)
|
||||
{
|
||||
$diff_engine = &new diff_engine();
|
||||
$diff_engine = new diff_engine();
|
||||
$this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr);
|
||||
}
|
||||
|
||||
@ -62,7 +65,7 @@ class diff
|
||||
*
|
||||
* Example:
|
||||
* <code>
|
||||
* $diff = &new diff($lines1, $lines2);
|
||||
* $diff = new diff($lines1, $lines2);
|
||||
* $rev = $diff->reverse();
|
||||
* </code>
|
||||
*
|
||||
@ -285,7 +288,7 @@ class diff_op
|
||||
var $orig;
|
||||
var $final;
|
||||
|
||||
function reverse()
|
||||
function &reverse()
|
||||
{
|
||||
trigger_error('[diff] Abstract method', E_USER_ERROR);
|
||||
}
|
||||
@ -413,7 +416,7 @@ class diff3 extends diff
|
||||
*/
|
||||
function diff3(&$orig, &$final1, &$final2)
|
||||
{
|
||||
$diff_engine = &new diff_engine();
|
||||
$diff_engine = new diff_engine();
|
||||
|
||||
$diff_1 = $diff_engine->diff($orig, $final1);
|
||||
$diff_2 = $diff_engine->diff($orig, $final2);
|
||||
@ -548,7 +551,7 @@ class diff3 extends diff
|
||||
function _diff3(&$edits1, &$edits2)
|
||||
{
|
||||
$edits = array();
|
||||
$bb = &new diff3_block_builder();
|
||||
$bb = new diff3_block_builder();
|
||||
|
||||
$e1 = current($edits1);
|
||||
$e2 = current($edits2);
|
||||
@ -565,7 +568,7 @@ class diff3 extends diff
|
||||
}
|
||||
|
||||
$ncopy = min($e1->norig(), $e2->norig());
|
||||
$edits[] = &new diff3_op_copy(array_slice($e1->orig, 0, $ncopy));
|
||||
$edits[] = new diff3_op_copy(array_slice($e1->orig, 0, $ncopy));
|
||||
|
||||
if ($e1->norig() > $ncopy)
|
||||
{
|
||||
@ -759,7 +762,7 @@ class diff3_block_builder
|
||||
}
|
||||
else
|
||||
{
|
||||
$edit = &new diff3_op($this->orig, $this->final1, $this->final2);
|
||||
$edit = new diff3_op($this->orig, $this->final1, $this->final2);
|
||||
$this->_init();
|
||||
return $edit;
|
||||
}
|
||||
|
@ -17,21 +17,20 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Code from pear.php.net, Text_Diff-0.2.1 (beta) package
|
||||
* http://pear.php.net/package/Text_Diff/
|
||||
* Code from pear.php.net, Text_Diff-1.0.0 package
|
||||
* http://pear.php.net/package/Text_Diff/ (native engine)
|
||||
*
|
||||
* Modified by phpBB Group to meet our coding standards
|
||||
* and being able to integrate into phpBB
|
||||
*
|
||||
* Class used internally by Diff to actually compute the diffs. This class is
|
||||
* implemented using native PHP code.
|
||||
* Class used internally by Text_Diff to actually compute the diffs. This
|
||||
* class is implemented using native PHP code.
|
||||
*
|
||||
* The algorithm used here is mostly lifted from the perl module
|
||||
* Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
|
||||
* http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip
|
||||
*
|
||||
* More ideas are taken from:
|
||||
* http://www.ics.uci.edu/~eppstein/161/960229.html
|
||||
* More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html
|
||||
*
|
||||
* Some ideas (and a bit of code) are taken from analyze.c, of GNU
|
||||
* diffutils-2.7, which can be found at:
|
||||
@ -41,6 +40,8 @@ if (!defined('IN_PHPBB'))
|
||||
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
|
||||
* code was written by him, and is used/adapted with his permission.
|
||||
*
|
||||
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
|
||||
*
|
||||
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
|
||||
* @package diff
|
||||
*
|
||||
@ -251,7 +252,7 @@ class diff_engine
|
||||
}
|
||||
}
|
||||
|
||||
$x1 = $xoff + (int)(($numer + ($xlim-$xoff)*$chunk) / $nchunks);
|
||||
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
|
||||
|
||||
for (; $x < $x1; $x++)
|
||||
{
|
||||
@ -262,7 +263,8 @@ class diff_engine
|
||||
}
|
||||
$matches = $ymatches[$line];
|
||||
|
||||
foreach ($matches as $y)
|
||||
reset($matches);
|
||||
while (list(, $y) = each($matches))
|
||||
{
|
||||
if (empty($this->in_seq[$y]))
|
||||
{
|
||||
@ -273,7 +275,7 @@ class diff_engine
|
||||
}
|
||||
|
||||
// no reset() here
|
||||
while (list($junk, $y) = each($matches))
|
||||
while (list(, $y) = each($matches))
|
||||
{
|
||||
if ($y > $this->seq[$k - 1])
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Code from pear.php.net, Text_Diff-0.2.1 (beta) package
|
||||
* Code from pear.php.net, Text_Diff-1.0.0 package
|
||||
* http://pear.php.net/package/Text_Diff/
|
||||
*
|
||||
* Modified by phpBB Group to meet our coding standards
|
||||
@ -28,6 +28,8 @@ if (!defined('IN_PHPBB'))
|
||||
* This class renders the diff in classic diff format. It is intended that
|
||||
* this class be customized via inheritance, to obtain fancier outputs.
|
||||
*
|
||||
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
|
||||
*
|
||||
* @package diff
|
||||
*/
|
||||
class diff_renderer
|
||||
@ -105,7 +107,7 @@ class diff_renderer
|
||||
|
||||
unset($diff3);
|
||||
|
||||
$diff = &new diff($diff_1, $diff_2);
|
||||
$diff = new diff($diff_1, $diff_2);
|
||||
}
|
||||
|
||||
$nlead = $this->_leading_context_lines;
|
||||
@ -116,19 +118,24 @@ class diff_renderer
|
||||
|
||||
foreach ($diffs as $i => $edit)
|
||||
{
|
||||
// If these are unchanged (copied) lines, and we want to keep leading or trailing context lines, extract them from the copy block.
|
||||
if (is_a($edit, 'diff_op_copy'))
|
||||
{
|
||||
// Do we have any diff blocks yet?
|
||||
if (is_array($block))
|
||||
{
|
||||
// How many lines to keep as context from the copy block.
|
||||
$keep = ($i == sizeof($diffs) - 1) ? $ntrail : $nlead + $ntrail;
|
||||
if (sizeof($edit->orig) <= $keep)
|
||||
{
|
||||
// We have less lines in the block than we want for context => keep the whole block.
|
||||
$block[] = $edit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($ntrail)
|
||||
{
|
||||
// Create a new block with as many lines as we need for the trailing context.
|
||||
$context = array_slice($edit->orig, 0, $ntrail);
|
||||
$block[] = &new diff_op_copy($context);
|
||||
}
|
||||
@ -137,12 +144,15 @@ class diff_renderer
|
||||
$block = false;
|
||||
}
|
||||
}
|
||||
// Keep the copy block as the context for the next block.
|
||||
$context = $edit->orig;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't we have any diff blocks yet?
|
||||
if (!is_array($block))
|
||||
{
|
||||
// Extract context lines from the preceding copy block.
|
||||
$context = array_slice($context, sizeof($context) - $nlead);
|
||||
$x0 = $xi - sizeof($context);
|
||||
$y0 = $yi - sizeof($context);
|
||||
@ -219,6 +229,16 @@ class diff_renderer
|
||||
$ybeg .= ',' . ($ybeg + $ylen - 1);
|
||||
}
|
||||
|
||||
// this matches the GNU Diff behaviour
|
||||
if ($xlen && !$ylen)
|
||||
{
|
||||
$ybeg--;
|
||||
}
|
||||
else if (!$xlen)
|
||||
{
|
||||
$xbeg--;
|
||||
}
|
||||
|
||||
return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
|
||||
}
|
||||
|
||||
@ -449,11 +469,11 @@ class diff_renderer_inline extends diff_renderer
|
||||
$splitted_text_1 = $this->_split_on_words($text1, $nl);
|
||||
$splitted_text_2 = $this->_split_on_words($text2, $nl);
|
||||
|
||||
$diff = &new diff($splitted_text_1, $splitted_text_2);
|
||||
$diff = new diff($splitted_text_1, $splitted_text_2);
|
||||
unset($splitted_text_1, $splitted_text_2);
|
||||
|
||||
// Get the diff in inline format.
|
||||
$renderer = &new diff_renderer_inline(array_merge($this->get_params(), array('split_level' => 'words')));
|
||||
$renderer = new diff_renderer_inline(array_merge($this->get_params(), array('split_level' => 'words')));
|
||||
|
||||
// Run the diff and get the output.
|
||||
return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
|
||||
|
@ -356,6 +356,11 @@ function phpbb_hash($password)
|
||||
|
||||
/**
|
||||
* Check for correct password
|
||||
*
|
||||
* @param string $password The password in plain text
|
||||
* @param string $hash The stored password hash
|
||||
*
|
||||
* @return bool Returns true if the password is correct, false if not.
|
||||
*/
|
||||
function phpbb_check_hash($password, $hash)
|
||||
{
|
||||
|
@ -399,13 +399,11 @@ class jabber
|
||||
$second_time = isset($this->session['id']);
|
||||
$this->session['id'] = $xml['stream:stream'][0]['@']['id'];
|
||||
|
||||
/** Currently commented out due to problems with some jabber server - reason unknown
|
||||
if ($second_time)
|
||||
{
|
||||
// If we are here for the second time after TLS, we need to continue logging in
|
||||
$this->login();
|
||||
return;
|
||||
}*/
|
||||
return $this->login();
|
||||
}
|
||||
|
||||
// go on with authentication?
|
||||
if (isset($this->features['stream:features'][0]['#']['bind']) || !empty($this->session['tls']))
|
||||
|
@ -1432,7 +1432,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
|
||||
$sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
|
||||
}
|
||||
|
||||
$sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
|
||||
$sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
|
||||
|
||||
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
|
||||
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
||||
|
@ -1837,7 +1837,7 @@ class user extends session
|
||||
|
||||
if ((@include $language_filename) === false)
|
||||
{
|
||||
trigger_error('Language file ' . basename($language_filename) . ' couldn\'t be opened.', E_USER_ERROR);
|
||||
trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
else if ($use_db)
|
||||
|
@ -176,6 +176,7 @@ $sql_array = array(
|
||||
|
||||
'FROM' => array(
|
||||
FORUMS_TABLE => 'f',
|
||||
TOPICS_TABLE => 't',
|
||||
)
|
||||
);
|
||||
|
||||
@ -239,7 +240,6 @@ else
|
||||
}
|
||||
|
||||
$sql_array['WHERE'] .= ')';
|
||||
$sql_array['FROM'][TOPICS_TABLE] = 't';
|
||||
|
||||
// Join to forum table on topic forum_id unless topic forum_id is zero
|
||||
// whereupon we join on the forum_id passed as a parameter ... this
|
||||
|
Loading…
x
Reference in New Issue
Block a user