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 322 | Zeile 323 |
---|
/** * 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 343 | Zeile 344 |
---|
{ if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user)) {
|
{ if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user)) {
|
$offset = $mybb->user['timezone'];
| $offset = (float)$mybb->user['timezone'];
|
$dstcorrection = $mybb->user['dst']; } elseif(defined("IN_ADMINCP")) {
|
$dstcorrection = $mybb->user['dst']; } elseif(defined("IN_ADMINCP")) {
|
$offset = $mybbadmin['timezone'];
| $offset = (float)$mybbadmin['timezone'];
|
$dstcorrection = $mybbadmin['dst']; } else {
|
$dstcorrection = $mybbadmin['dst']; } else {
|
$offset = $mybb->settings['timezoneoffset'];
| $offset = (float)$mybb->settings['timezoneoffset'];
|
$dstcorrection = $mybb->settings['dstcorrection']; }
| $dstcorrection = $mybb->settings['dstcorrection']; }
|
Zeile 380 | Zeile 381 |
---|
}
$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 400 | Zeile 401 |
---|
if($format == 'relative') { // Relative formats both date and time
|
if($format == 'relative') { // Relative formats both date and time
|
| $real_date = $real_time = ''; if($adodb == true) { $real_date = adodb_date($mybb->settings['dateformat'], $stamp + ($offset * 3600)); $real_time = $mybb->settings['datetimesep']; $real_time .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600)); } else { $real_date = gmdate($mybb->settings['dateformat'], $stamp + ($offset * 3600)); $real_time = $mybb->settings['datetimesep']; $real_time .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);
|
if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);
|
if($diff < 0) { $diff = abs($diff); $relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
| if($diff < 0) { $diff = abs($diff); $relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
|
$relative['minute'] = floor($diff / 60);
if($relative['minute'] <= 1)
| $relative['minute'] = floor($diff / 60);
if($relative['minute'] <= 1)
|
Zeile 426 | Zeile 441 |
---|
$relative['prefix'] = $lang->rel_less_than; }
|
$relative['prefix'] = $lang->rel_less_than; }
|
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);
| $date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix'], $real_date, $real_time);
|
} elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) {
| } elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) {
|
Zeile 446 | Zeile 461 |
---|
{ $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
{ $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
}
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix']); }
| }
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time); }
|
else { if($ty) { if($todaysdate == $date)
|
else { if($ty) { if($todaysdate == $date)
|
{ $date = $lang->today;
| { $date = $lang->sprintf($lang->today_rel, $real_date);
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->yesterday;
| $date = $lang->sprintf($lang->yesterday_rel, $real_date);
|
}
|
}
|
}
| }
|
$date .= $mybb->settings['datetimesep']; if($adodb == true)
|
$date .= $mybb->settings['datetimesep']; if($adodb == true)
|
{
| {
|
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
}
| }
|
else
|
else
|
{
| {
|
$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 497 | Zeile 537 |
---|
else { $date = gmdate($format, $stamp + ($offset * 3600));
|
else { $date = gmdate($format, $stamp + ($offset * 3600));
|
} }
| } }
|
}
if(is_object($plugins))
| }
if(is_object($plugins))
|
Zeile 533 | Zeile 573 |
---|
if(!is_object($mail)) { require_once MYBB_ROOT."inc/class_mailhandler.php";
|
if(!is_object($mail)) { require_once MYBB_ROOT."inc/class_mailhandler.php";
|
|
|
if($mybb->settings['mail_handler'] == 'smtp')
|
if($mybb->settings['mail_handler'] == 'smtp')
|
{
| {
|
require_once MYBB_ROOT."inc/mailhandlers/smtp.php"; $mail = new SmtpMail(); }
| require_once MYBB_ROOT."inc/mailhandlers/smtp.php"; $mail = new SmtpMail(); }
|
Zeile 543 | Zeile 583 |
---|
{ require_once MYBB_ROOT."inc/mailhandlers/php.php"; $mail = new PhpMail();
|
{ require_once MYBB_ROOT."inc/mailhandlers/php.php"; $mail = new PhpMail();
|
} }
| } }
|
// Using SMTP based mail if($mybb->settings['mail_handler'] == 'smtp')
| // Using SMTP based mail if($mybb->settings['mail_handler'] == 'smtp')
|
Zeile 556 | Zeile 596 |
---|
}
// Using PHP based mail()
|
}
// Using PHP based mail()
|
else
| else
|
{ if($mybb->settings['mail_parameters'] != '') {
| { if($mybb->settings['mail_parameters'] != '') {
|
Zeile 567 | Zeile 607 |
---|
// Build and send $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); return $mail->send();
|
// Build and send $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); return $mail->send();
|
}
| }
|
/**
|
/**
|
* 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']);
| $seed .= $mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate'];
|
}
|
}
|
// Guests get a special string
| |
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 736 | 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 829 | Zeile 885 |
---|
foreach($errors as $error) {
|
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 966 | Zeile 1022 |
---|
run_shutdown();
|
run_shutdown();
|
if(!my_validate_url($url, true))
| if(!my_validate_url($url, true, true))
|
{ header("Location: {$mybb->settings['bburl']}/{$url}"); }
| { header("Location: {$mybb->settings['bburl']}/{$url}"); }
|
Zeile 981 | Zeile 1037 |
---|
/** * Generate a listing of page - pagination
|
/** * Generate a listing of page - pagination
|
*
| *
|
* @param int $count The number of items * @param int $perpage The number of items to be shown per page * @param int $page The current page number
| * @param int $count The number of items * @param int $perpage The number of items to be shown per page * @param int $page The current page number
|
Zeile 991 | 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)
|
if($count <= $perpage)
|
{
| {
|
return ''; }
|
return ''; }
|
| $args = array( 'count' => &$count, 'perpage' => &$perpage, 'page' => &$page, 'url' => &$url, 'breadcrumb' => &$breadcrumb, ); $plugins->run_hooks('multipage', $args);
$page = (int)$page;
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 1076 | Zeile 1143 |
---|
$end = ''; if($to < $pages)
|
$end = ''; if($to < $pages)
|
{
| {
|
if($to+1 == $pages) { $lang->multipage_link_end = ''; }
|
if($to+1 == $pages) { $lang->multipage_link_end = ''; }
|
|
|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";"); }
$nextpage = ''; if($page < $pages)
|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";"); }
$nextpage = ''; if($page < $pages)
|
{
| {
|
$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")."\";");
|
Zeile 1100 | Zeile 1167 |
---|
// 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")."\";");
|
}
| }
|
|
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
| $multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
|
if($breadcrumb == true) {
| if($breadcrumb == true) {
|
Zeile 1124 | Zeile 1191 |
---|
* @return string */ function fetch_page_url($url, $page)
|
* @return string */ function fetch_page_url($url, $page)
|
{
| {
|
if($page <= 1) { $find = array(
| if($page <= 1) { $find = array(
|
Zeile 1136 | Zeile 1203 |
---|
// Remove "Page 1" to the defacto URL $url = str_replace($find, array("", "", $page), $url); return $url;
|
// Remove "Page 1" to the defacto URL $url = str_replace($find, array("", "", $page), $url); 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)
|
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)
|
{
| {
|
$url .= "?"; } else { $url .= "&"; }
|
$url .= "?"; } else { $url .= "&"; }
|
|
|
$url .= "page=$page"; } else
| $url .= "page=$page"; } else
|
Zeile 1162 | 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 === 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 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 1461 | Zeile 1534 |
---|
$current_permissions = $groupperms; } return $current_permissions;
|
$current_permissions = $groupperms; } 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 1476 | Zeile 1593 |
---|
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
$showform = true;
|
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
$showform = true;
|
|
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums();
| if(!is_array($forum_cache)) { $forum_cache = cache_forums();
|
Zeile 1488 | Zeile 1605 |
---|
// 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']))
|
{
| {
|
$parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); } if(!empty($parents)) { foreach($parents as $parent_id)
|
$parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); } if(!empty($parents)) { foreach($parents as $parent_id)
|
{
| {
|
if($parent_id == $fid || $parent_id == $pid)
|
if($parent_id == $fid || $parent_id == $pid)
|
{
| {
|
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);
|
{ my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true);
|
$showform = false; }
| $showform = false; }
|
else { eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
| else { eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
|
Zeile 1526 | Zeile 1642 |
---|
} else {
|
} else {
|
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))
| if(!forum_password_validated($forum_cache[$fid]))
|
{ $showform = true; }
| { $showform = true; }
|
Zeile 1662 | 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 1686 | Zeile 1802 |
---|
if($uid == 0) { $uid = $mybb->user['uid'];
|
if($uid == 0) { $uid = $mybb->user['uid'];
|
}
| }
|
if($uid == 0) {
| if($uid == 0) {
|
Zeile 1717 | 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;
|
}
$groups = explode(',', $user_perms['all_usergroups']);
| }
$groups = explode(',', $user_perms['all_usergroups']);
|
foreach($groups as $group) { if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action])))
| foreach($groups as $group) { if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action])))
|
Zeile 1730 | Zeile 1846 |
---|
return true; } }
|
return true; } }
|
} }
| } }
|
return false; } else
| return false; } else
|
Zeile 1741 | Zeile 1857 |
---|
if(!$action && $modperms) { return true;
|
if(!$action && $modperms) { return true;
|
}
| }
|
else { if(isset($modperms[$action]) && $modperms[$action] == 1)
|
else { if(isset($modperms[$action]) && $modperms[$action] == 1)
|
{
| {
|
return true; } else
| return true; } else
|
Zeile 1755 | 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 1774 | Zeile 1946 |
---|
$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 1820 | Zeile 1992 |
---|
* @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 1868 | Zeile 2041 |
---|
if($httponly == true) { $cookie .= "; HttpOnly";
|
if($httponly == true) { $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 1983 | Zeile 2166 |
---|
return false; }
|
return false; }
|
$stack = array(); $expected = array();
| $stack = $list = $expected = array();
|
/* * states:
| /* * states:
|
Zeile 3011 | Zeile 3193 |
---|
*/ 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}");
if($userin == 0)
| static $formattednames = array();
if(!isset($formattednames[$username]))
|
{
|
{
|
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
|
$format = "{username}";
|
$format = "{username}";
|
}
| |
|
|
$format = stripslashes($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 str_replace("{username}", $username, $format);
| return $formattednames[$username];
|
}
/**
| }
/**
|
Zeile 3056 | Zeile 3254 |
---|
}
if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])
|
}
if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])
|
{
| {
|
// Remote avatar, but remote avatars are disallowed. $avatar = null; }
| // Remote avatar, but remote avatars are disallowed. $avatar = null; }
|
Zeile 3067 | Zeile 3265 |
---|
if(defined('IN_ADMINCP')) { $theme['imgdir'] = '../images';
|
if(defined('IN_ADMINCP')) { $theme['imgdir'] = '../images';
|
}
| }
|
$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']); $dimensions = $mybb->settings['useravatardims'];
|
$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']); $dimensions = $mybb->settings['useravatardims'];
|
}
| }
|
if(!$max_dimensions) { $max_dimensions = $mybb->settings['maxavatardims'];
| if(!$max_dimensions) { $max_dimensions = $mybb->settings['maxavatardims'];
|
Zeile 3083 | Zeile 3281 |
---|
if(empty($key)) { $key = 'default';
|
if(empty($key)) { $key = 'default';
|
}
| }
|
$key2 = $max_dimensions; if(empty($key2)) { $key2 = 'default';
|
$key2 = $max_dimensions; if(empty($key2)) { $key2 = 'default';
|
}
| }
|
if(isset($avatars[$avatar][$key][$key2])) { return $avatars[$avatar][$key][$key2];
| if(isset($avatars[$avatar][$key][$key2])) { return $avatars[$avatar][$key][$key2];
|
Zeile 3099 | 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 3114 | Zeile 3312 |
---|
else { $avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";
|
else { $avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";
|
} } }
| } } }
|
$avatars[$avatar][$key][$key2] = array( 'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),
| $avatars[$avatar][$key][$key2] = array( 'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),
|
Zeile 3200 | 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 3210 | Zeile 3408 |
---|
"editor_maximize" => "Maximize" ); $editor_language = "(function ($) {\n$.sceditor.locale[\"mybblang\"] = {\n";
|
"editor_maximize" => "Maximize" ); $editor_language = "(function ($) {\n$.sceditor.locale[\"mybblang\"] = {\n";
|
|
|
$editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);
$editor_languages_count = count($editor_lang_strings);
| $editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);
$editor_languages_count = count($editor_lang_strings);
|
Zeile 3370 | 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 3384 | Zeile 3629 |
---|
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 3396 | Zeile 3641 |
---|
$smilie_cache = $cache->read("smilies"); } foreach($smilie_cache as $smilie)
|
$smilie_cache = $cache->read("smilies"); } foreach($smilie_cache as $smilie)
|
{
| {
|
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']); $smiliecache[$smilie['sid']] = $smilie; }
| $smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']); $smiliecache[$smilie['sid']] = $smilie; }
|
Zeile 3412 | Zeile 3657 |
---|
if($mybb->settings['smilieinsertertot'] >= $smiliecount) { $mybb->settings['smilieinsertertot'] = $smiliecount;
|
if($mybb->settings['smilieinsertertot'] >= $smiliecount) { $mybb->settings['smilieinsertertot'] = $smiliecount;
|
}
| }
|
else if($mybb->settings['smilieinsertertot'] < $smiliecount) { $smiliecount = $mybb->settings['smilieinsertertot'];
| else if($mybb->settings['smilieinsertertot'] < $smiliecount) { $smiliecount = $mybb->settings['smilieinsertertot'];
|
Zeile 3474 | Zeile 3719 |
---|
return $clickablesmilies; }
|
return $clickablesmilies; }
|
|
|
/** * Builds thread prefixes and returns a selected prefix (or all) *
| /** * Builds thread prefixes and returns a selected prefix (or all) *
|
Zeile 3489 | Zeile 3734 |
---|
if(is_array($prefixes_cache)) { if($pid > 0 && is_array($prefixes_cache[$pid]))
|
if(is_array($prefixes_cache)) { if($pid > 0 && is_array($prefixes_cache[$pid]))
|
{
| {
|
return $prefixes_cache[$pid]; }
| return $prefixes_cache[$pid]; }
|
Zeile 3520 | Zeile 3765 |
---|
return $prefixes_cache[$pid]; } else if(!empty($prefixes_cache))
|
return $prefixes_cache[$pid]; } else if(!empty($prefixes_cache))
|
{
| {
|
return $prefixes_cache; }
| return $prefixes_cache; }
|
Zeile 3781 | Zeile 4026 |
---|
{ $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 3799 | Zeile 4051 |
---|
"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 4121 | Zeile 4389 |
---|
$permissioncache = forum_permissions(); }
|
$permissioncache = forum_permissions(); }
|
$password_forums = $unviewable = array();
| $unviewable = array();
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
| foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
|
Zeile 4131 | Zeile 4399 |
---|
else { $perms = $mybb->usergroup;
|
else { $perms = $mybb->usergroup;
|
}
$pwverified = 1;
if($forum['password'] != "") { if($mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0; }
$password_forums[$forum['fid']] = $forum['password']; }
| }
$pwverified = 1;
if(!forum_password_validated($forum, true)) { $pwverified = 0; }
|
else { // Check parents for passwords $parents = explode(",", $forum['parentlist']); foreach($parents as $parent) {
|
else { // Check parents for passwords $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;
|
} } }
if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
|
} } }
if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
|
{
| {
|
$unviewable[] = $forum['fid']; } }
| $unviewable[] = $forum['fid']; } }
|
Zeile 4189 | Zeile 4454 |
---|
* Build the breadcrumb navigation trail from the specified items * * @return string The formatted breadcrumb navigation trail
|
* Build the breadcrumb navigation trail from the specified items * * @return string The formatted breadcrumb navigation trail
|
*/
| */
|
function build_breadcrumb() { global $nav, $navbits, $templates, $theme, $lang, $mybb;
| function build_breadcrumb() { global $nav, $navbits, $templates, $theme, $lang, $mybb;
|
Zeile 4240 | 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 4264 | Zeile 4527 |
---|
* @param string $url The URL of the item to add */ function add_breadcrumb($name, $url="")
|
* @param string $url The URL of the item to add */ function add_breadcrumb($name, $url="")
|
{ global $navbits;
| { global $navbits;
|
$navsize = count($navbits); $navbits[$navsize]['name'] = $name; $navbits[$navsize]['url'] = $url;
| $navsize = count($navbits); $navbits[$navsize]['name'] = $name; $navbits[$navsize]['url'] = $url;
|
Zeile 4282 | Zeile 4545 |
---|
function build_forum_breadcrumb($fid, $multipage=array()) { global $pforumcache, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;
|
function build_forum_breadcrumb($fid, $multipage=array()) { global $pforumcache, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;
|
|
|
if(!$pforumcache) { if(!is_array($forum_cache))
|
if(!$pforumcache) { if(!is_array($forum_cache))
|
{
| {
|
cache_forums();
|
cache_forums();
|
}
| }
|
foreach($forum_cache as $key => $val) {
| foreach($forum_cache as $key => $val) {
|
Zeile 4297 | Zeile 4560 |
---|
}
if(is_array($pforumcache[$fid]))
|
}
if(is_array($pforumcache[$fid]))
|
{
| {
|
foreach($pforumcache[$fid] as $key => $forumnav) { if($fid == $forumnav['fid'])
| foreach($pforumcache[$fid] as $key => $forumnav) { if($fid == $forumnav['fid'])
|
Zeile 4343 | Zeile 4606 |
---|
/** * Resets the breadcrumb navigation to the first item, and clears the rest
|
/** * Resets the breadcrumb navigation to the first item, and clears the rest
|
*/
| */
|
function reset_breadcrumb() { global $navbits;
| function reset_breadcrumb() { global $navbits;
|
Zeile 4388 | Zeile 4651 |
---|
break; case "announcement": $url = "{$base_url}announcement-{$id}.html";
|
break; case "announcement": $url = "{$base_url}announcement-{$id}.html";
|
break; case "forum":
| break; case "forum":
|
$url = "{$base_url}forum-{$id}.html"; break; default:
| $url = "{$base_url}forum-{$id}.html"; break; default:
|
Zeile 4418 | Zeile 4681 |
---|
$query_time = format_time_duration($db->query_time);
$call_time = format_time_duration($cache->call_time);
|
$query_time = format_time_duration($db->query_time);
$call_time = format_time_duration($cache->call_time);
|
|
|
$phpversion = PHP_VERSION;
$serverload = get_server_load();
| $phpversion = PHP_VERSION;
$serverload = get_server_load();
|
Zeile 4463 | Zeile 4726 |
---|
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Global.php Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$globaltime</span></td>\n";
|
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Global.php Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$globaltime</span></td>\n";
|
echo "</tr>\n"; echo "<tr>\n";
| echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Version:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phpversion</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n";
| echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Version:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phpversion</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n";
|
Zeile 4492 | Zeile 4755 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";
|
echo "</tr>\n";
echo "</table>\n";
| echo "</tr>\n";
echo "</table>\n";
|
echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
| echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
Zeile 4503 | Zeile 4766 |
---|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
|
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain;
| echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain;
|
Zeile 4511 | Zeile 4774 |
---|
{ echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n"; echo $cache->cache_debug;
|
{ echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n"; echo $cache->cache_debug;
|
}
echo "<h2>Template Statistics</h2>\n";
| }
echo "<h2>Template Statistics</h2>\n";
|
if(count($templates->cache) > 0) {
| if(count($templates->cache) > 0) {
|
Zeile 4554 | 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 4675 | Zeile 4935 |
---|
$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 4716 | Zeile 5020 |
---|
if($hours == 1) { $nicetime['hours'] = "1".$lang_hour;
|
if($hours == 1) { $nicetime['hours'] = "1".$lang_hour;
|
}
| }
|
else if($hours > 1) { $nicetime['hours'] = $hours.$lang_hours;
| else if($hours > 1) { $nicetime['hours'] = $hours.$lang_hours;
|
Zeile 4726 | Zeile 5030 |
---|
if(!isset($options['minutes']) || $options['minutes'] !== false) { if($minutes == 1)
|
if(!isset($options['minutes']) || $options['minutes'] !== false) { if($minutes == 1)
|
{
| {
|
$nicetime['minutes'] = "1".$lang_minute; } else if($minutes > 1)
| $nicetime['minutes'] = "1".$lang_minute; } else if($minutes > 1)
|
Zeile 4748 | Zeile 5052 |
---|
}
if(is_array($nicetime))
|
}
if(is_array($nicetime))
|
{
| {
|
return implode(", ", $nicetime); } }
| return implode(", ", $nicetime); } }
|
Zeile 4779 | Zeile 5083 |
---|
/** * Add a user to a specific additional user group.
|
/** * Add a user to a specific additional user group.
|
*
| *
|
* @param int $uid The user ID * @param int $joingroup The user group ID to join * @return bool
| * @param int $uid The user ID * @param int $joingroup The user group ID to join * @return bool
|
Zeile 4789 | Zeile 5093 |
---|
global $db, $mybb;
if($uid == $mybb->user['uid'])
|
global $db, $mybb;
if($uid == $mybb->user['uid'])
|
{
| {
|
$user = $mybb->user;
|
$user = $mybb->user;
|
} else {
| } else {
|
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".(int)$uid."'"); $user = $db->fetch_array($query); }
|
$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; $groupslist = ""; $groups = explode(",", $usergroups);
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; } } }
// What's the point in updating if they're the same? if($groupslist != $user['additionalgroups'])
| // Build the new list of additional groups for this user and make sure they're in the right format $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);
$groupslist = implode(',', $groups);
|
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'"); return true;
|
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'"); return true;
|
} else
| } else
|
{ return false; }
| { return false; }
|
Zeile 4842 | Zeile 5137 |
---|
$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 4880 | 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 4915 | Zeile 5207 |
---|
if($quick) { return $location;
|
if($quick) { return $location;
|
| }
if(!is_array($ignore)) { $ignore = array($ignore);
|
}
if($fields == true) {
|
}
if($fields == true) {
|
global $mybb;
if(!is_array($ignore)) { $ignore = array($ignore); }
| |
$form_html = ''; if(!empty($mybb->input))
| $form_html = ''; if(!empty($mybb->input))
|
Zeile 4944 | Zeile 5235 |
---|
} else {
|
} 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']);
| $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((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
| 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])) { $addloc[] = urlencode($var).'='.urlencode($_POST[$var]); } }
if(isset($addloc) && is_array($addloc)) { if(strpos($location, "?") === false) { $location .= "?"; } else
| if(isset($_POST[$var]) && !in_array($var, $ignore))
|
{
|
{
|
$location .= "&";
| $parameters[$var] = $_POST[$var];
|
}
|
}
|
$location .= implode("&", $addloc);
| |
}
|
}
|
| }
if(!empty($parameters)) { $location .= '?'.http_build_query($parameters, '', '&');
|
}
return $location;
|
}
return $location;
|
} }
| } }
|
/** * Build a theme selection menu
| /** * Build a theme selection menu
|
Zeile 5008 | Zeile 5306 |
---|
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'");
|
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;
| while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
|
Zeile 5022 | Zeile 5320 |
---|
}
if(is_array($tcache[$tid]))
|
}
if(is_array($tcache[$tid]))
|
{
| {
|
foreach($tcache[$tid] as $theme) { $sel = "";
| foreach($tcache[$tid] as $theme) { $sel = "";
|
Zeile 5062 | Zeile 5360 |
---|
}
return $themeselect;
|
}
return $themeselect;
|
} else
| } else
|
{ return false; }
| { return false; }
|
Zeile 5344 | Zeile 5642 |
---|
$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 5398 | Zeile 5695 |
---|
{ array_pop($find); array_pop($replace);
|
{ array_pop($find); array_pop($replace);
|
}
| }
|
return str_replace($find, $replace, $display); }
| return str_replace($find, $replace, $display); }
|
Zeile 5432 | Zeile 5729 |
---|
* Updates the first posts in a thread. * * @param int $tid The thread id for which to update the first post id.
|
* Updates the first posts in a thread. * * @param int $tid The thread id for which to update the first post id.
|
*/
| */
|
function update_first_post($tid) { global $db;
| function update_first_post($tid) { global $db;
|
Zeile 5611 | 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 5651 | Zeile 5975 |
---|
if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string);
|
if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string);
|
}
| }
|
else { $string = strtoupper($string); }
return $string;
|
else { $string = strtoupper($string); }
return $string;
|
}
| }
|
/** * Returns any html entities to their original character * * @param string $string The string to un-htmlentitize. * @return string The un-htmlentitied' string.
|
/** * Returns any html entities to their original character * * @param string $string The string to un-htmlentitize. * @return string The un-htmlentitied' string.
|
*/
| */
|
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); $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). *
|
* @param int $c The ascii to characterize. * @return string|bool The characterized ascii. False on failure */ function unichr($c) { if($c <= 0x7F)
|
* @param int $c The ascii to characterize. * @return string|bool The characterized ascii. False on failure */ function unichr($c) { if($c <= 0x7F)
|
{
| {
|
return chr($c); } else if($c <= 0x7FF)
| return chr($c); } else if($c <= 0x7FF)
|
Zeile 5710 | Zeile 6034 |
---|
{ 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 5783 | Zeile 6129 |
---|
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 6062 | 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 6202 | Zeile 6548 |
---|
* * @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'])) { $loginattempts = $mybb->cookies['loginattempts']; }
if(!empty($mybb->cookies['failedlogin'])) { $failedlogin = $mybb->cookies['failedlogin'];
| */ 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) { $query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1); $attempts = $db->fetch_array($query);
if($attempts['loginattempts'] <= 0) { return 0; }
|
}
|
}
|
// Work out if the user has had more than the allowed number of login attempts if($loginattempts > $mybb->settings['failedlogincount'])
| // This user has a cookie lockout, show waiting time elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)
|
{
|
{
|
// 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; } else { $failedtime = $mybb->cookies['failedlogin']; }
$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))
| if($fatal)
|
{
|
{
|
my_setcookie('failedlogin', $now); if($fatal) { error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false; }
| $secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now); $hoursleft = floor($secsleft / 3600); $minsleft = floor(($secsleft / 60) % 60); $secsleft = floor($secsleft % 60);
|
|
|
// 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))
| error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false; }
if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount']) { // 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 { $failedtime = $mybb->cookies['lockoutexpiry']; }
// 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 {
if($uid > 0) { $db->update_query("users", array( "loginattempts" => 0, "loginlockoutexpiry" => 0 ), "uid='{$uid}'"); }
// 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 6299 | Zeile 6654 |
---|
*/ 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 6341 | Zeile 6691 |
---|
{ global $db, $mybb;
|
{ 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'];
|
| $setting['name'] = addcslashes($setting['name'], "\\'");
|
$setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n"; }
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
$setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\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 6462 | Zeile 6803 |
---|
// 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 6484 | Zeile 6825 |
---|
}
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 6601 | Zeile 6954 |
---|
}
// Still here - good email
|
}
// Still here - good email
|
return false; }
| return false; }
|
/** * Checks if a specific IP address has been banned. *
| /** * Checks if a specific IP address has been banned. *
|
Zeile 6633 | Zeile 6986 |
---|
$ip_range = fetch_ip_range($banned_ip['filter']); if(is_array($ip_range))
|
$ip_range = fetch_ip_range($banned_ip['filter']); if(is_array($ip_range))
|
{
| {
|
if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0) { $banned = true; } } elseif($ip_address == $ip_range)
|
if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0) { $banned = true; } } elseif($ip_address == $ip_range)
|
{
| {
|
$banned = true; } if($banned)
| $banned = true; } if($banned)
|
Zeile 6662 | Zeile 7015 |
---|
* Returns an array of supported timezones * * @return string[] Key is timezone offset, Value the language description
|
* Returns an array of supported timezones * * @return string[] Key is timezone offset, Value the language description
|
*/
| */
|
function get_supported_timezones() { global $lang;
| function get_supported_timezones() { global $lang;
|
Zeile 6778 | Zeile 7131 |
---|
{ global $mybb, $config;
|
{ global $mybb, $config;
|
$url_components = @parse_url($url);
| if(!my_validate_url($url, true)) { return false; }
$url_components = @parse_url($url);
if(!isset($url_components['scheme'])) { $url_components['scheme'] = 'https'; } if(!isset($url_components['port'])) { $url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80; }
|
if( !$url_components || empty($url_components['host']) || (!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
|
if( !$url_components || empty($url_components['host']) || (!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
|
(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||
| (!in_array($url_components['port'], array(80, 8080, 443))) ||
|
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts'])) )
|
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts'])) )
|
{
| {
|
return false; }
|
return false; }
|
| $addresses = get_ip_by_hostname($url_components['host']); $destination_address = $addresses[0];
|
if(!empty($config['disallowed_remote_addresses']))
|
if(!empty($config['disallowed_remote_addresses']))
|
{ $addresses = gethostbynamel($url_components['host']); if($addresses) { foreach($config['disallowed_remote_addresses'] as $disallowed_address)
| { foreach($config['disallowed_remote_addresses'] as $disallowed_address) { $ip_range = fetch_ip_range($disallowed_address);
$packed_address = my_inet_pton($destination_address);
if(is_array($ip_range))
|
{
|
{
|
$ip_range = fetch_ip_range($disallowed_address); foreach($addresses as $address)
| if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
|
{
|
{
|
$packed_address = my_inet_pton($address);
if(is_array($ip_range)) { if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0) { return false; } } elseif($address == $disallowed_address) { return false; }
| return false;
|
}
|
}
|
| } elseif($destination_address == $disallowed_address) { return false;
|
} } }
$post_body = ''; if(!empty($post_data))
|
} } }
$post_body = ''; if(!empty($post_data))
|
{
| {
|
foreach($post_data as $key => $val) { $post_body .= '&'.urlencode($key).'='.urlencode($val); } $post_body = ltrim($post_body, '&'); }
|
foreach($post_data as $key => $val) { $post_body .= '&'.urlencode($key).'='.urlencode($val); } $post_body = ltrim($post_body, '&'); }
|
|
|
if(function_exists("curl_init")) {
|
if(function_exists("curl_init")) {
|
$can_followlocation = @ini_get('open_basedir') === '' && !$mybb->safemode;
$request_header = $max_redirects != 0 && !$can_followlocation;
| $fetch_header = $max_redirects > 0;
|
$ch = curl_init();
|
$ch = curl_init();
|
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $request_header); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if($max_redirects != 0 && $can_followlocation) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects); }
| $curlopt = array( CURLOPT_URL => $url, CURLOPT_HEADER => $fetch_header, CURLOPT_TIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 0, );
if($ca_bundle_path = get_ca_bundle_path()) { $curlopt[CURLOPT_SSL_VERIFYPEER] = 1; $curlopt[CURLOPT_CAINFO] = $ca_bundle_path; } else { $curlopt[CURLOPT_SSL_VERIFYPEER] = 0; }
$curl_version_info = curl_version(); $curl_version = $curl_version_info['version'];
if(version_compare(PHP_VERSION, '7.0.7', '>=') && version_compare($curl_version, '7.49', '>=')) { // CURLOPT_CONNECT_TO $curlopt[10243] = array( $url_components['host'].':'.$url_components['port'].':'.$destination_address ); } elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>=')) { // CURLOPT_RESOLVE $curlopt[10203] = array( $url_components['host'].':'.$url_components['port'].':'.$destination_address ); }
|
if(!empty($post_body)) {
|
if(!empty($post_body)) {
|
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
| $curlopt[CURLOPT_POST] = 1; $curlopt[CURLOPT_POSTFIELDS] = $post_body;
|
}
|
}
|
| curl_setopt_array($ch, $curlopt);
|
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
if($request_header)
| if($fetch_header)
|
{ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size);
| { $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size);
|
Zeile 6864 | 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 6886 | Zeile 7275 |
---|
} else if(function_exists("fsockopen")) {
|
} else if(function_exists("fsockopen")) {
|
if(!isset($url_components['port'])) { $url_components['port'] = 80; }
| |
if(!isset($url_components['path'])) { $url_components['path'] = "/";
| if(!isset($url_components['path'])) { $url_components['path'] = "/";
|
Zeile 6905 | Zeile 7290 |
---|
{ $scheme = 'ssl://'; if($url_components['port'] == 80)
|
{ $scheme = 'ssl://'; if($url_components['port'] == 80)
|
{
| {
|
$url_components['port'] = 443; } }
|
$url_components['port'] = 443; } }
|
$fp = @fsockopen($scheme.$url_components['host'], $url_components['port'], $error_no, $error, 10);
| if(function_exists('stream_context_create')) { if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path()) { $context = stream_context_create(array( 'ssl' => array( 'verify_peer' => true, 'verify_peer_name' => true, 'peer_name' => $url_components['host'], 'cafile' => $ca_bundle_path, ), )); } else { $context = stream_context_create(array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'peer_name' => $url_components['host'], ), )); }
$fp = @stream_socket_client($scheme.$destination_address.':'.(int)$url_components['port'], $error_no, $error, 10, STREAM_CLIENT_CONNECT, $context); } else { $fp = @fsockopen($scheme.$url_components['host'], (int)$url_components['port'], $error_no, $error, 10); }
|
@stream_set_timeout($fp, 10); if(!$fp) {
| @stream_set_timeout($fp, 10); if(!$fp) {
|
Zeile 6922 | Zeile 7337 |
---|
$headers[] = "POST {$url_components['path']} HTTP/1.0"; $headers[] = "Content-Length: ".strlen($post_body); $headers[] = "Content-Type: application/x-www-form-urlencoded";
|
$headers[] = "POST {$url_components['path']} HTTP/1.0"; $headers[] = "Content-Length: ".strlen($post_body); $headers[] = "Content-Type: application/x-www-form-urlencoded";
|
} else
| } else
|
{ $headers[] = "GET {$url_components['path']} HTTP/1.0"; }
| { $headers[] = "GET {$url_components['path']} HTTP/1.0"; }
|
Zeile 6931 | Zeile 7346 |
---|
$headers[] = "Host: {$url_components['host']}"; $headers[] = "Connection: Close"; $headers[] = '';
|
$headers[] = "Host: {$url_components['host']}"; $headers[] = "Connection: Close"; $headers[] = '';
|
|
|
if(!empty($post_body)) { $headers[] = $post_body;
| if(!empty($post_body)) { $headers[] = $post_body;
|
Zeile 6944 | Zeile 7359 |
---|
$headers = implode("\r\n", $headers); if(!@fwrite($fp, $headers))
|
$headers = implode("\r\n", $headers); if(!@fwrite($fp, $headers))
|
{ return false;
| { return false;
|
}
|
}
|
|
|
$data = null;
while(!feof($fp))
|
$data = null;
while(!feof($fp))
|
{ $data .= fgets($fp, 12800);
| { $data .= fgets($fp, 12800);
|
} fclose($fp);
| } fclose($fp);
|
Zeile 6962 | Zeile 7377 |
---|
$status_line = current(explode("\n\n", $header, 1)); $body = $data[1];
|
$status_line = current(explode("\n\n", $header, 1)); $body = $data[1];
|
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 6978 | Zeile 7393 |
---|
return $data; }
|
return $data; }
|
else if(empty($post_data))
| else { return false; } }
/** * Resolves a hostname into a set of IP addresses. * * @param string $hostname The hostname to be resolved * @return array|bool The resulting IP addresses. False on failure */ function get_ip_by_hostname($hostname) { $addresses = @gethostbynamel($hostname);
if(!$addresses) { $result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);
if($result_set) { $addresses = array_column($result_set, 'ip'); } else { return false; } }
return $addresses; }
/** * Returns the location of the CA bundle defined in the PHP configuration. * * @return string|bool The location of the CA bundle, false if not set */ function get_ca_bundle_path() { if($path = ini_get('openssl.cafile')) { return $path; } if($path = ini_get('curl.cainfo'))
|
{
|
{
|
return @implode("", @file($url)); } else { return false;
| return $path;
|
}
|
}
|
| return false;
|
}
/**
| }
/**
|
Zeile 7329 | 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 7610 | Zeile 8067 |
---|
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 7640 | Zeile 8096 |
---|
global $mybb, $checksums, $bad_verify_files;
// We don't need to check these types of files
|
global $mybb, $checksums, $bad_verify_files;
// We don't need to check these types of files
|
$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif", "logo.png");
| $ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");
|
$ignore_ext = array("attach");
if(substr($path, -1, 1) == "/")
| $ignore_ext = array("attach");
if(substr($path, -1, 1) == "/")
|
Zeile 7651 | Zeile 8107 |
---|
if(!is_array($bad_verify_files)) { $bad_verify_files = array();
|
if(!is_array($bad_verify_files)) { $bad_verify_files = array();
|
}
| }
|
// Make sure that we're in a directory and it's not a symbolic link if(@is_dir($path) && !@is_link($path))
| // Make sure that we're in a directory and it's not a symbolic link if(@is_dir($path) && !@is_link($path))
|
Zeile 7662 | Zeile 8118 |
---|
while(($file = @readdir($dh)) !== false) { if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))
|
while(($file = @readdir($dh)) !== false) { if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))
|
{ continue; }
| { continue; }
|
// Recurse through the directory tree if(is_dir($path."/".$file))
| // Recurse through the directory tree if(is_dir($path."/".$file))
|
Zeile 7681 | Zeile 8137 |
---|
{ $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 7721 | Zeile 8177 |
---|
if($count == 0) { return $bad_verify_files;
|
if($count == 0) { return $bad_verify_files;
|
} }
/**
| } }
/**
|
* Returns a signed value equal to an integer * * @param int $int The integer
| * Returns a signed value equal to an integer * * @param int $int The integer
|
Zeile 7757 | Zeile 8213 |
---|
{ $output = random_bytes($bytes); } catch (Exception $e) {
|
{ $output = random_bytes($bytes); } catch (Exception $e) {
|
} }
if(strlen($output) < $bytes) {
| } }
if(strlen($output) < $bytes) {
|
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb'))) { $output = @fread($handle, $bytes); @fclose($handle);
|
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb'))) { $output = @fread($handle, $bytes); @fclose($handle);
|
} } else { return $output; }
if(strlen($output) < $bytes)
| } } else { return $output; }
if(strlen($output) < $bytes)
|
{ if(function_exists('mcrypt_create_iv')) {
| { if(function_exists('mcrypt_create_iv')) {
|
Zeile 7805 | Zeile 8261 |
---|
if ($crypto_strong == false) { $output = null;
|
if ($crypto_strong == false) { $output = null;
|
} } } } else { return $output; }
| } } } } else { return $output; }
|
if(strlen($output) < $bytes) {
| if(strlen($output) < $bytes) {
|
Zeile 7826 | Zeile 8282 |
---|
$output = $CAPI_Util->GetRandom($bytes, 0); } } catch (Exception $e) {
|
$output = $CAPI_Util->GetRandom($bytes, 0); } } catch (Exception $e) {
|
} } } else { return $output; }
| } } } else { return $output; }
|
if(strlen($output) < $bytes) { // Close to what PHP basically uses internally to seed, but not quite.
| if(strlen($output) < $bytes) { // Close to what PHP basically uses internally to seed, but not quite.
|
Zeile 8159 | Zeile 8615 |
---|
{ $string .= '?'; break;
|
{ $string .= '?'; break;
|
}
| }
|
else { return false;
| else { return false;
|
Zeile 8239 | Zeile 8695 |
---|
global $lang, $mybb, $db, $session;
if($mybb->settings['enablepms'] == 0)
|
global $lang, $mybb, $db, $session;
if($mybb->settings['enablepms'] == 0)
|
{ return false;
| { return false;
|
}
if(!is_array($pm))
| }
if(!is_array($pm))
|
Zeile 8267 | Zeile 8723 |
---|
$num_args = count($pm[$key]);
for($i = 1; $i < $num_args; $i++)
|
$num_args = count($pm[$key]);
for($i = 1; $i < $num_args; $i++)
|
{
| {
|
$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string); } }
| $lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string); } }
|
Zeile 8340 | Zeile 8796 |
---|
}
$pm['options'] = array(
|
}
$pm['options'] = array(
|
"signature" => 0,
| |
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
| "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
|
Zeile 8425 | 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 8432 | Zeile 8899 |
---|
if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT) { $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
|
if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT) { $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
|
}
$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;
| }
$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;
|
if(!($dir_exists = is_dir($cdn_upload_path))) { $dir_exists = @mkdir($cdn_upload_path, 0777, true);
|
if(!($dir_exists = is_dir($cdn_upload_path))) { $dir_exists = @mkdir($cdn_upload_path, 0777, true);
|
}
| }
|
if($dir_exists) { if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)
| if($dir_exists) { if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)
|
Zeile 8470 | Zeile 8937 |
---|
}
return $success;
|
}
return $success;
|
}
| }
|
/** * Validate an url * * @param string $url The url to validate. * @param bool $relative_path Whether or not the url could be a relative path.
|
/** * Validate an url * * @param string $url The url to validate. * @param bool $relative_path Whether or not the url could be a relative path.
|
| * @param bool $allow_local Whether or not the url could be pointing to local networks.
|
* * @return bool Whether this is a valid url. */
|
* * @return bool Whether this is a valid url. */
|
function my_validate_url($url, $relative_path=false)
| function my_validate_url($url, $relative_path=false, $allow_local=false)
|
{
|
{
|
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))
| if($allow_local) { $regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS'; } else { $regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS'; }
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))
|
{ return true;
|
{ return true;
|
| } return false; }
/** * 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 * * @return string Striped string */ function my_strip_tags($string, $allowable_tags = '') { $pattern = array( '@(<)style[^(>)]*?(>).*?(<)/style(>)@siu', '@(<)script[^(>)]*?.*?(<)/script(>)@siu', '@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu', ); $string = preg_replace($pattern, '', $string); return strip_tags($string, $allowable_tags); }
/** * Escapes a RFC 4180-compliant CSV string. * Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867 * * @param string $string The string to be escaped * @param boolean $escape_active_content Whether or not to escape active content trigger characters * @return string The escaped string */ function my_escape_csv($string, $escape_active_content=true) { if($escape_active_content) { $active_content_triggers = array('=', '+', '-', '@'); $delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");
$first_character = mb_substr($string, 0, 1);
if( in_array($first_character, $active_content_triggers, true) || in_array($first_character, $delimiters, true) ) { $string = "'".$string; }
foreach($delimiters as $delimiter) { foreach($active_content_triggers as $trigger) { $string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $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 false;
| return $referrals;
|
}
| }
|