Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: functions.php 4116 2008-08-15 15:37:11Z ybwzrd $
| * $Id: functions.php 4182 2008-09-07 18:05:30Z Tikitiki $
|
*/
/**
| */
/**
|
Zeile 3080 | Zeile 3080 |
---|
if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1) { header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
|
if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1) { header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
| header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); }
| header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); }
|
Zeile 3318 | Zeile 3318 |
---|
} else {
|
} else {
|
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='{$uid}'");
| $query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".intval($uid)."'");
|
$user = $db->fetch_array($query); }
| $user = $db->fetch_array($query); }
|
Zeile 3341 | Zeile 3341 |
---|
} }
|
} }
|
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='$uid'");
| $db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
|
}
/**
| }
/**
|
Zeile 3360 | Zeile 3360 |
---|
} else {
|
} else {
|
$query = $db->simple_select("users", "*", "uid='{$uid}'");
| $query = $db->simple_select("users", "*", "uid='".intval($uid)."'");
|
$user = $db->fetch_array($query); }
$usergroups = "";
|
$user = $db->fetch_array($query); }
$usergroups = "";
|
| $groupslist = "";
|
$usergroups = $user['additionalgroups'].",";
$groups = explode(",", $user['additionalgroups']);
| $usergroups = $user['additionalgroups'].",";
$groups = explode(",", $user['additionalgroups']);
|
Zeile 3382 | Zeile 3383 |
---|
} }
|
} }
|
| $dispupdate = "";
|
if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
| if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
Zeile 3390 | Zeile 3392 |
---|
$db->write_query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate
|
$db->write_query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate
|
WHERE uid='$uid'
| WHERE uid='".intval($uid)."'
|
"); $cache->update_moderators();
| "); $cache->update_moderators();
|
Zeile 3412 | Zeile 3414 |
---|
if(!empty($_SERVER['PATH_INFO'])) {
|
if(!empty($_SERVER['PATH_INFO'])) {
|
$location = $_SERVER['PATH_INFO'];
| $location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
|
} elseif(!empty($_ENV['PATH_INFO'])) {
|
} elseif(!empty($_ENV['PATH_INFO'])) {
|
$location = $_ENV['PATH_INFO'];
| $location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
} elseif(!empty($_ENV['PHP_SELF']))
|
} elseif(!empty($_ENV['PHP_SELF']))
|
{ $location = $_ENV['PHP_SELF']; } else { $location = $_SERVER['PHP_SELF'];
| { $location = htmlspecialchars_uni($_ENV['PHP_SELF']); } else { $location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
}
if($fields == true)
| }
if($fields == true)
|
Zeile 3432 | Zeile 3434 |
---|
global $mybb; if(!is_array($ignore))
|
global $mybb; if(!is_array($ignore))
|
{
| {
|
$ignore = array($ignore);
|
$ignore = array($ignore);
|
}
| }
|
$form_html = ""; $field_parts = explode('&', $field_parts);
| $form_html = ""; $field_parts = explode('&', $field_parts);
|
Zeile 3453 | Zeile 3455 |
---|
} return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
|
} return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
|
}
| }
|
else { if(isset($_SERVER['QUERY_STRING'])) {
|
else { if(isset($_SERVER['QUERY_STRING'])) {
|
$location .= "?".$_SERVER['QUERY_STRING'];
| $location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
} else if(isset($_ENV['QUERY_STRING']))
|
} else if(isset($_ENV['QUERY_STRING']))
|
{ $location = "?".$_ENV['QUERY_STRING'];
| { $location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
|
} if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
| } if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
|
Zeile 3473 | Zeile 3475 |
---|
{ if(isset($_POST[$var])) {
|
{ if(isset($_POST[$var])) {
|
$addloc[] = $var.'='.$_POST[$var];
| $addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
|
} }
| } }
|
Zeile 3482 | Zeile 3484 |
---|
$location .= "?".implode("&", $addloc); } }
|
$location .= "?".implode("&", $addloc); } }
|
| |
return $location;
|
return $location;
|
} }
| } }
|
/** * Build a theme selection menu *
| /** * Build a theme selection menu *
|
Zeile 3517 | Zeile 3518 |
---|
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
|
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
|
}
| }
|
}
if(is_array($tcache[$tid]))
| }
if(is_array($tcache[$tid]))
|
Zeile 3545 | Zeile 3546 |
---|
$is_allowed = true; break; }
|
$is_allowed = true; break; }
|
} }
| } }
|
// Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
| // Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
|
Zeile 3554 | Zeile 3555 |
---|
if($theme['tid'] == $selected) { $sel = " selected=\"selected\"";
|
if($theme['tid'] == $selected) { $sel = " selected=\"selected\"";
|
}
| }
|
if($theme['pid'] != 0) { $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--";
|
if($theme['pid'] != 0) { $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--";
|
}
| }
|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override); } } }
|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override); } } }
|
}
| }
|
if($tid == 1) { $themeselect .= "</select>"; }
return $themeselect;
|
if($tid == 1) { $themeselect .= "</select>"; }
return $themeselect;
|
}
| }
|
/** * Custom function for htmlspecialchars which takes in to account unicode
|
/** * Custom function for htmlspecialchars which takes in to account unicode
|
*
| *
|
* @param string The string to format * @return string The string with htmlspecialchars applied */
| * @param string The string to format * @return string The string with htmlspecialchars applied */
|
Zeile 3602 | Zeile 3603 |
---|
function my_number_format($number) { global $mybb;
|
function my_number_format($number) { global $mybb;
|
|
|
if($number == "-")
|
if($number == "-")
|
{
| {
|
return $number;
|
return $number;
|
}
if(is_int($number)) { return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); }
| }
if(is_int($number)) { return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); }
|
else { $parts = explode('.', $number);
|
else { $parts = explode('.', $number);
|
|
|
if(isset($parts[1])) { $decimals = my_strlen($parts[1]);
|
if(isset($parts[1])) { $decimals = my_strlen($parts[1]);
|
}
| }
|
else { $decimals = 0;
| else { $decimals = 0;
|
Zeile 3642 | Zeile 3643 |
---|
if($mybb->settings['wordwrap'] > 0) { if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))
|
if($mybb->settings['wordwrap'] > 0) { if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))
|
{
| {
|
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0 ", $message); } else
| $message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0 ", $message); } else
|
Zeile 3703 | Zeile 3704 |
---|
return array( 31, ($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),
|
return array( 31, ($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),
|
31,
| 31,
|
30, 31, 30,
| 30, 31, 30,
|
Zeile 3774 | Zeile 3775 |
---|
my_substr($by, 2), $by, ($bd[0] == 0 ? my_substr($bd, 1) : $bd),
|
my_substr($by, 2), $by, ($bd[0] == 0 ? my_substr($bd, 1) : $bd),
|
($db == 1 || $db == 21 || $db == 31 ? 'st' : ($db == 2 || $db == 22 ? 'nd' : ($db == 3 || $db == 23 ? 'rd' : 'th'))),
| ($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
|
$bdays[$wd], $bmonth[$bm-1], );
| $bdays[$wd], $bmonth[$bm-1], );
|
Zeile 3794 | Zeile 3795 |
---|
if(!$bday[2]) { return;
|
if(!$bday[2]) { return;
|
}
| }
|
list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));
$age = $year-$bday[2];
| list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));
$age = $year-$bday[2];
|
Zeile 3855 | Zeile 3856 |
---|
$string = str_replace(chr(0xCA), "", $string); } $string = trim($string);
|
$string = str_replace(chr(0xCA), "", $string); } $string = trim($string);
|
|
|
if(function_exists("mb_strlen")) { $string_length = mb_strlen($string);
| if(function_exists("mb_strlen")) { $string_length = mb_strlen($string);
|
Zeile 4586 | Zeile 4587 |
---|
/** * Rebuilds settings.php
|
/** * Rebuilds settings.php
|
*
| *
|
*/ function rebuild_settings() {
| */ function rebuild_settings() {
|
Zeile 4630 | Zeile 4631 |
---|
*/ function build_highlight_array($terms) {
|
*/ function build_highlight_array($terms) {
|
$terms = htmlspecialchars_uni($terms);
| |
// Strip out any characters that shouldn't be included $bad_characters = array( "(",
| // Strip out any characters that shouldn't be included $bad_characters = array( "(",
|
Zeile 4648 | Zeile 4647 |
---|
$inquote = false; $terms = explode("\"", $terms); foreach($terms as $phrase)
|
$inquote = false; $terms = explode("\"", $terms); foreach($terms as $phrase)
|
{
| { $phrase = htmlspecialchars_uni($phrase);
|
if($phrase != "") { if($inquote)
| if($phrase != "") { if($inquote)
|
Zeile 4678 | Zeile 4678 |
---|
// Otherwise just a simple search query with no phrases else {
|
// Otherwise just a simple search query with no phrases else {
|
| $terms = htmlspecialchars_uni($terms);
|
$split_words = preg_split("#\s{1,}#", $terms, -1); if(!is_array($split_words)) {
| $split_words = preg_split("#\s{1,}#", $terms, -1); if(!is_array($split_words)) {
|
Zeile 4708 | Zeile 4709 |
---|
// Special boolean operators should be stripped if($word == "" || $word == "or" || $word == "not" || $word == "and")
|
// Special boolean operators should be stripped if($word == "" || $word == "or" || $word == "not" || $word == "and")
|
{
| {
|
continue; }
| continue; }
|
Zeile 4799 | Zeile 4800 |
---|
* Check if a specific email address has been banned. * * @param string The email address.
|
* Check if a specific email address has been banned. * * @param string The email address.
|
* @param boolean True if the 'last used' dateline should be updated if a match is found.
| * @param boolean True if the 'last used' dateline should be updated if a match is found.
|
* @return boolean True if banned, false if not banned */ function is_banned_email($email, $update_lastuse=false)
| * @return boolean True if banned, false if not banned */ function is_banned_email($email, $update_lastuse=false)
|
Zeile 4830 | Zeile 4831 |
---|
* @param string The IP address. * @param boolean True if the 'last used' dateline should be updated if a match is found. * @return boolean True if banned, false if not banned.
|
* @param string The IP address. * @param boolean True if the 'last used' dateline should be updated if a match is found. * @return boolean True if banned, false if not banned.
|
*/
| */
|
function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
| function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
|
Zeile 4922 | Zeile 4923 |
---|
{ $label = ''; if($timezone != 0)
|
{ $label = ''; if($timezone != 0)
|
{
| {
|
$label = $timezone; if($timezone > 0) {
| $label = $timezone; if($timezone > 0) {
|
Zeile 4952 | Zeile 4953 |
---|
* * @param string The URL of the remote file * @return string The remote file contents.
|
* * @param string The URL of the remote file * @return string The remote file contents.
|
*/
| */
|
function fetch_remote_file($url) { if(function_exists("curl_init"))
| function fetch_remote_file($url) { if(function_exists("curl_init"))
|
Zeile 5074 | Zeile 5075 |
---|
if($in_escape) { $strings[] = trim($string);
|
if($in_escape) { $strings[] = trim($string);
|
}
| }
|
else { $split_strings = explode($delimeter, $string);
| else { $split_strings = explode($delimeter, $string);
|
Zeile 5086 | Zeile 5087 |
---|
} } $in_escape = !$in_escape;
|
} } $in_escape = !$in_escape;
|
}
| }
|
if(!count($strings)) { return $original;
| if(!count($strings)) { return $original;
|
Zeile 5105 | Zeile 5106 |
---|
$ip_bits = explode(".", $ip);
if($ip == "*") return array(ip2long(0), ip2long(255));
|
$ip_bits = explode(".", $ip);
if($ip == "*") return array(ip2long(0), ip2long(255));
|
|
|
if(strpos($ip, ".*") === false) { $ip = str_replace("*", "", $ip);
| if(strpos($ip, ".*") === false) { $ip = str_replace("*", "", $ip);
|
Zeile 5114 | Zeile 5115 |
---|
return ip2long($ip); } else
|
return ip2long($ip); } else
|
{
| {
|
return array(ip2long($ip.".0"), ip2long($ip.".255"));
|
return array(ip2long($ip.".0"), ip2long($ip.".255"));
|
} }
| } }
|
// Wildcard based IP provided else { foreach($ip_bits as $piece) { if($piece == "*")
|
// Wildcard based IP provided else { foreach($ip_bits as $piece) { if($piece == "*")
|
{
| {
|
return array(ip2long($ip_string."0"), ip2long($ip_string."255")); } else { $ip_string .= $piece."."; }
|
return array(ip2long($ip_string."0"), ip2long($ip_string."255")); } else { $ip_string .= $piece."."; }
|
} } }
/**
| } } }
/**
|
* Fetch a list of ban times for a user account. * * @return array Array of ban times
| * Fetch a list of ban times for a user account. * * @return array Array of ban times
|
Zeile 5143 | Zeile 5144 |
---|
function fetch_ban_times() { global $plugins, $lang;
|
function fetch_ban_times() { global $plugins, $lang;
|
|
|
// Days-Months-Years $ban_times = array( "1-0-0" => "1 {$lang->day}",
| // Days-Months-Years $ban_times = array( "1-0-0" => "1 {$lang->day}",
|
Zeile 5166 | Zeile 5167 |
---|
);
$plugins->run_hooks_by_ref("functions_fetch_ban_times", $ban_times);
|
);
$plugins->run_hooks_by_ref("functions_fetch_ban_times", $ban_times);
|
|
|
$ban_times['---'] = $lang->permanent; return $ban_times;
|
$ban_times['---'] = $lang->permanent; return $ban_times;
|
}
| }
|
/** * Format a ban length in to a UNIX timestamp.
|
/** * Format a ban length in to a UNIX timestamp.
|
*
| *
|
* @param string The ban length string * @param int The optional UNIX timestamp, if 0, current time is used. * @return int The UNIX timestamp when the ban will be lifted
| * @param string The ban length string * @param int The optional UNIX timestamp, if 0, current time is used. * @return int The UNIX timestamp when the ban will be lifted
|
Zeile 5195 | Zeile 5196 |
---|
/** * Expire old warnings in the database.
|
/** * Expire old warnings in the database.
|
* */
| * */
|
function expire_warnings() { global $db;
| function expire_warnings() { global $db;
|
Zeile 5226 | Zeile 5227 |
---|
/** * Unicode function for php function chr()
|
/** * Unicode function for php function chr()
|
*
| *
|
* @param string The character * @return mixed The unicoded chr() */
| * @param string The character * @return mixed The unicoded chr() */
|
Zeile 5239 | Zeile 5240 |
---|
elseif($c <= 0x7FF) { return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
|
elseif($c <= 0x7FF) { return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
|
}
| }
|
elseif($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
|
elseif($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
|
. chr(0x80 | $c & 0x3F);
| . chr(0x80 | $c & 0x3F);
|
} elseif($c <= 0x10FFFF)
|
} elseif($c <= 0x10FFFF)
|
{
| {
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
}
| }
|
else { return false;
|
else { return false;
|
} }
/**
| } }
/**
|
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks * * @param string The file to chmod
| * Custom chmod function to fix problems with hosts who's server configurations screw up umasks * * @param string The file to chmod
|
Zeile 5318 | Zeile 5319 |
---|
} return @unlink($path);
|
} return @unlink($path);
|
| }
/** * Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid * * @param array The array of forums * @return integer The number of sub forums */ function subforums_count($array) { $count = 0; foreach($array as $array2) { $count += count($array2); } return $count;
|
}
?>
| }
?>
|