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 426 | Zeile 440 |
---|
$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 448 | Zeile 462 |
---|
$relative['plural'] = $lang->rel_hours_single; }
|
$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 {
| } else {
|
Zeile 456 | Zeile 470 |
---|
{ if($todaysdate == $date) {
|
{ if($todaysdate == $date) {
|
$date = $lang->today;
| $date = $lang->sprintf($lang->today, $real_date);
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->yesterday;
| $date = $lang->sprintf($lang->yesterday, $real_date);
|
} }
| } }
|
Zeile 481 | Zeile 495 |
---|
{ if($todaysdate == $date) {
|
{ if($todaysdate == $date) {
|
$date = $lang->today;
| $date = $lang->sprintf($lang->today, $real_date);
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->yesterday;
| $date = $lang->sprintf($lang->yesterday, $real_date);
|
} } else
| } } else
|
Zeile 966 | Zeile 980 |
---|
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 3482 | Zeile 3496 |
---|
* @return array The thread prefix's values (or all thread prefixes) */ function build_prefixes($pid=0)
|
* @return array The thread prefix's values (or all thread prefixes) */ function build_prefixes($pid=0)
|
{
| {
|
global $cache; static $prefixes_cache;
| global $cache; static $prefixes_cache;
|
Zeile 5533 | Zeile 5547 |
---|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
}
| }
|
$string = trim($string);
if(function_exists("mb_strlen"))
| $string = trim($string);
if(function_exists("mb_strlen"))
|
Zeile 5544 | Zeile 5558 |
---|
{ $string_length = strlen($string); }
|
{ $string_length = strlen($string); }
|
|
|
return $string_length; }
/** * Cuts a string at a specified point, mb strings accounted for
|
return $string_length; }
/** * Cuts a string at a specified point, mb strings accounted for
|
*
| *
|
* @param string $string The string to cut. * @param int $start Where to cut * @param int $length (optional) How much to cut
| * @param string $string The string to cut. * @param int $start Where to cut * @param int $length (optional) How much to cut
|
Zeile 5560 | Zeile 5574 |
---|
function my_substr($string, $start, $length=null, $handle_entities = false) { if($handle_entities)
|
function my_substr($string, $start, $length=null, $handle_entities = false) { if($handle_entities)
|
{
| {
|
$string = unhtmlentities($string); } if(function_exists("mb_substr"))
|
$string = unhtmlentities($string); } if(function_exists("mb_substr"))
|
{ if($length != null) {
| { if($length != null) {
|
$cut_string = mb_substr($string, $start, $length); } else
| $cut_string = mb_substr($string, $start, $length); } else
|
Zeile 5598 | Zeile 5612 |
---|
* * @param string $string The string to lower. * @return string The lowered string.
|
* * @param string $string The string to lower. * @return string The lowered string.
|
*/
| */
|
function my_strtolower($string) { if(function_exists("mb_strtolower"))
| function my_strtolower($string) { if(function_exists("mb_strtolower"))
|
Zeile 5662 | Zeile 5676 |
---|
/** * Returns any html entities to their original character
|
/** * Returns any html entities to their original character
|
*
| *
|
* @param string $string The string to un-htmlentitize. * @return string The un-htmlentitied' string. */
| * @param string $string The string to un-htmlentitize. * @return string The un-htmlentitied' string. */
|
Zeile 5671 | Zeile 5685 |
---|
// 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);
|
// 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);
|
|
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
}
| }
|
/** * Returns any ascii to it's character (utf-8 safe).
| /** * Returns any ascii to it's character (utf-8 safe).
|
Zeile 5709 | Zeile 5723 |
---|
else { return false;
|
else { return false;
|
} }
| } }
|
/** * Get the event poster.
| /** * Get the event poster.
|
Zeile 5724 | Zeile 5738 |
---|
$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']); $event_poster = build_profile_link($event['username'], $event['author']); return $event_poster;
|
$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. *
| /** * Get the event date. *
|
Zeile 5735 | Zeile 5749 |
---|
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);
return $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;
|
}
| }
|
/** * Get the profile link. *
| /** * Get the profile link. *
|
Zeile 5757 | Zeile 5771 |
---|
/** * Get the announcement link.
|
/** * Get the announcement link.
|
*
| *
|
* @param int $aid The announement id of the announcement. * @return string The url to the announcement. */
| * @param int $aid The announement id of the announcement. * @return string The url to the announcement. */
|
Zeile 5789 | Zeile 5803 |
---|
{ // Return the guest's nickname if user is a guest but has a nickname return $username;
|
{ // 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}\""; }
|
if(!empty($onclick)) { $onclick = " onclick=\"{$onclick}\""; }
|
|
|
return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
} }
| } }
|
/** * Build the forum link. *
| /** * Build the forum link. *
|
Zeile 5819 | Zeile 5833 |
---|
if($page > 0) { $link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
|
if($page > 0) { $link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
|
$link = str_replace("{page}", $page, $link); return htmlspecialchars_uni($link); } else
| $link = str_replace("{page}", $page, $link); return htmlspecialchars_uni($link); } else
|
{ $link = str_replace("{fid}", $fid, FORUM_URL); return htmlspecialchars_uni($link);
| { $link = str_replace("{fid}", $fid, FORUM_URL); return htmlspecialchars_uni($link);
|
Zeile 5838 | Zeile 5852 |
---|
* @return string The url to the thread. */ function get_thread_link($tid, $page=0, $action='')
|
* @return string The url to the thread. */ function get_thread_link($tid, $page=0, $action='')
|
{
| {
|
if($page > 1) { if($action)
| if($page > 1) { if($action)
|
Zeile 5852 | Zeile 5866 |
---|
} $link = str_replace("{tid}", $tid, $link); $link = str_replace("{page}", $page, $link);
|
} $link = str_replace("{tid}", $tid, $link); $link = str_replace("{page}", $page, $link);
|
return htmlspecialchars_uni($link); } else
| return htmlspecialchars_uni($link); } else
|
{ if($action)
|
{ if($action)
|
{
| {
|
$link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link);
|
$link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link);
|
}
| }
|
else { $link = THREAD_URL; } $link = str_replace("{tid}", $tid, $link);
|
else { $link = THREAD_URL; } $link = str_replace("{tid}", $tid, $link);
|
return htmlspecialchars_uni($link); } }
/**
| return htmlspecialchars_uni($link); } }
/**
|
* Build the post link. * * @param int $pid The post ID of the post
| * Build the post link. * * @param int $pid The post ID of the post
|
Zeile 5886 | Zeile 5900 |
---|
return htmlspecialchars_uni($link); } else
|
return htmlspecialchars_uni($link); } else
|
{
| {
|
$link = str_replace("{pid}", $pid, POST_URL); return htmlspecialchars_uni($link); }
| $link = str_replace("{pid}", $pid, POST_URL); return htmlspecialchars_uni($link); }
|
Zeile 5918 | Zeile 5932 |
---|
if($day > 0) { $link = str_replace("{month}", $month, CALENDAR_URL_DAY);
|
if($day > 0) { $link = str_replace("{month}", $month, CALENDAR_URL_DAY);
|
$link = str_replace("{year}", $year, $link);
| $link = str_replace("{year}", $year, $link);
|
$link = str_replace("{day}", $day, $link); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
| $link = str_replace("{day}", $day, $link); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
|
Zeile 5949 | Zeile 5963 |
---|
* @return string The URL of the calendar */ function get_calendar_week_link($calendar, $week)
|
* @return string The URL of the calendar */ function get_calendar_week_link($calendar, $week)
|
{
| {
|
if($week < 0) { $week = str_replace('-', "n", $week);
| if($week < 0) { $week = str_replace('-', "n", $week);
|
Zeile 5981 | Zeile 5995 |
---|
return $user_cache[$uid]; } elseif($uid > 0)
|
return $user_cache[$uid]; } elseif($uid > 0)
|
{
| {
|
$query = $db->simple_select("users", "*", "uid = '{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
| $query = $db->simple_select("users", "*", "uid = '{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
|
Zeile 6045 | Zeile 6059 |
---|
if(isset($options['exists'])) { return (bool)$db->num_rows($query);
|
if(isset($options['exists'])) { return (bool)$db->num_rows($query);
|
}
| }
|
return $db->fetch_array($query); }
| return $db->fetch_array($query); }
|
Zeile 6121 | Zeile 6135 |
---|
else { $thread_cache[$tid] = false;
|
else { $thread_cache[$tid] = false;
|
return false; } } }
/**
| return false; } } }
/**
|
* Get the post of a post id. * * @param int $pid The post id of the post.
| * Get the post of a post id. * * @param int $pid The post id of the post.
|
Zeile 6136 | Zeile 6150 |
---|
{ global $db; static $post_cache;
|
{ global $db; static $post_cache;
|
|
|
$pid = (int)$pid;
if(isset($post_cache[$pid])) { return $post_cache[$pid];
|
$pid = (int)$pid;
if(isset($post_cache[$pid])) { return $post_cache[$pid];
|
}
| }
|
else { $query = $db->simple_select("posts", "*", "pid = '{$pid}'");
| else { $query = $db->simple_select("posts", "*", "pid = '{$pid}'");
|
Zeile 6173 | Zeile 6187 |
---|
if(!$forum_cache) { cache_forums();
|
if(!$forum_cache) { cache_forums();
|
}
| }
|
$inactive = array();
foreach($forum_cache as $fid => $forum)
| $inactive = array();
foreach($forum_cache as $fid => $forum)
|
Zeile 6188 | Zeile 6202 |
---|
{ $inactive[] = $fid1; }
|
{ $inactive[] = $fid1; }
|
}
| }
|
} }
|
} }
|
$inactiveforums = implode(",", $inactive);
| $inactiveforums = implode(",", $inactive);
|
return $inactiveforums; }
| return $inactiveforums; }
|
Zeile 6204 | Zeile 6218 |
---|
* @return bool|int Number of logins when success, false if failed. */ function login_attempt_check($fatal = 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)
| global $mybb, $lang, $session, $db;
if($mybb->settings['failedlogincount'] == 0)
|
Zeile 6236 | Zeile 6250 |
---|
$now = TIME_NOW;
if(empty($mybb->cookies['failedlogin']))
|
$now = TIME_NOW;
if(empty($mybb->cookies['failedlogin']))
|
{
| {
|
$failedtime = $now; } else
| $failedtime = $now; } else
|
Zeile 6300 | Zeile 6314 |
---|
function validate_email_format($email) { if(strpos($email, ' ') !== false)
|
function validate_email_format($email) { if(strpos($email, ' ') !== false)
|
{ return 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); }
| // 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); }
|
Zeile 6558 | Zeile 6572 |
---|
} } // Still here - good username
|
} } // Still here - good username
|
return false;
| return false;
|
}
/**
| }
/**
|
Zeile 6815 | Zeile 6829 |
---|
$ip_range = fetch_ip_range($disallowed_address);
$packed_address = my_inet_pton($destination_address);
|
$ip_range = fetch_ip_range($disallowed_address);
$packed_address = my_inet_pton($destination_address);
|
|
|
if(is_array($ip_range)) { if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
| if(is_array($ip_range)) { if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
|
Zeile 6862 | Zeile 6876 |
---|
else { $curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
|
else { $curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
|
}
| }
|
$curl_version_info = curl_version(); $curl_version = $curl_version_info['version'];
| $curl_version_info = curl_version(); $curl_version = $curl_version_info['version'];
|
Zeile 6910 | Zeile 6924 |
---|
else { $data = $body;
|
else { $data = $body;
|
} }
| } }
|
else
|
else
|
{
| {
|
$data = $response;
|
$data = $response;
|
}
| }
|
curl_close($ch); return $data;
| curl_close($ch); return $data;
|
Zeile 6927 | Zeile 6941 |
---|
$url_components['path'] = "/"; } if(isset($url_components['query']))
|
$url_components['path'] = "/"; } if(isset($url_components['query']))
|
{
| {
|
$url_components['path'] .= "?{$url_components['query']}";
|
$url_components['path'] .= "?{$url_components['query']}";
|
}
$scheme = '';
| }
$scheme = '';
|
if($url_components['scheme'] == 'https') {
| if($url_components['scheme'] == 'https') {
|
Zeile 6943 | Zeile 6957 |
---|
}
if(function_exists('stream_context_create'))
|
}
if(function_exists('stream_context_create'))
|
{
| {
|
if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path()) { $context = stream_context_create(array(
| if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path()) { $context = stream_context_create(array(
|
Zeile 6974 | Zeile 6988 |
---|
@stream_set_timeout($fp, 10); if(!$fp)
|
@stream_set_timeout($fp, 10); if(!$fp)
|
{
| {
|
return false; } $headers = array();
| return false; } $headers = array();
|
Zeile 7005 | Zeile 7019 |
---|
$headers = implode("\r\n", $headers); if(!@fwrite($fp, $headers))
|
$headers = implode("\r\n", $headers); if(!@fwrite($fp, $headers))
|
{ return false; }
$data = null;
| { return false; }
$data = null;
|
while(!feof($fp)) { $data .= fgets($fp, 12800); } fclose($fp);
|
while(!feof($fp)) { $data .= fgets($fp, 12800); } fclose($fp);
|
|
|
$data = explode("\r\n\r\n", $data, 2);
$header = $data[0]; $status_line = current(explode("\n\n", $header, 1)); $body = $data[1];
|
$data = explode("\r\n\r\n", $data, 2);
$header = $data[0]; $status_line = current(explode("\n\n", $header, 1)); $body = $data[1];
|
|
|
if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 '))) { preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
| if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 '))) { preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
|
Zeile 7031 | Zeile 7045 |
---|
{ $data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects); }
|
{ $data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects); }
|
}
| }
|
else { $data = $body; }
return $data;
|
else { $data = $body; }
return $data;
|
}
| }
|
else { return false;
| else { return false;
|
Zeile 7054 | Zeile 7068 |
---|
function get_ip_by_hostname($hostname) { $addresses = @gethostbynamel($hostname);
|
function get_ip_by_hostname($hostname) { $addresses = @gethostbynamel($hostname);
|
|
|
if(!$addresses) { $result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);
|
if(!$addresses) { $result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);
|
|
|
if($result_set)
|
if($result_set)
|
{
| {
|
$addresses = array_column($result_set, 'ip');
|
$addresses = array_column($result_set, 'ip');
|
}
| }
|
else { return false; } }
|
else { return false; } }
|
|
|
return $addresses;
|
return $addresses;
|
}
| }
|
/** * Returns the location of the CA bundle defined in the PHP configuration. *
| /** * Returns the location of the CA bundle defined in the PHP configuration. *
|
Zeile 7080 | Zeile 7094 |
---|
function get_ca_bundle_path() { if($path = ini_get('openssl.cafile'))
|
function get_ca_bundle_path() { if($path = ini_get('openssl.cafile'))
|
{ return $path;
| { return $path;
|
} if($path = ini_get('curl.cainfo')) { return $path;
|
} if($path = ini_get('curl.cainfo')) { return $path;
|
}
| }
|
return false; }
| return false; }
|
Zeile 7151 | Zeile 7165 |
---|
if(!is_array($groups)) { if((int)$groups == -1)
|
if(!is_array($groups)) { if((int)$groups == -1)
|
{
| {
|
return $memberships; } else
| return $memberships; } else
|
Zeile 7199 | Zeile 7213 |
---|
else { $escape_preg = preg_quote($escape, "#");
|
else { $escape_preg = preg_quote($escape, "#");
|
}
| }
|
$quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string); } else
| $quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string); } else
|
Zeile 7211 | Zeile 7225 |
---|
if($string != "") { if($in_escape)
|
if($string != "") { if($in_escape)
|
{
| {
|
$strings[] = trim($string);
|
$strings[] = trim($string);
|
} else {
| } else {
|
$split_strings = explode($delimeter, $string); foreach($split_strings as $string) {
| $split_strings = explode($delimeter, $string); foreach($split_strings as $string) {
|
Zeile 7225 | Zeile 7239 |
---|
} } $in_escape = !$in_escape;
|
} } $in_escape = !$in_escape;
|
}
| }
|
if(!count($strings)) { return $original; } return $strings;
|
if(!count($strings)) { return $original; } return $strings;
|
}
| }
|
/** * DEPRECATED! Please use IPv6 compatible fetch_ip_range!
| /** * DEPRECATED! Please use IPv6 compatible fetch_ip_range!
|
Zeile 7247 | Zeile 7261 |
---|
$ip_string1 = $ip_string2 = "";
if($ip == "*")
|
$ip_string1 = $ip_string2 = "";
if($ip == "*")
|
{
| {
|
return array(ip2long('0.0.0.0'), ip2long('255.255.255.255')); }
| return array(ip2long('0.0.0.0'), ip2long('255.255.255.255')); }
|
Zeile 7327 | Zeile 7341 |
---|
* @param string $date The ban length string * @param int $stamp The optional UNIX timestamp, if 0, current time is used. * @return int The UNIX timestamp when the ban will be lifted
|
* @param string $date The ban length string * @param int $stamp The optional UNIX timestamp, if 0, current time is used. * @return int The UNIX timestamp when the ban will be lifted
|
*/
| */
|
function ban_date2timestamp($date, $stamp=0) { if($stamp == 0)
| function ban_date2timestamp($date, $stamp=0) { if($stamp == 0)
|
Zeile 7341 | Zeile 7355 |
---|
$n[2] += $d[1]; $n[3] += $d[2]; return mktime(date("G", $stamp), date("i", $stamp), 0, $n[2], $n[1], $n[3]);
|
$n[2] += $d[1]; $n[3] += $d[2]; return mktime(date("G", $stamp), date("i", $stamp), 0, $n[2], $n[1], $n[3]);
|
}
/**
| }
/**
|
* Expire old warnings in the database. * * @return bool
| * Expire old warnings in the database. * * @return bool
|
Zeile 7351 | Zeile 7365 |
---|
function expire_warnings() { global $warningshandler;
|
function expire_warnings() { global $warningshandler;
|
|
|
if(!is_object($warningshandler)) { require_once MYBB_ROOT.'inc/datahandlers/warnings.php';
| if(!is_object($warningshandler)) { require_once MYBB_ROOT.'inc/datahandlers/warnings.php';
|
Zeile 7359 | Zeile 7373 |
---|
}
return $warningshandler->expire_warnings();
|
}
return $warningshandler->expire_warnings();
|
}
| }
|
/** * Custom chmod function to fix problems with hosts who's server configurations screw up umasks
| /** * Custom chmod function to fix problems with hosts who's server configurations screw up umasks
|
Zeile 7439 | Zeile 7453 |
---|
{ $count += count($array2); }
|
{ $count += count($array2); }
|
|
|
return $count; }
| return $count; }
|
Zeile 7455 | Zeile 7469 |
---|
function my_ip2long($ip) { $ip_long = ip2long($ip);
|
function my_ip2long($ip) { $ip_long = ip2long($ip);
|
|
|
if(!$ip_long) { $ip_long = sprintf("%u", ip2long($ip));
| if(!$ip_long) { $ip_long = sprintf("%u", ip2long($ip));
|
Zeile 7583 | Zeile 7597 |
---|
array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r;
|
array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r;
|
}
| }
|
return false; } }
| return false; } }
|
Zeile 7598 | Zeile 7612 |
---|
{ // Wildcard if(strpos($ipaddress, '*') !== false)
|
{ // Wildcard if(strpos($ipaddress, '*') !== false)
|
{
| {
|
if(strpos($ipaddress, ':') !== false) { // IPv6
| if(strpos($ipaddress, ':') !== false) { // IPv6
|
Zeile 7614 | Zeile 7628 |
---|
// Support for 127.0.* $replacement = str_repeat('.*', 4-$ip_bits); $ipaddress = substr_replace($ipaddress, $replacement, strrpos($ipaddress, '*')+1, 0);
|
// Support for 127.0.* $replacement = str_repeat('.*', 4-$ip_bits); $ipaddress = substr_replace($ipaddress, $replacement, strrpos($ipaddress, '*')+1, 0);
|
}
| }
|
$upper = str_replace('*', '255', $ipaddress); $lower = str_replace('*', '0', $ipaddress); }
| $upper = str_replace('*', '255', $ipaddress); $lower = str_replace('*', '0', $ipaddress); }
|
Zeile 7678 | Zeile 7692 |
---|
// Lower IP $ip_lower_pack = '';
|
// Lower IP $ip_lower_pack = '';
|
for($i=0; $i < $ip_bits_size; $i=$i+8)
| for($i=0; $i < $ip_bits_size; $i=$i+8)
|
{ $chr = substr($ip_lower_bits, $i, 8); $chr = chr(bindec($chr));
| { $chr = substr($ip_lower_bits, $i, 8); $chr = chr(bindec($chr));
|
Zeile 7712 | Zeile 7726 |
---|
{ static $time_start;
|
{ static $time_start;
|
$time = microtime(true);
| $time = microtime(true);
|
// Just starting timer, init and return if(!$time_start)
| // Just starting timer, init and return if(!$time_start)
|
Zeile 7773 | Zeile 7787 |
---|
if(is_dir($path."/".$file)) { verify_files($path."/".$file, ($count+1));
|
if(is_dir($path."/".$file)) { verify_files($path."/".$file, ($count+1));
|
continue; }
| continue; }
|
// 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;
| // 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;
|
Zeile 7790 | Zeile 7804 |
---|
$contents .= fread($handle, 8192); } fclose($handle);
|
$contents .= fread($handle, 8192); } fclose($handle);
|
|
|
$md5 = md5($contents);
|
$md5 = md5($contents);
|
|
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes) if(!in_array($md5, $checksums[$file_path])) {
| // Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes) if(!in_array($md5, $checksums[$file_path])) {
|
Zeile 7802 | Zeile 7816 |
---|
unset($checksums[$file_path]); } @closedir($dh);
|
unset($checksums[$file_path]); } @closedir($dh);
|
} }
if($count == 0) {
| } }
if($count == 0) {
|
if(!empty($checksums)) { foreach($checksums as $file_path => $hashes)
| if(!empty($checksums)) { foreach($checksums as $file_path => $hashes)
|
Zeile 7822 | Zeile 7836 |
---|
// uh oh if($count == 0)
|
// uh oh if($count == 0)
|
{
| {
|
return $bad_verify_files;
|
return $bad_verify_files;
|
}
| }
|
}
/**
| }
/**
|
Zeile 7836 | Zeile 7850 |
---|
function signed($int) { if($int < 0)
|
function signed($int) { if($int < 0)
|
{
| {
|
return "$int";
|
return "$int";
|
} else {
| } else {
|
return "+$int"; } }
| return "+$int"; } }
|
Zeile 7869 | Zeile 7883 |
---|
{ $output = @fread($handle, $bytes); @fclose($handle);
|
{ $output = @fread($handle, $bytes); @fclose($handle);
|
} } else {
| } } else {
|
return $output; }
| return $output; }
|
Zeile 7887 | Zeile 7901 |
---|
else { $source = MCRYPT_RAND;
|
else { $source = MCRYPT_RAND;
|
}
| }
|
$output = @mcrypt_create_iv($bytes, $source); } }
| $output = @mcrypt_create_iv($bytes, $source); } }
|
Zeile 7920 | Zeile 7934 |
---|
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 7930 | Zeile 7944 |
---|
} } 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.
| if(strlen($output) < $bytes) { // Close to what PHP basically uses internally to seed, but not quite.
|
Zeile 7968 | Zeile 7982 |
---|
* @return int An integer equivalent of a secure hexadecimal seed */ function secure_seed_rng()
|
* @return int An integer equivalent of a secure hexadecimal seed */ function secure_seed_rng()
|
{
| {
|
$bytes = PHP_INT_SIZE;
do
| $bytes = PHP_INT_SIZE;
do
|
Zeile 8224 | Zeile 8238 |
---|
{ // Valid UTF-8 sequence? if(!preg_match('##u', $input))
|
{ // Valid UTF-8 sequence? if(!preg_match('##u', $input))
|
{
| {
|
$string = ''; $len = strlen($input); for($i = 0; $i < $len; $i++)
| $string = ''; $len = strlen($input); for($i = 0; $i < $len; $i++)
|
Zeile 8238 | Zeile 8252 |
---|
{ $string .= '?'; continue;
|
{ $string .= '?'; continue;
|
} else {
| } else {
|
return false; } }
| return false; } }
|
Zeile 8304 | Zeile 8318 |
---|
} } $input = $string;
|
} } $input = $string;
|
}
| }
|
if($return) { if($allow_mb4)
| if($return) { if($allow_mb4)
|
Zeile 8352 | Zeile 8366 |
---|
}
if(isset($pm['language']))
|
}
if(isset($pm['language']))
|
{
| {
|
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language'])) { // Load user language
| if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language'])) { // Load user language
|
Zeile 8580 | Zeile 8594 |
---|
* * @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)
|
{
|
{
|
return true;
| $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;
|
return false;
|
}
| }
|
/** * Strip html tags from string, also removes <script> and <style> contents.
|
/** * Strip html tags from string, also removes <script> and <style> contents.
|
*
| *
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags *
| * @param string $string String to stripe * @param string $allowable_tags Allowed html tags *
|
Zeile 8611 | Zeile 8634 |
---|
); $string = preg_replace($pattern, '', $string); return strip_tags($string, $allowable_tags);
|
); $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;
|
}
| }
|