Zeile 1036 | Zeile 1036 |
---|
{ return ''; }
|
{ return ''; }
|
| $page = (int)$page;
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 1063 | Zeile 1065 |
---|
{ $from = 1; $to = $from+$mybb->settings['maxmultipagelinks']-1;
|
{ $from = 1; $to = $from+$mybb->settings['maxmultipagelinks']-1;
|
}
| }
|
if($to > $pages) { $to = $pages;
| if($to > $pages) { $to = $pages;
|
Zeile 1090 | Zeile 1092 |
---|
$page_url = fetch_page_url($url, 1); eval("\$start = \"".$templates->get("multipage_start")."\";");
|
$page_url = fetch_page_url($url, 1); eval("\$start = \"".$templates->get("multipage_start")."\";");
|
}
| }
|
$mppage = ''; for($i = $from; $i <= $to; ++$i) {
| $mppage = ''; for($i = $from; $i <= $to; ++$i) {
|
Zeile 1131 | Zeile 1133 |
---|
$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) {
|
Zeile 1141 | 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) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
}
| }
|
else { eval("\$multipage = \"".$templates->get("multipage")."\";");
| else { eval("\$multipage = \"".$templates->get("multipage")."\";");
|
Zeile 1186 | Zeile 1188 |
---|
else { $url .= "&";
|
else { $url .= "&";
|
}
| }
|
$url .= "page=$page";
|
$url .= "page=$page";
|
}
| }
|
else { $url = str_replace("{page}", $page, $url); }
|
else { $url = str_replace("{page}", $page, $url); }
|
|
|
return $url; }
/** * Fetch the permissions for a specific user
|
return $url; }
/** * 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 === null) { $uid = $mybb->user['uid']; }
// Its a guest. Return the group permissions directly from cache
|
if($uid == 0) {
|
if($uid == 0) {
|
$uid = $mybb->user['uid'];
| return $groupscache[1];
|
}
// User id does not match current user, fetch permissions
| }
// User id does not match current user, fetch permissions
|
Zeile 1228 | Zeile 1236 |
---|
{ $user_cache[$uid] = get_user($uid); }
|
{ $user_cache[$uid] = get_user($uid); }
|
|
|
// Collect group permissions. $gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid);
| // Collect group permissions. $gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid);
|
Zeile 1253 | Zeile 1261 |
---|
function usergroup_permissions($gid=0) { global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
function usergroup_permissions($gid=0) { global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
if(!is_array($groupscache)) {
| if(!is_array($groupscache)) {
|
$groupscache = $cache->read("usergroups");
|
$groupscache = $cache->read("usergroups");
|
}
$groups = explode(",", $gid);
| }
$groups = explode(",", $gid);
|
if(count($groups) == 1) {
| if(count($groups) == 1) {
|
Zeile 1269 | Zeile 1277 |
---|
$usergroup = array(); $usergroup['all_usergroups'] = $gid;
|
$usergroup = array(); $usergroup['all_usergroups'] = $gid;
|
|
|
foreach($groups as $gid) { if(trim($gid) == "" || empty($groupscache[$gid]))
|
foreach($groups as $gid) { if(trim($gid) == "" || empty($groupscache[$gid]))
|
{
| {
|
continue; }
| continue; }
|
Zeile 1282 | Zeile 1290 |
---|
if(!in_array($perm, $grouppermignore)) { if(isset($usergroup[$perm]))
|
if(!in_array($perm, $grouppermignore)) { if(isset($usergroup[$perm]))
|
{
| {
|
$permbit = $usergroup[$perm]; } else
|
$permbit = $usergroup[$perm]; } else
|
{
| {
|
$permbit = "";
|
$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)) { $usergroup[$perm] = 0; continue;
|
// 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;
|
}
| }
|
if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility? { $usergroup[$perm] = $access;
| if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility? { $usergroup[$perm] = $access;
|
Zeile 1350 | Zeile 1358 |
---|
{ $uid = $mybb->user['uid']; }
|
{ $uid = $mybb->user['uid']; }
|
|
|
if(!$gid || $gid == 0) // If no group, we need to fetch it { if($uid != 0 && $uid != $mybb->user['uid'])
|
if(!$gid || $gid == 0) // If no group, we need to fetch it { if($uid != 0 && $uid != $mybb->user['uid'])
|
{
| {
|
$user = get_user($uid);
$gid = $user['usergroup'].",".$user['additionalgroups'];
| $user = get_user($uid);
$gid = $user['usergroup'].",".$user['additionalgroups'];
|
Zeile 1363 | Zeile 1371 |
---|
else { $gid = $mybb->user['usergroup'];
|
else { $gid = $mybb->user['usergroup'];
|
|
|
if(isset($mybb->user['additionalgroups'])) { $gid .= ",".$mybb->user['additionalgroups'];
| if(isset($mybb->user['additionalgroups'])) { $gid .= ",".$mybb->user['additionalgroups'];
|
Zeile 1792 | Zeile 1800 |
---|
return false; } }
|
return false; } }
|
} } }
/**
| } } }
/**
|
* Generate a list of the posticons. * * @return string The template of posticons.
| * Generate a list of the posticons. * * @return string The template of posticons.
|
Zeile 1813 | 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 = array(); foreach($posticons_cache as $posticon) {
|
Zeile 1838 | Zeile 1846 |
---|
}
eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");
|
}
eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");
|
}
| }
|
if(!empty($iconlist)) { eval("\$posticons = \"".$templates->get("posticons")."\";");
|
if(!empty($iconlist)) { eval("\$posticons = \"".$templates->get("posticons")."\";");
|
}
| }
|
else { $posticons = '';
| else { $posticons = '';
|
Zeile 1851 | Zeile 1859 |
---|
return $posticons; }
|
return $posticons; }
|
|
|
/** * MyBB setcookie() wrapper. *
| /** * MyBB setcookie() wrapper. *
|
Zeile 1859 | 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 1892 | Zeile 1901 |
---|
if($expires > 0) { $cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
|
if($expires > 0) { $cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
|
}
| }
|
if(!empty($mybb->settings['cookiepath']))
|
if(!empty($mybb->settings['cookiepath']))
|
{
| {
|
$cookie .= "; path={$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 2949 | Zeile 2968 |
---|
if($selitem == $forum['fid']) { $optionselected = 'selected="selected"';
|
if($selitem == $forum['fid']) { $optionselected = 'selected="selected"';
|
}
$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
| }
$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
|
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
|
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
|
|
|
if($forum_cache[$forum['fid']]) { $newdepth = $depth."--"; $forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall); } }
|
if($forum_cache[$forum['fid']]) { $newdepth = $depth."--"; $forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall); } }
|
} } }
| } } }
|
if($addselect) { if($showextras == 0)
|
if($addselect) { if($showextras == 0)
|
{
| {
|
$template = "special"; } else
| $template = "special"; } else
|
Zeile 2978 | Zeile 2997 |
---|
if(strpos(FORUM_URL, '.html') !== false) { $forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";
|
if(strpos(FORUM_URL, '.html') !== false) { $forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";
|
}
| }
|
else { $forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);
| else { $forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);
|
Zeile 3050 | 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))
| static $formattednames = array();
if(!isset($formattednames[$username]))
|
{
|
{
|
$groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
$format = "{username}";
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);
|
|
|
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
| $format = $parameters['format'];
|
|
|
if($userin == 0) { $format = "{username}";
| $formattednames[$username] = str_replace("{username}", $username, $format);
|
}
|
}
|
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
| return $formattednames[$username];
|
}
/**
| }
/**
|
Zeile 5450 | 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 5479 | Zeile 5513 |
---|
'F', 'l', 'M',
|
'F', 'l', 'M',
|
);
| );
|
$bdays = str_replace($find, $html, $bdays); $bmonth = str_replace($find, $html, $bmonth);
| $bdays = str_replace($find, $html, $bdays); $bmonth = str_replace($find, $html, $bmonth);
|
Zeile 5496 | Zeile 5530 |
---|
$bmonth[$bm-1], $wd, ($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),
|
$bmonth[$bm-1], $wd, ($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),
|
);
| );
|
// Do we have the full month in our output? // If so there's no need for the short month if(strpos($display, 'F') !== false)
|
// Do we have the full month in our output? // If so there's no need for the short month if(strpos($display, 'F') !== false)
|
{
| {
|
array_pop($find); array_pop($replace); }
| array_pop($find); array_pop($replace); }
|
Zeile 5521 | Zeile 5555 |
---|
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 5540 | Zeile 5574 |
---|
* @param int $tid The thread id for which to update the first post id. */ function update_first_post($tid)
|
* @param int $tid The thread id for which to update the first post id. */ function update_first_post($tid)
|
{ global $db;
| { global $db;
|
$query = $db->query(" SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
| $query = $db->query(" SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
|
Zeile 5558 | Zeile 5592 |
---|
$firstpost['username'] = $firstpost['postusername']; } $firstpost['username'] = $db->escape_string($firstpost['username']);
|
$firstpost['username'] = $firstpost['postusername']; } $firstpost['username'] = $db->escape_string($firstpost['username']);
|
|
|
$update_array = array( 'firstpost' => (int)$firstpost['pid'], 'username' => $firstpost['username'], 'uid' => (int)$firstpost['uid'], 'dateline' => (int)$firstpost['dateline']
|
$update_array = array( 'firstpost' => (int)$firstpost['pid'], 'username' => $firstpost['username'], 'uid' => (int)$firstpost['uid'], 'dateline' => (int)$firstpost['dateline']
|
);
| );
|
$db->update_query("threads", $update_array, "tid='{$tid}'"); }
| $db->update_query("threads", $update_array, "tid='{$tid}'"); }
|
Zeile 5586 | Zeile 5620 |
---|
LIMIT 1" ); $lastpost = $db->fetch_array($query);
|
LIMIT 1" ); $lastpost = $db->fetch_array($query);
|
|
|
if(empty($lastpost['username'])) { $lastpost['username'] = $lastpost['postusername'];
| if(empty($lastpost['username'])) { $lastpost['username'] = $lastpost['postusername'];
|
Zeile 5674 | Zeile 5708 |
---|
if($length != null) { $cut_string = mb_substr($string, $start, $length);
|
if($length != null) { $cut_string = mb_substr($string, $start, $length);
|
} else {
| } else {
|
$cut_string = mb_substr($string, $start); } }
| $cut_string = mb_substr($string, $start); } }
|
Zeile 5693 | Zeile 5727 |
---|
}
if($handle_entities)
|
}
if($handle_entities)
|
{
| {
|
$cut_string = htmlspecialchars_uni($cut_string); } return $cut_string;
|
$cut_string = htmlspecialchars_uni($cut_string); } return $cut_string;
|
}
/**
| }
/**
|
* Lowers the case of a string, mb strings accounted for * * @param string $string The string to lower.
| * Lowers the case of a string, mb strings accounted for * * @param string $string The string to lower.
|
Zeile 5710 | Zeile 5744 |
---|
if(function_exists("mb_strtolower")) { $string = mb_strtolower($string);
|
if(function_exists("mb_strtolower")) { $string = mb_strtolower($string);
|
}
| }
|
else { $string = strtolower($string);
| else { $string = strtolower($string);
|
Zeile 5721 | Zeile 5755 |
---|
/** * Finds a needle in a haystack and returns it position, mb strings accounted for
|
/** * Finds a needle in a haystack and returns it position, mb strings accounted for
|
*
| *
|
* @param string $haystack String to look in (haystack) * @param string $needle What to look for (needle) * @param int $offset (optional) How much to offset * @return int|bool false on needle not found, integer position if found
|
* @param string $haystack String to look in (haystack) * @param string $needle What to look for (needle) * @param int $offset (optional) How much to offset * @return int|bool false on needle not found, integer position if found
|
*/
| */
|
function my_strpos($haystack, $needle, $offset=0) { if($needle == '')
| function my_strpos($haystack, $needle, $offset=0) { if($needle == '')
|
Zeile 5737 | Zeile 5771 |
---|
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset);
|
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset);
|
}
| }
|
else { $position = strpos($haystack, $needle, $offset);
|
else { $position = strpos($haystack, $needle, $offset);
|
}
| }
|
return $position; }
| return $position; }
|
Zeile 5764 | Zeile 5798 |
---|
}
return $string;
|
}
return $string;
|
}
/**
| }
/**
|
* Returns any html entities to their original character * * @param string $string The string to un-htmlentitize.
| * Returns any html entities to their original character * * @param string $string The string to un-htmlentitize.
|
Zeile 5777 | Zeile 5811 |
---|
// Replace numeric entities $string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string); $string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);
|
// Replace numeric entities $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); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
}
| }
|
/** * Returns any ascii to it's character (utf-8 safe).
| /** * Returns any ascii to it's character (utf-8 safe).
|
Zeile 5794 | Zeile 5828 |
---|
function unichr($c) { if($c <= 0x7F)
|
function unichr($c) { if($c <= 0x7F)
|
{
| {
|
return chr($c); } else if($c <= 0x7FF)
| return chr($c); } else if($c <= 0x7FF)
|
Zeile 5804 | Zeile 5838 |
---|
else if($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
|
else if($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
|
. chr(0x80 | $c & 0x3F); }
| . chr(0x80 | $c & 0x3F); }
|
else if($c <= 0x10FFFF)
|
else if($c <= 0x10FFFF)
|
{
| {
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
} else { return false; } }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches.
| } else { 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 string|bool The characterized ascii. False on failure */ function unichr_callback1($matches)
|
Zeile 5838 | Zeile 5872 |
---|
function unichr_callback2($matches) { return unichr($matches[1]);
|
function unichr_callback2($matches) { return unichr($matches[1]);
|
}
| }
|
/** * Get the event poster. *
| /** * Get the event poster. *
|
Zeile 5892 | Zeile 5926 |
---|
function get_announcement_link($aid=0) { $link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);
|
function get_announcement_link($aid=0) { $link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
}
/**
| }
/**
|
Zeile 6034 | Zeile 6068 |
---|
/** * Build the link to a specified date on the calendar
|
/** * Build the link to a specified date on the calendar
|
*
| *
|
* @param int $calendar The ID of the calendar * @param int $year The year * @param int $month The month
| * @param int $calendar The ID of the calendar * @param int $year The year * @param int $month The month
|
Zeile 6052 | Zeile 6086 |
---|
return htmlspecialchars_uni($link); } else if($month > 0)
|
return htmlspecialchars_uni($link); } else if($month > 0)
|
{
| {
|
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH); $link = str_replace("{year}", $year, $link); $link = str_replace("{calendar}", $calendar, $link);
| $link = str_replace("{month}", $month, CALENDAR_URL_MONTH); $link = str_replace("{year}", $year, $link); $link = str_replace("{calendar}", $calendar, $link);
|
Zeile 6079 | Zeile 6113 |
---|
function get_calendar_week_link($calendar, $week) { if($week < 0)
|
function get_calendar_week_link($calendar, $week) { if($week < 0)
|
{
| {
|
$week = str_replace('-', "n", $week); } $link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
| $week = str_replace('-', "n", $week); } $link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
|
Zeile 6097 | Zeile 6131 |
---|
{ global $mybb, $db; static $user_cache;
|
{ global $mybb, $db; static $user_cache;
|
|
|
$uid = (int)$uid;
if(!empty($mybb->user) && $uid == $mybb->user['uid'])
| $uid = (int)$uid;
if(!empty($mybb->user) && $uid == $mybb->user['uid'])
|
Zeile 6105 | Zeile 6139 |
---|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
{
| {
|
return $user_cache[$uid]; } elseif($uid > 0)
| return $user_cache[$uid]; } elseif($uid > 0)
|
Zeile 6114 | Zeile 6148 |
---|
$user_cache[$uid] = $db->fetch_array($query);
return $user_cache[$uid];
|
$user_cache[$uid] = $db->fetch_array($query);
return $user_cache[$uid];
|
}
| }
|
return array(); }
| return array(); }
|
Zeile 6132 | Zeile 6166 |
---|
$username = $db->escape_string(my_strtolower($username));
if(!isset($options['username_method']))
|
$username = $db->escape_string(my_strtolower($username));
if(!isset($options['username_method']))
|
{
| {
|
$options['username_method'] = 0; }
| $options['username_method'] = 0; }
|
Zeile 6150 | Zeile 6184 |
---|
}
switch($options['username_method'])
|
}
switch($options['username_method'])
|
{
| {
|
case 1: $sqlwhere = "{$efield}='{$username}'"; break;
| case 1: $sqlwhere = "{$efield}='{$username}'"; break;
|
Zeile 6166 | Zeile 6200 |
---|
if(isset($options['fields'])) { $fields = array_merge((array)$options['fields'], $fields);
|
if(isset($options['fields'])) { $fields = array_merge((array)$options['fields'], $fields);
|
}
$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));
| }
$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));
|
if(isset($options['exists'])) { return (bool)$db->num_rows($query); }
return $db->fetch_array($query);
|
if(isset($options['exists'])) { return (bool)$db->num_rows($query); }
return $db->fetch_array($query);
|
}
| }
|
/** * Get the forum of a specific forum id.
| /** * Get the forum of a specific forum id.
|
Zeile 6184 | Zeile 6218 |
---|
* @param int $fid The forum id of the forum. * @param int $active_override (Optional) If set to 1, will override the active forum status * @return array|bool The database row of a forum. False on failure
|
* @param int $fid The forum id of the forum. * @param int $active_override (Optional) If set to 1, will override the active forum status * @return array|bool The database row of a forum. False on failure
|
*/
| */
|
function get_forum($fid, $active_override=0) { global $cache;
| function get_forum($fid, $active_override=0) { global $cache;
|
Zeile 6193 | Zeile 6227 |
---|
if(!isset($forum_cache) || is_array($forum_cache)) { $forum_cache = $cache->read("forums");
|
if(!isset($forum_cache) || is_array($forum_cache)) { $forum_cache = $cache->read("forums");
|
}
| }
|
if(empty($forum_cache[$fid]))
|
if(empty($forum_cache[$fid]))
|
{
| {
|
return false; }
if($active_override != 1)
|
return false; }
if($active_override != 1)
|
{
| {
|
$parents = explode(",", $forum_cache[$fid]['parentlist']); if(is_array($parents)) {
| $parents = explode(",", $forum_cache[$fid]['parentlist']); if(is_array($parents)) {
|
Zeile 6245 | Zeile 6279 |
---|
{ $thread_cache[$tid] = $thread; return $thread;
|
{ $thread_cache[$tid] = $thread; return $thread;
|
} else {
| } else {
|
$thread_cache[$tid] = false; return false; }
| $thread_cache[$tid] = false; return false; }
|
Zeile 6256 | Zeile 6290 |
---|
/** * Get the post of a post id.
|
/** * Get the post of a post id.
|
*
| *
|
* @param int $pid The post id of the post. * @return array|bool The database row of the post. False on failure */
| * @param int $pid The post id of the post. * @return array|bool The database row of the post. False on failure */
|
Zeile 6265 | Zeile 6299 |
---|
global $db; static $post_cache;
|
global $db; static $post_cache;
|
$pid = (int)$pid;
| $pid = (int)$pid;
|
if(isset($post_cache[$pid])) { return $post_cache[$pid];
| if(isset($post_cache[$pid])) { return $post_cache[$pid];
|
Zeile 6316 | Zeile 6350 |
---|
{ $inactive[] = $fid1; }
|
{ $inactive[] = $fid1; }
|
} } }
| } } }
|
$inactiveforums = implode(",", $inactive);
|
$inactiveforums = implode(",", $inactive);
|
|
|
return $inactiveforums; }
/** * Checks to make sure a user has not tried to login more times than permitted
|
return $inactiveforums; }
/** * Checks to make sure a user has not tried to login more times than permitted
|
*
| *
|
* @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) { global $mybb, $lang, $session, $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']))
| */ function login_attempt_check($uid = 0, $fatal = true) { global $mybb, $lang, $db;
$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'])) { $failedtime = $now; }
| // Set the expiry dateline if not set yet if($attempts['loginlockoutexpiry'] == 0) { $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; }
|
return false; }
|
| // Unlock if enough time has passed else {
|
|
|
// 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)
| if($uid > 0)
|
{
|
{
|
$update_array = array( 'loginattempts' => 1 ); $db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
| $db->update_query("users", array( "loginattempts" => 0, "loginlockoutexpiry" => 0 ), "uid='{$uid}'");
|
}
|
}
|
return 1; } // Not waited long enough else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60)) { if($fatal) { error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
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 6427 | Zeile 6470 |
---|
*/ 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 7842 | 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 7913 | 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 8289 | Zeile 8326 |
---|
$ord = ord($string[$i]); if(array_key_exists($ord, $array))
|
$ord = ord($string[$i]); if(array_key_exists($ord, $array))
|
{
| {
|
$level = $array[$ord]; ++$n; if(is_array($level))
| $level = $array[$ord]; ++$n; if(is_array($level))
|
Zeile 8317 | Zeile 8354 |
---|
return $gd_version; } if(!extension_loaded('gd'))
|
return $gd_version; } if(!extension_loaded('gd'))
|
{
| {
|
return; }
| return; }
|
Zeile 8400 | Zeile 8437 |
---|
$valid = true; $multibytes = $input[$i]; while($bytes > 1)
|
$valid = true; $multibytes = $input[$i]; while($bytes > 1)
|
{
| {
|
$i++; $b = ord($input[$i]); if($b < 128 || $b > 191)
| $i++; $b = ord($input[$i]); if($b < 128 || $b > 191)
|
Zeile 8572 | Zeile 8609 |
---|
}
$pm['options'] = array(
|
}
$pm['options'] = array(
|
"signature" => 0,
| |
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
| "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
|
Zeile 8734 | Zeile 8770 |
---|
/** * 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 *
|