Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: functions.php 4868 2010-04-11 05:15:23Z RyanGordon $
| * $Id: functions.php 5379 2011-02-21 11:06:42Z Tomm $
|
*/
/**
| */
/**
|
Zeile 1581 | Zeile 1581 |
---|
$cookie = unserialize($mybb->cookies['mybb'][$name]);
|
$cookie = unserialize($mybb->cookies['mybb'][$name]);
|
if(isset($cookie[$id]))
| if(is_array($cookie) && isset($cookie[$id]))
|
{ return $cookie[$id]; }
| { return $cookie[$id]; }
|
Zeile 1604 | Zeile 1604 |
---|
$cookie = $mybb->cookies['mybb']; $newcookie = unserialize($cookie[$name]);
|
$cookie = $mybb->cookies['mybb']; $newcookie = unserialize($cookie[$name]);
|
| if(!is_array($newcookie)) { // Burnt / malformed cookie - reset $newcookie = array(); }
|
$newcookie[$id] = $value; $newcookie = serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie));
| $newcookie[$id] = $value; $newcookie = serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie));
|
Zeile 1622 | Zeile 1629 |
---|
global $lang;
$serverload = array();
|
global $lang;
$serverload = array();
|
|
|
// DIRECTORY_SEPARATOR checks if running windows if(DIRECTORY_SEPARATOR != '\\') {
| // DIRECTORY_SEPARATOR checks if running windows if(DIRECTORY_SEPARATOR != '\\') {
|
Zeile 1630 | Zeile 1637 |
---|
{ $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4);
|
{ $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4);
|
}
| }
|
if(!is_numeric($serverload[0])) { if(@ini_get('safe_mode') == 'On')
| if(!is_numeric($serverload[0])) { if(@ini_get('safe_mode') == 'On')
|
Zeile 1640 | Zeile 1647 |
---|
// Suhosin likes to throw a warning if exec is disabled then die - weird if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
|
// Suhosin likes to throw a warning if exec is disabled then die - weird if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
|
{ if(strpos(",".$func_blacklist.",", 'exec') !== false) { return $lang->unknown; } }
| { if(strpos(",".$func_blacklist.",", 'exec') !== false) { return $lang->unknown; } }
|
// PHP disabled functions? if($func_blacklist = @ini_get('disable_functions')) {
| // PHP disabled functions? if($func_blacklist = @ini_get('disable_functions')) {
|
Zeile 1653 | Zeile 1660 |
---|
{ return $lang->unknown; }
|
{ return $lang->unknown; }
|
}
| }
|
$load = @exec("uptime"); $load = explode("load average: ", $load);
| $load = @exec("uptime"); $load = explode("load average: ", $load);
|
Zeile 1661 | Zeile 1668 |
---|
if(!is_array($serverload)) { return $lang->unknown;
|
if(!is_array($serverload)) { return $lang->unknown;
|
} } } else { return $lang->unknown;
| } } } else { return $lang->unknown;
|
}
$returnload = trim($serverload[0]);
| }
$returnload = trim($serverload[0]);
|
Zeile 1853 | Zeile 1860 |
---|
* @param int The forum ID */ function update_forum_lastpost($fid)
|
* @param int The forum ID */ function update_forum_lastpost($fid)
|
{ global $db;
| { global $db;
|
// Fetch the last post for this forum $query = $db->query(" SELECT tid, lastpost, lastposter, lastposteruid, subject
| // Fetch the last post for this forum $query = $db->query(" SELECT tid, lastpost, lastposter, lastposteruid, subject
|
Zeile 2107 | Zeile 2114 |
---|
} $forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
|
} $forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
|
|
|
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
if($forum_cache[$forum['fid']])
| eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
if($forum_cache[$forum['fid']])
|
Zeile 2292 | Zeile 2299 |
---|
}
return $codeinsert;
|
}
return $codeinsert;
|
}
/**
| }
/**
|
* Build the javascript clickable smilie inserter * * @return string The clickable smilies list
| * Build the javascript clickable smilie inserter * * @return string The clickable smilies list
|
Zeile 2420 | Zeile 2427 |
---|
if(isset($encoding)) { header("Content-Encoding: $encoding");
|
if(isset($encoding)) { header("Content-Encoding: $encoding");
|
|
|
if(function_exists("gzencode")) { $contents = gzencode($contents, $level);
| if(function_exists("gzencode")) { $contents = gzencode($contents, $level);
|
Zeile 2608 | Zeile 2615 |
---|
* @return string The friendly file size */ function get_friendly_size($size)
|
* @return string The friendly file size */ function get_friendly_size($size)
|
{ global $lang;
| { global $lang;
|
if(!is_numeric($size)) { return $lang->na;
| if(!is_numeric($size)) { return $lang->na;
|
Zeile 2618 | Zeile 2625 |
---|
// Yottabyte (1024 Zettabytes) if($size >= 1208925819614629174706176)
|
// Yottabyte (1024 Zettabytes) if($size >= 1208925819614629174706176)
|
{
| {
|
$size = my_number_format(round(($size / 1208925819614629174706176), 2))." ".$lang->size_yb; } // Zetabyte (1024 Exabytes)
| $size = my_number_format(round(($size / 1208925819614629174706176), 2))." ".$lang->size_yb; } // Zetabyte (1024 Exabytes)
|
Zeile 2650 | Zeile 2657 |
---|
elseif($size >= 1048576) { $size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;
|
elseif($size >= 1048576) { $size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;
|
}
| }
|
// Kilobyte (1024 bytes) elseif($size >= 1024) {
| // Kilobyte (1024 bytes) elseif($size >= 1024) {
|
Zeile 2673 | Zeile 2680 |
---|
* * @param string The file extension * @return string The attachment icon
|
* * @param string The file extension * @return string The attachment icon
|
*/
| */
|
function get_attachment_icon($ext) { global $cache, $attachtypes, $theme;
| function get_attachment_icon($ext) { global $cache, $attachtypes, $theme;
|
Zeile 2799 | Zeile 2806 |
---|
$format = str_replace("y", my_substr($year, -2), $format);
return $format;
|
$format = str_replace("y", my_substr($year, -2), $format);
return $format;
|
}
| }
|
/** * Build the breadcrumb navigation trail from the specified items
| /** * Build the breadcrumb navigation trail from the specified items
|
Zeile 2860 | Zeile 2867 |
---|
$navsize = count($navbits); $navbits[$navsize]['name'] = $name; $navbits[$navsize]['url'] = $url;
|
$navsize = count($navbits); $navbits[$navsize]['name'] = $name; $navbits[$navsize]['url'] = $url;
|
}
/**
| }
/**
|
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums) * * @param int The forum ID to build the navigation for
| * Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums) * * @param int The forum ID to build the navigation for
|
Zeile 2988 | Zeile 2995 |
---|
$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2); $percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);
|
$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2); $percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);
|
|
|
$phpversion = phpversion();
$serverload = get_server_load();
| $phpversion = phpversion();
$serverload = get_server_load();
|
Zeile 3114 | Zeile 3121 |
---|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
|
}
| }
|
}
/**
| }
/**
|
Zeile 3238 | Zeile 3245 |
---|
else if($years > 1) { $nicetime['years'] = $years.$lang_years;
|
else if($years > 1) { $nicetime['years'] = $years.$lang_years;
|
}
| }
|
if($months == 1)
|
if($months == 1)
|
{
| {
|
$nicetime['months'] = "1".$lang_month; } else if($months > 1)
|
$nicetime['months'] = "1".$lang_month; } else if($months > 1)
|
{
| {
|
$nicetime['months'] = $months.$lang_months; }
| $nicetime['months'] = $months.$lang_months; }
|
Zeile 3261 | Zeile 3268 |
---|
if($days == 1) { $nicetime['days'] = "1".$lang_day;
|
if($days == 1) { $nicetime['days'] = "1".$lang_day;
|
}
| }
|
else if($days > 1) { $nicetime['days'] = $days.$lang_days; }
if($options['hours'] !== false)
|
else if($days > 1) { $nicetime['days'] = $days.$lang_days; }
if($options['hours'] !== false)
|
{
| {
|
if($hours == 1)
|
if($hours == 1)
|
{
| {
|
$nicetime['hours'] = "1".$lang_hour; } else if($hours > 1) { $nicetime['hours'] = $hours.$lang_hours;
|
$nicetime['hours'] = "1".$lang_hour; } else if($hours > 1) { $nicetime['hours'] = $hours.$lang_hours;
|
}
| }
|
}
if($options['minutes'] !== false)
| }
if($options['minutes'] !== false)
|
Zeile 3284 | Zeile 3291 |
---|
if($minutes == 1) { $nicetime['minutes'] = "1".$lang_minute;
|
if($minutes == 1) { $nicetime['minutes'] = "1".$lang_minute;
|
}
| }
|
else if($minutes > 1) { $nicetime['minutes'] = $minutes.$lang_minutes;
| else if($minutes > 1) { $nicetime['minutes'] = $minutes.$lang_minutes;
|
Zeile 3300 | Zeile 3307 |
---|
else if($seconds > 1) { $nicetime['seconds'] = $seconds.$lang_seconds;
|
else if($seconds > 1) { $nicetime['seconds'] = $seconds.$lang_seconds;
|
} }
| } }
|
if(is_array($nicetime)) {
| if(is_array($nicetime)) {
|
Zeile 3488 | Zeile 3495 |
---|
if(in_array($name, $ignore)) { continue;
|
if(in_array($name, $ignore)) { continue;
|
}
| }
|
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars((string)$name)."\" value=\"".htmlspecialchars((string)$value)."\" />\n"; }
| $form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars((string)$name)."\" value=\"".htmlspecialchars((string)$value)."\" />\n"; }
|
Zeile 3614 | Zeile 3621 |
---|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
|
} } } }
| } } } }
|
if($tid == 1) {
| if($tid == 1) {
|
Zeile 5578 | Zeile 5585 |
---|
function secure_seed_rng($count=8) { $output = '';
|
function secure_seed_rng($count=8) { $output = '';
|
// Try the OpenSSL method first. This is the strongest. if(function_exists('openssl_random_pseudo_bytes')) { $output = openssl_random_pseudo_bytes($count, $strong); if($strong !== true) { $output = ''; } } if($output == '')
| // Try the unix/linux method if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
|
{
|
{
|
// Then try the unix/linux method if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb'))) { $output = @fread($handle, $count); @fclose($handle); }
| $output = @fread($handle, $count); @fclose($handle);
|
} // Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
| } // Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
|
Zeile 5607 | Zeile 5600 |
---|
// 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); $output .= pack('H*', md5($unique_state));
|
for($i = 0; $i < $count; $i += 16) { $unique_state = md5(microtime().$unique_state); $output .= pack('H*', md5($unique_state));
|
} }
| } }
|
// /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));
|
Zeile 5632 | Zeile 5625 |
---|
function my_rand($min=null, $max=null, $force_seed=false) { static $seeded = false;
|
function my_rand($min=null, $max=null, $force_seed=false) { static $seeded = false;
|
| static $obfuscator = 0;
|
if($seeded == false || $force_seed == true)
|
if($seeded == false || $force_seed == true)
|
{
| {
|
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(); }
|
}
|
}
|
|
|
if($min !== null && $max !== null) {
|
if($min !== null && $max !== null) {
|
return mt_rand($min, $max);
| $distance = $max - $min; if ($distance > 0) { return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1)); } else { return mt_rand($min, $max); }
|
} else {
|
} else {
|
return mt_rand();
| $val = mt_rand() ^ $obfuscator; return $val;
|
} }
| } }
|