Zeile 322 | Zeile 322 |
---|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
* @param string $format A date format according to PHP's date structure.
| * @param string $format A date format (either relative, normal or PHP's date() structure).
|
* @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
| * @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
|
Zeile 343 | Zeile 343 |
---|
{ 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 380 |
---|
}
$todaysdate = $yesterdaysdate = '';
|
}
$todaysdate = $yesterdaysdate = '';
|
if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))
| if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))
|
{ $_stamp = TIME_NOW; if($adodb == true)
| { $_stamp = TIME_NOW; if($adodb == true)
|
Zeile 400 | Zeile 400 |
---|
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;
| if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp;
|
Zeile 411 | Zeile 425 |
---|
$relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
|
$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)
|
{
| {
|
$relative['minute'] = 1; $relative['plural'] = $lang->rel_minutes_single;
|
$relative['minute'] = 1; $relative['plural'] = $lang->rel_minutes_single;
|
}
| }
|
if($diff <= 60) { // Less than a minute $relative['prefix'] = $lang->rel_less_than; }
|
if($diff <= 60) { // Less than a minute $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) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);
|
} elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_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['hour'] = floor($diff / 3600);
| }
$relative['hour'] = floor($diff / 3600);
|
if($relative['hour'] <= 1) { $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
if($relative['hour'] <= 1) { $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'];
|
} }
$date .= $mybb->settings['datetimesep'];
|
if($adodb == true) {
| 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 482 | Zeile 521 |
---|
if($todaysdate == $date) { $date = $lang->today;
|
if($todaysdate == $date) { $date = $lang->today;
|
}
| }
|
else if($yesterdaysdate == $date) { $date = $lang->yesterday;
| else if($yesterdaysdate == $date) { $date = $lang->yesterday;
|
Zeile 528 | Zeile 567 |
---|
{ global $mybb; static $mail;
|
{ global $mybb; static $mail;
|
|
|
// Does our object not exist? Create it if(!is_object($mail)) {
| // Does our object not exist? Create it if(!is_object($mail)) {
|
Zeile 966 | Zeile 1005 |
---|
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 997 | Zeile 1036 |
---|
{ return ''; }
|
{ return ''; }
|
| $page = (int)$page;
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 1102 | Zeile 1143 |
---|
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";"); }
|
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";"); }
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
| $multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
|
if($breadcrumb == true) {
| if($breadcrumb == true) {
|
Zeile 1150 | Zeile 1191 |
---|
}
$url .= "page=$page";
|
}
$url .= "page=$page";
|
} else {
| } else {
|
$url = str_replace("{page}", $page, $url); }
| $url = str_replace("{page}", $page, $url); }
|
Zeile 1168 | Zeile 1209 |
---|
function user_permissions($uid=0) { global $mybb, $cache, $groupscache, $user_cache;
|
function user_permissions($uid=0) { global $mybb, $cache, $groupscache, $user_cache;
|
|
|
// If no user id is specified, assume it is the current user if($uid == 0) {
| // If no user id is specified, assume it is the current user if($uid == 0) {
|
Zeile 1179 | Zeile 1220 |
---|
if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
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 1216 | Zeile 1257 |
---|
global $cache, $groupscache, $grouppermignore, $groupzerogreater;
if(!is_array($groupscache))
|
global $cache, $groupscache, $grouppermignore, $groupzerogreater;
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups"); }
| $groupscache = $cache->read("usergroups"); }
|
Zeile 1247 | Zeile 1288 |
---|
$permbit = $usergroup[$perm]; } else
|
$permbit = $usergroup[$perm]; } else
|
{
| {
|
$permbit = ""; }
| $permbit = ""; }
|
Zeile 1278 | Zeile 1319 |
---|
function usergroup_displaygroup($gid) { global $cache, $groupscache, $displaygroupfields;
|
function usergroup_displaygroup($gid) { global $cache, $groupscache, $displaygroupfields;
|
|
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
| }
|
$displaygroup = array(); $group = $groupscache[$gid];
| $displaygroup = array(); $group = $groupscache[$gid];
|
Zeile 1291 | Zeile 1332 |
---|
{ $displaygroup[$field] = $group[$field]; }
|
{ $displaygroup[$field] = $group[$field]; }
|
|
|
return $displaygroup;
|
return $displaygroup;
|
}
| }
|
/** * Build the forum permissions for a specific forum, user or group *
| /** * Build the forum permissions for a specific forum, user or group *
|
Zeile 1356 | Zeile 1397 |
---|
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms); } return $cached_forum_permissions_permissions[$gid][$fid];
|
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms); } return $cached_forum_permissions_permissions[$gid][$fid];
|
}
| }
|
else { if(empty($cached_forum_permissions[$gid]))
| else { if(empty($cached_forum_permissions[$gid]))
|
Zeile 1402 | Zeile 1443 |
---|
// If our permissions arn't inherited we need to figure them out if(empty($fpermcache[$fid][$gid]))
|
// If our permissions arn't inherited we need to figure them out if(empty($fpermcache[$fid][$gid]))
|
{
| {
|
$parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents))
| $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents))
|
Zeile 1448 | Zeile 1489 |
---|
if($only_view_own_threads == 0) { $current_permissions["canonlyviewownthreads"] = 0;
|
if($only_view_own_threads == 0) { $current_permissions["canonlyviewownthreads"] = 0;
|
}
| }
|
// Figure out if we can reply more than our own threads if($only_reply_own_threads == 0) {
| // Figure out if we can reply more than our own threads if($only_reply_own_threads == 0) {
|
Zeile 1481 | Zeile 1522 |
---|
{ $forum_cache = cache_forums(); if(!$forum_cache)
|
{ $forum_cache = cache_forums(); if(!$forum_cache)
|
{
| {
|
return false; } }
| return false; } }
|
Zeile 1512 | Zeile 1553 |
---|
{ $password = $forum_cache[$fid]['password']; if(isset($mybb->input['pwverify']) && $pid == 0)
|
{ $password = $forum_cache[$fid]['password']; if(isset($mybb->input['pwverify']) && $pid == 0)
|
{
| {
|
if($password === $mybb->get_input('pwverify'))
|
if($password === $mybb->get_input('pwverify'))
|
{
| {
|
my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true); $showform = false; }
| my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true); $showform = false; }
|
Zeile 1527 | Zeile 1568 |
---|
else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))
|
else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))
|
{
| {
|
$showform = true; } else
| $showform = true; } else
|
Zeile 1574 | Zeile 1615 |
---|
{ global $mybb, $cache, $db; static $modpermscache;
|
{ global $mybb, $cache, $db; static $modpermscache;
|
|
|
if($uid < 1) { $uid = $mybb->user['uid'];
|
if($uid < 1) { $uid = $mybb->user['uid'];
|
}
| }
|
if($uid == 0) { return false;
|
if($uid == 0) { return false;
|
}
| }
|
if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid];
|
if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid];
|
}
| }
|
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
| if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
|
Zeile 1619 | Zeile 1660 |
---|
{ // No perms or we're not after this forum continue;
|
{ // No perms or we're not after this forum continue;
|
}
| }
|
// User settings override usergroup settings if(is_array($forum['users'][$uid])) {
| // User settings override usergroup settings if(is_array($forum['users'][$uid])) {
|
Zeile 1651 | Zeile 1692 |
---|
{ // There are no permissions set for this group continue;
|
{ // There are no permissions set for this group continue;
|
}
| }
|
$perm = $forum['usergroups'][$group]; foreach($perm as $action => $value)
| $perm = $forum['usergroups'][$group]; foreach($perm as $action => $value)
|
Zeile 1774 | Zeile 1815 |
---|
$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 1861 |
---|
* @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 1910 |
---|
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 1901 | Zeile 1953 |
---|
* @param string $name The cookie identifier. * @param int $id The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
|
* @param string $name The cookie identifier. * @param int $id The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
|
*/
| */
|
function my_get_array_cookie($name, $id) { global $mybb;
| function my_get_array_cookie($name, $id) { global $mybb;
|
Zeile 1909 | Zeile 1961 |
---|
if(!isset($mybb->cookies['mybb'][$name])) { return false;
|
if(!isset($mybb->cookies['mybb'][$name])) { return false;
|
}
| }
|
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id])) { return $cookie[$id];
|
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id])) { return $cookie[$id];
|
} else
| } else
|
{ return 0; }
| { return 0; }
|
Zeile 1948 | Zeile 2000 |
---|
$newcookie[$id] = $value; $newcookie = my_serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie), $expires);
|
$newcookie[$id] = $value; $newcookie = my_serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie), $expires);
|
|
|
// Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie; }
| // Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie; }
|
Zeile 2011 | Zeile 2063 |
---|
{ $value = $matches[1] == '1' ? true : false; $str = substr($str, 4);
|
{ $value = $matches[1] == '1' ? true : false; $str = substr($str, 4);
|
}
| }
|
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
|
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
|
{
| {
|
$value = (int)$matches[1]; $str = $matches[2]; }
| $value = (int)$matches[1]; $str = $matches[2]; }
|
Zeile 2026 | Zeile 2078 |
---|
{ $value = substr($matches[2], 0, (int)$matches[1]); $str = substr($matches[2], (int)$matches[1] + 2);
|
{ $value = substr($matches[2], 0, (int)$matches[1]); $str = substr($matches[2], (int)$matches[1] + 2);
|
}
| }
|
else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) { $expectedLength = (int)$matches[1]; $str = $matches[2];
|
else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) { $expectedLength = (int)$matches[1]; $str = $matches[2];
|
}
| }
|
else
|
else
|
{
| {
|
// object or unknown/malformed type return false; }
| // object or unknown/malformed type return false; }
|
Zeile 2041 | Zeile 2093 |
---|
switch($state) { case 3: // in array, expecting value or another array
|
switch($state) { case 3: // in array, expecting value or another array
|
if($type == 'a') {
| if($type == 'a') {
|
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) { // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
| if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) { // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
|
Zeile 2052 | Zeile 2104 |
---|
$stack[] = &$list; $list[$key] = array(); $list = &$list[$key];
|
$stack[] = &$list; $list[$key] = array(); $list = &$list[$key];
|
$expected[] = $expectedLength; $state = 2; break; } if($type != '}') {
| $expected[] = $expectedLength; $state = 2; break; } if($type != '}') {
|
$list[$key] = $value; $state = 2; break;
| $list[$key] = $value; $state = 2; break;
|
Zeile 2072 | Zeile 2124 |
---|
if(count($list) < end($expected)) { // array size less than expected
|
if(count($list) < end($expected)) { // array size less than expected
|
return false; }
| return false; }
|
unset($list); $list = &$stack[count($stack)-1];
| unset($list); $list = &$stack[count($stack)-1];
|
Zeile 2150 | Zeile 2202 |
---|
* @return mixed */ function my_unserialize($str)
|
* @return mixed */ function my_unserialize($str)
|
{
| {
|
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
|
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
|
if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2)) { $mbIntEnc = mb_internal_encoding(); mb_internal_encoding('ASCII'); }
$out = _safe_unserialize($str);
if(isset($mbIntEnc)) { mb_internal_encoding($mbIntEnc); }
return $out;
| if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2)) { $mbIntEnc = mb_internal_encoding(); mb_internal_encoding('ASCII'); }
$out = _safe_unserialize($str);
if(isset($mbIntEnc)) { mb_internal_encoding($mbIntEnc); }
return $out;
|
}
/**
| }
/**
|
Zeile 2196 | Zeile 2248 |
---|
}
if(is_float($value))
|
}
if(is_float($value))
|
{
| {
|
return 'd:'.str_replace(',', '.', $value).';';
|
return 'd:'.str_replace(',', '.', $value).';';
|
}
| }
|
if(is_string($value))
|
if(is_string($value))
|
{
| {
|
return 's:'.strlen($value).':"'.$value.'";'; }
| return 's:'.strlen($value).':"'.$value.'";'; }
|
Zeile 2211 | Zeile 2263 |
---|
foreach($value as $k => $v) { $out .= _safe_serialize($k) . _safe_serialize($v);
|
foreach($value as $k => $v) { $out .= _safe_serialize($k) . _safe_serialize($v);
|
}
| }
|
return 'a:'.count($value).':{'.$out.'}'; }
| return 'a:'.count($value).':{'.$out.'}'; }
|
Zeile 2273 | Zeile 2325 |
---|
if(!is_numeric($serverload[0])) { if($mybb->safemode)
|
if(!is_numeric($serverload[0])) { if($mybb->safemode)
|
{ return $lang->unknown;
| { return $lang->unknown;
|
}
// Suhosin likes to throw a warning if exec is disabled then die - weird
| }
// Suhosin likes to throw a warning if exec is disabled then die - weird
|
Zeile 2321 | Zeile 2373 |
---|
function get_memory_usage() { if(function_exists('memory_get_peak_usage'))
|
function get_memory_usage() { if(function_exists('memory_get_peak_usage'))
|
{
| {
|
return memory_get_peak_usage(true); } elseif(function_exists('memory_get_usage'))
| return memory_get_peak_usage(true); } elseif(function_exists('memory_get_usage'))
|
Zeile 2398 | Zeile 2450 |
---|
{ // We had relative values? Then it is still relative if($new_stats[$counter] >= 0)
|
{ // We had relative values? Then it is still relative if($new_stats[$counter] >= 0)
|
{
| {
|
$new_stats[$counter] = "+{$new_stats[$counter]}"; } }
| $new_stats[$counter] = "+{$new_stats[$counter]}"; } }
|
Zeile 2441 | Zeile 2493 |
---|
if(is_array($stats)) { $stats = array_merge($stats, $new_stats); // Overwrite changed values
|
if(is_array($stats)) { $stats = array_merge($stats, $new_stats); // Overwrite changed values
|
} else { $stats = $new_stats;
| } else { $stats = $new_stats;
|
} }
| } }
|
Zeile 2505 | Zeile 2557 |
---|
{ $update_query[$counter] = 0; }
|
{ $update_query[$counter] = 0; }
|
} }
| } }
|
// Only update if we're actually doing something if(count($update_query) > 0)
|
// Only update if we're actually doing something if(count($update_query) > 0)
|
{
| {
|
$db->update_query("forums", $update_query, "fid='".(int)$fid."'"); }
| $db->update_query("forums", $update_query, "fid='".(int)$fid."'"); }
|
Zeile 2522 | Zeile 2574 |
---|
if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}";
|
if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}";
|
} else
| } else
|
{ $new_stats['numthreads'] = "{$threads_diff}"; }
| { $new_stats['numthreads'] = "{$threads_diff}"; }
|
Zeile 2896 | Zeile 2948 |
---|
}
if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
|
}
if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
|
{
| {
|
foreach($jumpfcache[$pid] as $main) { foreach($main as $forum)
| foreach($jumpfcache[$pid] as $main) { foreach($main as $forum)
|
Zeile 2910 | Zeile 2962 |
---|
if($selitem == $forum['fid']) { $optionselected = 'selected="selected"';
|
if($selitem == $forum['fid']) { $optionselected = 'selected="selected"';
|
}
| }
|
$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
| $forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
|
Zeile 2922 | Zeile 2974 |
---|
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall); } }
|
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall); } }
|
} } }
| } } }
|
if($addselect) {
| if($addselect) {
|
Zeile 2950 | Zeile 3002 |
---|
}
return $forumjump;
|
}
return $forumjump;
|
}
/**
| }
/**
|
* Returns the extension of a file. * * @param string $file The filename.
| * Returns the extension of a file. * * @param string $file The filename.
|
Zeile 3010 | Zeile 3062 |
---|
* @return string The formatted username */ function format_name($username, $usergroup, $displaygroup=0)
|
* @return string The formatted username */ function format_name($username, $usergroup, $displaygroup=0)
|
{ global $groupscache, $cache;
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)
| { global $groupscache, $cache, $plugins;
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 3399 | Zeile 3467 |
---|
{ $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;
|
} }
unset($smilie);
| } }
unset($smilie);
|
if(is_array($smiliecache)) {
| if(is_array($smiliecache)) {
|
Zeile 3410 | Zeile 3478 |
---|
$getmore = ''; if($mybb->settings['smilieinsertertot'] >= $smiliecount)
|
$getmore = ''; if($mybb->settings['smilieinsertertot'] >= $smiliecount)
|
{
| {
|
$mybb->settings['smilieinsertertot'] = $smiliecount; } else if($mybb->settings['smilieinsertertot'] < $smiliecount) { $smiliecount = $mybb->settings['smilieinsertertot']; eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
|
$mybb->settings['smilieinsertertot'] = $smiliecount; } else if($mybb->settings['smilieinsertertot'] < $smiliecount) { $smiliecount = $mybb->settings['smilieinsertertot']; eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
|
}
| }
|
$smilies = ''; $counter = 0; $i = 0;
| $smilies = ''; $counter = 0; $i = 0;
|
Zeile 3465 | Zeile 3533 |
---|
else { $clickablesmilies = "";
|
else { $clickablesmilies = "";
|
}
| }
|
} else {
| } else {
|
Zeile 3491 | Zeile 3559 |
---|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
}
return $prefixes_cache; }
$prefix_cache = $cache->read("threadprefixes");
| }
return $prefixes_cache; }
$prefix_cache = $cache->read("threadprefixes");
|
if(!is_array($prefix_cache)) {
| if(!is_array($prefix_cache)) {
|
Zeile 3525 | Zeile 3593 |
---|
}
return false;
|
}
return false;
|
}
/**
| }
/**
|
* Build the thread prefix selection menu for the current user * * @param int|string $fid The forum ID (integer ID or string all)
| * Build the thread prefix selection menu for the current user * * @param int|string $fid The forum ID (integer ID or string all)
|
Zeile 3543 | Zeile 3611 |
---|
if($fid != 'all') { $fid = (int)$fid;
|
if($fid != 'all') { $fid = (int)$fid;
|
}
| }
|
$prefix_cache = build_prefixes(0); if(empty($prefix_cache)) {
| $prefix_cache = build_prefixes(0); if(empty($prefix_cache)) {
|
Zeile 3557 | Zeile 3625 |
---|
foreach($prefix_cache as $prefix) { if($fid != "all" && $prefix['forums'] != "-1")
|
foreach($prefix_cache as $prefix) { if($fid != "all" && $prefix['forums'] != "-1")
|
{ // Decide whether this prefix can be used in our forum
| { // Decide whether this prefix can be used in our forum
|
$forums = explode(",", $prefix['forums']);
|
$forums = explode(",", $prefix['forums']);
|
|
|
if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid) { // This prefix is not in our forum list continue; }
|
if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid) { // This prefix is not in our forum list continue; }
|
}
| }
|
if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid) { // The current user can use this prefix $prefixes[$prefix['pid']] = $prefix;
|
if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid) { // The current user can use this prefix $prefixes[$prefix['pid']] = $prefix;
|
} }
| } }
|
if(empty($prefixes))
|
if(empty($prefixes))
|
{
| {
|
return ''; }
| return ''; }
|
Zeile 3588 | Zeile 3656 |
---|
if($selected_pid == 'any') { $any_selected = " selected=\"selected\"";
|
if($selected_pid == 'any') { $any_selected = " selected=\"selected\"";
|
} }
| } }
|
$default_selected = ""; if(((int)$selected_pid == 0) && $selected_pid != 'any')
| $default_selected = ""; if(((int)$selected_pid == 0) && $selected_pid != 'any')
|
Zeile 3620 | Zeile 3688 |
---|
return $prefixselect; }
|
return $prefixselect; }
|
|
|
/** * Build the thread prefix selection menu for a forum without group permission checks *
| /** * Build the thread prefix selection menu for a forum without group permission checks *
|
Zeile 3636 | Zeile 3704 |
---|
$prefix_cache = build_prefixes(0); if(empty($prefix_cache))
|
$prefix_cache = build_prefixes(0); if(empty($prefix_cache))
|
{
| {
|
// We've got no prefixes to show return ''; }
|
// We've got no prefixes to show return ''; }
|
|
|
// Go through each of our prefixes and decide which ones we can use $prefixes = array(); foreach($prefix_cache as $prefix)
| // Go through each of our prefixes and decide which ones we can use $prefixes = array(); foreach($prefix_cache as $prefix)
|
Zeile 3651 | Zeile 3719 |
---|
$forums = explode(",", $prefix['forums']);
if(in_array($fid, $forums))
|
$forums = explode(",", $prefix['forums']);
if(in_array($fid, $forums))
|
{
| {
|
// This forum can use this prefix! $prefixes[$prefix['pid']] = $prefix; }
|
// This forum can use this prefix! $prefixes[$prefix['pid']] = $prefix; }
|
}
| }
|
else { // This prefix is for anybody to use...
| else { // This prefix is for anybody to use...
|
Zeile 3666 | Zeile 3734 |
---|
if(empty($prefixes)) { return '';
|
if(empty($prefixes)) { return '';
|
}
| }
|
$default_selected = array(); $selected_pid = (int)$selected_pid;
| $default_selected = array(); $selected_pid = (int)$selected_pid;
|
Zeile 3712 | Zeile 3780 |
---|
if(function_exists("gzcompress") && function_exists("crc32") && !headers_sent() && !(ini_get('output_buffering') && my_strpos(' '.ini_get('output_handler'), 'ob_gzhandler'))) { $httpaccept_encoding = '';
|
if(function_exists("gzcompress") && function_exists("crc32") && !headers_sent() && !(ini_get('output_buffering') && my_strpos(' '.ini_get('output_handler'), 'ob_gzhandler'))) { $httpaccept_encoding = '';
|
|
|
if(isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { $httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
|
if(isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { $httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
|
}
| }
|
if(my_strpos(" ".$httpaccept_encoding, "x-gzip")) { $encoding = "x-gzip";
|
if(my_strpos(" ".$httpaccept_encoding, "x-gzip")) { $encoding = "x-gzip";
|
}
| }
|
if(my_strpos(" ".$httpaccept_encoding, "gzip")) { $encoding = "gzip";
|
if(my_strpos(" ".$httpaccept_encoding, "gzip")) { $encoding = "gzip";
|
}
| }
|
if(isset($encoding)) { header("Content-Encoding: $encoding");
| if(isset($encoding)) { header("Content-Encoding: $encoding");
|
Zeile 3774 | Zeile 3842 |
---|
{ $tid = (int)$data['tid']; unset($data['tid']);
|
{ $tid = (int)$data['tid']; unset($data['tid']);
|
}
| }
|
$pid = 0; if(isset($data['pid']))
|
$pid = 0; if(isset($data['pid']))
|
{
| {
|
$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
| }
// Any remaining extra data - we my_serialize and insert in to its own column
|
Zeile 3799 | Zeile 3874 |
---|
"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 3821 | Zeile 3912 |
---|
elseif($reputation > 0) { $reputation_class = "reputation_positive";
|
elseif($reputation > 0) { $reputation_class = "reputation_positive";
|
} else {
| } else {
|
$reputation_class = "reputation_neutral"; }
| $reputation_class = "reputation_neutral"; }
|
Zeile 3900 | Zeile 3991 |
---|
if(is_array($addresses)) { foreach($addresses as $val)
|
if(is_array($addresses)) { foreach($addresses as $val)
|
{
| {
|
$val = trim($val); // Validate IP address and exclude private addresses if(my_inet_ntop(my_inet_pton($val)) == $val && !preg_match("#^(10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.|fe80:|fe[c-f][0-f]:|f[c-d][0-f]{2}:)#", $val))
| $val = trim($val); // Validate IP address and exclude private addresses if(my_inet_ntop(my_inet_pton($val)) == $val && !preg_match("#^(10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.|fe80:|fe[c-f][0-f]:|f[c-d][0-f]{2}:)#", $val))
|
Zeile 3963 | Zeile 4054 |
---|
elseif($size >= 1125899906842624) { $size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
|
elseif($size >= 1125899906842624) { $size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
|
}
| }
|
// Terabyte (1024 Gigabytes) elseif($size >= 1099511627776) {
| // Terabyte (1024 Gigabytes) elseif($size >= 1099511627776) {
|
Zeile 3994 | Zeile 4085 |
---|
}
return $size;
|
}
return $size;
|
}
| }
|
/** * Format a decimal number in to microseconds, milliseconds, or seconds. *
| /** * Format a decimal number in to microseconds, milliseconds, or seconds. *
|
Zeile 4005 | Zeile 4096 |
---|
function format_time_duration($time) { global $lang;
|
function format_time_duration($time) { global $lang;
|
|
|
if(!is_numeric($time)) { return $lang->na;
|
if(!is_numeric($time)) { return $lang->na;
|
}
| }
|
if(round(1000000 * $time, 2) < 1000)
|
if(round(1000000 * $time, 2) < 1000)
|
{
| {
|
$time = number_format(round(1000000 * $time, 2))." μs";
|
$time = number_format(round(1000000 * $time, 2))." μs";
|
}
| }
|
elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)
|
elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)
|
{
| {
|
$time = number_format(round((1000 * $time), 2))." ms";
|
$time = number_format(round((1000 * $time), 2))." ms";
|
}
| }
|
else { $time = round($time, 3)." seconds"; }
return $time;
|
else { $time = round($time, 3)." seconds"; }
return $time;
|
}
| }
|
/** * Get the attachment icon for a specific file extension *
| /** * Get the attachment icon for a specific file extension *
|
Zeile 4036 | Zeile 4127 |
---|
function get_attachment_icon($ext) { global $cache, $attachtypes, $theme, $templates, $lang, $mybb;
|
function get_attachment_icon($ext) { global $cache, $attachtypes, $theme, $templates, $lang, $mybb;
|
|
|
if(!$attachtypes) { $attachtypes = $cache->read("attachtypes");
|
if(!$attachtypes) { $attachtypes = $cache->read("attachtypes");
|
}
| }
|
$ext = my_strtolower($ext);
if($attachtypes[$ext]['icon'])
| $ext = my_strtolower($ext);
if($attachtypes[$ext]['icon'])
|
Zeile 4072 | Zeile 4163 |
---|
{ $attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); $attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
|
{ $attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); $attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
|
}
| }
|
}
$icon = $attach_icons_schemes[$ext];
| }
$icon = $attach_icons_schemes[$ext];
|
Zeile 4134 | Zeile 4225 |
---|
}
$pwverified = 1;
|
}
$pwverified = 1;
|
|
|
if($forum['password'] != "")
|
if($forum['password'] != "")
|
{
| {
|
if($mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
| if($mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
Zeile 4149 | Zeile 4240 |
---|
// Check parents for passwords $parents = explode(",", $forum['parentlist']); foreach($parents as $parent)
|
// 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])) { $pwverified = 0;
| if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent])) { $pwverified = 0;
|
Zeile 4397 | Zeile 4488 |
---|
}
return $url;
|
}
return $url;
|
}
| }
|
/** * Prints a debug information page
| /** * Prints a debug information page
|
Zeile 4426 | Zeile 4517 |
---|
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled";
|
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled";
|
} else
| } else
|
{ $gzipen = "Disabled"; }
| { $gzipen = "Disabled"; }
|
Zeile 4443 | Zeile 4534 |
---|
echo "<h1>MyBB Debug Information</h1>\n"; echo "<h2>Page Generation</h2>\n"; echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
echo "<h1>MyBB Debug Information</h1>\n"; echo "<h2>Page Generation</h2>\n"; echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
echo "<tr>\n";
| echo "<tr>\n";
|
echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
|
echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></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;\">Page Generation Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$totaltime</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. DB Queries:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$db->query_count</span></td>\n";
|
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Page Generation Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$totaltime</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. DB Queries:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$db->query_count</span></td>\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 Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phptime ($percentphp%)</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$query_time ($percentsql%)</span></td>\n";
|
echo "<tr>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phptime ($percentphp%)</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$query_time ($percentsql%)</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;\">Extensions Used:</span></b></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=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Extensions Used:</span></b></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";
|
Zeile 4521 | Zeile 4612 |
---|
echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n"; echo "</tr>\n";
|
echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n"; echo "</tr>\n";
|
echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n"; echo "</tr>\n";
| echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n"; echo "</tr>\n";
|
echo "</table>\n"; echo "<br />\n"; }
| echo "</table>\n"; echo "<br />\n"; }
|
Zeile 4675 | Zeile 4766 |
---|
$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) { $nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days;
| elseif($weeks > 0) { $options = array_merge(array( 'minutes' => false, 'seconds' => false ), $options); } elseif($days > 0) { $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 4718 | Zeile 4853 |
---|
$nicetime['hours'] = "1".$lang_hour; } else if($hours > 1)
|
$nicetime['hours'] = "1".$lang_hour; } else if($hours > 1)
|
{
| {
|
$nicetime['hours'] = $hours.$lang_hours; } }
| $nicetime['hours'] = $hours.$lang_hours; } }
|
Zeile 4750 | Zeile 4885 |
---|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
} }
/**
| } }
/**
|
* Select an alternating row colour based on the previous call to this function * * @param int $reset 1 to reset the row to trow1.
| * Select an alternating row colour based on the previous call to this function * * @param int $reset 1 to reset the row to trow1.
|
Zeile 4764 | Zeile 4899 |
---|
global $alttrow;
if($alttrow == "trow1" && !$reset)
|
global $alttrow;
if($alttrow == "trow1" && !$reset)
|
{
| {
|
$trow = "trow2"; } else
| $trow = "trow2"; } else
|
Zeile 4787 | Zeile 4922 |
---|
function join_usergroup($uid, $joingroup) { global $db, $mybb;
|
function join_usergroup($uid, $joingroup) { global $db, $mybb;
|
|
|
if($uid == $mybb->user['uid']) { $user = $mybb->user;
| if($uid == $mybb->user['uid']) { $user = $mybb->user;
|
Zeile 4810 | Zeile 4945 |
---|
foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
|
foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
|
{ $groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1; } } }
| { $groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1; } } }
|
// What's the point in updating if they're the same? if($groupslist != $user['additionalgroups']) {
| // What's the point in updating if they're the same? if($groupslist != $user['additionalgroups']) {
|
Zeile 4863 | Zeile 4998 |
---|
$dispupdate = ""; if($leavegroup == $user['displaygroup'])
|
$dispupdate = ""; if($leavegroup == $user['displaygroup'])
|
{
| {
|
$dispupdate = ", displaygroup=usergroup"; }
| $dispupdate = ", displaygroup=usergroup"; }
|
Zeile 4894 | Zeile 5029 |
---|
if(!empty($_SERVER['SCRIPT_NAME'])) { $location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);
|
if(!empty($_SERVER['SCRIPT_NAME'])) { $location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);
|
}
| }
|
elseif(!empty($_SERVER['PHP_SELF']))
|
elseif(!empty($_SERVER['PHP_SELF']))
|
{
| {
|
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
}
| }
|
elseif(!empty($_ENV['PHP_SELF']))
|
elseif(!empty($_ENV['PHP_SELF']))
|
{
| {
|
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);
|
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);
|
}
| }
|
elseif(!empty($_SERVER['PATH_INFO']))
|
elseif(!empty($_SERVER['PATH_INFO']))
|
{
| {
|
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
|
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
|
}
| }
|
else { $location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
else { $location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
}
| }
|
if($quick) { return $location;
| if($quick) { return $location;
|
Zeile 4958 | Zeile 5093 |
---|
$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($_POST[$var])) { $addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
|
Zeile 5004 | Zeile 5139 |
---|
$tid = 1; $num_themes = 0; $themeselect_option = '';
|
$tid = 1; $num_themes = 0; $themeselect_option = '';
|
|
|
if(!isset($lang->use_default))
|
if(!isset($lang->use_default))
|
{
| {
|
$lang->use_default = $lang->lang_select_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'");
|
Zeile 5020 | Zeile 5155 |
---|
$tcache[$theme['pid']][$theme['tid']] = $theme; } }
|
$tcache[$theme['pid']][$theme['tid']] = $theme; } }
|
|
|
if(is_array($tcache[$tid])) { foreach($tcache[$tid] as $theme)
| if(is_array($tcache[$tid])) { foreach($tcache[$tid] as $theme)
|
Zeile 5035 | Zeile 5170 |
---|
}
if($theme['pid'] != 0)
|
}
if($theme['pid'] != 0)
|
{
| {
|
$theme['name'] = htmlspecialchars_uni($theme['name']); eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";"); ++$num_themes;
| $theme['name'] = htmlspecialchars_uni($theme['name']); eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";"); ++$num_themes;
|
Zeile 5344 | Zeile 5479 |
---|
$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 5408 | Zeile 5542 |
---|
* * @param string $birthday The birthday of a user. * @return int The age of a user with that birthday.
|
* * @param string $birthday The birthday of a user. * @return int The age of a user with that birthday.
|
*/
| */
|
function get_age($birthday) { $bday = explode("-", $birthday);
| function get_age($birthday) { $bday = explode("-", $birthday);
|
Zeile 5669 | Zeile 5803 |
---|
function unhtmlentities($string) { // Replace numeric entities
|
function unhtmlentities($string) { // Replace numeric entities
|
$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string); $string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);
| $string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string); $string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
| // Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
|
Zeile 5710 | Zeile 5844 |
---|
{ 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 5717 | Zeile 5873 |
---|
* * @param array $event The event data array. * @return string The link to the event poster.
|
* * @param array $event The event data array. * @return string The link to the event poster.
|
*/
| */
|
function get_event_poster($event) { $event['username'] = htmlspecialchars_uni($event['username']); $event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']); $event_poster = build_profile_link($event['username'], $event['author']); return $event_poster;
|
function get_event_poster($event) { $event['username'] = htmlspecialchars_uni($event['username']); $event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']); $event_poster = build_profile_link($event['username'], $event['author']); return $event_poster;
|
}
/**
| }
/**
|
* Get the event date. * * @param array $event The event data array.
| * Get the event date. * * @param array $event The event data array.
|
Zeile 5735 | Zeile 5891 |
---|
function get_event_date($event) { global $mybb;
|
function get_event_date($event) { global $mybb;
|
|
|
$event_date = explode("-", $event['date']); $event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
|
$event_date = explode("-", $event['date']); $event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
|
|
|
return $event_date; }
| return $event_date; }
|
Zeile 5748 | Zeile 5904 |
---|
* * @param int $uid The user id of the profile. * @return string The url to the profile.
|
* * @param int $uid The user id of the profile. * @return string The url to the profile.
|
*/
| */
|
function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL);
| function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL);
|
Zeile 5775 | Zeile 5931 |
---|
* @param string $target The target frame * @param string $onclick Any onclick javascript. * @return string The complete profile link.
|
* @param string $target The target frame * @param string $onclick Any onclick javascript. * @return string The complete profile link.
|
*/
| */
|
function build_profile_link($username="", $uid=0, $target="", $onclick="") { global $mybb, $lang;
if(!$username && $uid == 0)
|
function build_profile_link($username="", $uid=0, $target="", $onclick="") { global $mybb, $lang;
if(!$username && $uid == 0)
|
{
| {
|
// Return Guest phrase for no UID, no guest nickname
|
// Return Guest phrase for no UID, no guest nickname
|
return $lang->guest; }
| return htmlspecialchars_uni($lang->guest); }
|
elseif($uid == 0) { // Return the guest's nickname if user is a guest but has a nickname return $username;
|
elseif($uid == 0) { // Return the guest's nickname if user is a guest but has a nickname return $username;
|
} else
| } else
|
{ // Build the profile link for the registered user if(!empty($target))
|
{ // Build the profile link for the registered user if(!empty($target))
|
{
| {
|
$target = " target=\"{$target}\"";
|
$target = " target=\"{$target}\"";
|
}
| }
|
if(!empty($onclick)) { $onclick = " onclick=\"{$onclick}\""; }
return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
if(!empty($onclick)) { $onclick = " onclick=\"{$onclick}\""; }
return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
}
| }
|
}
/**
| }
/**
|
Zeile 5840 | Zeile 5996 |
---|
function get_thread_link($tid, $page=0, $action='') { if($page > 1)
|
function get_thread_link($tid, $page=0, $action='') { if($page > 1)
|
{ if($action) { $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link); } else
| { if($action) { $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link); } else
|
{ $link = THREAD_URL_PAGED; }
| { $link = THREAD_URL_PAGED; }
|
Zeile 5860 | Zeile 6016 |
---|
{ $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link);
|
{ $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link);
|
} else {
| } else {
|
$link = THREAD_URL; } $link = str_replace("{tid}", $tid, $link);
| $link = THREAD_URL; } $link = str_replace("{tid}", $tid, $link);
|
Zeile 5888 | Zeile 6044 |
---|
else { $link = str_replace("{pid}", $pid, POST_URL);
|
else { $link = str_replace("{pid}", $pid, POST_URL);
|
return htmlspecialchars_uni($link); } }
| return htmlspecialchars_uni($link); } }
|
/** * Build the event link. *
| /** * Build the event link. *
|
Zeile 5947 | Zeile 6103 |
---|
* @param int $calendar The ID of the calendar * @param int $week The week * @return string The URL of the calendar
|
* @param int $calendar The ID of the calendar * @param int $week The week * @return string The URL of the calendar
|
*/
| */
|
function get_calendar_week_link($calendar, $week) { if($week < 0)
| function get_calendar_week_link($calendar, $week) { if($week < 0)
|
Zeile 5975 | Zeile 6131 |
---|
if(!empty($mybb->user) && $uid == $mybb->user['uid']) { return $mybb->user;
|
if(!empty($mybb->user) && $uid == $mybb->user['uid']) { return $mybb->user;
|
}
| }
|
elseif(isset($user_cache[$uid])) { return $user_cache[$uid];
| elseif(isset($user_cache[$uid])) { return $user_cache[$uid];
|
Zeile 6203 | Zeile 6359 |
---|
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True * @return bool|int Number of logins when success, false if failed. */
|
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True * @return bool|int Number of logins when success, false if failed. */
|
function login_attempt_check($fatal = true)
| function login_attempt_check($uid = 0, $fatal = true)
|
{
|
{
|
global $mybb, $lang, $session, $db;
| global $mybb, $lang, $db;
|
|
|
if($mybb->settings['failedlogincount'] == 0)
| $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)
|
{
|
{
|
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']; }
| $query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1); $attempts = $db->fetch_array($query);
|
|
|
// 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; } 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)) { my_setcookie('failedlogin', $now); if($fatal) { error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false;
| 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);
|
|
|
// 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 6464 |
---|
*/ 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 6313 | Zeile 6473 |
---|
* @param string $email The email to check. * @param int $uid User ID of the user (updating only) * @return boolean True when in use, false when not.
|
* @param string $email The email to check. * @param int $uid User ID of the user (updating only) * @return boolean True when in use, false when not.
|
*/
| */
|
function email_already_in_use($email, $uid=0) { global $db;
| function email_already_in_use($email, $uid=0) { global $db;
|
Zeile 6341 | Zeile 6501 |
---|
{ 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'];
|
Zeile 6365 | Zeile 6515 |
---|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
|
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode); @fwrite($file, $settings); @fclose($file);
| file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);
|
$GLOBALS['settings'] = &$mybb->settings; }
| $GLOBALS['settings'] = &$mybb->settings; }
|
Zeile 6462 | Zeile 6611 |
---|
// 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 6633 |
---|
}
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 6777 | Zeile 6938 |
---|
function fetch_remote_file($url, $post_data=array(), $max_redirects=20) { global $mybb, $config;
|
function fetch_remote_file($url, $post_data=array(), $max_redirects=20) { global $mybb, $config;
|
| if(!my_validate_url($url, true)) { return false; }
|
$url_components = @parse_url($url);
|
$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'])) ) { return false; }
|
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts'])) ) { 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);
| foreach($post_data as $key => $val) { $post_body .= '&'.urlencode($key).'='.urlencode($val);
|
Zeile 6831 | Zeile 7003 |
---|
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 6886 | Zeile 7083 |
---|
} else if(function_exists("fsockopen")) {
|
} else if(function_exists("fsockopen")) {
|
if(!isset($url_components['port'])) { $url_components['port'] = 80; }
| |
if(!isset($url_components['path']))
|
if(!isset($url_components['path']))
|
{
| {
|
$url_components['path'] = "/";
|
$url_components['path'] = "/";
|
}
| }
|
if(isset($url_components['query'])) { $url_components['path'] .= "?{$url_components['query']}";
|
if(isset($url_components['query'])) { $url_components['path'] .= "?{$url_components['query']}";
|
}
$scheme = '';
| }
$scheme = '';
|
if($url_components['scheme'] == 'https')
|
if($url_components['scheme'] == 'https')
|
{
| {
|
$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, ), )); }
$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 7144 |
---|
$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"; }
|
|
|
$headers[] = "Host: {$url_components['host']}"; $headers[] = "Connection: Close"; $headers[] = '';
| $headers[] = "Host: {$url_components['host']}"; $headers[] = "Connection: Close"; $headers[] = '';
|
Zeile 6935 | Zeile 7157 |
---|
if(!empty($post_body)) { $headers[] = $post_body;
|
if(!empty($post_body)) { $headers[] = $post_body;
|
}
| }
|
else
|
else
|
{
| {
|
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts $headers[] = '';
|
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts $headers[] = '';
|
}
| }
|
$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))
|
Zeile 6962 | Zeile 7184 |
---|
$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|$)/', $header, $matches);
|
Zeile 6973 | Zeile 7195 |
---|
} else {
|
} else {
|
$data = $body;
| $data = $body; }
return $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 $data; } else if(empty($post_data))
| }
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 7122 | Zeile 7386 |
---|
} } $in_escape = !$in_escape;
|
} } $in_escape = !$in_escape;
|
}
| }
|
if(!count($strings)) { return $original;
| if(!count($strings)) { return $original;
|
Zeile 7179 | Zeile 7443 |
---|
$sep = "."; } return array(ip2long($ip_string1), ip2long($ip_string2));
|
$sep = "."; } return array(ip2long($ip_string1), ip2long($ip_string2));
|
} }
| } }
|
/** * Fetch a list of ban times for a user account. *
| /** * Fetch a list of ban times for a user account. *
|
Zeile 7211 | Zeile 7475 |
---|
"0-0-1" => "1 {$lang->year}", "0-0-2" => "2 {$lang->years}" );
|
"0-0-1" => "1 {$lang->year}", "0-0-2" => "2 {$lang->years}" );
|
|
|
$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);
$ban_times['---'] = $lang->permanent;
| $ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);
$ban_times['---'] = $lang->permanent;
|
Zeile 7242 | Zeile 7506 |
---|
/** * Expire old warnings in the database.
|
/** * Expire old warnings in the database.
|
* * @return bool
| * * @return bool
|
*/ function expire_warnings() {
| */ function expire_warnings() {
|
Zeile 7289 | Zeile 7553 |
---|
* @return bool */ function my_rmdir_recursive($path, $ignore=array())
|
* @return bool */ function my_rmdir_recursive($path, $ignore=array())
|
{
| {
|
global $orig_dir;
if(!isset($orig_dir))
| global $orig_dir;
if(!isset($orig_dir))
|
Zeile 7318 | Zeile 7582 |
---|
}
return @rmdir($path);
|
}
return @rmdir($path);
|
}
| }
|
return @unlink($path); }
| return @unlink($path); }
|
Zeile 7364 | Zeile 7628 |
---|
}
if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
|
}
if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
|
{
| {
|
$ip_long -= 4294967296; }
| $ip_long -= 4294967296; }
|
Zeile 7378 | Zeile 7642 |
---|
* @deprecated * @param integer $long The IP to convert (will accept 64-bit IPs as well) * @return string IP in IPv4 format
|
* @deprecated * @param integer $long The IP to convert (will accept 64-bit IPs as well) * @return string IP in IPv4 format
|
*/
| */
|
function my_long2ip($long) { // On 64-bit machines is_int will return true. On 32-bit it will return false
| function my_long2ip($long) { // On 64-bit machines is_int will return true. On 32-bit it will return false
|
Zeile 7392 | Zeile 7656 |
---|
/** * Converts a human readable IP address to its packed in_addr representation
|
/** * Converts a human readable IP address to its packed in_addr representation
|
*
| *
|
* @param string $ip The IP to convert * @return string IP in 32bit or 128bit binary format */
| * @param string $ip The IP to convert * @return string IP in 32bit or 128bit binary format */
|
Zeile 7406 | Zeile 7670 |
---|
{ /** * Replace inet_pton()
|
{ /** * Replace inet_pton()
|
* * @category PHP
| * * @category PHP
|
* @package PHP_Compat * @license LGPL - http://www.gnu.org/licenses/lgpl.html * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
| * @package PHP_Compat * @license LGPL - http://www.gnu.org/licenses/lgpl.html * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
|
Zeile 7480 | Zeile 7744 |
---|
array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r;
|
array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r;
|
} return false; } }
/**
| } return false; } }
/**
|
* Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses. * * @param string $ipaddress The IP address to convert to a range
| * Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses. * * @param string $ipaddress The IP address to convert to a range
|
Zeile 7500 | Zeile 7764 |
---|
{ // IPv6 $upper = str_replace('*', 'ffff', $ipaddress);
|
{ // IPv6 $upper = str_replace('*', 'ffff', $ipaddress);
|
$lower = str_replace('*', '0', $ipaddress); }
| $lower = str_replace('*', '0', $ipaddress); }
|
else { // IPv4
| else { // IPv4
|
Zeile 7564 | Zeile 7828 |
---|
$bit = decbin(ord($ip_pack[$i])); $bit = str_pad($bit, 8, '0', STR_PAD_LEFT); $ip_bits .= $bit;
|
$bit = decbin(ord($ip_pack[$i])); $bit = str_pad($bit, 8, '0', STR_PAD_LEFT); $ip_bits .= $bit;
|
}
| }
|
// Significative bits (from the ip range) $ip_bits = substr($ip_bits, 0, $ip_range);
| // Significative bits (from the ip range) $ip_bits = substr($ip_bits, 0, $ip_range);
|
Zeile 7609 | Zeile 7873 |
---|
{ static $time_start;
|
{ static $time_start;
|
$time = microtime(true);
| $time = microtime(true);
|
// Just starting timer, init and return if(!$time_start) { $time_start = $time; return;
|
// Just starting timer, init and return if(!$time_start) { $time_start = $time; return;
|
}
| }
|
// Timer has run, return execution time else {
| // Timer has run, return execution time else {
|
Zeile 7625 | Zeile 7888 |
---|
if($total < 0) $total = 0; $time_start = 0; return $total;
|
if($total < 0) $total = 0; $time_start = 0; return $total;
|
} }
| } }
|
/** * Processes a checksum list on MyBB files and returns a result set *
| /** * Processes a checksum list on MyBB files and returns a result set *
|
Zeile 7640 | Zeile 7903 |
---|
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 7674 | Zeile 7937 |
---|
}
// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)
|
}
// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)
|
$file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;
| $file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;
|
// Does this file even exist in our official list? Perhaps it's a plugin if(array_key_exists($file_path, $checksums)) { $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
// Does this file even exist in our official list? Perhaps it's a plugin if(array_key_exists($file_path, $checksums)) { $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 7739 | Zeile 8002 |
---|
else { return "+$int";
|
else { return "+$int";
|
}
| }
|
}
/**
| }
/**
|
Zeile 7766 | Zeile 8029 |
---|
{ $output = @fread($handle, $bytes); @fclose($handle);
|
{ $output = @fread($handle, $bytes); @fclose($handle);
|
} } else { return $output;
| } } else { return $output;
|
}
if(strlen($output) < $bytes)
| }
if(strlen($output) < $bytes)
|
Zeile 7817 | Zeile 8080 |
---|
if(strlen($output) < $bytes) { if(class_exists('COM'))
|
if(strlen($output) < $bytes) { if(class_exists('COM'))
|
{
| {
|
try { $CAPI_Util = new COM('CAPICOM.Utilities.1');
| try { $CAPI_Util = new COM('CAPICOM.Utilities.1');
|
Zeile 7827 | Zeile 8090 |
---|
} } catch (Exception $e) { }
|
} } 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. $unique_state = microtime().@getmypid();
|
if(strlen($output) < $bytes) { // Close to what PHP basically uses internally to seed, but not quite. $unique_state = microtime().@getmypid();
|
$rounds = ceil($bytes / 16);
| $rounds = ceil($bytes / 16);
|
for($i = 0; $i < $rounds; $i++) { $unique_state = md5(microtime().$unique_state);
| for($i = 0; $i < $rounds; $i++) { $unique_state = md5(microtime().$unique_state);
|
Zeile 7849 | Zeile 8112 |
---|
$output = substr($output, 0, ($bytes * 2));
|
$output = substr($output, 0, ($bytes * 2));
|
$output = pack('H*', $output);
return $output; }
| $output = pack('H*', $output);
return $output; }
|
else { return $output;
| else { return $output;
|
Zeile 7863 | Zeile 8126 |
---|
* Returns a securely generated seed integer * * @return int An integer equivalent of a secure hexadecimal seed
|
* Returns a securely generated seed integer * * @return int An integer equivalent of a secure hexadecimal seed
|
*/
| */
|
function secure_seed_rng() { $bytes = PHP_INT_SIZE;
| function secure_seed_rng() { $bytes = PHP_INT_SIZE;
|
Zeile 8340 | Zeile 8603 |
---|
}
$pm['options'] = array(
|
}
$pm['options'] = array(
|
"signature" => 0,
| |
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
| "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
|
Zeile 8356 | Zeile 8618 |
---|
if($pmhandler->validate_pm()) { $pmhandler->insert_pm();
|
if($pmhandler->validate_pm()) { $pmhandler->insert_pm();
|
return true; }
return false; }
| return true; }
return false; }
|
/** * Log a user spam block from StopForumSpam (or other spam service providers...) *
| /** * Log a user spam block from StopForumSpam (or other spam service providers...) *
|
Zeile 8408 | Zeile 8670 |
---|
* @return bool Whether the file was copied successfully. */ function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
|
* @return bool Whether the file was copied successfully. */ function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
|
{
| {
|
global $mybb, $plugins;
$success = false;
| global $mybb, $plugins;
$success = false;
|
Zeile 8439 | Zeile 8701 |
---|
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 8452 | Zeile 8714 |
---|
$uploaded_path = $cdn_upload_path; } }
|
$uploaded_path = $cdn_upload_path; } }
|
} }
| } }
|
if(is_object($plugins)) { $hook_args = array(
| if(is_object($plugins)) { $hook_args = array(
|
Zeile 8464 | Zeile 8726 |
---|
'uploaded_path' => &$uploaded_path, 'success' => &$success, );
|
'uploaded_path' => &$uploaded_path, 'success' => &$success, );
|
|
|
$plugins->run_hooks('copy_file_to_cdn_end', $hook_args); } }
return $success;
|
$plugins->run_hooks('copy_file_to_cdn_end', $hook_args); } }
return $success;
|
}
/**
| }
/**
|
* Validate an url
|
* 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 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 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)
|
{
|
{
|
return true;
| $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); } }
|
}
|
}
|
return false;
| $string = str_replace('"', '""', $string);
return $string;
|
}
| }
|