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 4818 | Zeile 4819 |
---|
* * @param int The post ID of the post * @param int The thread id of the post.
|
* * @param int The post ID of the post * @param int The thread id of the post.
|
*/
| */
|
function get_post_link($pid, $tid=0) { if($tid > 0)
| function get_post_link($pid, $tid=0) { if($tid > 0)
|
Zeile 5170 | Zeile 5171 |
---|
// User can attempt another login return $loginattempts;
|
// User can attempt another login return $loginattempts;
|
}
| }
|
/** * Validates the format of an email address.
| /** * Validates the format of an email address.
|
Zeile 5310 | Zeile 5311 |
---|
if(!is_array($split_words)) { continue;
|
if(!is_array($split_words)) { continue;
|
}
| }
|
foreach($split_words as $word) { if(!$word || strlen($word) < $mybb->settings['minsearchword'])
| foreach($split_words as $word) { if(!$word || strlen($word) < $mybb->settings['minsearchword'])
|
Zeile 5319 | Zeile 5320 |
---|
} $words[] = trim($word); }
|
} $words[] = trim($word); }
|
}
| }
|
} $inquote = !$inquote; }
| } $inquote = !$inquote; }
|
Zeile 5345 | Zeile 5346 |
---|
if(!is_array($words)) { return false;
|
if(!is_array($words)) { return false;
|
}
| }
|
// Sort the word array by length. Largest terms go first and work their way down to the smallest term. // This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
| // Sort the word array by length. Largest terms go first and work their way down to the smallest term. // This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
|
Zeile 5363 | Zeile 5364 |
---|
{ continue; }
|
{ continue; }
|
|
|
// Now make PREG compatible $find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui"; $replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
| // Now make PREG compatible $find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui"; $replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
|
Zeile 5380 | Zeile 5381 |
---|
* @param string Decimal value of a character reference */ function dec_to_utf8($src)
|
* @param string Decimal value of a character reference */ function dec_to_utf8($src)
|
{
| {
|
$dest = '';
if($src < 0)
| $dest = '';
if($src < 0)
|
Zeile 5416 | Zeile 5417 |
---|
}
return $dest;
|
}
return $dest;
|
}
| }
|
/** * Checks if a username has been disallowed for registration/use.
| /** * Checks if a username has been disallowed for registration/use.
|
Zeile 5451 | Zeile 5452 |
---|
* Check if a specific email address has been banned. * * @param string The email address.
|
* Check if a specific email address has been banned. * * @param string The email address.
|
* @param boolean True if the 'last used' dateline should be updated if a match is found.
| * @param boolean True if the 'last used' dateline should be updated if a match is found.
|
* @return boolean True if banned, false if not banned */ function is_banned_email($email, $update_lastuse=false)
| * @return boolean True if banned, false if not banned */ function is_banned_email($email, $update_lastuse=false)
|
Zeile 5802 | Zeile 5803 |
---|
return $original; } return $strings;
|
return $original; } return $strings;
|
}
| }
|
/** * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
| /** * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
|
Zeile 5942 | Zeile 5943 |
---|
else { $users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
|
else { $users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
|
}
| }
|
}
foreach($users as $uid => $warningpoints)
| }
foreach($users as $uid => $warningpoints)
|
Zeile 5950 | Zeile 5951 |
---|
if($warningpoints < 0) { $warningpoints = 0;
|
if($warningpoints < 0) { $warningpoints = 0;
|
}
| }
|
$updated_user = array( "warningpoints" => intval($warningpoints) ); $db->update_query("users", $updated_user, "uid='".intval($uid)."'");
|
$updated_user = array( "warningpoints" => intval($warningpoints) ); $db->update_query("users", $updated_user, "uid='".intval($uid)."'");
|
} }
/**
| } }
/**
|
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks * * @param string The file to chmod
| * Custom chmod function to fix problems with hosts who's server configurations screw up umasks * * @param string The file to chmod
|
Zeile 6012 | Zeile 6013 |
---|
// Are we done? Don't delete the main folder too and return true if($path == $orig_dir)
|
// Are we done? Don't delete the main folder too and return true if($path == $orig_dir)
|
{ return true;
| { return true;
|
}
|
}
|
|
|
return @rmdir($path); }
|
return @rmdir($path); }
|
|
|
return @unlink($path);
|
return @unlink($path);
|
}
/**
| }
/**
|
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid * * @param array The array of forums
| * Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid * * @param array The array of forums
|
Zeile 6083 | Zeile 6084 |
---|
$long += 4294967296; } return long2ip($long);
|
$long += 4294967296; } return long2ip($long);
|
}
| }
|
/**
|
/**
|
Zeile 6223 | Zeile 6224 |
---|
// 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 6469 | Zeile 6470 |
---|
}
/**
|
}
/**
|
* 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;
| |
} ?>
| } ?>
|