Zeile 322 | Zeile 322 |
---|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
* @param string $format A date format according to PHP's date structure.
| * @param string $format A date format (either relative, normal or PHP's date() structure).
|
* @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
| * @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
|
Zeile 380 | Zeile 380 |
---|
}
$todaysdate = $yesterdaysdate = '';
|
}
$todaysdate = $yesterdaysdate = '';
|
if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))
| if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))
|
{ $_stamp = TIME_NOW; if($adodb == true)
| { $_stamp = TIME_NOW; if($adodb == true)
|
Zeile 470 | Zeile 470 |
---|
{ if($todaysdate == $date) {
|
{ if($todaysdate == $date) {
|
$date = $lang->sprintf($lang->today, $real_date);
| $date = $lang->sprintf($lang->today_rel, $real_date);
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->sprintf($lang->yesterday, $real_date);
| $date = $lang->sprintf($lang->yesterday_rel, $real_date);
|
} }
| } }
|
Zeile 487 | Zeile 487 |
---|
{ $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
{ $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
| } } elseif($format == 'normal') { // Normal format both date and time if($ty != 2) { if($todaysdate == $date) { $date = $lang->today; } else if($yesterdaysdate == $date) { $date = $lang->yesterday; } }
$date .= $mybb->settings['datetimesep']; if($adodb == true) { $date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600)); } else { $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
} } else
| } } else
|
Zeile 495 | Zeile 520 |
---|
{ if($todaysdate == $date) {
|
{ if($todaysdate == $date) {
|
$date = $lang->sprintf($lang->today, $real_date);
| $date = $lang->today;
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->sprintf($lang->yesterday, $real_date);
| $date = $lang->yesterday;
|
} } else
| } } else
|
Zeile 521 | Zeile 546 |
---|
}
return $date;
|
}
return $date;
|
}
| }
|
/** * Sends an email using PHP's mail function, formatting it appropriately. *
| /** * Sends an email using PHP's mail function, formatting it appropriately. *
|
Zeile 585 | Zeile 610 |
---|
/** * Generates a unique code for POST requests to prevent XSS/CSRF attacks
|
/** * Generates a unique code for POST requests to prevent XSS/CSRF attacks
|
*
| *
|
* @return string The generated code */ function generate_post_check()
| * @return string The generated code */ function generate_post_check()
|
Zeile 615 | Zeile 640 |
---|
if(generate_post_check() !== $code) { if($silent == true)
|
if(generate_post_check() !== $code) { if($silent == true)
|
{ return false;
| { return false;
|
} else { if(defined("IN_ADMINCP"))
|
} else { if(defined("IN_ADMINCP"))
|
{
| {
|
return false;
|
return false;
|
}
| }
|
else { error($lang->invalid_post_code);
|
else { error($lang->invalid_post_code);
|
} } } else
| } } } else
|
{ return true; }
| { return true; }
|
Zeile 646 | Zeile 671 |
---|
{ global $forum_cache; static $forumarraycache;
|
{ global $forum_cache; static $forumarraycache;
|
|
|
if($forumarraycache[$fid]) { return $forumarraycache[$fid]['parentlist'];
|
if($forumarraycache[$fid]) { return $forumarraycache[$fid]['parentlist'];
|
}
| }
|
elseif($forum_cache[$fid])
|
elseif($forum_cache[$fid])
|
{ return $forum_cache[$fid]['parentlist']; }
| { return $forum_cache[$fid]['parentlist']; }
|
else { cache_forums(); return $forum_cache[$fid]['parentlist'];
|
else { cache_forums(); return $forum_cache[$fid]['parentlist'];
|
} }
| } }
|
/** * Build a parent list of a specific forum, suitable for querying *
| /** * Build a parent list of a specific forum, suitable for querying *
|
Zeile 676 | Zeile 701 |
---|
if(!$parentlist) { $parentlist = get_parent_list($fid);
|
if(!$parentlist) { $parentlist = get_parent_list($fid);
|
}
| }
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
|
|
foreach($parentsexploded as $key => $val) { $builtlist .= "$sep$column='$val'"; $sep = " $joiner "; }
|
foreach($parentsexploded as $key => $val) { $builtlist .= "$sep$column='$val'"; $sep = " $joiner "; }
|
$builtlist .= ")";
| $builtlist .= ")";
|
return $builtlist;
|
return $builtlist;
|
}
/**
| }
/**
|
* Load the forum cache in to memory * * @param boolean $force True to force a reload of the cache
| * Load the forum cache in to memory * * @param boolean $force True to force a reload of the cache
|
Zeile 707 | Zeile 732 |
---|
{ $forum_cache = $cache->read("forums", 1); return $forum_cache;
|
{ $forum_cache = $cache->read("forums", 1); return $forum_cache;
|
}
| }
|
if(!$forum_cache) { $forum_cache = $cache->read("forums");
| if(!$forum_cache) { $forum_cache = $cache->read("forums");
|
Zeile 740 | Zeile 765 |
---|
if($forum['active'] != 0) { $forums_by_parent[$forum['pid']][$forum['fid']] = $forum;
|
if($forum['active'] != 0) { $forums_by_parent[$forum['pid']][$forum['fid']] = $forum;
|
} } }
| } } }
|
if(!is_array($forums_by_parent[$fid])) { return $forums;
| if(!is_array($forums_by_parent[$fid])) { return $forums;
|
Zeile 991 | Zeile 1016 |
---|
}
exit;
|
}
exit;
|
}
/**
| }
/**
|
* Generate a listing of page - pagination * * @param int $count The number of items
| * Generate a listing of page - pagination * * @param int $count The number of items
|
Zeile 1006 | Zeile 1031 |
---|
function multipage($count, $perpage, $page, $url, $breadcrumb=false) { global $theme, $templates, $lang, $mybb;
|
function multipage($count, $perpage, $page, $url, $breadcrumb=false) { global $theme, $templates, $lang, $mybb;
|
|
|
if($count <= $perpage) { return ''; }
|
if($count <= $perpage) { return ''; }
|
| $page = (int)$page;
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 1116 | Zeile 1143 |
---|
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";"); }
|
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";"); }
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
| $multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
|
if($breadcrumb == true) {
| if($breadcrumb == true) {
|
Zeile 1176 | Zeile 1203 |
---|
/** * Fetch the permissions for a specific user *
|
/** * Fetch the permissions for a specific user *
|
* @param int $uid The user ID
| * @param int $uid The user ID, if no user ID is provided then current user's ID will be considered.
|
* @return array Array of user permissions for the specified user */
|
* @return array Array of user permissions for the specified user */
|
function user_permissions($uid=0)
| function user_permissions($uid=null)
|
{ global $mybb, $cache, $groupscache, $user_cache;
// If no user id is specified, assume it is the current user
|
{ global $mybb, $cache, $groupscache, $user_cache;
// If no user id is specified, assume it is the current user
|
if($uid == 0) {
| if($uid === null) {
|
$uid = $mybb->user['uid'];
|
$uid = $mybb->user['uid'];
|
| }
// Its a guest. Return the group permissions directly from cache if($uid == 0) { return $groupscache[1];
|
}
// User id does not match current user, fetch permissions if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
}
// User id does not match current user, fetch permissions if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
if($user_cache[$uid]['permissions'])
| if(!empty($user_cache[$uid]['permissions']))
|
{ return $user_cache[$uid]['permissions']; }
// This user was not already cached, fetch their user information.
|
{ return $user_cache[$uid]['permissions']; }
// This user was not already cached, fetch their user information.
|
if(!$user_cache[$uid])
| if(empty($user_cache[$uid]))
|
{ $user_cache[$uid] = get_user($uid); }
| { $user_cache[$uid] = get_user($uid); }
|
Zeile 1248 | Zeile 1281 |
---|
foreach($groups as $gid) { if(trim($gid) == "" || empty($groupscache[$gid]))
|
foreach($groups as $gid) { if(trim($gid) == "" || empty($groupscache[$gid]))
|
{
| {
|
continue; }
|
continue; }
|
|
|
foreach($groupscache[$gid] as $perm => $access) { if(!in_array($perm, $grouppermignore)) { if(isset($usergroup[$perm]))
|
foreach($groupscache[$gid] as $perm => $access) { if(!in_array($perm, $grouppermignore)) { if(isset($usergroup[$perm]))
|
{
| {
|
$permbit = $usergroup[$perm];
|
$permbit = $usergroup[$perm];
|
}
| }
|
else { $permbit = "";
|
else { $permbit = "";
|
}
| }
|
// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account. if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0)) {
| // 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account. if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0)) {
|
Zeile 1296 | Zeile 1329 |
---|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
| }
|
$displaygroup = array(); $group = $groupscache[$gid];
| $displaygroup = array(); $group = $groupscache[$gid];
|
Zeile 1327 | Zeile 1360 |
---|
}
if(!$gid || $gid == 0) // If no group, we need to fetch it
|
}
if(!$gid || $gid == 0) // If no group, we need to fetch it
|
{
| {
|
if($uid != 0 && $uid != $mybb->user['uid'])
|
if($uid != 0 && $uid != $mybb->user['uid'])
|
{
| {
|
$user = get_user($uid);
|
$user = get_user($uid);
|
|
|
$gid = $user['usergroup'].",".$user['additionalgroups']; $groupperms = usergroup_permissions($gid); }
| $gid = $user['usergroup'].",".$user['additionalgroups']; $groupperms = usergroup_permissions($gid); }
|
Zeile 1343 | Zeile 1376 |
---|
{ $gid .= ",".$mybb->user['additionalgroups']; }
|
{ $gid .= ",".$mybb->user['additionalgroups']; }
|
|
|
$groupperms = $mybb->usergroup;
|
$groupperms = $mybb->usergroup;
|
} }
| } }
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums();
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums();
|
|
|
if(!$forum_cache) { return false;
| if(!$forum_cache) { return false;
|
Zeile 1359 | Zeile 1392 |
---|
}
if(!is_array($fpermcache))
|
}
if(!is_array($fpermcache))
|
{
| {
|
$fpermcache = $cache->read("forumpermissions");
|
$fpermcache = $cache->read("forumpermissions");
|
}
| }
|
if($fid) // Fetch the permissions for a single forum {
| if($fid) // Fetch the permissions for a single forum {
|
Zeile 1374 | Zeile 1407 |
---|
else { if(empty($cached_forum_permissions[$gid]))
|
else { if(empty($cached_forum_permissions[$gid]))
|
{
| {
|
foreach($forum_cache as $forum) { $cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
| foreach($forum_cache as $forum) { $cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
|
Zeile 1434 | Zeile 1467 |
---|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions))
|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions))
|
{
| {
|
$level_permissions = $groupscache[$gid];
|
$level_permissions = $groupscache[$gid];
|
}
| }
|
foreach($level_permissions as $permission => $access)
|
foreach($level_permissions as $permission => $access)
|
{
| {
|
if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no")) { $current_permissions[$permission] = $access;
| if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no")) { $current_permissions[$permission] = $access;
|
Zeile 1449 | Zeile 1482 |
---|
if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"])) { $only_view_own_threads = 0;
|
if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"])) { $only_view_own_threads = 0;
|
}
| }
|
if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"])) {
| if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"])) {
|
Zeile 1495 | Zeile 1528 |
---|
{ $forum_cache = cache_forums(); if(!$forum_cache)
|
{ $forum_cache = cache_forums(); if(!$forum_cache)
|
{ return false; } }
| { return false; } }
|
// Loop through each of parent forums to ensure we have a password for them too if(isset($forum_cache[$fid]['parentlist'])) {
| // Loop through each of parent forums to ensure we have a password for them too if(isset($forum_cache[$fid]['parentlist'])) {
|
Zeile 1513 | Zeile 1546 |
---|
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 1558 | Zeile 1591 |
---|
if($return) { return $showform;
|
if($return) { return $showform;
|
}
| }
|
if($showform) { if($pid)
| if($showform) { if($pid)
|
Zeile 1620 | Zeile 1653 |
---|
$extra_groups = explode(",", $user['additionalgroups']);
foreach($extra_groups as $extra_group)
|
$extra_groups = explode(",", $user['additionalgroups']);
foreach($extra_groups as $extra_group)
|
{
| {
|
$groups[] = $extra_group; } }
| $groups[] = $extra_group; } }
|
Zeile 1665 | Zeile 1698 |
---|
{ // 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) {
| $perm = $forum['usergroups'][$group]; foreach($perm as $action => $value) {
|
Zeile 1674 | Zeile 1707 |
---|
{ continue; }
|
{ continue; }
|
|
|
$perms[$action] = max($perm[$action], $perms[$action]);
|
$perms[$action] = max($perm[$action], $perms[$action]);
|
} } }
$modpermscache[$fid][$uid] = $perms;
| } } }
$modpermscache[$fid][$uid] = $perms;
|
return $perms; }
| return $perms; }
|
Zeile 1696 | Zeile 1729 |
---|
function is_moderator($fid=0, $action="", $uid=0) { global $mybb, $cache;
|
function is_moderator($fid=0, $action="", $uid=0) { global $mybb, $cache;
|
if($uid == 0) {
| if($uid == 0) {
|
$uid = $mybb->user['uid'];
|
$uid = $mybb->user['uid'];
|
}
| }
|
if($uid == 0) {
| if($uid == 0) {
|
Zeile 1711 | Zeile 1744 |
---|
if($user_perms['issupermod'] == 1) { if($fid)
|
if($user_perms['issupermod'] == 1) { if($fid)
|
{
| {
|
$forumpermissions = forum_permissions($fid); if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads']) {
| $forumpermissions = forum_permissions($fid); if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads']) {
|
Zeile 1742 | Zeile 1775 |
---|
if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action]))) { return true;
|
if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action]))) { return true;
|
} } } }
| } } } }
|
return false; } else
| return false; } else
|
Zeile 1753 | Zeile 1786 |
---|
$modperms = get_moderator_permissions($fid, $uid);
if(!$action && $modperms)
|
$modperms = get_moderator_permissions($fid, $uid);
if(!$action && $modperms)
|
{
| {
|
return true; } else
| return true; } else
|
Zeile 1761 | Zeile 1794 |
---|
if(isset($modperms[$action]) && $modperms[$action] == 1) { return true;
|
if(isset($modperms[$action]) && $modperms[$action] == 1) { return true;
|
}
| }
|
else { return false;
| else { return false;
|
Zeile 1777 | Zeile 1810 |
---|
* @return string The template of posticons. */ function get_post_icons()
|
* @return string The template of posticons. */ function get_post_icons()
|
{
| {
|
global $mybb, $cache, $icon, $theme, $templates, $lang;
if(isset($mybb->input['icon']))
| global $mybb, $cache, $icon, $theme, $templates, $lang;
if(isset($mybb->input['icon']))
|
Zeile 1788 | Zeile 1821 |
---|
$iconlist = ''; $no_icons_checked = " checked=\"checked\""; // read post icons from cache, and sort them accordingly
|
$iconlist = ''; $no_icons_checked = " checked=\"checked\""; // read post icons from cache, and sort them accordingly
|
$posticons_cache = $cache->read("posticons");
| $posticons_cache = (array)$cache->read("posticons");
|
$posticons = array(); foreach($posticons_cache as $posticon) { $posticons[$posticon['name']] = $posticon;
|
$posticons = array(); foreach($posticons_cache as $posticon) { $posticons[$posticon['name']] = $posticon;
|
}
| }
|
krsort($posticons);
foreach($posticons as $dbicon)
| krsort($posticons);
foreach($posticons as $dbicon)
|
Zeile 1834 | Zeile 1867 |
---|
* @param string $value The cookie value. * @param int|string $expires The timestamp of the expiry date. * @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)
|
* @param string $value The cookie value. * @param int|string $expires The timestamp of the expiry date. * @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)
|
| * @param string $samesite The samesite attribute to prevent CSRF.
|
*/
|
*/
|
function my_setcookie($name, $value="", $expires="", $httponly=false)
| function my_setcookie($name, $value="", $expires="", $httponly=false, $samesite="")
|
{ global $mybb;
| { global $mybb;
|
Zeile 1872 | Zeile 1906 |
---|
if(!empty($mybb->settings['cookiepath'])) { $cookie .= "; path={$mybb->settings['cookiepath']}";
|
if(!empty($mybb->settings['cookiepath'])) { $cookie .= "; path={$mybb->settings['cookiepath']}";
|
}
| }
|
if(!empty($mybb->settings['cookiedomain']))
|
if(!empty($mybb->settings['cookiedomain']))
|
{
| {
|
$cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
$cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
}
| }
|
if($httponly == true)
|
if($httponly == true)
|
{
| {
|
$cookie .= "; HttpOnly";
|
$cookie .= "; HttpOnly";
|
| }
if($samesite != "" && $mybb->settings['cookiesamesiteflag']) { $samesite = strtolower($samesite);
if($samesite == "lax" || $samesite == "strict") { $cookie .= "; SameSite=".$samesite; }
|
}
if($mybb->settings['cookiesecureflag'])
| }
if($mybb->settings['cookiesecureflag'])
|
Zeile 1900 | Zeile 1944 |
---|
* @param string $name The cookie identifier. */ function my_unsetcookie($name)
|
* @param string $name The cookie identifier. */ function my_unsetcookie($name)
|
{ global $mybb;
| { global $mybb;
|
$expires = -3600; my_setcookie($name, "", $expires);
|
$expires = -3600; my_setcookie($name, "", $expires);
|
|
|
unset($mybb->cookies[$name]); }
| unset($mybb->cookies[$name]); }
|
Zeile 1915 | Zeile 1959 |
---|
* @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.
|
*/
| */
|
function my_get_array_cookie($name, $id) { global $mybb;
|
function my_get_array_cookie($name, $id) { global $mybb;
|
|
|
if(!isset($mybb->cookies['mybb'][$name]))
|
if(!isset($mybb->cookies['mybb'][$name]))
|
{ return false; }
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id])) { return $cookie[$id]; }
| { return false; }
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id])) { return $cookie[$id]; }
|
else { return 0;
| else { return 0;
|
Zeile 1989 | Zeile 2033 |
---|
if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH) { // input exceeds MAX_SERIALIZED_INPUT_LENGTH
|
if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH) { // input exceeds MAX_SERIALIZED_INPUT_LENGTH
|
return false; }
| return false; }
|
if(empty($str) || !is_string($str)) { return false;
| if(empty($str) || !is_string($str)) { return false;
|
Zeile 2115 | Zeile 2159 |
---|
$key = $value; $state = 3;
|
$key = $value; $state = 3;
|
break; }
| break; }
|
// illegal array index type return false;
| // illegal array index type return false;
|
Zeile 2492 | Zeile 2536 |
---|
// Fetch above counters for this forum $query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'"); $forum = $db->fetch_array($query);
|
// Fetch above counters for this forum $query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'"); $forum = $db->fetch_array($query);
|
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) == "-") { if((int)$changes[$counter] != 0) {
| 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) == "-") { if((int)$changes[$counter] != 0) {
|
$update_query[$counter] = $forum[$counter] + $changes[$counter]; } }
| $update_query[$counter] = $forum[$counter] + $changes[$counter]; } }
|
Zeile 2519 | Zeile 2563 |
---|
{ $update_query[$counter] = 0; }
|
{ $update_query[$counter] = 0; }
|
} }
| } }
|
// 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 2536 | Zeile 2580 |
---|
if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}";
|
if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}";
|
} else
| } else
|
{ $new_stats['numthreads'] = "{$threads_diff}"; }
| { $new_stats['numthreads'] = "{$threads_diff}"; }
|
Zeile 2547 | Zeile 2591 |
---|
{ $unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads']; if($unapprovedthreads_diff > -1)
|
{ $unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads']; if($unapprovedthreads_diff > -1)
|
{
| {
|
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}"; } else { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
|
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}"; } else { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
|
} }
| } }
|
if(array_key_exists('posts', $update_query)) {
| if(array_key_exists('posts', $update_query)) {
|
Zeile 2562 | Zeile 2606 |
---|
if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}";
|
if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}";
|
}
| }
|
else { $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(array_key_exists('unapprovedposts', $update_query)) { $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];
|
Zeile 2630 | Zeile 2674 |
---|
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);
| "); $lastpost = $db->fetch_array($query);
|
$updated_forum = array( "lastpost" => (int)$lastpost['lastpost'],
| $updated_forum = array( "lastpost" => (int)$lastpost['lastpost'],
|
Zeile 3007 | Zeile 3051 |
---|
for($i = 0; $i < $length; ++$i) { $str[] = $set[my_rand(0, 61)];
|
for($i = 0; $i < $length; ++$i) { $str[] = $set[my_rand(0, 61)];
|
}
| }
|
// Make sure they're in random order and convert them to a string shuffle($str);
| // Make sure they're in random order and convert them to a string shuffle($str);
|
Zeile 3025 | Zeile 3069 |
---|
*/ function format_name($username, $usergroup, $displaygroup=0) {
|
*/ function format_name($username, $usergroup, $displaygroup=0) {
|
global $groupscache, $cache;
| global $groupscache, $cache, $plugins;
|
|
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
| static $formattednames = array();
|
|
|
if($userin == 0)
| if(!isset($formattednames[$username]))
|
{
|
{
|
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
|
$format = "{username}";
|
$format = "{username}";
|
}
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
| if(isset($groupscache[$usergroup])) { $ugroup = $groupscache[$usergroup];
if(strpos($ugroup['namestyle'], "{username}") !== false) { $format = $ugroup['namestyle']; } }
$format = stripslashes($format);
$parameters = compact('username', 'usergroup', 'displaygroup', 'format');
$parameters = $plugins->run_hooks('format_name', $parameters);
$format = $parameters['format'];
$formattednames[$username] = str_replace("{username}", $username, $format); }
return $formattednames[$username];
|
}
/**
| }
/**
|
Zeile 3079 | Zeile 3139 |
---|
{ // Default avatar if(defined('IN_ADMINCP'))
|
{ // Default avatar if(defined('IN_ADMINCP'))
|
{
| {
|
$theme['imgdir'] = '../images'; }
$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']); $dimensions = $mybb->settings['useravatardims'];
|
$theme['imgdir'] = '../images'; }
$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']); $dimensions = $mybb->settings['useravatardims'];
|
}
| }
|
if(!$max_dimensions) {
| if(!$max_dimensions) {
|
Zeile 3095 | Zeile 3155 |
---|
// An empty key wouldn't work so we need to add a fall back $key = $dimensions; if(empty($key))
|
// An empty key wouldn't work so we need to add a fall back $key = $dimensions; if(empty($key))
|
{
| {
|
$key = 'default'; } $key2 = $max_dimensions;
| $key = 'default'; } $key2 = $max_dimensions;
|
Zeile 3142 | Zeile 3202 |
---|
/** * Build the javascript based MyCode inserter.
|
/** * Build the javascript based MyCode inserter.
|
*
| *
|
* @param string $bind The ID of the textarea to bind to. Defaults to "message". * @param bool $smilies Whether to include smilies. Defaults to true. *
| * @param string $bind The ID of the textarea to bind to. Defaults to "message". * @param bool $smilies Whether to include smilies. Defaults to true. *
|
Zeile 3518 | Zeile 3578 |
---|
$prefix_cache = $cache->read("threadprefixes", true);
if(!is_array($prefix_cache))
|
$prefix_cache = $cache->read("threadprefixes", true);
if(!is_array($prefix_cache))
|
{
| {
|
return array(); } }
| return array(); } }
|
Zeile 3527 | Zeile 3587 |
---|
foreach($prefix_cache as $prefix) { $prefixes_cache[$prefix['pid']] = $prefix;
|
foreach($prefix_cache as $prefix) { $prefixes_cache[$prefix['pid']] = $prefix;
|
}
| }
|
if($pid != 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
if($pid != 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
}
| }
|
else if(!empty($prefixes_cache)) { return $prefixes_cache; }
|
else if(!empty($prefixes_cache)) { return $prefixes_cache; }
|
|
|
return false; }
| return false; }
|
Zeile 3555 | Zeile 3615 |
---|
global $cache, $db, $lang, $mybb, $templates;
if($fid != 'all')
|
global $cache, $db, $lang, $mybb, $templates;
if($fid != 'all')
|
{
| {
|
$fid = (int)$fid;
|
$fid = (int)$fid;
|
}
| }
|
$prefix_cache = build_prefixes(0); if(empty($prefix_cache)) {
| $prefix_cache = build_prefixes(0); if(empty($prefix_cache)) {
|
Zeile 3569 | Zeile 3629 |
---|
// Go through each of our prefixes and decide which ones we can use $prefixes = array(); foreach($prefix_cache as $prefix)
|
// Go through each of our prefixes and decide which ones we can use $prefixes = array(); foreach($prefix_cache as $prefix)
|
{
| {
|
if($fid != "all" && $prefix['forums'] != "-1") { // Decide whether this prefix can be used in our forum
| if($fid != "all" && $prefix['forums'] != "-1") { // Decide whether this prefix can be used in our forum
|
Zeile 3580 | Zeile 3640 |
---|
// This prefix is not in our forum list continue; }
|
// This prefix is not in our forum list continue; }
|
}
| }
|
if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid) { // The current user can use this prefix
|
if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid) { // The current user can use this prefix
|
$prefixes[$prefix['pid']] = $prefix; } }
if(empty($prefixes)) { return ''; }
| $prefixes[$prefix['pid']] = $prefix; } }
if(empty($prefixes)) { return ''; }
|
$prefixselect = $prefixselect_prefix = '';
| $prefixselect = $prefixselect_prefix = '';
|
Zeile 3665 | Zeile 3725 |
---|
$forums = explode(",", $prefix['forums']);
if(in_array($fid, $forums))
|
$forums = explode(",", $prefix['forums']);
if(in_array($fid, $forums))
|
{
| {
|
// This forum can use this prefix! $prefixes[$prefix['pid']] = $prefix; }
| // This forum can use this prefix! $prefixes[$prefix['pid']] = $prefix; }
|
Zeile 3675 | Zeile 3735 |
---|
// This prefix is for anybody to use... $prefixes[$prefix['pid']] = $prefix; }
|
// This prefix is for anybody to use... $prefixes[$prefix['pid']] = $prefix; }
|
}
| }
|
if(empty($prefixes)) {
| if(empty($prefixes)) {
|
Zeile 3684 | Zeile 3744 |
---|
$default_selected = array(); $selected_pid = (int)$selected_pid;
|
$default_selected = array(); $selected_pid = (int)$selected_pid;
|
|
|
if($selected_pid == 0) { $default_selected['all'] = ' selected="selected"';
| if($selected_pid == 0) { $default_selected['all'] = ' selected="selected"';
|
Zeile 3702 | Zeile 3762 |
---|
{ $selected = ''; if($prefix['pid'] == $selected_pid)
|
{ $selected = ''; if($prefix['pid'] == $selected_pid)
|
{
| {
|
$selected = ' selected="selected"'; }
| $selected = ' selected="selected"'; }
|
Zeile 3795 | Zeile 3855 |
---|
{ $pid = (int)$data['pid']; unset($data['pid']);
|
{ $pid = (int)$data['pid']; unset($data['pid']);
|
| }
$tids = array(); if(isset($data['tids'])) { $tids = (array)$data['tids']; unset($data['tids']);
|
}
// Any remaining extra data - we my_serialize and insert in to its own column if(is_array($data)) { $data = my_serialize($data);
|
}
// Any remaining extra data - we my_serialize and insert in to its own column if(is_array($data)) { $data = my_serialize($data);
|
}
| }
|
$sql_array = array( "uid" => (int)$mybb->user['uid'], "dateline" => TIME_NOW,
| $sql_array = array( "uid" => (int)$mybb->user['uid'], "dateline" => TIME_NOW,
|
Zeile 3813 | Zeile 3880 |
---|
"data" => $db->escape_string($data), "ipaddress" => $db->escape_binary($session->packedip) );
|
"data" => $db->escape_string($data), "ipaddress" => $db->escape_binary($session->packedip) );
|
$db->insert_query("moderatorlog", $sql_array);
| if($tids) { $multiple_sql_array = array();
foreach($tids as $tid) { $sql_array['tid'] = (int)$tid; $multiple_sql_array[] = $sql_array; }
$db->insert_query_multiple("moderatorlog", $multiple_sql_array); } else { $db->insert_query("moderatorlog", $sql_array); }
|
}
/**
| }
/**
|
Zeile 4689 | Zeile 4772 |
---|
$stamp %= $msecs; $seconds = $stamp;
|
$stamp %= $msecs; $seconds = $stamp;
|
if($years == 1)
| // Prevent gross over accuracy ($options parameter will override these) if($years > 0)
|
{
|
{
|
$nicetime['years'] = "1".$lang_year;
| $options = array_merge(array( 'days' => false, 'hours' => false, 'minutes' => false, 'seconds' => false ), $options);
|
}
|
}
|
else if($years > 1)
| elseif($months > 0)
|
{
|
{
|
$nicetime['years'] = $years.$lang_years;
| $options = array_merge(array( 'hours' => false, 'minutes' => false, 'seconds' => false ), $options);
|
}
|
}
|
if($months == 1) { $nicetime['months'] = "1".$lang_month; } else if($months > 1) { $nicetime['months'] = $months.$lang_months; }
if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; }
if($days == 1)
| elseif($weeks > 0)
|
{
|
{
|
$nicetime['days'] = "1".$lang_day;
| $options = array_merge(array( 'minutes' => false, 'seconds' => false ), $options);
|
}
|
}
|
else if($days > 1)
| elseif($days > 0)
|
{
|
{
|
$nicetime['days'] = $days.$lang_days;
| $options = array_merge(array( 'seconds' => false ), $options); }
if(!isset($options['years']) || $options['years'] !== false) { if($years == 1) { $nicetime['years'] = "1".$lang_year; } else if($years > 1) { $nicetime['years'] = $years.$lang_years; } }
if(!isset($options['months']) || $options['months'] !== false) { if($months == 1) { $nicetime['months'] = "1".$lang_month; } else if($months > 1) { $nicetime['months'] = $months.$lang_months; } }
if(!isset($options['weeks']) || $options['weeks'] !== false) { if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; } }
if(!isset($options['days']) || $options['days'] !== false) { if($days == 1) { $nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days; }
|
}
if(!isset($options['hours']) || $options['hours'] !== false)
| }
if(!isset($options['hours']) || $options['hours'] !== false)
|
Zeile 4759 | Zeile 4886 |
---|
{ $nicetime['seconds'] = $seconds.$lang_seconds; }
|
{ $nicetime['seconds'] = $seconds.$lang_seconds; }
|
}
| }
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
| if(is_array($nicetime)) { return implode(", ", $nicetime);
|
Zeile 4780 | Zeile 4907 |
---|
if($alttrow == "trow1" && !$reset) { $trow = "trow2";
|
if($alttrow == "trow1" && !$reset) { $trow = "trow2";
|
}
| }
|
else { $trow = "trow1"; }
|
else { $trow = "trow1"; }
|
|
|
$alttrow = $trow;
|
$alttrow = $trow;
|
|
|
return $trow;
|
return $trow;
|
}
| }
|
/** * Add a user to a specific additional user group. *
| /** * Add a user to a specific additional user group. *
|
Zeile 4801 | Zeile 4928 |
---|
function join_usergroup($uid, $joingroup) { global $db, $mybb;
|
function join_usergroup($uid, $joingroup) { global $db, $mybb;
|
|
|
if($uid == $mybb->user['uid'])
|
if($uid == $mybb->user['uid'])
|
{
| {
|
$user = $mybb->user;
|
$user = $mybb->user;
|
}
| }
|
else { $query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".(int)$uid."'"); $user = $db->fetch_array($query);
|
else { $query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".(int)$uid."'"); $user = $db->fetch_array($query);
|
}
| }
|
// Build the new list of additional groups for this user and make sure they're in the right format $usergroups = ""; $usergroups = $user['additionalgroups'].",".$joingroup;
| // Build the new list of additional groups for this user and make sure they're in the right format $usergroups = ""; $usergroups = $user['additionalgroups'].",".$joingroup;
|
Zeile 4821 | Zeile 4948 |
---|
if(is_array($groups)) { $comma = '';
|
if(is_array($groups)) { $comma = '';
|
foreach($groups as $gid)
| foreach($groups as $gid)
|
{ if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid])) {
| { if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid])) {
|
Zeile 4830 | Zeile 4957 |
---|
$donegroup[$gid] = 1; } }
|
$donegroup[$gid] = 1; } }
|
}
| }
|
// What's the point in updating if they're the same? if($groupslist != $user['additionalgroups']) {
| // What's the point in updating if they're the same? if($groupslist != $user['additionalgroups']) {
|
Zeile 4871 | Zeile 4998 |
---|
$groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1;
|
$groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1;
|
}
| }
|
}
|
}
|
}
| }
|
$dispupdate = ""; if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
$dispupdate = ""; if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
}
| }
|
$db->write_query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate
| $db->write_query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate
|
Zeile 4910 | Zeile 5037 |
---|
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']); } elseif(!empty($_SERVER['PHP_SELF']))
|
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']); } elseif(!empty($_SERVER['PHP_SELF']))
|
{
| {
|
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
}
| }
|
elseif(!empty($_ENV['PHP_SELF']))
|
elseif(!empty($_ENV['PHP_SELF']))
|
{
| {
|
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);
|
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);
|
}
| }
|
elseif(!empty($_SERVER['PATH_INFO'])) { $location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
|
elseif(!empty($_SERVER['PATH_INFO'])) { $location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
|
}
| }
|
else
|
else
|
{
| {
|
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
}
| }
|
if($quick) { return $location; }
|
if($quick) { return $location; }
|
|
|
if($fields == true) { global $mybb;
| if($fields == true) { global $mybb;
|
Zeile 4951 | Zeile 5078 |
---|
}
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";
|
}
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";
|
} }
| } }
|
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else { if(isset($_SERVER['QUERY_STRING']))
|
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else { if(isset($_SERVER['QUERY_STRING']))
|
{
| {
|
$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
}
| }
|
else if(isset($_ENV['QUERY_STRING']))
|
else if(isset($_ENV['QUERY_STRING']))
|
{
| {
|
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']); }
if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
|
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']); }
if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
|
{
| {
|
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');
foreach($post_array as $var)
| $post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');
foreach($post_array as $var)
|
Zeile 4976 | Zeile 5103 |
---|
if(isset($_POST[$var])) { $addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
|
if(isset($_POST[$var])) { $addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
|
} }
| } }
|
if(isset($addloc) && is_array($addloc)) {
| if(isset($addloc) && is_array($addloc)) {
|
Zeile 5022 | Zeile 5149 |
---|
if(!isset($lang->use_default)) { $lang->use_default = $lang->lang_select_default;
|
if(!isset($lang->use_default)) { $lang->use_default = $lang->lang_select_default;
|
} }
if(!is_array($tcache)) { $query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme; } }
| } }
if(!is_array($tcache)) { $query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme; } }
|
if(is_array($tcache[$tid])) {
| if(is_array($tcache[$tid])) {
|
Zeile 5044 | Zeile 5171 |
---|
if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true) { if($theme['tid'] == $selected)
|
if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true) { if($theme['tid'] == $selected)
|
{
| {
|
$sel = " selected=\"selected\""; }
| $sel = " selected=\"selected\""; }
|
Zeile 5054 | Zeile 5181 |
---|
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";"); ++$num_themes; $depthit = $depth."--";
|
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";"); ++$num_themes; $depthit = $depth."--";
|
}
| }
|
if(array_key_exists($theme['tid'], $tcache)) {
| if(array_key_exists($theme['tid'], $tcache)) {
|
Zeile 5073 | Zeile 5200 |
---|
else { eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
|
else { eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
|
}
| }
|
return $themeselect; } else
| return $themeselect; } else
|
Zeile 5113 | Zeile 5240 |
---|
{ $s_theme = $theme; break 2;
|
{ $s_theme = $theme; break 2;
|
} } }
| } } }
|
return $s_theme; }
| return $s_theme; }
|
Zeile 5146 | Zeile 5273 |
---|
global $mybb;
if($number == "-")
|
global $mybb;
if($number == "-")
|
{
| {
|
return $number; }
| return $number; }
|
Zeile 5166 | Zeile 5293 |
---|
{ $decimals = 0; }
|
{ $decimals = 0; }
|
|
|
return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); } }
| return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); } }
|
Zeile 5186 | Zeile 5313 |
---|
static $use_iconv;
if(!isset($charset))
|
static $use_iconv;
if(!isset($charset))
|
{
| {
|
$charset = my_strtolower($lang->settings['charset']);
|
$charset = my_strtolower($lang->settings['charset']);
|
}
| }
|
if($charset == "utf-8") { return $str; }
if(!isset($use_iconv))
|
if($charset == "utf-8") { return $str; }
if(!isset($use_iconv))
|
{
| {
|
$use_iconv = function_exists("iconv"); }
| $use_iconv = function_exists("iconv"); }
|
Zeile 5358 | Zeile 5485 |
---|
$lang->month_11, $lang->month_12 );
|
$lang->month_11, $lang->month_12 );
|
| |
// This needs to be in this specific order $find = array(
| // This needs to be in this specific order $find = array(
|
Zeile 5683 | Zeile 5809 |
---|
function unhtmlentities($string) { // Replace numeric entities
|
function unhtmlentities($string) { // Replace numeric entities
|
$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string); $string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);
| $string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string); $string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
| // Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
|
Zeile 5724 | Zeile 5850 |
---|
{ return false; }
|
{ return false; }
|
| }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches. * @return string|bool The characterized ascii. False on failure */ function unichr_callback1($matches) { return unichr(hexdec($matches[1])); }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches. * @return string|bool The characterized ascii. False on failure */ function unichr_callback2($matches) { return unichr($matches[1]);
|
}
/**
| }
/**
|
Zeile 5797 | Zeile 5945 |
---|
if(!$username && $uid == 0) { // Return Guest phrase for no UID, no guest nickname
|
if(!$username && $uid == 0) { // Return Guest phrase for no UID, no guest nickname
|
return $lang->guest;
| return htmlspecialchars_uni($lang->guest);
|
} elseif($uid == 0) {
| } elseif($uid == 0) {
|
Zeile 6036 | Zeile 6184 |
---|
}
switch($options['username_method'])
|
}
switch($options['username_method'])
|
{
| {
|
case 1: $sqlwhere = "{$efield}='{$username}'"; break;
| case 1: $sqlwhere = "{$efield}='{$username}'"; break;
|
Zeile 6059 | Zeile 6207 |
---|
if(isset($options['exists'])) { return (bool)$db->num_rows($query);
|
if(isset($options['exists'])) { return (bool)$db->num_rows($query);
|
}
| }
|
return $db->fetch_array($query); }
| return $db->fetch_array($query); }
|
Zeile 6084 | Zeile 6232 |
---|
if(empty($forum_cache[$fid])) { return false;
|
if(empty($forum_cache[$fid])) { return false;
|
}
| }
|
if($active_override != 1) { $parents = explode(",", $forum_cache[$fid]['parentlist']);
| if($active_override != 1) { $parents = explode(",", $forum_cache[$fid]['parentlist']);
|
Zeile 6135 | Zeile 6283 |
---|
else { $thread_cache[$tid] = false;
|
else { $thread_cache[$tid] = false;
|
return false; } } }
| return false; } } }
|
/** * Get the post of a post id. *
| /** * Get the post of a post id. *
|
Zeile 6152 | Zeile 6300 |
---|
static $post_cache;
$pid = (int)$pid;
|
static $post_cache;
$pid = (int)$pid;
|
|
|
if(isset($post_cache[$pid])) { return $post_cache[$pid];
| if(isset($post_cache[$pid])) { return $post_cache[$pid];
|
Zeile 6203 | Zeile 6351 |
---|
$inactive[] = $fid1; } }
|
$inactive[] = $fid1; } }
|
} }
| } }
|
$inactiveforums = implode(",", $inactive);
| $inactiveforums = implode(",", $inactive);
|
Zeile 6217 | Zeile 6365 |
---|
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True * @return bool|int Number of logins when success, false if failed. */
|
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True * @return bool|int Number of logins when success, false if failed. */
|
function login_attempt_check($fatal = true)
| function login_attempt_check($uid = 0, $fatal = true)
|
{
|
{
|
global $mybb, $lang, $session, $db;
| global $mybb, $lang, $db;
|
|
|
if($mybb->settings['failedlogincount'] == 0) { return 1; } // Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.
// Use cookie if possible, otherwise use session // Find better solution to prevent clearing cookies $loginattempts = 0; $failedlogin = 0;
if(!empty($mybb->cookies['loginattempts']))
| $attempts = array(); $uid = (int)$uid; $now = TIME_NOW;
// Get this user's login attempts and eventual lockout, if a uid is provided if($uid > 0)
|
{
|
{
|
$loginattempts = $mybb->cookies['loginattempts'];
| $query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1); $attempts = $db->fetch_array($query);
if($attempts['loginattempts'] <= 0) { return 0; } } // This user has a cookie lockout, show waiting time elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now) { if($fatal) { $secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now); $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;
|
}
|
}
|
if(!empty($mybb->cookies['failedlogin']))
| if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
|
{
|
{
|
$failedlogin = $mybb->cookies['failedlogin']; }
// Work out if the user has had more than the allowed number of login attempts if($loginattempts > $mybb->settings['failedlogincount']) { // If so, then we need to work out if they can try to login again // Some maths to work out how long they have left and display it to them $now = TIME_NOW;
if(empty($mybb->cookies['failedlogin']))
| // Set the expiry dateline if not set yet if($attempts['loginlockoutexpiry'] == 0)
|
{
|
{
|
$failedtime = $now;
| $attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);
// Add a cookie lockout. This is used to prevent access to the login page immediately. // A deep lockout is issued if he tries to login into a locked out account my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);
$db->update_query("users", array( "loginlockoutexpiry" => $attempts['loginlockoutexpiry'] ), "uid='{$uid}'"); }
if(empty($mybb->cookies['lockoutexpiry'])) { $failedtime = $attempts['loginlockoutexpiry'];
|
} else {
|
} else {
|
$failedtime = $mybb->cookies['failedlogin'];
| $failedtime = $mybb->cookies['lockoutexpiry'];
|
}
|
}
|
$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now; $hoursleft = floor($secondsleft / 3600); $minsleft = floor(($secondsleft / 60) % 60); $secsleft = floor($secondsleft % 60);
// This value will be empty the first time the user doesn't login in, set it if(empty($failedlogin)) { my_setcookie('failedlogin', $now);
| // Are we still locked out? if($attempts['loginlockoutexpiry'] > $now) {
|
if($fatal) {
|
if($fatal) {
|
| $secsleft = (int)($attempts['loginlockoutexpiry'] - $now); $hoursleft = floor($secsleft / 3600); $minsleft = floor(($secsleft / 60) % 60); $secsleft = floor($secsleft % 60);
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
|
}
| }
return false; } // Unlock if enough time has passed else {
|
|
|
return false; }
// Work out if the user has waited long enough before letting them login again if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60)) { my_setcookie('loginattempts', 1); my_unsetcookie('failedlogin'); if($mybb->user['uid'] != 0) { $update_array = array( 'loginattempts' => 1 ); $db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'"); } return 1; } // Not waited long enough else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60)) { if($fatal)
| if($uid > 0)
|
{
|
{
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
| $db->update_query("users", array( "loginattempts" => 0, "loginlockoutexpiry" => 0 ), "uid='{$uid}'");
|
}
|
}
|
return false;
| // Wipe the cookie, no matter if a guest or a member my_unsetcookie('lockoutexpiry');
return 0;
|
} }
// User can attempt another login
|
} }
// User can attempt another login
|
return $loginattempts;
| return $attempts['loginattempts'];
|
}
/**
| }
/**
|
Zeile 6310 | Zeile 6467 |
---|
* * @param string $email The string to check. * @return boolean True when valid, false when invalid.
|
* * @param string $email The string to check. * @return boolean True when valid, false when invalid.
|
*/
| */
|
function validate_email_format($email) {
|
function validate_email_format($email) {
|
if(strpos($email, ' ') !== false) { return false; } // Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);
| return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
|
}
/**
| }
/**
|
Zeile 6327 | Zeile 6479 |
---|
* @param string $email The email to check. * @param int $uid User ID of the user (updating only) * @return boolean True when in use, false when not.
|
* @param string $email The email to check. * @param int $uid User ID of the user (updating only) * @return boolean True when in use, false when not.
|
*/
| */
|
function email_already_in_use($email, $uid=0) { global $db;
|
function email_already_in_use($email, $uid=0) { global $db;
|
|
|
$uid_string = ""; if($uid) { $uid_string = " AND uid != '".(int)$uid."'"; } $query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
|
$uid_string = ""; if($uid) { $uid_string = " AND uid != '".(int)$uid."'"; } $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; }
|
if($db->fetch_field($query, "emails") > 0) { return true; }
|
|
|
return false; }
/** * Rebuilds settings.php
|
return false; }
/** * Rebuilds settings.php
|
*
| *
|
*/ function rebuild_settings() { global $db, $mybb;
|
*/ function rebuild_settings() { global $db, $mybb;
|
if(!file_exists(MYBB_ROOT."inc/settings.php")) { $mode = "x"; } else { $mode = "w"; }
$options = array( "order_by" => "title", "order_dir" => "ASC" ); $query = $db->simple_select("settings", "value, name", "", $options);
| $query = $db->simple_select("settings", "value, name", "", array( 'order_by' => 'title', 'order_dir' => 'ASC', ));
|
|
|
$settings = null;
| $settings = '';
|
while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
| while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
|
Zeile 6379 | Zeile 6521 |
---|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode); @fwrite($file, $settings); @fclose($file);
| file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);
|
$GLOBALS['settings'] = &$mybb->settings; }
| $GLOBALS['settings'] = &$mybb->settings; }
|
Zeile 6399 | Zeile 6540 |
---|
if($mybb->settings['minsearchword'] < 1) { $mybb->settings['minsearchword'] = 3;
|
if($mybb->settings['minsearchword'] < 1) { $mybb->settings['minsearchword'] = 3;
|
}
| }
|
if(is_array($terms)) { $terms = implode(' ', $terms);
| if(is_array($terms)) { $terms = implode(' ', $terms);
|
Zeile 6472 | Zeile 6613 |
---|
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
|
usort($words, create_function('$a,$b', 'return strlen($b) - strlen($a);'));
| usort($words, 'build_highlight_array_sort');
|
// 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 6498 | Zeile 6639 |
---|
}
return $highlight_cache;
|
}
return $highlight_cache;
|
| }
/** * Sort the word array by length. Largest terms go first and work their way down to the smallest term. * * @param string $a First word. * @param string $b Second word. * @return integer Result of comparison function. */ function build_highlight_array_sort($a, $b) { return strlen($b) - strlen($a);
|
}
/**
| }
/**
|
Zeile 6606 | Zeile 6759 |
---|
{ // Updating last use if($update_lastuse == true)
|
{ // Updating last use if($update_lastuse == true)
|
{
| {
|
$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;
|
Zeile 7727 | Zeile 7880 |
---|
static $time_start;
$time = microtime(true);
|
static $time_start;
$time = microtime(true);
|
| |
// Just starting timer, init and return if(!$time_start)
| // Just starting timer, init and return if(!$time_start)
|
Zeile 7798 | Zeile 7950 |
---|
{ $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
{ $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
$contents = '';
| $hashingContext = hash_init('sha512');
|
while(!feof($handle)) {
|
while(!feof($handle)) {
|
$contents .= fread($handle, 8192);
| hash_update($hashingContext, fread($handle, 8192));
|
} fclose($handle);
|
} fclose($handle);
|
$md5 = md5($contents);
| $checksum = hash_final($hashingContext);
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
|
if(!in_array($md5, $checksums[$file_path]))
| if(!in_array($checksum, $checksums[$file_path]))
|
{ $bad_verify_files[] = array("status" => "changed", "path" => $file_path); }
| { $bad_verify_files[] = array("status" => "changed", "path" => $file_path); }
|
Zeile 8397 | Zeile 8549 |
---|
}
if(isset($revert))
|
}
if(isset($revert))
|
{
| {
|
// Revert language $lang->set_language($mybb->user['language']); $lang->load($pm['language_file']);
| // Revert language $lang->set_language($mybb->user['language']); $lang->load($pm['language_file']);
|
Zeile 8457 | Zeile 8609 |
---|
}
$pm['options'] = array(
|
}
$pm['options'] = array(
|
"signature" => 0,
| |
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
| "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
|
Zeile 8618 | Zeile 8769 |
---|
/** * Strip html tags from string, also removes <script> and <style> contents.
|
/** * Strip html tags from string, also removes <script> and <style> contents.
|
*
| * * @deprecated
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags
|
*
| *
|
* @return string Striped string */ function my_strip_tags($string, $allowable_tags = '')
| * @return string Striped string */ function my_strip_tags($string, $allowable_tags = '')
|