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 658 | Zeile 672 |
---|
* @return string The query string generated */ function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")
|
* @return string The query string generated */ function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")
|
{
| {
|
if(!$parentlist)
|
if(!$parentlist)
|
{
| {
|
$parentlist = get_parent_list($fid);
|
$parentlist = get_parent_list($fid);
|
}
| }
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
|
|
foreach($parentsexploded as $key => $val) { $builtlist .= "$sep$column='$val'"; $sep = " $joiner ";
|
foreach($parentsexploded as $key => $val) { $builtlist .= "$sep$column='$val'"; $sep = " $joiner ";
|
}
$builtlist .= ")";
| }
$builtlist .= ")";
|
return $builtlist; }
| return $builtlist; }
|
Zeile 688 | Zeile 702 |
---|
function cache_forums($force=false) { global $forum_cache, $cache;
|
function cache_forums($force=false) { global $forum_cache, $cache;
|
|
|
if($force == true) { $forum_cache = $cache->read("forums", 1);
| if($force == true) { $forum_cache = $cache->read("forums", 1);
|
Zeile 719 | Zeile 733 |
---|
$forums = array(); if(!is_array($forums_by_parent))
|
$forums = array(); if(!is_array($forums_by_parent))
|
{
| {
|
$forum_cache = cache_forums(); foreach($forum_cache as $forum) {
| $forum_cache = cache_forums(); foreach($forum_cache as $forum) {
|
Zeile 728 | Zeile 742 |
---|
$forums_by_parent[$forum['pid']][$forum['fid']] = $forum; } }
|
$forums_by_parent[$forum['pid']][$forum['fid']] = $forum; } }
|
}
| }
|
if(!is_array($forums_by_parent[$fid]))
|
if(!is_array($forums_by_parent[$fid]))
|
{
| {
|
return $forums; }
foreach($forums_by_parent[$fid] as $forum)
|
return $forums; }
foreach($forums_by_parent[$fid] as $forum)
|
{
| {
|
$forums[] = $forum['fid']; $children = get_child_list($forum['fid']); if(is_array($children))
| $forums[] = $forum['fid']; $children = get_child_list($forum['fid']); if(is_array($children))
|
Zeile 783 | Zeile 797 |
---|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
exit; }
| exit; }
|
/** * Produce an error message for displaying inline on a page *
| /** * Produce an error message for displaying inline on a page *
|
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 1037 | Zeile 1051 |
---|
}
if($to == 0)
|
}
if($to == 0)
|
{
| {
|
$to = $pages; }
| $to = $pages; }
|
Zeile 1412 | Zeile 1426 |
---|
if(!empty($fpermcache[$parent_id][$gid])) { $level_permissions = $fpermcache[$parent_id][$gid];
|
if(!empty($fpermcache[$parent_id][$gid])) { $level_permissions = $fpermcache[$parent_id][$gid];
|
break; } } } }
| break; } } } }
|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions)) {
| // If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions)) {
|
Zeile 1430 | Zeile 1444 |
---|
{ $current_permissions[$permission] = $access; }
|
{ $current_permissions[$permission] = $access; }
|
}
| }
|
if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"])) { $only_view_own_threads = 0;
| if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"])) { $only_view_own_threads = 0;
|
Zeile 1495 | Zeile 1509 |
---|
if(!empty($parents)) { foreach($parents as $parent_id)
|
if(!empty($parents)) { foreach($parents as $parent_id)
|
{
| {
|
if($parent_id == $fid || $parent_id == $pid) { continue;
| if($parent_id == $fid || $parent_id == $pid) { continue;
|
Zeile 1527 | Zeile 1541 |
---|
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;
|
$showform = true;
|
}
| }
|
else { $showform = false; } }
|
else { $showform = false; } }
|
}
| }
|
else { $showform = false; }
if($return)
|
else { $showform = false; }
if($return)
|
{
| {
|
return $showform; }
| return $showform; }
|
Zeile 1792 | Zeile 1806 |
---|
{ $checked = " checked=\"checked\""; $no_icons_checked = '';
|
{ $checked = " checked=\"checked\""; $no_icons_checked = '';
|
} else {
| } else {
|
$checked = ''; }
| $checked = ''; }
|
Zeile 1826 | Zeile 1840 |
---|
global $mybb;
if(!$mybb->settings['cookiepath'])
|
global $mybb;
if(!$mybb->settings['cookiepath'])
|
{
| {
|
$mybb->settings['cookiepath'] = "/";
|
$mybb->settings['cookiepath'] = "/";
|
}
| }
|
if($expires == -1)
|
if($expires == -1)
|
{
| {
|
$expires = 0;
|
$expires = 0;
|
}
| }
|
elseif($expires == "" || $expires == null)
|
elseif($expires == "" || $expires == null)
|
{
| {
|
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time
|
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time
|
}
| }
|
else { $expires = TIME_NOW + (int)$expires;
|
else { $expires = TIME_NOW + (int)$expires;
|
}
| }
|
$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']); $mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']); $mybb->settings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);
| $mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']); $mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']); $mybb->settings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);
|
Zeile 1873 | Zeile 1887 |
---|
if($mybb->settings['cookiesecureflag']) { $cookie .= "; Secure";
|
if($mybb->settings['cookiesecureflag']) { $cookie .= "; Secure";
|
}
| }
|
$mybb->cookies[$name] = $value;
| $mybb->cookies[$name] = $value;
|
Zeile 1905 | Zeile 1919 |
---|
function my_get_array_cookie($name, $id) { global $mybb;
|
function my_get_array_cookie($name, $id) { global $mybb;
|
|
|
if(!isset($mybb->cookies['mybb'][$name]))
|
if(!isset($mybb->cookies['mybb'][$name]))
|
{
| {
|
return false;
|
return false;
|
}
| }
|
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
| $cookie = my_unserialize($mybb->cookies['mybb'][$name]);
|
Zeile 1920 | Zeile 1934 |
---|
else { return 0;
|
else { return 0;
|
}
| }
|
}
/**
| }
/**
|
Zeile 2041 | Zeile 2055 |
---|
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(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) { // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH return false;
| if($type == 'a') { if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) { // array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH return false;
|
}
$stack[] = &$list;
| }
$stack[] = &$list;
|
Zeile 2298 | Zeile 2312 |
---|
$load = explode("load average: ", $load); $serverload = explode(",", $load[1]); if(!is_array($serverload))
|
$load = explode("load average: ", $load); $serverload = explode(",", $load[1]); if(!is_array($serverload))
|
{
| {
|
return $lang->unknown; } }
| return $lang->unknown; } }
|
Zeile 2330 | Zeile 2344 |
---|
} return false; }
|
} return false; }
|
|
|
/** * Updates the forum statistics with specific values (or addition/subtraction of the previous value) *
| /** * Updates the forum statistics with specific values (or addition/subtraction of the previous value) *
|
Zeile 2346 | Zeile 2360 |
---|
{ // Update stats after all changes are done add_shutdown('update_stats', array(array(), true));
|
{ // Update stats after all changes are done add_shutdown('update_stats', array(array(), true));
|
}
| }
|
if(empty($stats_changes) || $stats_changes['inserted']) {
| if(empty($stats_changes) || $stats_changes['inserted']) {
|
Zeile 2360 | Zeile 2374 |
---|
'numdeletedthreads' => '+0', 'inserted' => false // Reset after changes are inserted into cache );
|
'numdeletedthreads' => '+0', 'inserted' => false // Reset after changes are inserted into cache );
|
$stats = $stats_changes; }
| $stats = $stats_changes; }
|
if($force) // Force writing to cache? {
| if($force) // Force writing to cache? {
|
Zeile 2376 | Zeile 2390 |
---|
else { $stats = $stats_changes;
|
else { $stats = $stats_changes;
|
}
| }
|
$new_stats = array(); $counters = array('numthreads', 'numunapprovedthreads', 'numposts', 'numunapprovedposts', 'numusers', 'numdeletedposts', 'numdeletedthreads'); foreach($counters as $counter)
| $new_stats = array(); $counters = array('numthreads', 'numunapprovedthreads', 'numposts', 'numunapprovedposts', 'numusers', 'numdeletedposts', 'numdeletedthreads'); foreach($counters as $counter)
|
Zeile 2424 | Zeile 2438 |
---|
if(!$force) { $stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
|
if(!$force) { $stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
|
return;
| return;
|
}
// Fetch latest user if the user count is changing
| }
// Fetch latest user if the user count is changing
|
Zeile 5450 | Zeile 5464 |
---|
if(empty($firstpost['username'])) { $firstpost['username'] = $firstpost['postusername'];
|
if(empty($firstpost['username'])) { $firstpost['username'] = $firstpost['postusername'];
|
}
| }
|
$firstpost['username'] = $db->escape_string($firstpost['username']);
|
$firstpost['username'] = $db->escape_string($firstpost['username']);
|
|
|
$update_array = array( 'firstpost' => (int)$firstpost['pid'], 'username' => $firstpost['username'],
| $update_array = array( 'firstpost' => (int)$firstpost['pid'], 'username' => $firstpost['username'],
|
Zeile 5466 | Zeile 5480 |
---|
* Updates the last posts in a thread. * * @param int $tid The thread id for which to update the last post id.
|
* Updates the last posts in a thread. * * @param int $tid The thread id for which to update the last post id.
|
*/
| */
|
function update_last_post($tid) { global $db;
| function update_last_post($tid) { global $db;
|
Zeile 5511 | Zeile 5525 |
---|
'lastposteruid' => (int)$lastpost['uid'] ); $db->update_query("threads", $update_array, "tid='{$tid}'");
|
'lastposteruid' => (int)$lastpost['uid'] ); $db->update_query("threads", $update_array, "tid='{$tid}'");
|
}
| }
|
/** * Checks for the length of a string, mb strings accounted for
| /** * Checks for the length of a string, mb strings accounted for
|
Zeile 5526 | Zeile 5540 |
---|
$string = preg_replace("#&\#([0-9]+);#", "-", $string);
if(strtolower($lang->settings['charset']) == "utf-8")
|
$string = preg_replace("#&\#([0-9]+);#", "-", $string);
if(strtolower($lang->settings['charset']) == "utf-8")
|
{
| {
|
// Get rid of any excess RTL and LTR override for they are the workings of the devil $string = str_replace(dec_to_utf8(8238), "", $string); $string = str_replace(dec_to_utf8(8237), "", $string);
|
// Get rid of any excess RTL and LTR override for they are the workings of the devil $string = str_replace(dec_to_utf8(8238), "", $string); $string = str_replace(dec_to_utf8(8237), "", $string);
|
|
|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string); } $string = trim($string);
if(function_exists("mb_strlen"))
|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string); } $string = trim($string);
if(function_exists("mb_strlen"))
|
{
| {
|
$string_length = mb_strlen($string);
|
$string_length = mb_strlen($string);
|
} else {
| } else {
|
$string_length = strlen($string); }
| $string_length = strlen($string); }
|
Zeile 5572 | Zeile 5586 |
---|
else { $cut_string = mb_substr($string, $start);
|
else { $cut_string = mb_substr($string, $start);
|
} } else {
| } } else {
|
if($length != null)
|
if($length != null)
|
{
| {
|
$cut_string = substr($string, $start, $length);
|
$cut_string = substr($string, $start, $length);
|
}
| }
|
else { $cut_string = substr($string, $start);
| else { $cut_string = substr($string, $start);
|
Zeile 5591 | Zeile 5605 |
---|
$cut_string = htmlspecialchars_uni($cut_string); } return $cut_string;
|
$cut_string = htmlspecialchars_uni($cut_string); } return $cut_string;
|
}
| }
|
/** * Lowers the case of a string, mb strings accounted for
| /** * Lowers the case of a string, mb strings accounted for
|
Zeile 5638 | Zeile 5652 |
---|
}
return $position;
|
}
return $position;
|
}
| }
|
/** * Ups the case of a string, mb strings accounted for
| /** * Ups the case of a string, mb strings accounted for
|
Zeile 5701 | Zeile 5715 |
---|
. chr(0x80 | $c & 0x3F); } else if($c <= 0x10FFFF)
|
. chr(0x80 | $c & 0x3F); } else if($c <= 0x10FFFF)
|
{
| {
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
| return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
Zeile 5714 | Zeile 5728 |
---|
/** * Get the event poster.
|
/** * Get the event poster.
|
* * @param array $event The event data array.
| * * @param array $event The event data array.
|
* @return string The link to the event poster. */ function get_event_poster($event)
| * @return string The link to the event poster. */ function get_event_poster($event)
|
Zeile 5745 | Zeile 5759 |
---|
/** * Get the profile link.
|
/** * Get the profile link.
|
*
| *
|
* @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. */
|
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 { // Build the profile link for the registered user if(!empty($target)) { $target = " target=\"{$target}\"";
|
else { // Build the profile link for the registered user if(!empty($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 5817 | Zeile 5831 |
---|
function get_forum_link($fid, $page=0) { if($page > 0)
|
function get_forum_link($fid, $page=0) { if($page > 0)
|
{
| {
|
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
|
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
|
$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("{page}", $page, $link); return htmlspecialchars_uni($link); } else { $link = str_replace("{fid}", $fid, FORUM_URL); return htmlspecialchars_uni($link); } }
|
/** * Build the thread link.
| /** * Build the thread link.
|
Zeile 6078 | Zeile 6092 |
---|
if(is_array($parents)) { foreach($parents as $parent)
|
if(is_array($parents)) { foreach($parents as $parent)
|
{
| {
|
if($forum_cache[$parent]['active'] == 0) { return false;
| if($forum_cache[$parent]['active'] == 0) { return false;
|
Zeile 6107 | Zeile 6121 |
---|
if(isset($thread_cache[$tid]) && !$recache) { return $thread_cache[$tid];
|
if(isset($thread_cache[$tid]) && !$recache) { return $thread_cache[$tid];
|
} else {
| } else {
|
$query = $db->simple_select("threads", "*", "tid = '{$tid}'"); $thread = $db->fetch_array($query);
|
$query = $db->simple_select("threads", "*", "tid = '{$tid}'"); $thread = $db->fetch_array($query);
|
|
|
if($thread) { $thread_cache[$tid] = $thread; return $thread;
|
if($thread) { $thread_cache[$tid] = $thread; return $thread;
|
}
| }
|
else { $thread_cache[$tid] = false;
|
else { $thread_cache[$tid] = false;
|
return false; } } }
| return false; } } }
|
/** * Get the post of a post id. *
| /** * Get the post of a post id. *
|
Zeile 6140 | Zeile 6154 |
---|
$pid = (int)$pid;
if(isset($post_cache[$pid]))
|
$pid = (int)$pid;
if(isset($post_cache[$pid]))
|
{
| {
|
return $post_cache[$pid]; } else
| return $post_cache[$pid]; } else
|
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 6456 | Zeile 6470 |
---|
}
if(!is_array($words))
|
}
if(!is_array($words))
|
{ return false; }
| { return false; }
|
// 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);'));
| // 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);'));
|
Zeile 6710 | Zeile 6724 |
---|
"14" => $lang->timezone_gmt_1400 ); return $timezones;
|
"14" => $lang->timezone_gmt_1400 ); return $timezones;
|
}
/**
| }
/**
|
* Build a time zone selection list. * * @param string $name The name of the select
| * Build a time zone selection list. * * @param string $name The name of the select
|
Zeile 6728 | Zeile 6742 |
---|
$selected = str_replace("+", "", $selected); foreach($timezones as $timezone => $label)
|
$selected = str_replace("+", "", $selected); foreach($timezones as $timezone => $label)
|
{
| {
|
$selected_add = ""; if($selected == $timezone) {
| $selected_add = ""; if($selected == $timezone) {
|
Zeile 6760 | Zeile 6774 |
---|
}
eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");
|
}
eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");
|
}
| }
|
eval("\$select = \"".$templates->get("usercp_options_timezone")."\";"); return $select;
| eval("\$select = \"".$templates->get("usercp_options_timezone")."\";"); return $select;
|
Zeile 6778 | Zeile 6792 |
---|
{ global $mybb, $config;
|
{ global $mybb, $config;
|
$url_components = @parse_url($url);
| if(!my_validate_url($url, true)) { return false; }
$url_components = @parse_url($url);
if(!isset($url_components['scheme'])) { $url_components['scheme'] = 'https'; } if(!isset($url_components['port'])) { $url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80; }
|
if( !$url_components || empty($url_components['host']) || (!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
|
if( !$url_components || empty($url_components['host']) || (!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
|
(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||
| (!in_array($url_components['port'], array(80, 8080, 443))) ||
|
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts'])) ) { 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 6856 |
---|
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); $body = substr($response, $header_size);
|
{ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size);
|
|
|
if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302))) { preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
| if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302))) { preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
|
Zeile 6870 | Zeile 6920 |
---|
{ $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;
|
else { $data = $body;
|
} } else { $data = $response;
| } } else { $data = $response;
|
}
curl_close($ch);
| }
curl_close($ch);
|
Zeile 6886 | Zeile 6936 |
---|
} else if(function_exists("fsockopen")) {
|
} else if(function_exists("fsockopen")) {
|
if(!isset($url_components['port'])) { $url_components['port'] = 80; }
| |
if(!isset($url_components['path'])) { $url_components['path'] = "/"; } if(isset($url_components['query']))
|
if(!isset($url_components['path'])) { $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 6910 | Zeile 6956 |
---|
} }
|
} }
|
$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 6926 | Zeile 7001 |
---|
else { $headers[] = "GET {$url_components['path']} HTTP/1.0";
|
else { $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 6962 | Zeile 7037 |
---|
$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 6978 | Zeile 7053 |
---|
return $data; }
|
return $data; }
|
else if(empty($post_data))
| else { return false; } }
/** * Resolves a hostname into a set of IP addresses. * * @param string $hostname The hostname to be resolved * @return array|bool The resulting IP addresses. False on failure */ function get_ip_by_hostname($hostname) { $addresses = @gethostbynamel($hostname);
if(!$addresses) { $result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);
if($result_set) { $addresses = array_column($result_set, 'ip'); } else { return false; } }
return $addresses; }
/** * Returns the location of the CA bundle defined in the PHP configuration. * * @return string|bool The location of the CA bundle, false if not set */ function get_ca_bundle_path() { if($path = ini_get('openssl.cafile')) { return $path; } if($path = ini_get('curl.cainfo'))
|
{
|
{
|
return @implode("", @file($url)); } else { return false;
| return $path;
|
}
|
}
|
| return false;
|
}
/**
| }
/**
|
Zeile 6993 | Zeile 7110 |
---|
* * @param int $uid The user ID to check against the list of super admins * @return boolean True if a super admin, false if not
|
* * @param int $uid The user ID to check against the list of super admins * @return boolean True if a super admin, false if not
|
*/
| */
|
function is_super_admin($uid) { static $super_admins;
|
function is_super_admin($uid) { static $super_admins;
|
|
|
if(!isset($super_admins)) { global $mybb; $super_admins = str_replace(" ", "", $mybb->config['super_admins']);
|
if(!isset($super_admins)) { global $mybb; $super_admins = str_replace(" ", "", $mybb->config['super_admins']);
|
}
| }
|
if(my_strpos(",{$super_admins},", ",{$uid},") === false) { return false;
|
if(my_strpos(",{$super_admins},", ",{$uid},") === false) { return false;
|
} else
| } else
|
{ return true; }
| { return true; }
|
Zeile 7024 | Zeile 7141 |
---|
* @return array Array of groups specified in the first param to which the user belongs */ function is_member($groups, $user = false)
|
* @return array Array of groups specified in the first param to which the user belongs */ function is_member($groups, $user = false)
|
{
| {
|
global $mybb;
if(empty($groups))
| global $mybb;
if(empty($groups))
|
Zeile 7086 | Zeile 7203 |
---|
if($escape) { if(is_array($escape))
|
if($escape) { if(is_array($escape))
|
{
| {
|
function escaped_explode_escape($string) { return preg_quote($string, "#");
| function escaped_explode_escape($string) { return preg_quote($string, "#");
|
Zeile 7118 | Zeile 7235 |
---|
{ if($string == "") continue; $strings[] = trim($string);
|
{ if($string == "") continue; $strings[] = trim($string);
|
} }
| } }
|
} $in_escape = !$in_escape; }
| } $in_escape = !$in_escape; }
|
Zeile 7369 | Zeile 7486 |
---|
}
return $ip_long;
|
}
return $ip_long;
|
}
/**
| }
/**
|
* DEPRECATED! Please use IPv6 compatible my_inet_ntop! * As above, fix for PHP's long2ip on 64-bit versions *
| * DEPRECATED! Please use IPv6 compatible my_inet_ntop! * As above, fix for PHP's long2ip on 64-bit versions *
|
Zeile 7401 | Zeile 7518 |
---|
if(function_exists('inet_pton')) { return @inet_pton($ip);
|
if(function_exists('inet_pton')) { return @inet_pton($ip);
|
} else {
| } else {
|
/** * Replace inet_pton() *
| /** * Replace inet_pton() *
|
Zeile 7419 | Zeile 7536 |
---|
if($r !== false && $r != -1) { return pack('N', $r);
|
if($r !== false && $r != -1) { return pack('N', $r);
|
}
| }
|
$delim_count = substr_count($ip, ':'); if($delim_count < 1 || $delim_count > 7) { return false;
|
$delim_count = substr_count($ip, ':'); if($delim_count < 1 || $delim_count > 7) { return false;
|
}
| }
|
$r = explode(':', $ip); $rcount = count($r);
| $r = explode(':', $ip); $rcount = count($r);
|
Zeile 7433 | Zeile 7550 |
---|
{ $length = (!$doub || $doub == $rcount - 1 ? 2 : 1); array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));
|
{ $length = (!$doub || $doub == $rcount - 1 ? 2 : 1); array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));
|
}
| }
|
$r = array_map('hexdec', $r); array_unshift($r, 'n*'); $r = call_user_func_array('pack', $r);
|
$r = array_map('hexdec', $r); array_unshift($r, 'n*'); $r = call_user_func_array('pack', $r);
|
|
|
return $r; } }
| return $r; } }
|
Zeile 7450 | Zeile 7567 |
---|
* @return string IP in human readable format */ function my_inet_ntop($ip)
|
* @return string IP in human readable format */ function my_inet_ntop($ip)
|
{
| {
|
if(function_exists('inet_ntop')) { return @inet_ntop($ip);
| if(function_exists('inet_ntop')) { return @inet_ntop($ip);
|
Zeile 7497 | Zeile 7614 |
---|
if(strpos($ipaddress, '*') !== false) { if(strpos($ipaddress, ':') !== false)
|
if(strpos($ipaddress, '*') !== false) { if(strpos($ipaddress, ':') !== false)
|
{
| {
|
// IPv6 $upper = str_replace('*', 'ffff', $ipaddress); $lower = str_replace('*', '0', $ipaddress);
| // IPv6 $upper = str_replace('*', 'ffff', $ipaddress); $lower = str_replace('*', '0', $ipaddress);
|
Zeile 7875 | Zeile 7992 |
---|
// convert binary data to a decimal number if ($bytes == 4)
|
// convert binary data to a decimal number if ($bytes == 4)
|
{
| {
|
$elements = unpack('i', $output); $output = abs($elements[1]); }
| $elements = unpack('i', $output); $output = abs($elements[1]); }
|
Zeile 8378 | Zeile 8495 |
---|
if(!is_array($data)) { $data = array($data);
|
if(!is_array($data)) { $data = array($data);
|
}
| }
|
if(!$ip_address) { $ip_address = get_ip();
| if(!$ip_address) { $ip_address = get_ip();
|
Zeile 8442 | Zeile 8559 |
---|
}
if($dir_exists)
|
}
if($dir_exists)
|
{
| {
|
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false) { $success = @copy($file_path, $cdn_upload_path.DIRECTORY_SEPARATOR.$file_name);
| if(($cdn_upload_path = realpath($cdn_upload_path)) !== false) { $success = @copy($file_path, $cdn_upload_path.DIRECTORY_SEPARATOR.$file_name);
|
Zeile 8474 | Zeile 8591 |
---|
/** * 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 true; }
|
| |
return false; }
/** * Strip html tags from string, also removes <script> and <style> contents.
|
return false; }
/** * 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 8508 | 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;
|
}
| }
|