Zeile 18 | Zeile 18 |
---|
global $db, $lang, $theme, $templates, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
|
global $db, $lang, $theme, $templates, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
|
| $contents = $plugins->run_hooks("pre_parse_page", $contents);
|
$contents = parse_page($contents); $totaltime = format_time_duration($maintimer->stop()); $contents = $plugins->run_hooks("pre_output_page", $contents);
| $contents = parse_page($contents); $totaltime = format_time_duration($maintimer->stop()); $contents = $plugins->run_hooks("pre_output_page", $contents);
|
Zeile 223 | Zeile 224 |
---|
// Loop through and run them all foreach($shutdown_queries as $query) {
|
// Loop through and run them all foreach($shutdown_queries as $query) {
|
$db->query($query);
| $db->write_query($query);
|
} }
| } }
|
Zeile 609 | Zeile 610 |
---|
}
/**
|
}
/**
|
* Generates a unique code for POST requests to prevent XSS/CSRF attacks
| * Generates a code for POST requests to prevent XSS/CSRF attacks. * Unique for each user or guest session and rotated every 6 hours.
|
*
|
*
|
| * @param int $rotation_shift Adjustment of the rotation number to generate a past/future code
|
* @return string The generated code */
|
* @return string The generated code */
|
function generate_post_check()
| function generate_post_check($rotation_shift=0)
|
{ global $mybb, $session;
|
{ global $mybb, $session;
|
| $rotation_interval = 6 * 3600; $rotation = floor(TIME_NOW / $rotation_interval) + $rotation_shift;
$seed = $rotation;
|
if($mybb->user['uid'])
|
if($mybb->user['uid'])
|
{ return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']); } // Guests get a special string
| { $seed .= $mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']; }
|
else {
|
else {
|
return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
| $seed .= $session->sid;
|
}
|
}
|
| $seed .= $mybb->settings['internal']['encryption_key'];
return md5($seed);
|
}
/**
|
}
/**
|
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
| * Verifies a POST check code is valid (i.e. generated using a rotation number from the past 24 hours)
|
* * @param string $code The incoming POST check code
|
* * @param string $code The incoming POST check code
|
* @param boolean $silent Silent mode or not (silent mode will not show the error to the user but returns false) * @return bool
| * @param boolean $silent Don't show an error to the user * @return bool|void Result boolean if $silent is true, otherwise shows an error to the user
|
*/ function verify_post_check($code, $silent=false) { global $lang;
|
*/ function verify_post_check($code, $silent=false) { global $lang;
|
if(generate_post_check() !== $code)
| if( generate_post_check() !== $code && generate_post_check(-1) !== $code && generate_post_check(-2) !== $code && generate_post_check(-3) !== $code )
|
{ if($silent == true) {
| { if($silent == true) {
|
Zeile 653 | Zeile 670 |
---|
{ error($lang->invalid_post_code); }
|
{ error($lang->invalid_post_code); }
|
}
| }
|
} else {
| } else {
|
Zeile 684 | Zeile 701 |
---|
{ cache_forums(); return $forum_cache[$fid]['parentlist'];
|
{ 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 701 | Zeile 718 |
---|
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 *
| /** * Load the forum cache in to memory *
|
Zeile 732 | Zeile 749 |
---|
{ $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 748 | Zeile 765 |
---|
/** * Generate an array of all child and descendant forums for a specific forum.
|
/** * Generate an array of all child and descendant forums for a specific forum.
|
* * @param int $fid The forum ID
| * * @param int $fid The forum ID
|
* @return Array of descendants */ function get_child_list($fid)
| * @return Array of descendants */ function get_child_list($fid)
|
Zeile 775 | Zeile 792 |
---|
foreach($forums_by_parent[$fid] as $forum) {
|
foreach($forums_by_parent[$fid] as $forum) {
|
$forums[] = $forum['fid'];
| $forums[] = (int)$forum['fid'];
|
$children = get_child_list($forum['fid']); if(is_array($children)) {
| $children = get_child_list($forum['fid']); if(is_array($children)) {
|
Zeile 813 | Zeile 830 |
---|
if(!$title) { $title = $mybb->settings['bbname'];
|
if(!$title) { $title = $mybb->settings['bbname'];
|
}
| }
|
$timenow = my_date('relative', TIME_NOW); reset_breadcrumb(); add_breadcrumb($lang->error);
| $timenow = my_date('relative', TIME_NOW); reset_breadcrumb(); add_breadcrumb($lang->error);
|
Zeile 845 | Zeile 862 |
---|
if(!is_array($errors)) { $errors = array($errors);
|
if(!is_array($errors)) { $errors = array($errors);
|
}
| }
|
// AJAX error message? if($mybb->get_input('ajax', MyBB::INPUT_INT)) {
| // AJAX error message? if($mybb->get_input('ajax', MyBB::INPUT_INT)) {
|
Zeile 854 | Zeile 871 |
---|
@header("Content-type: application/json; charset={$lang->settings['charset']}");
if(empty($json_data))
|
@header("Content-type: application/json; charset={$lang->settings['charset']}");
if(empty($json_data))
|
{
| {
|
echo json_encode(array("errors" => $errors));
|
echo json_encode(array("errors" => $errors));
|
}
| }
|
else { echo json_encode(array_merge(array("errors" => $errors), $json_data)); } exit;
|
else { echo json_encode(array_merge(array("errors" => $errors), $json_data)); } exit;
|
}
| }
|
$errorlist = '';
foreach($errors as $error) {
|
$errorlist = '';
foreach($errors as $error) {
|
$errorlist .= "<li>".$error."</li>\n";
| eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";");
|
}
eval("\$errors = \"".$templates->get("error_inline")."\";");
| }
eval("\$errors = \"".$templates->get("error_inline")."\";");
|
Zeile 878 | Zeile 895 |
---|
/** * Presents the user with a "no permission" page
|
/** * Presents the user with a "no permission" page
|
*/
| */
|
function error_no_permission() { global $mybb, $theme, $templates, $db, $lang, $plugins, $session;
| function error_no_permission() { global $mybb, $theme, $templates, $db, $lang, $plugins, $session;
|
Zeile 1030 | Zeile 1047 |
---|
*/ function multipage($count, $perpage, $page, $url, $breadcrumb=false) {
|
*/ function multipage($count, $perpage, $page, $url, $breadcrumb=false) {
|
global $theme, $templates, $lang, $mybb;
| global $theme, $templates, $lang, $mybb, $plugins;
|
if($count <= $perpage) { return ''; }
|
if($count <= $perpage) { return ''; }
|
| $args = array( 'count' => &$count, 'perpage' => &$perpage, 'page' => &$page, 'url' => &$url, 'breadcrumb' => &$breadcrumb, ); $plugins->run_hooks('multipage', $args);
|
$page = (int)$page;
| $page = (int)$page;
|
Zeile 1133 | Zeile 1159 |
---|
$next = $page+1; $page_url = fetch_page_url($url, $next); eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");
|
$next = $page+1; $page_url = fetch_page_url($url, $next); eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");
|
}
| }
|
$jumptopage = ''; if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)
|
$jumptopage = ''; if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)
|
{
| {
|
// 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);
if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
$multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
}
| }
|
else { eval("\$multipage = \"".$templates->get("multipage")."\";"); }
|
else { eval("\$multipage = \"".$templates->get("multipage")."\";"); }
|
|
|
return $multipage; }
| return $multipage; }
|
Zeile 1163 | Zeile 1189 |
---|
* @param string $url The URL being passed * @param int $page The page number * @return string
|
* @param string $url The URL being passed * @param int $page The page number * @return string
|
*/
| */
|
function fetch_page_url($url, $page) { if($page <= 1)
| function fetch_page_url($url, $page) { if($page <= 1)
|
Zeile 1179 | Zeile 1205 |
---|
return $url; } else if(strpos($url, "{page}") === false)
|
return $url; } else if(strpos($url, "{page}") === false)
|
{
| {
|
// If no page identifier is specified we tack it on to the end of the URL if(strpos($url, "?") === false) {
| // If no page identifier is specified we tack it on to the end of the URL if(strpos($url, "?") === false) {
|
Zeile 1203 | Zeile 1229 |
---|
/** * 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
| }
// User id does not match current user, fetch permissions
|
Zeile 1223 | Zeile 1255 |
---|
if(!empty($user_cache[$uid]['permissions'])) { return $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. if(empty($user_cache[$uid])) {
| // This user was not already cached, fetch their user information. if(empty($user_cache[$uid])) {
|
Zeile 1256 | Zeile 1288 |
---|
{ global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
{ global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
$groups = explode(",", $gid);
if(count($groups) == 1)
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
$groups = explode(",", $gid);
if(count($groups) == 1)
|
{ $groupscache[$gid]['all_usergroups'] = $gid; return $groupscache[$gid]; }
|
{ $groupscache[$gid]['all_usergroups'] = $gid; return $groupscache[$gid]; }
|
|
|
$usergroup = array(); $usergroup['all_usergroups'] = $gid;
| $usergroup = array(); $usergroup['all_usergroups'] = $gid;
|
Zeile 1277 | Zeile 1309 |
---|
if(trim($gid) == "" || empty($groupscache[$gid])) { continue;
|
if(trim($gid) == "" || empty($groupscache[$gid])) { 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 = "";
|
Zeile 1294 | Zeile 1326 |
---|
// 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))
|
{
| {
|
$usergroup[$perm] = 0; continue;
|
$usergroup[$perm] = 0; continue;
|
}
| }
|
if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility? {
| if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility? {
|
Zeile 1306 | Zeile 1338 |
---|
} } }
|
} } }
|
|
|
return $usergroup;
|
return $usergroup;
|
}
/**
| }
/**
|
* Fetch the display group properties for a specific display group * * @param int $gid The group ID to fetch the display properties for
| * Fetch the display group properties for a specific display group * * @param int $gid The group ID to fetch the display properties for
|
Zeile 1372 | Zeile 1404 |
---|
}
$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 1386 | Zeile 1418 |
---|
}
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 1436 | Zeile 1468 |
---|
$only_reply_own_threads = 1;
foreach($groups as $gid)
|
$only_reply_own_threads = 1;
foreach($groups as $gid)
|
{
| {
|
if(!empty($groupscache[$gid])) { $level_permissions = $fpermcache[$fid][$gid];
| if(!empty($groupscache[$gid])) { $level_permissions = $fpermcache[$fid][$gid];
|
Zeile 1481 | Zeile 1513 |
---|
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;
|
} } }
| } } }
|
// Figure out if we can view more than our own threads if($only_view_own_threads == 0) { $current_permissions["canonlyviewownthreads"] = 0;
|
// Figure out if we can view more than our own threads if($only_view_own_threads == 0) { $current_permissions["canonlyviewownthreads"] = 0;
|
}
| }
|
// Figure out if we can reply more than our own threads if($only_reply_own_threads == 0) {
| // Figure out if we can reply more than our own threads if($only_reply_own_threads == 0) {
|
Zeile 1500 | Zeile 1532 |
---|
if(count($current_permissions) == 0) { $current_permissions = $groupperms;
|
if(count($current_permissions) == 0) { $current_permissions = $groupperms;
|
}
| }
|
return $current_permissions;
|
return $current_permissions;
|
| }
/** * Check whether password for given forum was validated for the current user * * @param array $forum The forum data * @param bool $ignore_empty Whether to treat forum password configured as an empty string as validated * @param bool $check_parents Whether to check parent forums using `parentlist` * @return bool */ function forum_password_validated($forum, $ignore_empty=false, $check_parents=false) { global $mybb, $forum_cache;
if($check_parents && isset($forum['parentlist'])) { if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache) { return false; } }
$parents = explode(',', $forum['parentlist']); rsort($parents);
foreach($parents as $parent_id) { if($parent_id != $forum['fid'] && !forum_password_validated($forum_cache[$parent_id], true)) { return false; } } }
return ($ignore_empty && $forum['password'] === '') || ( isset($mybb->cookies['forumpass'][$forum['fid']]) && my_hash_equals( md5($mybb->user['uid'].$forum['password']), $mybb->cookies['forumpass'][$forum['fid']] ) );
|
}
/**
| }
/**
|
Zeile 1515 | Zeile 1591 |
---|
function check_forum_password($fid, $pid=0, $return=false) { global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
|
function check_forum_password($fid, $pid=0, $return=false) { global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
|
|
|
$showform = true;
if(!is_array($forum_cache))
| $showform = true;
if(!is_array($forum_cache))
|
Zeile 1542 | Zeile 1618 |
---|
continue; }
|
continue; }
|
if($forum_cache[$parent_id]['password'] != "")
| if($forum_cache[$parent_id]['password'] !== "")
|
{ check_forum_password($parent_id, $fid);
|
{ check_forum_password($parent_id, $fid);
|
} } }
if(!empty($forum_cache[$fid]['password']))
| } } }
if($forum_cache[$fid]['password'] !== '')
|
{
|
{
|
$password = $forum_cache[$fid]['password'];
| |
if(isset($mybb->input['pwverify']) && $pid == 0)
|
if(isset($mybb->input['pwverify']) && $pid == 0)
|
{ if($password === $mybb->get_input('pwverify'))
| { 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); $showform = false;
|
{ my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true); $showform = false;
|
}
| }
|
else
|
else
|
{
| {
|
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";"); $showform = true; }
|
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";"); $showform = true; }
|
} else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid])) { $showform = true; }
| } else { if(!forum_password_validated($forum_cache[$fid])) { $showform = true; }
|
else { $showform = false;
| else { $showform = false;
|
Zeile 1600 | Zeile 1675 |
---|
output_page($pwform); } exit;
|
output_page($pwform); } exit;
|
}
| }
|
}
/**
| }
/**
|
Zeile 1632 | Zeile 1707 |
---|
}
if(!$parentslist)
|
}
if(!$parentslist)
|
{
| {
|
$parentslist = explode(',', get_parent_list($fid)); }
| $parentslist = explode(',', get_parent_list($fid)); }
|
Zeile 1647 | Zeile 1722 |
---|
$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 1657 | Zeile 1732 |
---|
foreach($mod_cache as $forumid => $forum) { if(!is_array($forum) || !in_array($forumid, $parentslist))
|
foreach($mod_cache as $forumid => $forum) { if(!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; }
|
Zeile 1666 | Zeile 1741 |
---|
if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
foreach($perm as $action => $value)
| foreach($perm as $action => $value)
|
{ if(strpos($action, "can") === false)
|
{ if(strpos($action, "can") === false)
|
{
| {
|
continue;
|
continue;
|
}
| }
|
// Figure out the user permissions if($value == 0)
|
// Figure out the user permissions if($value == 0)
|
{
| {
|
// The user doesn't have permission to set this action $perms[$action] = 0; } else { $perms[$action] = max($perm[$action], $perms[$action]);
|
// The user doesn't have permission to set this action $perms[$action] = 0; } else { $perms[$action] = max($perm[$action], $perms[$action]);
|
} } }
| } } }
|
foreach($groups as $group) { if(!is_array($forum['usergroups'][$group]))
|
foreach($groups as $group) { if(!is_array($forum['usergroups'][$group]))
|
{
| {
|
// There are no permissions set for this group continue; }
| // There are no permissions set for this group continue; }
|
Zeile 1703 | Zeile 1778 |
---|
}
$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 1721 | Zeile 1796 |
---|
* @return bool Returns true if the user has permission, false if they do not */ function is_moderator($fid=0, $action="", $uid=0)
|
* @return bool Returns true if the user has permission, false if they do not */ function is_moderator($fid=0, $action="", $uid=0)
|
{
| {
|
global $mybb, $cache;
if($uid == 0)
| global $mybb, $cache;
if($uid == 0)
|
Zeile 1758 | Zeile 1833 |
---|
foreach($modcache as $modusers) { if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))
|
foreach($modcache as $modusers) { if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))
|
{
| {
|
return true; }
| return true; }
|
Zeile 1796 | Zeile 1871 |
---|
} } }
|
} } }
|
| }
/** * Get an array of fids that the forum moderator has access to. * Do not use for administraotrs or global moderators as they moderate any forum and the function will return false. * * @param int $uid The user ID (0 assumes current user) * @return array|bool an array of the fids the user has moderator access to or bool if called incorrectly. */ function get_moderated_fids($uid=0) { global $mybb, $cache;
if($uid == 0) { $uid = $mybb->user['uid']; }
if($uid == 0) { return array(); }
$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == 1) { return false; }
$fids = array();
$modcache = $cache->read('moderators'); if(!empty($modcache)) { $groups = explode(',', $user_perms['all_usergroups']);
foreach($modcache as $fid => $forum) { if(isset($forum['users'][$uid]) && $forum['users'][$uid]['mid']) { $fids[] = $fid; continue; }
foreach($groups as $group) { if(trim($group) != '' && isset($forum['usergroups'][$group])) { $fids[] = $fid; } } } }
return $fids;
|
}
/**
| }
/**
|
Zeile 2035 | Zeile 2166 |
---|
return false; }
|
return false; }
|
$stack = array(); $expected = array();
| $stack = $list = $expected = array();
|
/* * states:
| /* * states:
|
Zeile 3167 | Zeile 3297 |
---|
if($dimensions) {
|
if($dimensions) {
|
$dimensions = explode("|", $dimensions);
| $dimensions = preg_split('/[|x]/', $dimensions);
|
if($dimensions[0] && $dimensions[1]) {
|
if($dimensions[0] && $dimensions[1]) {
|
list($max_width, $max_height) = explode('x', $max_dimensions);
| list($max_width, $max_height) = preg_split('/[|x]/', $max_dimensions);
|
if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height)) {
| if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height)) {
|
Zeile 3268 | Zeile 3398 |
---|
"editor_invalidyoutube" => "Invalid YouTube video", "editor_dailymotion" => "Dailymotion", "editor_metacafe" => "MetaCafe",
|
"editor_invalidyoutube" => "Invalid YouTube video", "editor_dailymotion" => "Dailymotion", "editor_metacafe" => "MetaCafe",
|
"editor_veoh" => "Veoh",
| "editor_mixer" => "Mixer",
|
"editor_vimeo" => "Vimeo", "editor_youtube" => "Youtube", "editor_facebook" => "Facebook",
| "editor_vimeo" => "Vimeo", "editor_youtube" => "Youtube", "editor_facebook" => "Facebook",
|
Zeile 3438 | Zeile 3568 |
---|
}
return $codeinsert;
|
}
return $codeinsert;
|
| }
/** * @param int $tid * @param array $postoptions The options carried with form submit * * @return string Predefined / updated subscription method of the thread for the user */ function get_subscription_method($tid = 0, $postoptions = array()) { global $mybb;
$subscription_methods = array('', 'none', 'email', 'pm'); // Define methods $subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default
// If no user default method available then reset method if(!$subscription_method) { $subscription_method = 0; }
// Return user default if no thread id available, in case if(!(int)$tid || (int)$tid <= 0) { return $subscription_methods[$subscription_method]; }
// If method not predefined set using data from database if(isset($postoptions['subscriptionmethod'])) { $method = trim($postoptions['subscriptionmethod']); return (in_array($method, $subscription_methods)) ? $method : $subscription_methods[0]; } else { global $db;
$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1)); $subscription = $db->fetch_array($query);
if($subscription['tid']) { $subscription_method = (int)$subscription['notification'] + 1; } }
return $subscription_methods[$subscription_method];
|
}
/**
| }
/**
|
Zeile 3448 | Zeile 3625 |
---|
function build_clickable_smilies() { global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;
|
function build_clickable_smilies() { global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;
|
|
|
if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) { if(!$smiliecount)
|
if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) { if(!$smiliecount)
|
{
| {
|
$smilie_cache = $cache->read("smilies"); $smiliecount = count($smilie_cache); }
| $smilie_cache = $cache->read("smilies"); $smiliecount = count($smilie_cache); }
|
Zeile 3460 | Zeile 3637 |
---|
if(!$smiliecache) { if(!is_array($smilie_cache))
|
if(!$smiliecache) { if(!is_array($smilie_cache))
|
{
| {
|
$smilie_cache = $cache->read("smilies"); } foreach($smilie_cache as $smilie) { $smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']); $smiliecache[$smilie['sid']] = $smilie;
|
$smilie_cache = $cache->read("smilies"); } foreach($smilie_cache as $smilie) { $smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']); $smiliecache[$smilie['sid']] = $smilie;
|
} }
unset($smilie);
| } }
unset($smilie);
|
if(is_array($smiliecache)) { reset($smiliecache);
| if(is_array($smiliecache)) { reset($smiliecache);
|
Zeile 3559 | Zeile 3736 |
---|
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 3623 | Zeile 3800 |
---|
// 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 3634 | Zeile 3811 |
---|
// 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
|
Zeile 3647 | Zeile 3824 |
---|
{ return ''; }
|
{ return ''; }
|
|
|
$prefixselect = $prefixselect_prefix = '';
if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any')
|
$prefixselect = $prefixselect_prefix = '';
if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any')
|
{
| {
|
$any_selected = " selected=\"selected\"";
|
$any_selected = " selected=\"selected\"";
|
} }
| } }
|
$default_selected = ""; if(((int)$selected_pid == 0) && $selected_pid != 'any') {
| $default_selected = ""; if(((int)$selected_pid == 0) && $selected_pid != 'any') {
|
Zeile 3666 | Zeile 3843 |
---|
}
foreach($prefixes as $prefix)
|
}
foreach($prefixes as $prefix)
|
{
| {
|
$selected = ""; if($prefix['pid'] == $selected_pid) {
| $selected = ""; if($prefix['pid'] == $selected_pid) {
|
Zeile 3684 | Zeile 3861 |
---|
else { eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");
|
else { eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");
|
}
| }
|
return $prefixselect; }
| return $prefixselect; }
|
Zeile 3923 | Zeile 4100 |
---|
if($uid != 0) { eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");
|
if($uid != 0) { eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");
|
} else
| } else
|
{ eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";"); }
|
{ eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";"); }
|
|
|
return $display_reputation; }
/** * Fetch a color coded version of a warning level (based on it's percentage)
|
return $display_reputation; }
/** * Fetch a color coded version of a warning level (based on it's percentage)
|
*
| *
|
* @param int $level The warning level (percentage of 100) * @return string Formatted warning level */
| * @param int $level The warning level (percentage of 100) * @return string Formatted warning level */
|
Zeile 3944 | Zeile 4121 |
---|
$warning_class = ''; if($level >= 80)
|
$warning_class = ''; if($level >= 80)
|
{
| {
|
$warning_class = "high_warning";
|
$warning_class = "high_warning";
|
}
| }
|
else if($level >= 50)
|
else if($level >= 50)
|
{
| {
|
$warning_class = "moderate_warning";
|
$warning_class = "moderate_warning";
|
}
| }
|
else if($level >= 25) { $warning_class = "low_warning";
|
else if($level >= 25) { $warning_class = "low_warning";
|
}
| }
|
else { $warning_class = "normal_warning";
| else { $warning_class = "normal_warning";
|
Zeile 3974 | Zeile 4151 |
---|
global $mybb, $plugins;
$ip = strtolower($_SERVER['REMOTE_ADDR']);
|
global $mybb, $plugins;
$ip = strtolower($_SERVER['REMOTE_ADDR']);
|
|
|
if($mybb->settings['ip_forwarded_check']) { $addresses = array();
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
if($mybb->settings['ip_forwarded_check']) { $addresses = array();
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
{
| {
|
$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR'])); } elseif(isset($_SERVER['HTTP_X_REAL_IP']))
|
$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR'])); } elseif(isset($_SERVER['HTTP_X_REAL_IP']))
|
{
| {
|
$addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP'])); }
| $addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP'])); }
|
Zeile 4004 | Zeile 4181 |
---|
}
if(!$ip)
|
}
if(!$ip)
|
{
| {
|
if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = strtolower($_SERVER['HTTP_CLIENT_IP']);
| if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = strtolower($_SERVER['HTTP_CLIENT_IP']);
|
Zeile 4163 | Zeile 4340 |
---|
{ $attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); $attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
|
{ $attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); $attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
|
} }
| } }
|
$icon = $attach_icons_schemes[$ext];
| $icon = $attach_icons_schemes[$ext];
|
Zeile 4173 | Zeile 4350 |
---|
else { if(defined("IN_ADMINCP"))
|
else { if(defined("IN_ADMINCP"))
|
{
| {
|
$theme['imgdir'] = "../images"; } else if(defined("IN_PORTAL"))
| $theme['imgdir'] = "../images"; } else if(defined("IN_PORTAL"))
|
Zeile 4191 | Zeile 4368 |
---|
eval("\$attachment_icon = \"".$templates->get("attachment_icon")."\";"); return $attachment_icon; }
|
eval("\$attachment_icon = \"".$templates->get("attachment_icon")."\";"); return $attachment_icon; }
|
|
|
/** * Get a list of the unviewable forums for the current user *
| /** * Get a list of the unviewable forums for the current user *
|
Zeile 4212 | Zeile 4389 |
---|
$permissioncache = forum_permissions(); }
|
$permissioncache = forum_permissions(); }
|
$password_forums = $unviewable = array();
| $unviewable = array();
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
} else {
| } else {
|
$perms = $mybb->usergroup; }
|
$perms = $mybb->usergroup; }
|
|
|
$pwverified = 1;
|
$pwverified = 1;
|
if($forum['password'] != "")
| if(!forum_password_validated($forum, true))
|
{
|
{
|
if($mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0; }
$password_forums[$forum['fid']] = $forum['password'];
| $pwverified = 0;
|
} else {
| } else {
|
Zeile 4241 | Zeile 4414 |
---|
$parents = explode(",", $forum['parentlist']); foreach($parents as $parent) {
|
$parents = explode(",", $forum['parentlist']); foreach($parents as $parent) {
|
if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent]))
| if(!forum_password_validated($forum_cache[$parent], true))
|
{ $pwverified = 0;
|
{ $pwverified = 0;
|
| break;
|
} } }
| } } }
|
Zeile 4331 | Zeile 4505 |
---|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
| $navsize = count($navbits); $navbit = $navbits[$navsize-1];
|
}
|
}
|
$activesep = ''; $navsize = count($navbits); $navbit = $navbits[$navsize-1];
| |
if($nav) {
| if($nav) {
|
Zeile 4645 | Zeile 4817 |
---|
if($mybb->settings['nocacheheaders'] == 1) {
|
if($mybb->settings['nocacheheaders'] == 1) {
|
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
| header("Cache-Control: no-cache, private");
|
} }
| } }
|
Zeile 4934 | Zeile 5103 |
---|
}
// Build the new list of additional groups for this user and make sure they're in the right format
|
}
// Build the new list of additional groups for this user and make sure they're in the right format
|
$usergroups = ""; $usergroups = $user['additionalgroups'].",".$joingroup; $groupslist = ""; $groups = explode(",", $usergroups);
| $groups = array_map( 'intval', explode(',', $user['additionalgroups']) );
if(!in_array((int)$joingroup, $groups)) { $groups[] = (int)$joingroup; $groups = array_diff($groups, array($user['usergroup'])); $groups = array_unique($groups);
|
|
|
if(is_array($groups)) { $comma = ''; foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid])) { $groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1; } } }
| $groupslist = implode(',', $groups);
|
|
|
// What's the point in updating if they're the same? if($groupslist != $user['additionalgroups']) {
| |
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'"); return true; } else { return false;
|
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'"); return true; } else { return false;
|
}
| }
|
}
|
}
|
|
|
/** * Remove a user from a specific additional user group *
| /** * Remove a user from a specific additional user group *
|
Zeile 4974 | Zeile 5134 |
---|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
|
|
$user = get_user($uid);
|
$user = get_user($uid);
|
$groupslist = $comma = ''; $usergroups = $user['additionalgroups'].","; $donegroup = array();
$groups = explode(",", $user['additionalgroups']);
if(is_array($groups))
| if($user['usergroup'] == $leavegroup)
|
{
|
{
|
foreach($groups as $gid) { if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid])) { $groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1; } }
| return false;
|
}
|
}
|
| $groups = array_map( 'intval', explode(',', $user['additionalgroups']) ); $groups = array_diff($groups, array($leavegroup)); $groups = array_unique($groups);
$groupslist = implode(',', $groups);
|
$dispupdate = ""; if($leavegroup == $user['displaygroup'])
| $dispupdate = ""; if($leavegroup == $user['displaygroup'])
|
Zeile 5015 | Zeile 5170 |
---|
* Get the current location taking in to account different web serves and systems * * @param boolean $fields True to return as "hidden" fields
|
* Get the current location taking in to account different web serves and systems * * @param boolean $fields True to return as "hidden" fields
|
* @param array $ignore Array of fields to ignore if first argument is true
| * @param array $ignore Array of fields to ignore for returning "hidden" fields or URL being accessed
|
* @param boolean $quick True to skip all inputs and return only the file path part of the URL
|
* @param boolean $quick True to skip all inputs and return only the file path part of the URL
|
* @return string The current URL being accessed
| * @return string|array The current URL being accessed or form data if $fields is true
|
*/ function get_current_location($fields=false, $ignore=array(), $quick=false) {
|
*/ function get_current_location($fields=false, $ignore=array(), $quick=false) {
|
| global $mybb;
|
if(defined("MYBB_LOCATION")) { return MYBB_LOCATION;
| if(defined("MYBB_LOCATION")) { return MYBB_LOCATION;
|
Zeile 5052 | Zeile 5209 |
---|
return $location; }
|
return $location; }
|
if($fields == true)
| if(!is_array($ignore))
|
{
|
{
|
global $mybb;
| $ignore = array($ignore); }
|
|
|
if(!is_array($ignore)) { $ignore = array($ignore); }
| if($fields == true) {
|
$form_html = ''; if(!empty($mybb->input))
|
$form_html = ''; if(!empty($mybb->input))
|
{
| {
|
foreach($mybb->input as $name => $value) { if(in_array($name, $ignore) || is_array($name) || is_array($value))
| foreach($mybb->input as $name => $value) { if(in_array($name, $ignore) || is_array($name) || is_array($value))
|
Zeile 5072 | Zeile 5228 |
---|
}
$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 {
|
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else {
|
| $parameters = array();
|
if(isset($_SERVER['QUERY_STRING'])) {
|
if(isset($_SERVER['QUERY_STRING'])) {
|
$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
| $current_query_string = $_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")) {
| $current_query_string = $_ENV['QUERY_STRING']; } else { $current_query_string = ''; }
parse_str($current_query_string, $current_parameters);
foreach($current_parameters as $name => $value) { if(!in_array($name, $ignore)) { $parameters[$name] = $value; } }
if($mybb->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) {
|
if(isset($_POST[$var]))
| if(isset($_POST[$var]) && !in_array($var, $ignore))
|
{
|
{
|
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
| $parameters[$var] = $_POST[$var];
|
} }
|
} }
|
| }
|
|
|
if(isset($addloc) && is_array($addloc)) { if(strpos($location, "?") === false) { $location .= "?"; } else { $location .= "&"; } $location .= implode("&", $addloc); }
| if(!empty($parameters)) { $location .= '?'.http_build_query($parameters, '', '&');
|
}
return $location;
| }
return $location;
|
Zeile 5261 | Zeile 5424 |
---|
* * @param int $number The number to format. * @return int The formatted number.
|
* * @param int $number The number to format. * @return int The formatted number.
|
*/
| */
|
function my_number_format($number) { global $mybb;
|
function my_number_format($number) { global $mybb;
|
|
|
if($number == "-") { return $number; }
if(is_int($number))
|
if($number == "-") { return $number; }
if(is_int($number))
|
{
| {
|
return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); } else
| return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); } else
|
Zeile 5280 | Zeile 5443 |
---|
$parts = explode('.', $number);
if(isset($parts[1]))
|
$parts = explode('.', $number);
if(isset($parts[1]))
|
{
| {
|
$decimals = my_strlen($parts[1]);
|
$decimals = my_strlen($parts[1]);
|
} else {
| } else {
|
$decimals = 0; }
| $decimals = 0; }
|
Zeile 5319 | Zeile 5482 |
---|
if(!isset($use_iconv)) { $use_iconv = function_exists("iconv");
|
if(!isset($use_iconv)) { $use_iconv = function_exists("iconv");
|
}
| }
|
if(!isset($use_mb))
|
if(!isset($use_mb))
|
{
| {
|
$use_mb = function_exists("mb_convert_encoding"); }
| $use_mb = function_exists("mb_convert_encoding"); }
|
Zeile 5332 | Zeile 5495 |
---|
{ $from_charset = $lang->settings['charset']; $to_charset = "UTF-8";
|
{ $from_charset = $lang->settings['charset']; $to_charset = "UTF-8";
|
}
| }
|
else { $from_charset = "UTF-8";
| else { $from_charset = "UTF-8";
|
Zeile 5356 | Zeile 5519 |
---|
else { return utf8_decode($str);
|
else { return utf8_decode($str);
|
} }
| } }
|
else { return $str;
| else { return $str;
|
Zeile 5366 | Zeile 5529 |
---|
/** * DEPRECATED! Please use other alternatives.
|
/** * DEPRECATED! Please use other alternatives.
|
* * @deprecated
| * * @deprecated
|
* @param string $message
|
* @param string $message
|
*
| *
|
* @return string */ function my_wordwrap($message) { return $message;
|
* @return string */ function my_wordwrap($message) { return $message;
|
}
/** * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme) *
| }
/** * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme) *
|
* @param int $month The month of the birthday * @param int $day The day of the birthday * @param int $year The year of the bithday
| * @param int $month The month of the birthday * @param int $day The day of the birthday * @param int $year The year of the bithday
|
Zeile 5413 | Zeile 5576 |
---|
} } }
|
} } }
|
}
/**
| }
/**
|
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme) * * @param int $in The year.
| * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme) * * @param int $in The year.
|
Zeile 5426 | Zeile 5589 |
---|
return array( 31, ($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),
|
return array( 31, ($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),
|
31, 30,
| 31, 30,
|
31, 30, 31,
| 31, 30, 31,
|
Zeile 5452 | Zeile 5615 |
---|
* @return string The formatted birthday */ function format_bdays($display, $bm, $bd, $by, $wd)
|
* @return string The formatted birthday */ function format_bdays($display, $bm, $bd, $by, $wd)
|
{ global $lang;
| { global $lang;
|
$bdays = array( $lang->sunday, $lang->monday,
| $bdays = array( $lang->sunday, $lang->monday,
|
Zeile 5478 | Zeile 5641 |
---|
$lang->month_10, $lang->month_11, $lang->month_12
|
$lang->month_10, $lang->month_11, $lang->month_12
|
);
| );
|
// This needs to be in this specific order $find = array( 'm',
| // This needs to be in this specific order $find = array( 'm',
|
Zeile 5549 | Zeile 5712 |
---|
if(!$bday[2]) { return;
|
if(!$bday[2]) { return;
|
}
list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));
| }
list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));
|
$age = $year-$bday[2];
| $age = $year-$bday[2];
|
Zeile 5745 | Zeile 5908 |
---|
}
return $string;
|
}
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 */ function my_stripos($haystack, $needle, $offset=0) { if($needle == '') { return false; }
if(function_exists("mb_stripos")) { $position = mb_stripos($haystack, $needle, $offset); } else { $position = stripos($haystack, $needle, $offset); }
return $position;
|
}
/**
| }
/**
|
Zeile 6218 | Zeile 6408 |
---|
global $cache; static $forum_cache;
|
global $cache; static $forum_cache;
|
if(!isset($forum_cache) || is_array($forum_cache))
| if(!isset($forum_cache) || !is_array($forum_cache))
|
{ $forum_cache = $cache->read("forums"); }
| { $forum_cache = $cache->read("forums"); }
|
Zeile 6380 | Zeile 6570 |
---|
} // This user has a cookie lockout, show waiting time elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)
|
} // 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);
| if($fatal) { $secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
|
Zeile 6421 | Zeile 6611 |
---|
// Are we still locked out? if($attempts['loginlockoutexpiry'] > $now)
|
// Are we still locked out? if($attempts['loginlockoutexpiry'] > $now)
|
{
| {
|
if($fatal) { $secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
| if($fatal) { $secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
|
Zeile 6461 | Zeile 6651 |
---|
* * @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)
|
{
| {
|
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false; }
| return filter_var($email, FILTER_VALIDATE_EMAIL) !== false; }
|
Zeile 6477 | Zeile 6667 |
---|
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 = ""; if($uid) {
|
Zeile 6510 | Zeile 6700 |
---|
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['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n"; }
|
Zeile 7061 | Zeile 7253 |
---|
if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302))) {
|
if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302))) {
|
preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
| preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);
|
if($matches) {
| if($matches) {
|
Zeile 7122 | Zeile 7314 |
---|
'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false,
|
'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false,
|
| 'peer_name' => $url_components['host'],
|
), )); }
| ), )); }
|
Zeile 7186 | Zeile 7379 |
---|
if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 '))) {
|
if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 '))) {
|
preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
| preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);
|
if($matches) {
| if($matches) {
|
Zeile 7292 | Zeile 7485 |
---|
global $mybb;
if(empty($groups))
|
global $mybb;
if(empty($groups))
|
{
| {
|
return array(); }
| return array(); }
|
Zeile 7547 | Zeile 7740 |
---|
/** * Custom rmdir function to loop through an entire directory and delete all files/folders within
|
/** * Custom rmdir function to loop through an entire directory and delete all files/folders within
|
*
| *
|
* @param string $path The path to the directory * @param array $ignore Any files you wish to ignore (optional) * @return bool
| * @param string $path The path to the directory * @param array $ignore Any files you wish to ignore (optional) * @return bool
|
Zeile 7579 | Zeile 7772 |
---|
if($path == $orig_dir) { return true;
|
if($path == $orig_dir) { return true;
|
}
| }
|
return @rmdir($path); }
| return @rmdir($path); }
|
Zeile 7593 | Zeile 7786 |
---|
* @param array $array The array of forums * @return integer The number of sub forums */
|
* @param array $array The array of forums * @return integer The number of sub forums */
|
function subforums_count($array)
| function subforums_count($array=array())
|
{ $count = 0; foreach($array as $array2)
| { $count = 0; foreach($array as $array2)
|
Zeile 7633 | Zeile 7826 |
---|
}
return $ip_long;
|
}
return $ip_long;
|
}
| }
|
/** * DEPRECATED! Please use IPv6 compatible my_inet_ntop!
| /** * DEPRECATED! Please use IPv6 compatible my_inet_ntop!
|
Zeile 7644 | Zeile 7837 |
---|
* @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 7665 | Zeile 7858 |
---|
if(function_exists('inet_pton')) { return @inet_pton($ip);
|
if(function_exists('inet_pton')) { return @inet_pton($ip);
|
}
| }
|
else { /**
| else { /**
|
Zeile 7687 | Zeile 7880 |
---|
$delim_count = substr_count($ip, ':'); if($delim_count < 1 || $delim_count > 7)
|
$delim_count = substr_count($ip, ':'); if($delim_count < 1 || $delim_count > 7)
|
{
| {
|
return false; }
| return false; }
|
Zeile 7718 | Zeile 7911 |
---|
if(function_exists('inet_ntop')) { return @inet_ntop($ip);
|
if(function_exists('inet_ntop')) { return @inet_ntop($ip);
|
}
| }
|
else { /**
| else { /**
|
Zeile 7802 | Zeile 7995 |
---|
else { $ip_address = my_inet_pton($ip_address);
|
else { $ip_address = my_inet_pton($ip_address);
|
|
|
if(!$ip_address) { // Invalid IP address
| if(!$ip_address) { // Invalid IP address
|
Zeile 8050 | Zeile 8243 |
---|
}
$output = @mcrypt_create_iv($bytes, $source);
|
}
$output = @mcrypt_create_iv($bytes, $source);
|
} } else { return $output; }
| } } else { return $output; }
|
if(strlen($output) < $bytes) { if(function_exists('openssl_random_pseudo_bytes'))
| if(strlen($output) < $bytes) { if(function_exists('openssl_random_pseudo_bytes'))
|
Zeile 8068 | Zeile 8261 |
---|
if ($crypto_strong == false) { $output = null;
|
if ($crypto_strong == false) { $output = null;
|
} } } } else
| } } } } else
|
{ return $output; }
| { return $output; }
|
Zeile 8119 | Zeile 8312 |
---|
else { return $output;
|
else { return $output;
|
} }
| } }
|
/** * Returns a securely generated seed integer
| /** * Returns a securely generated seed integer
|
Zeile 8152 | Zeile 8345 |
---|
return $output; }
|
return $output; }
|
|
|
/** * Generates a cryptographically secure random number. *
| /** * Generates a cryptographically secure random number. *
|
Zeile 8179 | Zeile 8372 |
---|
if(isset($result)) { return $result;
|
if(isset($result)) { return $result;
|
} }
$seed = secure_seed_rng();
| } }
$seed = secure_seed_rng();
|
$distance = $max - $min; return $min + floor($distance * ($seed / PHP_INT_MAX) ); }
| $distance = $max - $min; return $min + floor($distance * ($seed / PHP_INT_MAX) ); }
|
Zeile 8199 | Zeile 8392 |
---|
function trim_blank_chrs($string, $charlist="") { $hex_chrs = array(
|
function trim_blank_chrs($string, $charlist="") { $hex_chrs = array(
|
0x09 => 1, // \x{0009}
| 0x09 => 1, // \x{0009}
|
0x0A => 1, // \x{000A} 0x0B => 1, // \x{000B} 0x0D => 1, // \x{000D}
| 0x0A => 1, // \x{000A} 0x0B => 1, // \x{000B} 0x0D => 1, // \x{000D}
|
Zeile 8215 | Zeile 8408 |
---|
0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF} 0xBE => array(0xA0 => 1), // \x{FFA0} 0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} - \x{FFFB}
|
0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF} 0xBE => array(0xA0 => 1), // \x{FFA0} 0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} - \x{FFFB}
|
);
| );
|
$hex_chrs_rev = array( 0x09 => 1, // \x{0009}
| $hex_chrs_rev = array( 0x09 => 1, // \x{0009}
|
Zeile 8261 | Zeile 8454 |
---|
);
// Start from the beginning and work our way in
|
);
// Start from the beginning and work our way in
|
do { // Check to see if we have matched a first character in our utf-8 array
| do { // Check to see if we have matched a first character in our utf-8 array
|
$offset = match_sequence($string, $hex_chrs); if(!$offset) {
| $offset = match_sequence($string, $hex_chrs); if(!$offset) {
|
Zeile 8310 | Zeile 8503 |
---|
* @param int $i Number in the string * @param int $n Number of matches * @return int The number matched
|
* @param int $i Number in the string * @param int $n Number of matches * @return int The number matched
|
*/
| */
|
function match_sequence($string, $array, $i=0, $n=0) { if($string === "")
| function match_sequence($string, $array, $i=0, $n=0) { if($string === "")
|
Zeile 8342 | Zeile 8535 |
---|
function gd_version() { static $gd_version;
|
function gd_version() { static $gd_version;
|
|
|
if($gd_version) { return $gd_version;
| if($gd_version) { return $gd_version;
|
Zeile 8405 | Zeile 8598 |
---|
} } elseif($c > 239)
|
} } elseif($c > 239)
|
{ $bytes = 4;
| { $bytes = 4;
|
} elseif($c > 223) {
| } elseif($c > 223) {
|
Zeile 8422 | Zeile 8615 |
---|
{ $string .= '?'; break;
|
{ $string .= '?'; break;
|
}
| }
|
else
|
else
|
{
| {
|
return false; } }
| return false; } }
|
Zeile 8437 | Zeile 8630 |
---|
if($b < 128 || $b > 191) { if($return)
|
if($b < 128 || $b > 191) { if($return)
|
{
| {
|
$valid = false; $string .= '?'; break;
| $valid = false; $string .= '?'; break;
|
Zeile 8687 | Zeile 8880 |
---|
if(file_exists($file_path)) {
|
if(file_exists($file_path)) {
|
| if(is_object($plugins)) { $hook_args = array( 'file_path' => &$file_path, 'real_file_path' => &$real_file_path, 'file_name' => &$file_name, 'file_dir_path' => &$file_dir_path ); $plugins->run_hooks('copy_file_to_cdn_start', $hook_args); }
|
if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath'])) { $cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
| if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath'])) { $cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
|
Zeile 8819 | Zeile 9024 |
---|
$string = str_replace('"', '""', $string);
return $string;
|
$string = str_replace('"', '""', $string);
return $string;
|
| }
// Fallback function for 'array_column', PHP < 5.5.0 compatibility if(!function_exists('array_column')) { function array_column($input, $column_key) { $values = array(); if(!is_array($input)) { $input = array($input); } foreach($input as $val) { if(is_array($val) && isset($val[$column_key])) { $values[] = $val[$column_key]; } elseif(is_object($val) && isset($val->$column_key)) { $values[] = $val->$column_key; } } return $values; } }
/** * Performs a timing attack safe string comparison. * * @param string $known_string The first string to be compared. * @param string $user_string The second, user-supplied string to be compared. * @return bool Result of the comparison. */ function my_hash_equals($known_string, $user_string) { if(version_compare(PHP_VERSION, '5.6.0', '>=')) { return hash_equals($known_string, $user_string); } else { $known_string_length = my_strlen($known_string); $user_string_length = my_strlen($user_string);
if($user_string_length != $known_string_length) { return false; }
$result = 0;
for($i = 0; $i < $known_string_length; $i++) { $result |= ord($known_string[$i]) ^ ord($user_string[$i]); }
return $result === 0; } }
/** * Retrieves all referrals for a specified user * * @param int uid * @param int start position * @param int total entries * @param bool false (default) only return display info, true for all info * @return array */ function get_user_referrals($uid, $start=0, $limit=0, $full=false) { global $db;
$referrals = $query_options = array(); $uid = (int) $uid;
if($uid === 0) { return $referrals; }
if($start && $limit) { $query_options['limit_start'] = $start; }
if($limit) { $query_options['limit'] = $limit; }
$fields = 'uid, username, usergroup, displaygroup, regdate'; if($full === true) { $fields = '*'; }
$query = $db->simple_select('users', $fields, "referrer='{$uid}'", $query_options);
while($referral = $db->fetch_array($query)) { $referrals[] = $referral; }
return $referrals;
|
}
| }
|