Zeile 1986 | Zeile 1986 |
---|
}
// Less than 0? That's bad
|
}
// Less than 0? That's bad
|
if(!$update_query[$counter])
| if($update_query[$counter] < 0)
|
{ $update_query[$counter] = 0; }
| { $update_query[$counter] = 0; }
|
Zeile 1995 | Zeile 1995 |
---|
// Only update if we're actually doing something if(count($update_query) > 0)
|
// Only update if we're actually doing something if(count($update_query) > 0)
|
{
| {
|
$db->update_query("forums", $update_query, "fid='".intval($fid)."'"); }
// Guess we should update the statistics too?
|
$db->update_query("forums", $update_query, "fid='".intval($fid)."'"); }
// Guess we should update the statistics too?
|
if(isset($update_query['threads']) || isset($update_query['posts']) || isset($update_query['unapprovedthreads']) || isset($update_query['unapprovedposts'])) { $new_stats = array(); if(array_key_exists('threads', $update_query)) { $threads_diff = $update_query['threads'] - $forum['threads']; if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}"; } else { $new_stats['numthreads'] = "{$threads_diff}"; } }
if(array_key_exists('unapprovedthreads', $update_query)) { $unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads']; if($unapprovedthreads_diff > -1) { $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}"; } else { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}"; } }
| $new_stats = array(); if(array_key_exists('threads', $update_query)) { $threads_diff = $update_query['threads'] - $forum['threads']; if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}"; } else { $new_stats['numthreads'] = "{$threads_diff}"; } }
if(array_key_exists('unapprovedthreads', $update_query)) { $unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads']; if($unapprovedthreads_diff > -1) { $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}"; } else { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}"; } }
if(array_key_exists('posts', $update_query)) { $posts_diff = $update_query['posts'] - $forum['posts']; if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}"; } else { $new_stats['numposts'] = "{$posts_diff}"; } }
|
|
|
if(array_key_exists('posts', $update_query))
| if(array_key_exists('unapprovedposts', $update_query)) { $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts']; if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}"; } else
|
{
|
{
|
$posts_diff = $update_query['posts'] - $forum['posts']; if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}"; } else { $new_stats['numposts'] = "{$posts_diff}"; } }
if(array_key_exists('unapprovedposts', $update_query)) { $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts']; if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}"; } else { $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; }
| $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
|
}
|
}
|
| }
if(!empty($new_stats)) {
|
update_stats($new_stats); }
|
update_stats($new_stats); }
|
|
|
// Update last post info update_forum_lastpost($fid);
$cache->update_forums(); }
|
// Update last post info update_forum_lastpost($fid);
$cache->update_forums(); }
|
|
|
/** * Update the last post information for a specific forum *
| /** * Update the last post information for a specific forum *
|
Zeile 2079 | Zeile 2080 |
---|
WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%' ORDER BY lastpost DESC LIMIT 0, 1
|
WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%' ORDER BY lastpost DESC LIMIT 0, 1
|
");
| ");
|
$lastpost = $db->fetch_array($query);
$updated_forum = array(
| $lastpost = $db->fetch_array($query);
$updated_forum = array(
|
Zeile 2095 | Zeile 2096 |
---|
/** * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
|
/** * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
|
* * @param int The thread ID
| * * @param int The thread ID
|
* @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1) */ function update_thread_counters($tid, $changes=array())
| * @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1) */ function update_thread_counters($tid, $changes=array())
|
Zeile 2104 | Zeile 2105 |
---|
global $db;
$update_query = array();
|
global $db;
$update_query = array();
|
|
|
$counters = array('replies','unapprovedposts','attachmentcount', 'attachmentcount');
// Fetch above counters for this thread
| $counters = array('replies','unapprovedposts','attachmentcount', 'attachmentcount');
// Fetch above counters for this thread
|
Zeile 2148 | Zeile 2149 |
---|
/** * Update the first post and lastpost data for a specific thread
|
/** * Update the first post and lastpost data for a specific thread
|
* * @param int The thread ID
| * * @param int The thread ID
|
*/ function update_thread_data($tid) {
| */ function update_thread_data($tid) {
|
Zeile 2185 | Zeile 2186 |
---|
"); $firstpost = $db->fetch_array($query);
|
"); $firstpost = $db->fetch_array($query);
|
$db->free_result($query);
| $db->free_result($query);
|
if(!$firstpost['username']) { $firstpost['username'] = $firstpost['postusername']; }
if(!$lastpost['username'])
|
if(!$firstpost['username']) { $firstpost['username'] = $firstpost['postusername']; }
if(!$lastpost['username'])
|
{
| {
|
$lastpost['username'] = $lastpost['postusername']; }
| $lastpost['username'] = $lastpost['postusername']; }
|
Zeile 2218 | Zeile 2219 |
---|
$db->update_query("threads", $update_array, "tid='{$tid}'");
unset($firstpost, $lastpost, $update_array);
|
$db->update_query("threads", $update_array, "tid='{$tid}'");
unset($firstpost, $lastpost, $update_array);
|
}
| }
|
function update_forum_count($fid) { die("Deprecated function call: update_forum_count");
| function update_forum_count($fid) { die("Deprecated function call: update_forum_count");
|
Zeile 2360 | Zeile 2361 |
---|
}
if($showextras == 0)
|
}
if($showextras == 0)
|
{
| {
|
$template = "special"; } else
| $template = "special"; } else
|
Zeile 2368 | Zeile 2369 |
---|
$template = "advanced";
if(strpos(FORUM_URL, '.html') !== false)
|
$template = "advanced";
if(strpos(FORUM_URL, '.html') !== false)
|
{
| {
|
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'"; } else
| $forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'"; } else
|
Zeile 2385 | Zeile 2386 |
---|
/** * Returns the extension of a file.
|
/** * Returns the extension of a file.
|
*
| *
|
* @param string The filename. * @return string The extension of the file. */ function get_extension($file) { return my_strtolower(my_substr(strrchr($file, "."), 1));
|
* @param string The filename. * @return string The extension of the file. */ function get_extension($file) { return my_strtolower(my_substr(strrchr($file, "."), 1));
|
}
/**
| }
/**
|
* Generates a random string. * * @param int The length of the string to generate.
| * Generates a random string. * * @param int The length of the string to generate.
|
Zeile 2429 | Zeile 2430 |
---|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
| }
|
if($displaygroup != 0) { $usergroup = $displaygroup;
| if($displaygroup != 0) { $usergroup = $displaygroup;
|
Zeile 2570 | Zeile 2571 |
---|
}
unset($smilie);
|
}
unset($smilie);
|
|
|
if(is_array($smiliecache)) { reset($smiliecache);
| if(is_array($smiliecache)) { reset($smiliecache);
|
Zeile 2709 | Zeile 2710 |
---|
$groups = array($mybb->user['usergroup']); if($mybb->user['additionalgroups'])
|
$groups = array($mybb->user['usergroup']); if($mybb->user['additionalgroups'])
|
{
| {
|
$exp = explode(",", $mybb->user['additionalgroups']);
foreach($exp as $group)
| $exp = explode(",", $mybb->user['additionalgroups']);
foreach($exp as $group)
|
Zeile 2848 | Zeile 2849 |
---|
$gzdata .= pack("V", $crc); $gzdata .= pack("V", $size); $contents = $gzdata;
|
$gzdata .= pack("V", $crc); $gzdata .= pack("V", $size); $contents = $gzdata;
|
} }
| } }
|
}
return $contents;
| }
return $contents;
|
Zeile 2874 | Zeile 2875 |
---|
{ $fid = $data['fid']; unset($data['fid']);
|
{ $fid = $data['fid']; unset($data['fid']);
|
}
| }
|
if($data['tid'] == '') {
| if($data['tid'] == '') {
|
Zeile 2891 | Zeile 2892 |
---|
{ $data = serialize($data); }
|
{ $data = serialize($data); }
|
|
|
$time = TIME_NOW;
$sql_array = array(
| $time = TIME_NOW;
$sql_array = array(
|
Zeile 2918 | Zeile 2919 |
---|
global $theme;
$display_reputation = '';
|
global $theme;
$display_reputation = '';
|
if($uid != 0)
| if($uid != 0)
|
{ $display_reputation = "<a href=\"reputation.php?uid={$uid}\">"; }
| { $display_reputation = "<a href=\"reputation.php?uid={$uid}\">"; }
|
Zeile 2937 | Zeile 2938 |
---|
else { $display_reputation .= "reputation_neutral";
|
else { $display_reputation .= "reputation_neutral";
|
}
| }
|
$display_reputation .= "\">{$reputation}</strong>";
| $display_reputation .= "\">{$reputation}</strong>";
|
Zeile 2954 | Zeile 2955 |
---|
* * @param int The warning level (percentage of 100) * @return string Formatted warning level
|
* * @param int The warning level (percentage of 100) * @return string Formatted warning level
|
*/
| */
|
function get_colored_warning_level($level) { if($level >= 80)
| function get_colored_warning_level($level) { if($level >= 80)
|
Zeile 2989 | Zeile 2990 |
---|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR'];
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR'];
|
}
| }
|
if($mybb->settings['ip_forwarded_check']) {
| if($mybb->settings['ip_forwarded_check']) {
|
Zeile 3041 | Zeile 3042 |
---|
function get_friendly_size($size) { global $lang;
|
function get_friendly_size($size) { global $lang;
|
|
|
if(!is_numeric($size)) { return $lang->na;
| if(!is_numeric($size)) { return $lang->na;
|
Zeile 3059 | Zeile 3060 |
---|
} // Exabyte (1024 Petabytes) elseif($size >= 1152921504606846976)
|
} // Exabyte (1024 Petabytes) elseif($size >= 1152921504606846976)
|
{
| {
|
$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb; } // Petabyte (1024 Terabytes)
| $size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb; } // Petabyte (1024 Terabytes)
|
Zeile 3086 | Zeile 3087 |
---|
elseif($size >= 1024) { $size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;
|
elseif($size >= 1024) { $size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;
|
}
| }
|
elseif($size == 0)
|
elseif($size == 0)
|
{
| {
|
$size = "0 ".$lang->size_bytes;
|
$size = "0 ".$lang->size_bytes;
|
}
| }
|
else { $size = my_number_format($size)." ".$lang->size_bytes;
|
else { $size = my_number_format($size)." ".$lang->size_bytes;
|
}
| }
|
return $size; }
| return $size; }
|
Zeile 3130 | Zeile 3131 |
---|
{ global $change_dir; $icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
|
{ global $change_dir; $icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
|
} else {
| } else {
|
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); } return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
| $icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); } return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
|
Zeile 6209 | Zeile 6210 |
---|
{ $output = '';
|
{ $output = '';
|
| // Use OpenSSL when available // PHP <5.3.4 had a bug which makes that function unusable on Windows if(function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>=')) { $output = openssl_random_pseudo_bytes($count); }
|
// Try the unix/linux method
|
// Try the unix/linux method
|
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
| elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
|
{ $output = @fread($handle, $count); @fclose($handle);
|
{ $output = @fread($handle, $count); @fclose($handle);
|
}
| } // Try Windows CAPICOM before using our own generator elseif(class_exists('COM')) { try { $CAPI_Util = new COM('CAPICOM.Utilities.1'); $output = $CAPI_Util->GetRandom($count, 0); } catch (Exception $ex) { } }
|
// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator if(strlen($output) < $count)
| // Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator if(strlen($output) < $count)
|
Zeile 6223 | Zeile 6240 |
---|
// Close to what PHP basically uses internally to seed, but not quite. $unique_state = microtime().@getmypid();
|
// Close to what PHP basically uses internally to seed, but not quite. $unique_state = microtime().@getmypid();
|
|
|
for($i = 0; $i < $count; $i += 16) { $unique_state = md5(microtime().$unique_state);
| for($i = 0; $i < $count; $i += 16) { $unique_state = md5(microtime().$unique_state);
|
Zeile 6233 | Zeile 6250 |
---|
// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters $output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));
|
// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters $output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));
|
|
|
return $output; }
| return $output; }
|
Zeile 6246 | Zeile 6263 |
---|
* @return int An integer equivalent of a secure hexadecimal seed */ function my_rand($min=null, $max=null, $force_seed=false)
|
* @return int An integer equivalent of a secure hexadecimal seed */ function my_rand($min=null, $max=null, $force_seed=false)
|
{
| {
|
static $seeded = false; static $obfuscator = 0;
| static $seeded = false; static $obfuscator = 0;
|
Zeile 6254 | Zeile 6271 |
---|
{ mt_srand(secure_seed_rng()); $seeded = true;
|
{ mt_srand(secure_seed_rng()); $seeded = true;
|
|
|
$obfuscator = abs((int) secure_seed_rng());
// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems. if($obfuscator > mt_getrandmax()) { $obfuscator -= mt_getrandmax();
|
$obfuscator = abs((int) secure_seed_rng());
// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems. if($obfuscator > mt_getrandmax()) { $obfuscator -= mt_getrandmax();
|
} }
| } }
|
if($min !== null && $max !== null) {
| if($min !== null && $max !== null) {
|
Zeile 6275 | Zeile 6292 |
---|
{ return mt_rand($min, $max); }
|
{ return mt_rand($min, $max); }
|
}
| }
|
else { $val = mt_rand() ^ $obfuscator; return $val;
|
else { $val = mt_rand() ^ $obfuscator; return $val;
|
} }
/**
| } }
/**
|
* More robust version of PHP's trim() function. It includes a list of UTF-16 blank characters * from http://kb.mozillazine.org/Network.IDN.blacklist_chars *
| * More robust version of PHP's trim() function. It includes a list of UTF-16 blank characters * from http://kb.mozillazine.org/Network.IDN.blacklist_chars *
|
Zeile 6428 | Zeile 6445 |
---|
}
return 0;
|
}
return 0;
|
}
/**
| }
/**
|
* Obtain the version of GD installed. * * @return float Version of GD
| * Obtain the version of GD installed. * * @return float Version of GD
|
Zeile 6469 | Zeile 6486 |
---|
}
/**
|
}
/**
|
* Handles 4 byte UTF-8 characters.
| * Validates an UTF-8 string.
|
*
|
*
|
* This can be used to either reject strings which contain 4 byte UTF-8 * characters, or replace them with question marks. This is limited to UTF-8 * collated databases using MySQL. * * Original: http://www.avidheap.org/2013/a-quick-way-to-normalize-a-utf8-string-when-your-mysql-database-is-not-utf8mb4 * * @param string The string to be checked. * @param bool If false don't return the string, only the boolean result. * @return mixed Return a string if the second parameter is true, boolean otherwise.
| * @param string The string to be checked * @param boolean Allow 4 byte UTF-8 characters? * @param boolean Return the cleaned string? * @return string/boolean Cleaned string or boolean
|
*/
|
*/
|
function utf8_handle_4byte_string($input, $return=true)
| function validate_utf8_string($input, $allow_mb4=true, $return=true)
|
{
|
{
|
global $config;
if($config['database']['type'] != 'mysql' && $config['database']['type'] != 'mysqli') { if($return == true) { return $input; } return true; }
$contains_4bytes = false; if(!empty($input)) { $utf8_2byte = 0xC0 /*1100 0000*/; $utf8_2byte_bmask = 0xE0 /*1110 0000*/;
$utf8_3byte = 0xE0 /*1110 0000*/; $utf8_3byte_bmask = 0XF0 /*1111 0000*/;
$utf8_4byte = 0xF0 /*1111 0000*/; $utf8_4byte_bmask = 0xF8 /*1111 1000*/;
$sanitized = "";
| // Valid UTF-8 sequence? if(!preg_match('##u', $input)) { $string = '';
|
$len = strlen($input);
|
$len = strlen($input);
|
for($i = 0; $i < $len; ++$i)
| for($i = 0; $i < $len; $i++)
|
{
|
{
|
$mb_char = $input[$i]; // Potentially a multibyte sequence $byte = ord($mb_char); if(($byte & $utf8_2byte_bmask) == $utf8_2byte)
| $c = ord($input[$i]); if($c > 128)
|
{
|
{
|
$mb_char .= $input[++$i]; } elseif(($byte & $utf8_3byte_bmask) == $utf8_3byte) { $mb_char .= $input[++$i]; $mb_char .= $input[++$i];
| if($c > 247 || $c <= 191) { if($return) { $string .= '?'; continue; } else { return false; } } elseif($c > 239) { $bytes = 4; } elseif($c > 223) { $bytes = 3; } elseif($c > 191) { $bytes = 2; } if(($i + $bytes) > $len) { if($return) { $string .= '?'; break; } else { return false; } } $valid = true; $multibytes = $input[$i]; while($bytes > 1) { $i++; $b = ord($input[$i]); if($b < 128 || $b > 191) { if($return) { $valid = false; $string .= '?'; break; } else { return false; } } else { $multibytes .= $input[$i]; } $bytes--; } if($valid) { $string .= $multibytes; }
|
}
|
}
|
elseif(($byte & $utf8_4byte_bmask) == $utf8_4byte)
| else
|
{
|
{
|
$contains_4bytes = true; // Replace with ? to avoid MySQL exception $mb_char = '?'; $i += 3;
| $string .= $input[$i];
|
}
|
}
|
$sanitized .= $mb_char;
if($contains_4bytes == true && $return == false) { return false; } }
$input = $sanitized;
| } $input = $string; } if($return) { if($allow_mb4) { return $input; } else { return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input); }
|
}
|
}
|
if($contains_4bytes == false && $return == false)
| else
|
{
|
{
|
return true;
| if($allow_mb4) { return true; } else { return !preg_match("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", $input); }
|
}
|
}
|
return $input;
| |
} ?>
| } ?>
|