Zeile 581 | Zeile 581 |
---|
{ require_once MYBB_ROOT . "inc/mailhandlers/php.php"; $my_mailhandler_builtin = new PhpMail();
|
{ require_once MYBB_ROOT . "inc/mailhandlers/php.php"; $my_mailhandler_builtin = new PhpMail();
|
if(!empty($mybb->settings['mail_parameters']))
| if(!empty($mybb->config['mail_parameters']))
|
{
|
{
|
$my_mailhandler_builtin->additional_parameters = $mybb->settings['mail_parameters'];
| $my_mailhandler_builtin->additional_parameters = $mybb->config['mail_parameters'];
|
} } }
|
} } }
|
$plugins->run_hooks('my_mailhandler_builtin_after_init', $my_mailhandler_builtin);
| if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mailhandler_builtin_after_init', $my_mailhandler_builtin); }
|
return $my_mailhandler_builtin; }
|
return $my_mailhandler_builtin; }
|
|
|
// If our mail handler doesn't exist, create it. if(!is_object($my_mailhandler)) { require_once MYBB_ROOT . "inc/class_mailhandler.php";
|
// If our mail handler doesn't exist, create it. if(!is_object($my_mailhandler)) { require_once MYBB_ROOT . "inc/class_mailhandler.php";
|
$plugins->run_hooks('my_mailhandler_init', $my_mailhandler);
| if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mailhandler_init', $my_mailhandler); }
|
// If no plugin has ever created the mail handler, resort to use the built-in one. if(!is_object($my_mailhandler) || !($my_mailhandler instanceof MailHandler))
| // If no plugin has ever created the mail handler, resort to use the built-in one. if(!is_object($my_mailhandler) || !($my_mailhandler instanceof MailHandler))
|
Zeile 663 | Zeile 669 |
---|
'is_mail_sent' => &$is_mail_sent, 'continue_process' => &$continue_process, );
|
'is_mail_sent' => &$is_mail_sent, 'continue_process' => &$continue_process, );
|
$plugins->run_hooks('my_mail_pre_build_message', $my_mail_parameters);
| if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mail_pre_build_message', $my_mail_parameters); }
|
// Build the mail message. $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
|
// Build the mail message. $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
|
$plugins->run_hooks('my_mail_pre_send', $my_mail_parameters);
| if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mail_pre_send', $my_mail_parameters); }
|
// Check if the hooked plugins still suggest to send the mail. if($continue_process)
|
// Check if the hooked plugins still suggest to send the mail. if($continue_process)
|
{
| {
|
$is_mail_sent = $mail->send();
|
$is_mail_sent = $mail->send();
|
}
| }
|
|
|
$plugins->run_hooks('my_mail_post_send', $my_mail_parameters);
| if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mail_post_send', $my_mail_parameters); }
|
return $is_mail_sent; }
| return $is_mail_sent; }
|
Zeile 856 | Zeile 871 |
---|
{ $forum_cache = cache_forums(); foreach($forum_cache as $forum)
|
{ $forum_cache = cache_forums(); foreach($forum_cache as $forum)
|
{
| {
|
if($forum['active'] != 0) { $forums_by_parent[$forum['pid']][$forum['fid']] = $forum;
| if($forum['active'] != 0) { $forums_by_parent[$forum['pid']][$forum['fid']] = $forum;
|
Zeile 1248 | Zeile 1263 |
---|
// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary $jump_url = fetch_page_url($url, 1); eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
|
// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary $jump_url = fetch_page_url($url, 1); eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
|
}
$multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
| }
$multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
|
if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
| if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
Zeile 1643 | Zeile 1658 |
---|
if(!is_array($fpermcache)) { $fpermcache = $cache->read("forumpermissions");
|
if(!is_array($fpermcache)) { $fpermcache = $cache->read("forumpermissions");
|
}
if($fid) // Fetch the permissions for a single forum
| }
if($fid) // Fetch the permissions for a single forum
|
{ if(empty($cached_forum_permissions_permissions[$gid][$fid]))
|
{ if(empty($cached_forum_permissions_permissions[$gid][$fid]))
|
{
| {
|
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms); } return $cached_forum_permissions_permissions[$gid][$fid];
| $cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms); } return $cached_forum_permissions_permissions[$gid][$fid];
|
Zeile 1658 | Zeile 1673 |
---|
if(empty($cached_forum_permissions[$gid])) { foreach($forum_cache as $forum)
|
if(empty($cached_forum_permissions[$gid])) { foreach($forum_cache as $forum)
|
{
| {
|
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms); } }
| $cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms); } }
|
Zeile 1679 | Zeile 1694 |
---|
{ global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
|
{ global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
|
$groups = explode(",", $gid);
if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions { return $groupperms; }
| if(isset($gid)) { $groups = explode(",", $gid); } else { $groups = array(); }
|
$current_permissions = array(); $only_view_own_threads = 1; $only_reply_own_threads = 1;
|
$current_permissions = array(); $only_view_own_threads = 1; $only_reply_own_threads = 1;
|
foreach($groups as $gid) { if(!empty($groupscache[$gid]))
| if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions { $current_permissions = $groupperms; } else { foreach($groups as $gid)
|
{
|
{
|
// If our permissions arn't inherited we need to figure them out if(empty($fpermcache[$fid][$gid])) { $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents)) { foreach($parents as $parent_id) { if(!empty($fpermcache[$parent_id][$gid])) { $level_permissions = $fpermcache[$parent_id][$gid]; break; } } } } else {
| // If this forum has custom or inherited permissions for the currently looped group. if(!empty($fpermcache[$fid][$gid])) {
|
$level_permissions = $fpermcache[$fid][$gid]; }
|
$level_permissions = $fpermcache[$fid][$gid]; }
|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions))
| // Or, use the group permission instead, if available. Some forum permissions not existing here will be added back later. else if(!empty($groupscache[$gid]))
|
{ $level_permissions = $groupscache[$gid];
|
{ $level_permissions = $groupscache[$gid];
|
| } // No permission is available for the currently looped group, probably we have bad data here. else { continue;
|
}
foreach($level_permissions as $permission => $access)
| }
foreach($level_permissions as $permission => $access)
|
Zeile 1738 | Zeile 1747 |
---|
if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"])) { $only_reply_own_threads = 0;
|
if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"])) { $only_reply_own_threads = 0;
|
}
| } }
if(count($current_permissions) == 0) { $current_permissions = $groupperms;
|
}
|
}
|
}
| }
|
// Figure out if we can view more than our own threads
|
// Figure out if we can view more than our own threads
|
if($only_view_own_threads == 0) {
| if($only_view_own_threads == 0 || !isset($current_permissions["canonlyviewownthreads"])) {
|
$current_permissions["canonlyviewownthreads"] = 0;
|
$current_permissions["canonlyviewownthreads"] = 0;
|
}
| }
|
// Figure out if we can reply more than our own threads
|
// Figure out if we can reply more than our own threads
|
if($only_reply_own_threads == 0) {
| if($only_reply_own_threads == 0 || !isset($current_permissions["canonlyreplyownthreads"])) {
|
$current_permissions["canonlyreplyownthreads"] = 0;
|
$current_permissions["canonlyreplyownthreads"] = 0;
|
}
| }
|
|
|
if(count($current_permissions) == 0) { $current_permissions = $groupperms; }
| |
return $current_permissions; }
| return $current_permissions; }
|
Zeile 1790 | Zeile 1800 |
---|
foreach($parents as $parent_id) { if($parent_id != $forum['fid'] && !forum_password_validated($forum_cache[$parent_id], true))
|
foreach($parents as $parent_id) { if($parent_id != $forum['fid'] && !forum_password_validated($forum_cache[$parent_id], true))
|
{ return false;
| { return false;
|
} } }
| } } }
|
Zeile 1803 | Zeile 1813 |
---|
$mybb->cookies['forumpass'][$forum['fid']] ) );
|
$mybb->cookies['forumpass'][$forum['fid']] ) );
|
}
/**
| }
/**
|
* Check the password given on a certain forum for validity * * @param int $fid The forum ID
| * Check the password given on a certain forum for validity * * @param int $fid The forum ID
|
Zeile 1837 | Zeile 1847 |
---|
if(!empty($parents)) { foreach($parents as $parent_id)
|
if(!empty($parents)) { foreach($parents as $parent_id)
|
{
| {
|
if($parent_id == $fid || $parent_id == $pid) { continue;
|
if($parent_id == $fid || $parent_id == $pid) { continue;
|
}
| }
|
if($forum_cache[$parent_id]['password'] !== "") { check_forum_password($parent_id, $fid);
| if($forum_cache[$parent_id]['password'] !== "") { check_forum_password($parent_id, $fid);
|
Zeile 1853 | Zeile 1863 |
---|
if($forum_cache[$fid]['password'] !== '') { if(isset($mybb->input['pwverify']) && $pid == 0)
|
if($forum_cache[$fid]['password'] !== '') { if(isset($mybb->input['pwverify']) && $pid == 0)
|
{
| {
|
if(my_hash_equals($forum_cache[$fid]['password'], $mybb->get_input('pwverify'))) { my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true);
| if(my_hash_equals($forum_cache[$fid]['password'], $mybb->get_input('pwverify'))) { my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true);
|
Zeile 1885 | Zeile 1895 |
---|
if($return) { return $showform;
|
if($return) { return $showform;
|
}
| }
|
if($showform) {
| if($showform) {
|
Zeile 1917 | Zeile 1927 |
---|
static $modpermscache;
if($uid < 1)
|
static $modpermscache;
if($uid < 1)
|
{ $uid = $mybb->user['uid']; }
if($uid == 0) { return false;
| { $uid = $mybb->user['uid']; }
if($uid == 0) { return false;
|
}
if(isset($modpermscache[$fid][$uid]))
|
}
if(isset($modpermscache[$fid][$uid]))
|
{
| {
|
return $modpermscache[$fid][$uid];
|
return $modpermscache[$fid][$uid];
|
}
| }
|
if(!$parentslist) {
| if(!$parentslist) {
|
Zeile 1940 | Zeile 1950 |
---|
$perms = array(); $user = get_user($uid);
|
$perms = array(); $user = get_user($uid);
|
$groups = array($user['usergroup']);
| $groups = array($user['usergroup']);
|
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
|
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
|
|
|
foreach($extra_groups as $extra_group) { $groups[] = $extra_group; } }
|
foreach($extra_groups as $extra_group) { $groups[] = $extra_group; } }
|
|
|
$mod_cache = $cache->read("moderators");
foreach($mod_cache as $forumid => $forum)
|
$mod_cache = $cache->read("moderators");
foreach($mod_cache as $forumid => $forum)
|
{
| {
|
if(empty($forum) || !is_array($forum) || !in_array($forumid, $parentslist))
|
if(empty($forum) || !is_array($forum) || !in_array($forumid, $parentslist))
|
{
| {
|
// No perms or we're not after this forum continue; }
|
// No perms or we're not after this forum continue; }
|
|
|
// User settings override usergroup settings if(!empty($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
// User settings override usergroup settings if(!empty($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
// Figure out the user permissions if($value == 0)
| foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
if(!isset($perms[$action])) { $perms[$action] = $value; } // Figure out the user permissions else if($value == 0)
|
{ // The user doesn't have permission to set this action $perms[$action] = 0;
| { // The user doesn't have permission to set this action $perms[$action] = 0;
|
Zeile 1989 | Zeile 2003 |
---|
foreach($groups as $group) { if(empty($forum['usergroups'][$group]) || !is_array($forum['usergroups'][$group]))
|
foreach($groups as $group) { if(empty($forum['usergroups'][$group]) || !is_array($forum['usergroups'][$group]))
|
{
| {
|
// There are no permissions set for this group continue;
|
// There are no permissions set for this group continue;
|
}
| }
|
$perm = $forum['usergroups'][$group]; foreach($perm as $action => $value) { if(strpos($action, "can") === false)
|
$perm = $forum['usergroups'][$group]; foreach($perm as $action => $value) { if(strpos($action, "can") === false)
|
{
| {
|
continue;
|
continue;
|
}
| }
|
|
|
$perms[$action] = max($perm[$action], $perms[$action]);
| if(!isset($perms[$action])) { $perms[$action] = $value; } else { $perms[$action] = max($perm[$action], $perms[$action]); }
|
} }
|
} }
|
}
$modpermscache[$fid][$uid] = $perms;
| }
$modpermscache[$fid][$uid] = $perms;
|
return $perms; }
| return $perms; }
|
Zeile 2023 | Zeile 2044 |
---|
function is_moderator($fid=0, $action="", $uid=0) { global $mybb, $cache, $plugins;
|
function is_moderator($fid=0, $action="", $uid=0) { global $mybb, $cache, $plugins;
|
|
|
if($uid == 0) { $uid = $mybb->user['uid'];
| if($uid == 0) { $uid = $mybb->user['uid'];
|
Zeile 2055 | Zeile 2076 |
---|
{ $forumpermissions = forum_permissions($fid); if(!empty($forumpermissions['canview']) && !empty($forumpermissions['canviewthreads']) && empty($forumpermissions['canonlyviewownthreads']))
|
{ $forumpermissions = forum_permissions($fid); if(!empty($forumpermissions['canview']) && !empty($forumpermissions['canviewthreads']) && empty($forumpermissions['canonlyviewownthreads']))
|
{ return true;
| { return true;
|
} return false; }
| } return false; }
|
Zeile 2319 | Zeile 2340 |
---|
/** * Get the contents from a serialised cookie array.
|
/** * Get the contents from a serialised cookie array.
|
*
| *
|
* @param string $name The cookie identifier. * @param int $id The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
| * @param string $name The cookie identifier. * @param int $id The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
|
Zeile 2327 | Zeile 2348 |
---|
function my_get_array_cookie($name, $id) { global $mybb;
|
function my_get_array_cookie($name, $id) { global $mybb;
|
|
|
if(!isset($mybb->cookies['mybb'][$name])) { return false; }
|
if(!isset($mybb->cookies['mybb'][$name])) { return false; }
|
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
| $cookie = my_unserialize($mybb->cookies['mybb'][$name], false);
|
if(is_array($cookie) && isset($cookie[$id]))
|
if(is_array($cookie) && isset($cookie[$id]))
|
{
| {
|
return $cookie[$id]; } else
| return $cookie[$id]; } else
|
Zeile 2359 | Zeile 2380 |
---|
if(isset($mybb->cookies['mybb'][$name])) {
|
if(isset($mybb->cookies['mybb'][$name])) {
|
$newcookie = my_unserialize($mybb->cookies['mybb'][$name]);
| $newcookie = my_unserialize($mybb->cookies['mybb'][$name], false);
|
} else {
| } else {
|
Zeile 2369 | Zeile 2390 |
---|
$newcookie[$id] = $value; $newcookie = my_serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie), $expires);
|
$newcookie[$id] = $value; $newcookie = my_serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie), $expires);
|
| if(isset($mybb->cookies['mybb']) && !is_array($mybb->cookies['mybb'])) { $mybb->cookies['mybb'] = array(); }
|
// Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie;
| // Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie;
|
Zeile 2388 | Zeile 2414 |
---|
* - does not unserialize objects * * @param string $str
|
* - does not unserialize objects * * @param string $str
|
| * @param bool $unlimited Whether to apply limits defined in MAX_SERIALIZED_* constants
|
* @return mixed * @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects) */
|
* @return mixed * @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects) */
|
function _safe_unserialize($str)
| function _safe_unserialize($str, $unlimited = true)
|
{
|
{
|
if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)
| if(!$unlimited && strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)
|
{ // input exceeds MAX_SERIALIZED_INPUT_LENGTH return false; }
if(empty($str) || !is_string($str))
|
{ // input exceeds MAX_SERIALIZED_INPUT_LENGTH return false; }
if(empty($str) || !is_string($str))
|
{
| {
|
return false; }
| return false; }
|
Zeile 2431 | Zeile 2458 |
---|
{ $value = $matches[1] == '1' ? true : false; $str = substr($str, 4);
|
{ $value = $matches[1] == '1' ? true : false; $str = substr($str, 4);
|
}
| }
|
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
|
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
|
{
| {
|
$value = (int)$matches[1]; $str = $matches[2]; }
| $value = (int)$matches[1]; $str = $matches[2]; }
|
Zeile 2441 | Zeile 2468 |
---|
{ $value = (float)$matches[1]; $str = $matches[3];
|
{ $value = (float)$matches[1]; $str = $matches[3];
|
}
| }
|
else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') { $value = substr($matches[2], 0, (int)$matches[1]); $str = substr($matches[2], (int)$matches[1] + 2); }
|
else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') { $value = substr($matches[2], 0, (int)$matches[1]); $str = substr($matches[2], (int)$matches[1] + 2); }
|
else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH)
| else if( $type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && ($unlimited || $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) )
|
{ $expectedLength = (int)$matches[1]; $str = $matches[2];
| { $expectedLength = (int)$matches[1]; $str = $matches[2];
|
Zeile 2463 | Zeile 2494 |
---|
case 3: // in array, expecting value or another array if($type == 'a') {
|
case 3: // in array, expecting value or another array if($type == 'a') {
|
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
| if(!$unlimited && count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
|
{ // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH return false;
| { // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH return false;
|
Zeile 2508 | Zeile 2539 |
---|
} if($type == 'i' || $type == 's') {
|
} if($type == 'i' || $type == 's') {
|
if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)
| if(!$unlimited && count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)
|
{ // array size exceeds MAX_SERIALIZED_ARRAY_LENGTH return false;
| { // array size exceeds MAX_SERIALIZED_ARRAY_LENGTH return false;
|
Zeile 2530 | Zeile 2561 |
---|
case 0: // expecting array or value if($type == 'a') {
|
case 0: // expecting array or value if($type == 'a') {
|
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
| if(!$unlimited && count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
|
{ // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH return false;
| { // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH return false;
|
Zeile 2567 | Zeile 2598 |
---|
* Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue * * @param string $str
|
* Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue * * @param string $str
|
| * @param bool $unlimited
|
* @return mixed */
|
* @return mixed */
|
function my_unserialize($str)
| function my_unserialize($str, $unlimited = true)
|
{ // Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
| { // Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
|
Zeile 2578 | Zeile 2610 |
---|
mb_internal_encoding('ASCII'); }
|
mb_internal_encoding('ASCII'); }
|
$out = _safe_unserialize($str);
| $out = _safe_unserialize($str, $unlimited);
|
if(isset($mbIntEnc)) {
| if(isset($mbIntEnc)) {
|
Zeile 2586 | Zeile 2618 |
---|
}
return $out;
|
}
return $out;
|
| }
/** * Unserializes data using PHP's `unserialize()`, and its safety options if possible. * This function should only be used for values from trusted sources. * * @param string $str * @return mixed */ function native_unserialize($str) { if(version_compare(PHP_VERSION, '7.0.0', '>=')) { return unserialize($str, array('allowed_classes' => false)); } else { return unserialize($str); }
|
}
/**
| }
/**
|
Zeile 2683 | Zeile 2734 |
---|
{ // sys_getloadavg() will return an array with [0] being load within the last minute. $serverload = sys_getloadavg();
|
{ // sys_getloadavg() will return an array with [0] being load within the last minute. $serverload = sys_getloadavg();
|
| if(!is_array($serverload)) { return $lang->unknown; }
|
$serverload[0] = round($serverload[0], 4); } else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
| $serverload[0] = round($serverload[0], 4); } else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
|
Zeile 2693 | Zeile 2750 |
---|
if(!is_numeric($serverload[0])) { if($mybb->safemode)
|
if(!is_numeric($serverload[0])) { if($mybb->safemode)
|
{
| {
|
return $lang->unknown; }
// Suhosin likes to throw a warning if exec is disabled then die - weird if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
|
return $lang->unknown; }
// 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 2720 | Zeile 2777 |
---|
if(!is_array($serverload)) { return $lang->unknown;
|
if(!is_array($serverload)) { return $lang->unknown;
|
} } } else
| } } } else
|
{ return $lang->unknown; }
| { return $lang->unknown; }
|
Zeile 2981 | Zeile 3038 |
---|
if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
|
if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
|
} else {
| } else {
|
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; } }
| $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; } }
|
Zeile 2994 | Zeile 3051 |
---|
if($deletedposts_diff > -1) { $new_stats['numdeletedposts'] = "+{$deletedposts_diff}";
|
if($deletedposts_diff > -1) { $new_stats['numdeletedposts'] = "+{$deletedposts_diff}";
|
} else
| } else
|
{ $new_stats['numdeletedposts'] = "{$deletedposts_diff}"; }
| { $new_stats['numdeletedposts'] = "{$deletedposts_diff}"; }
|
Zeile 3009 | Zeile 3066 |
---|
$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}"; } else
|
$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}"; } else
|
{
| {
|
$new_stats['numdeletedthreads'] = "{$deletedthreads_diff}"; }
|
$new_stats['numdeletedthreads'] = "{$deletedthreads_diff}"; }
|
}
| }
|
if(!empty($new_stats)) { update_stats($new_stats);
| if(!empty($new_stats)) { update_stats($new_stats);
|
Zeile 3024 | Zeile 3081 |
---|
* Update the last post information for a specific forum * * @param int $fid The forum ID
|
* Update the last post information for a specific forum * * @param int $fid The forum ID
|
*/
| */
|
function update_forum_lastpost($fid) { global $db;
| function update_forum_lastpost($fid) { global $db;
|
Zeile 3081 | Zeile 3138 |
---|
// Fetch above counters for this thread $query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'"); $thread = $db->fetch_array($query);
|
// Fetch above counters for this thread $query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'"); $thread = $db->fetch_array($query);
|
|
|
foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { if(substr($changes[$counter], 0, 2) == "+-")
|
foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { if(substr($changes[$counter], 0, 2) == "+-")
|
{
| {
|
$changes[$counter] = substr($changes[$counter], 1); } // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
|
$changes[$counter] = substr($changes[$counter], 1); } // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
|
{
| {
|
if((int)$changes[$counter] != 0) { $update_query[$counter] = $thread[$counter] + $changes[$counter];
|
if((int)$changes[$counter] != 0) { $update_query[$counter] = $thread[$counter] + $changes[$counter];
|
} } else { $update_query[$counter] = $changes[$counter]; }
// Less than 0? That's bad if(isset($update_query[$counter]) && $update_query[$counter] < 0) { $update_query[$counter] = 0; } } }
$db->free_result($query);
| } } else { $update_query[$counter] = $changes[$counter]; }
// Less than 0? That's bad if(isset($update_query[$counter]) && $update_query[$counter] < 0) { $update_query[$counter] = 0; } } }
$db->free_result($query);
|
// 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) {
|
Zeile 3126 | Zeile 3183 |
---|
* @param int $tid The thread ID */ function update_thread_data($tid)
|
* @param int $tid The thread ID */ function update_thread_data($tid)
|
{ global $db;
$thread = get_thread($tid);
| { global $db;
$thread = get_thread($tid);
|
// If this is a moved thread marker, don't update it - we need it to stay as it is if(strpos($thread['closed'], 'moved|') !== false)
| // If this is a moved thread marker, don't update it - we need it to stay as it is if(strpos($thread['closed'], 'moved|') !== false)
|
Zeile 3162 | Zeile 3219 |
---|
$db->free_result($query);
if(empty($firstpost['username']))
|
$db->free_result($query);
if(empty($firstpost['username']))
|
{
| {
|
$firstpost['username'] = $firstpost['postusername']; }
| $firstpost['username'] = $firstpost['postusername']; }
|
Zeile 3211 | Zeile 3268 |
---|
// Fetch above counters for this user $query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'"); $user = $db->fetch_array($query);
|
// Fetch above counters for this user $query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'"); $user = $db->fetch_array($query);
|
foreach($counters as $counter)
| if($user)
|
{
|
{
|
if(array_key_exists($counter, $changes))
| foreach($counters as $counter)
|
{
|
{
|
if(substr($changes[$counter], 0, 2) == "+-")
| if(array_key_exists($counter, $changes))
|
{
|
{
|
$changes[$counter] = substr($changes[$counter], 1); } // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { if((int)$changes[$counter] != 0)
| if(substr($changes[$counter], 0, 2) == "+-") { $changes[$counter] = substr($changes[$counter], 1); } // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { if((int)$changes[$counter] != 0) { $update_query[$counter] = $user[$counter] + $changes[$counter]; } } else { $update_query[$counter] = $changes[$counter]; }
// Less than 0? That's bad if(isset($update_query[$counter]) && $update_query[$counter] < 0)
|
{
|
{
|
$update_query[$counter] = $user[$counter] + $changes[$counter];
| $update_query[$counter] = 0;
|
}
|
}
|
} else { $update_query[$counter] = $changes[$counter]; }
// Less than 0? That's bad if(isset($update_query[$counter]) && $update_query[$counter] < 0) { $update_query[$counter] = 0;
| |
} }
|
} }
|
}
$db->free_result($query);
| }
$db->free_result($query);
|
// 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)
|
Zeile 3252 | Zeile 3312 |
---|
/** * Deletes a thread from the database
|
/** * Deletes a thread from the database
|
*
| *
|
* @param int $tid The thread ID * @return bool */ function delete_thread($tid) { global $moderation;
|
* @param int $tid The thread ID * @return bool */ function delete_thread($tid) { global $moderation;
|
|
|
if(!is_object($moderation)) { require_once MYBB_ROOT."inc/class_moderation.php"; $moderation = new Moderation; }
|
if(!is_object($moderation)) { require_once MYBB_ROOT."inc/class_moderation.php"; $moderation = new Moderation; }
|
|
|
return $moderation->delete_thread($tid);
|
return $moderation->delete_thread($tid);
|
}
| }
|
/** * Deletes a post from the database *
| /** * Deletes a post from the database *
|
Zeile 3283 | Zeile 3343 |
---|
{ require_once MYBB_ROOT."inc/class_moderation.php"; $moderation = new Moderation;
|
{ require_once MYBB_ROOT."inc/class_moderation.php"; $moderation = new Moderation;
|
}
| }
|
return $moderation->delete_post($pid); }
| return $moderation->delete_post($pid); }
|
Zeile 3317 | Zeile 3377 |
---|
foreach($forum_cache as $fid => $forum) { if($forum['active'] != 0)
|
foreach($forum_cache as $fid => $forum) { if($forum['active'] != 0)
|
{
| {
|
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; } }
|
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; } }
|
}
| }
|
if(!is_array($permissioncache)) {
| if(!is_array($permissioncache)) {
|
Zeile 3333 | Zeile 3393 |
---|
foreach($jumpfcache[$pid] as $main) { foreach($main as $forum)
|
foreach($jumpfcache[$pid] as $main) { foreach($main as $forum)
|
{
| {
|
$perms = $permissioncache[$forum['fid']];
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))
| $perms = $permissioncache[$forum['fid']];
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))
|
Zeile 3383 | Zeile 3443 |
---|
}
return $forumjump;
|
}
return $forumjump;
|
}
| }
|
/** * Returns the extension of a file.
| /** * Returns the extension of a file.
|
Zeile 3432 | Zeile 3492 |
---|
shuffle($str);
return implode($str);
|
shuffle($str);
return implode($str);
|
}
| }
|
/** * Formats a username based on their display group
| /** * Formats a username based on their display group
|
Zeile 3481 | Zeile 3541 |
---|
$format = $parameters['format'];
$formattednames[$username] = str_replace("{username}", $username, $format);
|
$format = $parameters['format'];
$formattednames[$username] = str_replace("{username}", $username, $format);
|
}
| }
|
return $formattednames[$username]; }
| return $formattednames[$username]; }
|
Zeile 3514 | Zeile 3574 |
---|
{ // Default avatar if(defined('IN_ADMINCP'))
|
{ // Default avatar if(defined('IN_ADMINCP'))
|
{
| {
|
$theme['imgdir'] = '../images'; }
| $theme['imgdir'] = '../images'; }
|
Zeile 3777 | Zeile 3837 |
---|
if($mybb->settings['allowsizemycode'] == 1) { $size = "size,";
|
if($mybb->settings['allowsizemycode'] == 1) { $size = "size,";
|
}
| }
|
if($mybb->settings['allowcolormycode'] == 1) {
| if($mybb->settings['allowcolormycode'] == 1) {
|
Zeile 3810 | Zeile 3870 |
---|
}
if($mybb->user['sourceeditor'] == 1)
|
}
if($mybb->user['sourceeditor'] == 1)
|
{
| {
|
$sourcemode = "MyBBEditor.sourceMode(true);"; }
| $sourcemode = "MyBBEditor.sourceMode(true);"; }
|
Zeile 3859 | Zeile 3919 |
---|
$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1)); $subscription = $db->fetch_array($query);
|
$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1)); $subscription = $db->fetch_array($query);
|
if(!empty($subscription) && $subscription['tid'])
| if($subscription)
|
{ $subscription_method = (int)$subscription['notification'] + 1; }
| { $subscription_method = (int)$subscription['notification'] + 1; }
|
Zeile 3910 | Zeile 3970 |
---|
$mybb->settings['smilieinsertertot'] = $smiliecount; } else if($mybb->settings['smilieinsertertot'] < $smiliecount)
|
$mybb->settings['smilieinsertertot'] = $smiliecount; } else if($mybb->settings['smilieinsertertot'] < $smiliecount)
|
{
| {
|
$smiliecount = $mybb->settings['smilieinsertertot']; eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";"); }
| $smiliecount = $mybb->settings['smilieinsertertot']; eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";"); }
|
Zeile 3987 | Zeile 4047 |
---|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
}
return $prefixes_cache; }
| }
return $prefixes_cache; }
|
$prefix_cache = $cache->read("threadprefixes");
| $prefix_cache = $cache->read("threadprefixes");
|
Zeile 4022 | Zeile 4082 |
---|
return false; }
|
return false; }
|
|
|
/** * Build the thread prefix selection menu for the current user *
| /** * Build the thread prefix selection menu for the current user *
|
Zeile 4039 | Zeile 4099 |
---|
if($fid != 'all') { $fid = (int)$fid;
|
if($fid != 'all') { $fid = (int)$fid;
|
}
$prefix_cache = build_prefixes(0);
| }
$prefix_cache = build_prefixes(0);
|
if(empty($prefix_cache)) { // We've got no prefixes to show
| if(empty($prefix_cache)) { // We've got no prefixes to show
|
Zeile 4830 | Zeile 4890 |
---|
{ // Set up link to forum in breadcrumb. if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
|
{ // Set up link to forum in breadcrumb. if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
|
{
| {
|
$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html"; } else
| $navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html"; } else
|
Zeile 5689 | Zeile 5749 |
---|
} else {
|
} else {
|
$parts = explode('.', $number);
| if(isset($number)) { $parts = explode('.', $number); } else { $parts = array(); }
|
if(isset($parts[1])) {
| if(isset($parts[1])) {
|
Zeile 6026 | Zeile 6093 |
---|
LIMIT 1" ); $lastpost = $db->fetch_array($query);
|
LIMIT 1" ); $lastpost = $db->fetch_array($query);
|
| if(!$lastpost) { return false; }
|
if(empty($lastpost['username'])) {
| if(empty($lastpost['username'])) {
|
Zeile 6071 | Zeile 6143 |
---|
$string = preg_replace("#&\#([0-9]+);#", "-", $string);
|
$string = preg_replace("#&\#([0-9]+);#", "-", $string);
|
if(strtolower($lang->settings['charset']) == "utf-8")
| if(isset($lang->settings['charset']) && strtolower($lang->settings['charset']) == "utf-8")
|
{ // Get rid of any excess RTL and LTR override for they are the workings of the devil $string = str_replace(dec_to_utf8(8238), "", $string);
| { // Get rid of any excess RTL and LTR override for they are the workings of the devil $string = str_replace(dec_to_utf8(8238), "", $string);
|
Zeile 6123 | Zeile 6195 |
---|
else { if($length != null)
|
else { if($length != null)
|
{
| {
|
$cut_string = substr($string, $start, $length);
|
$cut_string = substr($string, $start, $length);
|
}
| }
|
else { $cut_string = substr($string, $start); }
|
else { $cut_string = substr($string, $start); }
|
}
| }
|
if($handle_entities) { $cut_string = htmlspecialchars_uni($cut_string); } return $cut_string;
|
if($handle_entities) { $cut_string = htmlspecialchars_uni($cut_string); } return $cut_string;
|
}
| }
|
/** * Lowers the case of a string, mb strings accounted for
| /** * Lowers the case of a string, mb strings accounted for
|
Zeile 6150 | Zeile 6222 |
---|
if(function_exists("mb_strtolower")) { $string = mb_strtolower($string);
|
if(function_exists("mb_strtolower")) { $string = mb_strtolower($string);
|
} else
| } else
|
{ $string = strtolower($string); }
|
{ $string = strtolower($string); }
|
|
|
return $string; }
/** * Finds a needle in a haystack and returns it position, mb strings accounted for, case insensitive
|
return $string; }
/** * Finds a needle in a haystack and returns it position, mb strings accounted for, case insensitive
|
* * @param string $haystack String to look in (haystack) * @param string $needle What to look for (needle) * @param int $offset (optional) How much to offset * @return int|bool false on needle not found, integer position if found
| * * @param string $haystack String to look in (haystack) * @param string $needle What to look for (needle) * @param int $offset (optional) How much to offset * @return int|bool false on needle not found, integer position if found
|
*/ function my_stripos($haystack, $needle, $offset=0) {
| */ function my_stripos($haystack, $needle, $offset=0) {
|
Zeile 6177 | Zeile 6249 |
---|
if(function_exists("mb_stripos")) { $position = mb_stripos($haystack, $needle, $offset);
|
if(function_exists("mb_stripos")) { $position = mb_stripos($haystack, $needle, $offset);
|
} else {
| } else {
|
$position = stripos($haystack, $needle, $offset); }
| $position = stripos($haystack, $needle, $offset); }
|
Zeile 6193 | Zeile 6265 |
---|
* @param string $needle What to look for (needle) * @param int $offset (optional) How much to offset * @return int|bool false on needle not found, integer position if found
|
* @param string $needle What to look for (needle) * @param int $offset (optional) How much to offset * @return int|bool false on needle not found, integer position if found
|
*/
| */
|
function my_strpos($haystack, $needle, $offset=0) { if($needle == '')
| function my_strpos($haystack, $needle, $offset=0) { if($needle == '')
|
Zeile 6250 | Zeile 6322 |
---|
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
}
| }
|
/** * Returns any ascii to it's character (utf-8 safe).
| /** * Returns any ascii to it's character (utf-8 safe).
|
Zeile 6702 | Zeile 6774 |
---|
if(isset($thread_cache[$tid]) && !$recache) { return $thread_cache[$tid];
|
if(isset($thread_cache[$tid]) && !$recache) { return $thread_cache[$tid];
|
} else
| } else
|
{ $query = $db->simple_select("threads", "*", "tid = '{$tid}'"); $thread = $db->fetch_array($query);
| { $query = $db->simple_select("threads", "*", "tid = '{$tid}'"); $thread = $db->fetch_array($query);
|
Zeile 6771 | Zeile 6843 |
---|
}
$inactive = array();
|
}
$inactive = array();
|
|
|
foreach($forum_cache as $fid => $forum) { if($forum['active'] == 0)
| foreach($forum_cache as $fid => $forum) { if($forum['active'] == 0)
|
Zeile 6784 | Zeile 6856 |
---|
$inactive[] = $fid1; } }
|
$inactive[] = $fid1; } }
|
} }
| } }
|
$inactiveforums = implode(",", $inactive);
| $inactiveforums = implode(",", $inactive);
|
Zeile 6813 | Zeile 6885 |
---|
$attempts = $db->fetch_array($query);
if($attempts['loginattempts'] <= 0)
|
$attempts = $db->fetch_array($query);
if($attempts['loginattempts'] <= 0)
|
{ return 0; } }
| { return 0; } }
|
// This user has a cookie lockout, show waiting time elseif(!empty($mybb->cookies['lockoutexpiry']) && $mybb->cookies['lockoutexpiry'] > $now) {
| // This user has a cookie lockout, show waiting time elseif(!empty($mybb->cookies['lockoutexpiry']) && $mybb->cookies['lockoutexpiry'] > $now) {
|
Zeile 6826 | Zeile 6898 |
---|
$hoursleft = floor($secsleft / 3600); $minsleft = floor(($secsleft / 60) % 60); $secsleft = floor($secsleft % 60);
|
$hoursleft = floor($secsleft / 3600); $minsleft = floor(($secsleft / 60) % 60); $secsleft = floor($secsleft % 60);
|
|
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false;
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false;
|
}
| }
|
if($mybb->settings['failedlogincount'] > 0 && isset($attempts['loginattempts']) && $attempts['loginattempts'] >= $mybb->settings['failedlogincount']) {
| if($mybb->settings['failedlogincount'] > 0 && isset($attempts['loginattempts']) && $attempts['loginattempts'] >= $mybb->settings['failedlogincount']) {
|
Zeile 6930 | Zeile 7002 |
---|
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
if($db->fetch_field($query, "emails") > 0)
|
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
if($db->fetch_field($query, "emails") > 0)
|
{ return true; }
return false; }
/**
| { return true; }
return false; }
/**
|
* Rebuilds settings.php * */ function rebuild_settings() { global $db, $mybb;
|
* Rebuilds settings.php * */ function rebuild_settings() { global $db, $mybb;
|
|
|
$query = $db->simple_select("settings", "value, name", "", array( 'order_by' => 'title', 'order_dir' => 'ASC',
| $query = $db->simple_select("settings", "value, name", "", array( 'order_by' => 'title', 'order_dir' => 'ASC',
|
Zeile 6954 | Zeile 7026 |
---|
while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
|
while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
|
|
|
$setting['name'] = addcslashes($setting['name'], "\\'"); $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
| $setting['name'] = addcslashes($setting['name'], "\\'"); $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
Zeile 6996 | Zeile 7068 |
---|
"~" ); $terms = str_replace($bad_characters, '', $terms);
|
"~" ); $terms = str_replace($bad_characters, '', $terms);
|
| $words = array();
|
// Check if this is a "series of words" - should be treated as an EXACT match if(my_strpos($terms, "\"") !== false) { $inquote = false; $terms = explode("\"", $terms);
|
// Check if this is a "series of words" - should be treated as an EXACT match if(my_strpos($terms, "\"") !== false) { $inquote = false; $terms = explode("\"", $terms);
|
$words = array();
| |
foreach($terms as $phrase)
|
foreach($terms as $phrase)
|
{
| {
|
$phrase = htmlspecialchars_uni($phrase); if($phrase != "") {
| $phrase = htmlspecialchars_uni($phrase); if($phrase != "") {
|
Zeile 7048 | Zeile 7120 |
---|
$words[] = trim($word); } }
|
$words[] = trim($word); } }
|
}
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 usort($words, 'build_highlight_array_sort');
|
}
// 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 usort($words, 'build_highlight_array_sort');
|
| $highlight_cache = array();
|
// Loop through our words to build the PREG compatible strings foreach($words as $word)
| // Loop through our words to build the PREG compatible strings foreach($words as $word)
|
Zeile 7065 | Zeile 7134 |
---|
$word = trim($word);
$word = my_strtolower($word);
|
$word = trim($word);
$word = my_strtolower($word);
|
|
|
// Special boolean operators should be stripped if($word == "" || $word == "or" || $word == "not" || $word == "and")
|
// Special boolean operators should be stripped if($word == "" || $word == "or" || $word == "not" || $word == "and")
|
{ continue; }
| { continue; }
|
// Now make PREG compatible
|
// Now make PREG compatible
|
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui"; $replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
| $find = "/(?<!&|&#)\b([[:alnum:]]*)(".preg_quote($word, "/").")(?![^<>]*?>)/ui"; $replacement = "$1<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$2</span>";
|
$highlight_cache[$find] = $replacement; }
| $highlight_cache[$find] = $replacement; }
|
Zeile 7105 | Zeile 7174 |
---|
$dest = '';
if($src < 0)
|
$dest = '';
if($src < 0)
|
{ return false;
| { return false;
|
} elseif($src <= 0x007f) {
| } elseif($src <= 0x007f) {
|
Zeile 7137 | Zeile 7206 |
---|
}
return $dest;
|
}
return $dest;
|
}
/**
| }
/**
|
* Checks if a username has been disallowed for registration/use. * * @param string $username The username
| * Checks if a username has been disallowed for registration/use. * * @param string $username The username
|
Zeile 7155 | Zeile 7224 |
---|
// Make regular expression * match $banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#')); if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
|
// Make regular expression * match $banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#')); if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
|
{
| {
|
// Updating last use if($update_lastuse == true) {
| // Updating last use if($update_lastuse == true) {
|
Zeile 7203 | Zeile 7272 |
---|
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'"); } return true;
|
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'"); } return true;
|
} }
| } }
|
}
// Still here - good email
| }
// Still here - good email
|
Zeile 7221 | Zeile 7290 |
---|
function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
|
function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
|
|
|
$banned_ips = $cache->read("bannedips"); if(!is_array($banned_ips))
|
$banned_ips = $cache->read("bannedips"); if(!is_array($banned_ips))
|
{
| {
|
return false; }
|
return false; }
|
|
|
$ip_address = my_inet_pton($ip_address); foreach($banned_ips as $banned_ip) { if(!$banned_ip['filter']) { continue;
|
$ip_address = my_inet_pton($ip_address); foreach($banned_ips as $banned_ip) { if(!$banned_ip['filter']) { continue;
|
}
$banned = false;
| }
$banned = false;
|
$ip_range = fetch_ip_range($banned_ip['filter']); if(is_array($ip_range)) {
| $ip_range = fetch_ip_range($banned_ip['filter']); if(is_array($ip_range)) {
|
Zeile 7336 | Zeile 7405 |
---|
$selected = str_replace("+", "", $selected); $timezone_option = ''; foreach($timezones as $timezone => $label)
|
$selected = str_replace("+", "", $selected); $timezone_option = ''; foreach($timezones as $timezone => $label)
|
{
| {
|
$selected_add = ""; if($selected == $timezone) {
| $selected_add = ""; if($selected == $timezone) {
|
Zeile 7368 | Zeile 7437 |
---|
}
eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");
|
}
eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");
|
}
| }
|
eval("\$select = \"".$templates->get("usercp_options_timezone")."\";"); return $select;
| eval("\$select = \"".$templates->get("usercp_options_timezone")."\";"); return $select;
|
Zeile 7400 | Zeile 7469 |
---|
if(!isset($url_components['port'])) { $url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80;
|
if(!isset($url_components['port'])) { $url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80;
|
}
| }
|
if( !$url_components ||
| if( !$url_components ||
|
Zeile 7412 | Zeile 7481 |
---|
{ return false; }
|
{ return false; }
|
|
|
$addresses = get_ip_by_hostname($url_components['host']); $destination_address = $addresses[0];
if(!empty($config['disallowed_remote_addresses']))
|
$addresses = get_ip_by_hostname($url_components['host']); $destination_address = $addresses[0];
if(!empty($config['disallowed_remote_addresses']))
|
{
| {
|
foreach($config['disallowed_remote_addresses'] as $disallowed_address) { $ip_range = fetch_ip_range($disallowed_address);
| foreach($config['disallowed_remote_addresses'] as $disallowed_address) { $ip_range = fetch_ip_range($disallowed_address);
|
Zeile 7466 | Zeile 7535 |
---|
{ $curlopt[CURLOPT_SSL_VERIFYPEER] = 1; $curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
|
{ $curlopt[CURLOPT_SSL_VERIFYPEER] = 1; $curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
|
} else
| } else
|
{ $curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
|
{ $curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
|
}
| }
|
$curl_version_info = curl_version(); $curl_version = $curl_version_info['version'];
| $curl_version_info = curl_version(); $curl_version = $curl_version_info['version'];
|
Zeile 7479 | Zeile 7548 |
---|
{ // CURLOPT_CONNECT_TO $curlopt[10243] = array(
|
{ // CURLOPT_CONNECT_TO $curlopt[10243] = array(
|
$url_components['host'].':'.$url_components['port'].':'.$destination_address );
| $url_components['host'].':'.$url_components['port'].':'.$destination_address );
|
} elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>=')) {
| } elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>=')) {
|
Zeile 7488 | Zeile 7557 |
---|
$curlopt[10203] = array( $url_components['host'].':'.$url_components['port'].':'.$destination_address );
|
$curlopt[10203] = array( $url_components['host'].':'.$url_components['port'].':'.$destination_address );
|
| }
if(defined('CURLOPT_DISALLOW_USERNAME_IN_URL')) { $curlopt[CURLOPT_DISALLOW_USERNAME_IN_URL] = true;
|
}
if(!empty($post_body))
| }
if(!empty($post_body))
|
Zeile 7730 | Zeile 7804 |
---|
* Checks if a user is a member of a particular group * Originates from frostschutz's PluginLibrary * github.com/frostschutz
|
* Checks if a user is a member of a particular group * Originates from frostschutz's PluginLibrary * github.com/frostschutz
|
*
| *
|
* @param array|int|string A selection of groups (as array or comma seperated) to check or -1 for any group * @param bool|array|int False assumes the current user. Otherwise an user array or an id can be passed * @return array Array of groups specified in the first param to which the user belongs
| * @param array|int|string A selection of groups (as array or comma seperated) to check or -1 for any group * @param bool|array|int False assumes the current user. Otherwise an user array or an id can be passed * @return array Array of groups specified in the first param to which the user belongs
|
Zeile 7991 | Zeile 8065 |
---|
$result = chmod($file, octdec($mode)); umask($old_umask); return $result;
|
$result = chmod($file, octdec($mode)); umask($old_umask); return $result;
|
}
/**
| }
/**
|
* Custom rmdir function to loop through an entire directory and delete all files/folders within * * @param string $path The path to the directory
| * Custom rmdir function to loop through an entire directory and delete all files/folders within * * @param string $path The path to the directory
|
Zeile 8010 | Zeile 8084 |
---|
}
if(@is_dir($path) && !@is_link($path))
|
}
if(@is_dir($path) && !@is_link($path))
|
{
| {
|
if($dh = @opendir($path)) { while(($file = @readdir($dh)) !== false)
| if($dh = @opendir($path)) { while(($file = @readdir($dh)) !== false)
|
Zeile 8076 | Zeile 8150 |
---|
}
if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
|
}
if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
|
{
| {
|
$ip_long -= 4294967296; }
| $ip_long -= 4294967296; }
|
Zeile 8092 | Zeile 8166 |
---|
* @return string IP in IPv4 format */ function my_long2ip($long)
|
* @return string IP in IPv4 format */ function my_long2ip($long)
|
{
| {
|
// On 64-bit machines is_int will return true. On 32-bit it will return false if($long < 0 && is_int(2147483648)) {
| // On 64-bit machines is_int will return true. On 32-bit it will return false if($long < 0 && is_int(2147483648)) {
|
Zeile 8124 | Zeile 8198 |
---|
* @license LGPL - http://www.gnu.org/licenses/lgpl.html * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net> * @link http://php.net/inet_pton
|
* @license LGPL - http://www.gnu.org/licenses/lgpl.html * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net> * @link http://php.net/inet_pton
|
* @author Arpad Ray <arpad@php.net> * @version $Revision: 269597 $
| * @author Arpad Ray <arpad@php.net> * @version $Revision: 269597 $
|
*/ $r = ip2long($ip); if($r !== false && $r != -1) { return pack('N', $r);
|
*/ $r = ip2long($ip); if($r !== false && $r != -1) { return pack('N', $r);
|
}
| }
|
$delim_count = substr_count($ip, ':'); if($delim_count < 1 || $delim_count > 7) {
| $delim_count = substr_count($ip, ':'); if($delim_count < 1 || $delim_count > 7) {
|
Zeile 8142 | Zeile 8216 |
---|
$r = explode(':', $ip); $rcount = count($r); if(($doub = array_search('', $r, 1)) !== false)
|
$r = explode(':', $ip); $rcount = count($r); if(($doub = array_search('', $r, 1)) !== false)
|
{
| {
|
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1); array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0)); }
| $length = (!$doub || $doub == $rcount - 1 ? 2 : 1); array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0)); }
|
Zeile 8207 | Zeile 8281 |
---|
{ // Wildcard if(strpos($ipaddress, '*') !== false)
|
{ // Wildcard if(strpos($ipaddress, '*') !== false)
|
{
| {
|
if(strpos($ipaddress, ':') !== false) { // IPv6
| if(strpos($ipaddress, ':') !== false) { // IPv6
|
Zeile 8255 | Zeile 8329 |
---|
{ // Invalid IP address return false;
|
{ // Invalid IP address return false;
|
} }
| } }
|
/** * Taken from: https://github.com/NewEraCracker/php_work/blob/master/ipRangeCalculate.php
| /** * Taken from: https://github.com/NewEraCracker/php_work/blob/master/ipRangeCalculate.php
|
Zeile 8516 | Zeile 8590 |
---|
if ($crypto_strong == false) { $output = null;
|
if ($crypto_strong == false) { $output = null;
|
} } } }
| } } } }
|
else { return $output;
| else { return $output;
|
Zeile 8548 | Zeile 8622 |
---|
if(strlen($output) < $bytes) { // Close to what PHP basically uses internally to seed, but not quite.
|
if(strlen($output) < $bytes) { // Close to what PHP basically uses internally to seed, but not quite.
|
$unique_state = microtime().@getmypid();
| $unique_state = microtime().@getmypid();
|
$rounds = ceil($bytes / 16);
| $rounds = ceil($bytes / 16);
|
Zeile 8565 | Zeile 8639 |
---|
return $output; } else
|
return $output; } else
|
{
| {
|
return $output; } }
| return $output; } }
|
Zeile 8578 | Zeile 8652 |
---|
function secure_seed_rng() { $bytes = PHP_INT_SIZE;
|
function secure_seed_rng() { $bytes = PHP_INT_SIZE;
|
|
|
do
|
do
|
{
| {
|
$output = secure_binary_seed_rng($bytes);
|
$output = secure_binary_seed_rng($bytes);
|
|
|
// convert binary data to a decimal number if ($bytes == 4)
|
// convert binary data to a decimal number if ($bytes == 4)
|
{
| {
|
$elements = unpack('i', $output); $output = abs($elements[1]); }
| $elements = unpack('i', $output); $output = abs($elements[1]); }
|
Zeile 8594 | Zeile 8668 |
---|
{ $elements = unpack('N2', $output); $output = abs($elements[1] << 32 | $elements[2]);
|
{ $elements = unpack('N2', $output); $output = abs($elements[1] << 32 | $elements[2]);
|
}
} while($output > PHP_INT_MAX);
| }
} while($output > PHP_INT_MAX);
|
return $output; }
| return $output; }
|
Zeile 8614 | Zeile 8688 |
---|
{ $min = 0; $max = PHP_INT_MAX;
|
{ $min = 0; $max = PHP_INT_MAX;
|
}
| }
|
if(version_compare(PHP_VERSION, '7.0', '>=')) {
| if(version_compare(PHP_VERSION, '7.0', '>=')) {
|
Zeile 8647 | Zeile 8721 |
---|
function trim_blank_chrs($string, $charlist="") { $hex_chrs = array(
|
function trim_blank_chrs($string, $charlist="") { $hex_chrs = array(
|
0x09 => 1, // \x{0009} 0x0A => 1, // \x{000A} 0x0B => 1, // \x{000B} 0x0D => 1, // \x{000D} 0x20 => 1, // \x{0020}
| 0x09 => 1, // \x{0009} 0x0A => 1, // \x{000A} 0x0B => 1, // \x{000B} 0x0D => 1, // \x{000D} 0x20 => 1, // \x{0020}
|
0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD} 0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1), 0x9A => array(0x80 => 1), 0xA0 => array(0x8E => 1)), // \x{115F}, \x{1160}, \x{1680}, \x{180E}
| 0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD} 0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1), 0x9A => array(0x80 => 1), 0xA0 => array(0x8E => 1)), // \x{115F}, \x{1160}, \x{1680}, \x{180E}
|
Zeile 8714 | Zeile 8788 |
---|
{ // Check to see if we have matched a first character in our utf-8 array $offset = match_sequence($string, $hex_chrs);
|
{ // Check to see if we have matched a first character in our utf-8 array $offset = match_sequence($string, $hex_chrs);
|
if(!$offset) { // If not, then we must have a "good" character and we don't need to do anymore processing break;
| if(!$offset) { // If not, then we must have a "good" character and we don't need to do anymore processing break;
|
} $string = substr($string, $offset); }
| } $string = substr($string, $offset); }
|
Zeile 8766 | Zeile 8840 |
---|
if($string === "") { return 0;
|
if($string === "") { return 0;
|
}
| }
|
$ord = ord($string[$i]); if(array_key_exists($ord, $array))
| $ord = ord($string[$i]); if(array_key_exists($ord, $array))
|
Zeile 8782 | Zeile 8856 |
---|
}
return 0;
|
}
return 0;
|
}
| }
|
/** * Obtain the version of GD installed.
| /** * Obtain the version of GD installed.
|
Zeile 9001 | Zeile 9075 |
---|
} }
|
} }
|
if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))
| if(empty($pm['subject']) || empty($pm['message']) || empty($pm['touid']) || (empty($pm['receivepms']) && !$admin_override))
|
{ return false; }
| { return false; }
|
Zeile 9025 | Zeile 9099 |
---|
}
$recipients_bcc = array();
|
}
$recipients_bcc = array();
|
| // Workaround for eliminating PHP warnings in PHP 8. Ref: https://github.com/mybb/mybb/issues/4630#issuecomment-1369144163 if(isset($pm['sender']['uid']) && $pm['sender']['uid'] === -1 && $fromid === -1) { $sender = array( "uid" => 0, "username" => '' ); }
|
// Determine user ID if((int)$fromid == 0)
|
// Determine user ID if((int)$fromid == 0)
|
{
| {
|
$fromid = (int)$mybb->user['uid']; } elseif((int)$fromid < 0)
| $fromid = (int)$mybb->user['uid']; } elseif((int)$fromid < 0)
|
Zeile 9047 | Zeile 9130 |
---|
"do" => '', "pmid" => '' );
|
"do" => '', "pmid" => '' );
|
| // (continued) Workaround for eliminating PHP warnings in PHP 8. Ref: https://github.com/mybb/mybb/issues/4630#issuecomment-1369144163 if(isset($sender)) { $pm['sender'] = $sender; }
|
if(isset($session)) {
| if(isset($session)) {
|