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 4562 2009-11-29 22:04:37Z RyanGordon $
| * $Id: functions.php 5379 2011-02-21 11:06:42Z Tomm $
|
*/
/**
| */
/**
|
Zeile 154 | Zeile 154 |
---|
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct if(!is_object($db)) {
|
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct if(!is_object($db)) {
|
if(!isset($config))
| if(!isset($config) || empty($config['database']['type']))
|
{ require MYBB_ROOT."inc/config.php"; }
| { require MYBB_ROOT."inc/config.php"; }
|
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 {
| } } } else {
|
return $lang->unknown; }
| return $lang->unknown; }
|
Zeile 1851 | Zeile 1858 |
---|
* Update the last post information for a specific forum * * @param int The forum ID
|
* Update the last post information for a specific forum * * @param int The forum ID
|
*/
| */
|
function update_forum_lastpost($fid) { global $db;
| function update_forum_lastpost($fid) { global $db;
|
Zeile 1873 | Zeile 1880 |
---|
"lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']) );
|
"lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']) );
|
|
|
$db->update_query("forums", $updated_forum, "fid='{$fid}'"); }
| $db->update_query("forums", $updated_forum, "fid='{$fid}'"); }
|
Zeile 1912 | Zeile 1919 |
---|
if($update_query[$counter] < 0) { $update_query[$counter] = 0;
|
if($update_query[$counter] < 0) { $update_query[$counter] = 0;
|
} }
| } }
|
} $db->free_result($query);
| } $db->free_result($query);
|
Zeile 2099 | Zeile 2106 |
---|
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true)) { $optionselected = "";
|
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true)) { $optionselected = "";
|
|
|
if($selitem == $forum['fid']) { $optionselected = "selected=\"selected\"";
| if($selitem == $forum['fid']) { $optionselected = "selected=\"selected\"";
|
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 2160 | Zeile 2167 |
---|
/** * Generates a random string.
|
/** * Generates a random string.
|
*
| *
|
* @param int The length of the string to generate. * @return string The random string. */
| * @param int The length of the string to generate. * @return string The random string. */
|
Zeile 2171 | Zeile 2178 |
---|
for($i = 1; $i <= $length; ++$i) {
|
for($i = 1; $i <= $length; ++$i) {
|
$ch = mt_rand(0, count($set)-1);
| $ch = my_rand(0, count($set)-1);
|
$str .= $set[$ch]; }
| $str .= $set[$ch]; }
|
Zeile 2284 | Zeile 2291 |
---|
{ global $page; $codeinsert = $page->build_codebuttons_editor($bind, $editor_language);
|
{ global $page; $codeinsert = $page->build_codebuttons_editor($bind, $editor_language);
|
} else
| } else
|
{ eval("\$codeinsert = \"".$templates->get("codebuttons")."\";"); }
| { eval("\$codeinsert = \"".$templates->get("codebuttons")."\";"); }
|
Zeile 2408 | Zeile 2415 |
---|
}
if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
|
}
if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
|
{
| {
|
$encoding = "x-gzip";
|
$encoding = "x-gzip";
|
}
| }
|
if(my_strpos(" ".$httpaccept_encoding, "gzip")) { $encoding = "gzip";
|
if(my_strpos(" ".$httpaccept_encoding, "gzip")) { $encoding = "gzip";
|
}
| }
|
if(isset($encoding)) {
| if(isset($encoding)) {
|
Zeile 2470 | Zeile 2477 |
---|
{ $tid = $data['tid']; unset($data['tid']);
|
{ $tid = $data['tid']; unset($data['tid']);
|
}
| }
|
// Any remaining extra data - we serialize and insert in to its own column if(is_array($data)) { $data = serialize($data);
|
// Any remaining extra data - we serialize and insert in to its own column if(is_array($data)) { $data = serialize($data);
|
}
| }
|
$time = TIME_NOW;
$sql_array = array(
| $time = TIME_NOW;
$sql_array = array(
|
Zeile 2506 | Zeile 2513 |
---|
if($uid != 0) { $display_reputation = "<a href=\"reputation.php?uid={$uid}\">";
|
if($uid != 0) { $display_reputation = "<a href=\"reputation.php?uid={$uid}\">";
|
}
$display_reputation .= "<strong class=\"";
| }
$display_reputation .= "<strong class=\"";
|
if($reputation < 0) { $display_reputation .= "reputation_negative"; } elseif($reputation > 0)
|
if($reputation < 0) { $display_reputation .= "reputation_negative"; } elseif($reputation > 0)
|
{
| {
|
$display_reputation .= "reputation_positive";
|
$display_reputation .= "reputation_positive";
|
}
| }
|
else { $display_reputation .= "reputation_neutral";
|
else { $display_reputation .= "reputation_neutral";
|
}
$display_reputation .= "\">{$reputation}</strong>";
| }
$display_reputation .= "\">{$reputation}</strong>";
|
if($uid != 0) { $display_reputation .= "</a>"; }
|
if($uid != 0) { $display_reputation .= "</a>"; }
|
|
|
return $display_reputation;
|
return $display_reputation;
|
}
| }
|
/** * Fetch a color coded version of a warning level (based on it's percentage) *
| /** * Fetch a color coded version of a warning level (based on it's percentage) *
|
Zeile 2540 | Zeile 2547 |
---|
* @return string Formatted warning level */ function get_colored_warning_level($level)
|
* @return string Formatted warning level */ function get_colored_warning_level($level)
|
{
| {
|
if($level >= 80)
|
if($level >= 80)
|
{
| {
|
return "<span class=\"high_warning\">{$level}%</span>";
|
return "<span class=\"high_warning\">{$level}%</span>";
|
}
| }
|
else if($level >= 50) { return "<span class=\"moderate_warning\">{$level}%</span>";
|
else if($level >= 50) { return "<span class=\"moderate_warning\">{$level}%</span>";
|
}
| }
|
else if($level >= 25) { return "<span class=\"low_warning\">{$level}%</span>";
| else if($level >= 25) { return "<span class=\"low_warning\">{$level}%</span>";
|
Zeile 2571 | Zeile 2578 |
---|
$ip = $_SERVER['REMOTE_ADDR']; } elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
$ip = $_SERVER['REMOTE_ADDR']; } elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
{
| {
|
if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses)) { foreach($addresses[0] as $key => $val)
| if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses)) { foreach($addresses[0] as $key => $val)
|
Zeile 2594 | Zeile 2601 |
---|
else { $ip = '';
|
else { $ip = '';
|
} }
| } }
|
$ip = preg_replace("#([^.0-9 ]*)#", "", $ip); return $ip;
| $ip = preg_replace("#([^.0-9 ]*)#", "", $ip); return $ip;
|
Zeile 4079 | Zeile 4086 |
---|
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset);
|
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset);
|
} else {
| } else {
|
$position = strpos($haystack, $needle, $offset); }
| $position = strpos($haystack, $needle, $offset); }
|
Zeile 5567 | Zeile 5574 |
---|
} return $count;
|
} return $count;
|
| }
/** * Returns a securely generated seed for PHP's RNG (Random Number Generator) * * @param int Length of the seed bytes (8 is default. Provides good cryptographic variance) * @return int An integer equivilent of a secure hexadecimal seed */ function secure_seed_rng($count=8) { $output = ''; // Try the unix/linux method if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb'))) { $output = @fread($handle, $count); @fclose($handle); } // Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator if(strlen($output) < $count) { $output = ''; // 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)); } } // /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; }
/** * Wrapper function for mt_rand. Automatically seeds using a secure seed once. * * @param int Optional lowest value to be returned (default: 0) * @param int Optional highest value to be returned (default: mt_getrandmax()) * @param boolean True forces it to reseed the RNG first * @return int An integer equivilent of a secure hexadecimal seed */ function my_rand($min=null, $max=null, $force_seed=false) { static $seeded = false; static $obfuscator = 0;
if($seeded == false || $force_seed == 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) { $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 { $val = mt_rand() ^ $obfuscator; return $val; }
|
}
?>
| }
?>
|