Zeile 3 | Zeile 3 |
---|
* MyBB 1.2 * Copyright � 2006 MyBB Group, All Rights Reserved *
|
* MyBB 1.2 * Copyright � 2006 MyBB Group, All Rights Reserved *
|
* Website: http://www.mybboard.com * License: http://www.mybboard.com/eula.html
| * Website: http://www.mybboard.net * License: http://www.mybboard.net/eula.html
|
*
|
*
|
* $Id: functions.php 2794 2007-02-14 02:37:17Z chris $
| * $Id: functions.php 3845 2008-05-18 17:50:09Z Tikitiki $
|
*/
/**
| */
/**
|
Zeile 18 | Zeile 18 |
---|
{ global $db, $lang, $theme, $plugins, $mybb; global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
|
{ global $db, $lang, $theme, $plugins, $mybb; global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
|
| |
$contents = parse_page($contents); $totaltime = $maintimer->stop(); if($mybb->usergroup['cancp'] == "yes")
| $contents = parse_page($contents); $totaltime = $maintimer->stop(); if($mybb->usergroup['cancp'] == "yes")
|
Zeile 74 | Zeile 73 |
---|
$contents = gzip_encode($contents); } }
|
$contents = gzip_encode($contents); } }
|
| @header("Content-type: text/html; charset={$lang->settings['charset']}");
|
echo $contents;
$plugins->run_hooks("post_output_page");
// If the use shutdown functionality is turned off, run any shutdown related items now.
|
echo $contents;
$plugins->run_hooks("post_output_page");
// If the use shutdown functionality is turned off, run any shutdown related items now.
|
if(($mybb->settings['useshutdownfunc'] == "no" || phpversion() >= '5.0.5') && $mybb->use_shutdown != true)
| if(($mybb->settings['useshutdownfunc'] == "no"|| phpversion() >= '5.0.5') && $mybb->use_shutdown != true)
|
{ run_shutdown(); }
| { run_shutdown(); }
|
Zeile 219 | Zeile 221 |
---|
{ $contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents; }
|
{ $contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents; }
|
| $contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);
|
if($lang->settings['rtl'] == 1)
|
if($lang->settings['rtl'] == 1)
|
{
| {
|
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);
|
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);
|
}
| }
|
if($lang->settings['htmllang'])
|
if($lang->settings['htmllang'])
|
{ $contents = str_replace("<html", "<html lang=\"".$lang->settings['htmllang']."\"", $contents);
| { $contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
|
}
if($loadpmpopup)
| }
if($loadpmpopup)
|
Zeile 233 | Zeile 238 |
---|
if(my_substr($_SERVER['PHP_SELF'], -strlen("private.php")) != "private.php") { $contents = str_replace("<body", "<body onload=\"Javascript:MyBB.newPM()\"", $contents);
|
if(my_substr($_SERVER['PHP_SELF'], -strlen("private.php")) != "private.php") { $contents = str_replace("<body", "<body onload=\"Javascript:MyBB.newPM()\"", $contents);
|
} }
| } }
|
return $contents; }
| return $contents; }
|
Zeile 341 | Zeile 346 |
---|
else if($_SERVER['HTTP_HOST']) { $http_host = $_SERVER['HTTP_HOST'];
|
else if($_SERVER['HTTP_HOST']) { $http_host = $_SERVER['HTTP_HOST'];
|
} else
| } else
|
{ $http_host = "unknown.local"; }
| { $http_host = "unknown.local"; }
|
Zeile 353 | Zeile 358 |
---|
$headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: MyBB\n";
|
$headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: MyBB\n";
|
| if(defined("IN_ADMINCP")) { $_SERVER['PHP_SELF'] = str_replace($mybb->config['admin_dir']."/", "admin-", $_SERVER['PHP_SELF']); } $headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}\n";
|
// For some reason sendmail/qmail doesn't like \r\n $sendmail = @ini_get('sendmail_path');
| // For some reason sendmail/qmail doesn't like \r\n $sendmail = @ini_get('sendmail_path');
|
Zeile 368 | Zeile 378 |
---|
}
mail($to, $subject, $message, $headers);
|
}
mail($to, $subject, $message, $headers);
|
| }
/** * Generates a unique code for POST requests to prevent XSS/CSRF attacks * * @return string The generated code */ function generate_post_check() { global $mybb; if($mybb->user['uid']) { return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']); } // Guests get a special string else { return md5($mybb->config['hostname'].$mybb->config['username'].$mybb->config['password']); } }
/** * Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter) * * @param string The incoming POST check code * @param boolean Silent mode or not (silent mode will not show the error to the user but returns false) */ function verify_post_check($code, $silent=false) { global $lang; if(generate_post_check() != $code) { if($silent == true) { return false; } else { error($lang->invalid_post_code); } } else { return true; }
|
}
/**
| }
/**
|
Zeile 393 | Zeile 448 |
---|
{ cache_forums(); return $forum_cache[$fid]['parentlist'];
|
{ cache_forums(); return $forum_cache[$fid]['parentlist'];
|
} }
/**
| } }
/**
|
* Build a parent list of a specific forum, suitable for querying * * @param int The forum ID
| * Build a parent list of a specific forum, suitable for querying * * @param int The forum ID
|
Zeile 410 | Zeile 465 |
---|
if(!$parentlist) { $parentlist = get_parent_list($fid);
|
if(!$parentlist) { $parentlist = get_parent_list($fid);
|
}
| }
|
$parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
| $parentsexploded = explode(",", $parentlist); $builtlist = "("; $sep = '';
|
Zeile 436 | Zeile 491 |
---|
{ $forum_cache = $cache->read("forums", 1); return $forum_cache;
|
{ $forum_cache = $cache->read("forums", 1); return $forum_cache;
|
}
| }
|
if(!$forum_cache) {
| if(!$forum_cache) {
|
Zeile 448 | Zeile 503 |
---|
} } return $forum_cache;
|
} } return $forum_cache;
|
}
| }
|
/** * Produce a friendly error message page *
| /** * Produce a friendly error message page *
|
Zeile 516 | Zeile 571 |
---|
"location1" => 0, "location2" => 0 );
|
"location1" => 0, "location2" => 0 );
|
$db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'");
| $db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'", 1);
|
$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']); if($mybb->user['uid']) {
| $url = htmlspecialchars_uni($_SERVER['REQUEST_URI']); if($mybb->user['uid']) {
|
Zeile 557 | Zeile 612 |
---|
$url = htmlspecialchars($url); eval("\$redirectpage = \"".$templates->get("redirect")."\";"); output_page($redirectpage);
|
$url = htmlspecialchars($url); eval("\$redirectpage = \"".$templates->get("redirect")."\";"); output_page($redirectpage);
|
} else
| } else
|
{ $url = str_replace("#", "&#", $url); $url = str_replace("&", "&", $url);
| { $url = str_replace("#", "&#", $url); $url = str_replace("&", "&", $url);
|
Zeile 662 | Zeile 717 |
---|
}
// Collect group permissions.
|
}
// Collect group permissions.
|
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];
| $gid = $user_cache[$uid]['usergroup']; if($user_cache[$uid]['additionalgroups']) { $gid .= ",".$user_cache[$uid]['additionalgroups']; }
|
$groupperms = usergroup_permissions($gid);
// Store group permissions in user cache.
| $groupperms = usergroup_permissions($gid);
// Store group permissions in user cache.
|
Zeile 690 | Zeile 749 |
---|
{ $groupscache = $cache->read("usergroups"); }
|
{ $groupscache = $cache->read("usergroups"); }
|
|
|
$groups = explode(",", $gid); if(count($groups) == 1)
|
$groups = explode(",", $gid); if(count($groups) == 1)
|
{
| {
|
return $groupscache[$gid]; } foreach($groups as $gid)
| return $groupscache[$gid]; } foreach($groups as $gid)
|
Zeile 713 | Zeile 773 |
---|
{ $permbit = ""; }
|
{ $permbit = ""; }
|
$zerogreater = 0;
|
|
if(in_array($perm, $groupzerogreater))
|
if(in_array($perm, $groupzerogreater))
|
{
| {
|
if($access == 0) { $usergroup[$perm] = 0;
|
if($access == 0) { $usergroup[$perm] = 0;
|
$zerogreater = 1; } } if(($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) && $zerogreater != 1) {
| continue; } }
if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) {
|
$usergroup[$perm] = $access; } }
| $usergroup[$perm] = $access; } }
|
Zeile 734 | Zeile 795 |
---|
/** * Fetch the display group properties for a specific display group
|
/** * Fetch the display group properties for a specific display group
|
*
| *
|
* @param int The group ID to fetch the display properties for * @return array Array of display properties for the group */
| * @param int The group ID to fetch the display properties for * @return array Array of display properties for the group */
|
Zeile 745 | Zeile 806 |
---|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
| }
|
$displaygroup = array(); $group = $groupscache[$gid]; foreach($displaygroupfields as $field)
| $displaygroup = array(); $group = $groupscache[$gid]; foreach($displaygroupfields as $field)
|
Zeile 766 | Zeile 827 |
---|
function forum_permissions($fid=0, $uid=0, $gid=0) { global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;
|
function forum_permissions($fid=0, $uid=0, $gid=0) { global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;
|
| static $cached_forum_permissions;
|
if($uid == 0) { $uid = $mybb->user['uid']; } if(!$gid || $gid == 0) // If no group, we need to fetch it {
|
if($uid == 0) { $uid = $mybb->user['uid']; } if(!$gid || $gid == 0) // If no group, we need to fetch it {
|
if($uid != $mybb->user['uid'])
| if($uid != 0 && $uid != $mybb->user['uid'])
|
{ if($usercache[$uid]) {
| { if($usercache[$uid]) {
|
Zeile 807 | Zeile 868 |
---|
} if($fid) // Fetch the permissions for a single forum {
|
} if($fid) // Fetch the permissions for a single forum {
|
$permissions = fetch_forum_permissions($fid, $gid, $groupperms);
| if(!$cached_forum_permissions[$gid][$fid]) { $cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms); } return $cached_forum_permissions_permissions[$gid][$fid];
|
} else {
|
} else {
|
foreach($forum_cache as $forum)
| if(!$cached_forum_permissions[$gid])
|
{
|
{
|
$permissions[$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
| foreach($forum_cache as $forum) { $cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms); }
|
}
|
}
|
| return $cached_forum_permissions[$gid];
|
}
|
}
|
return $permissions;
| |
}
/**
| }
/**
|
Zeile 833 | Zeile 901 |
---|
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
$groups = explode(",", $gid);
|
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
$groups = explode(",", $gid);
|
|
|
if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
|
if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
|
{
| { $groupperms['fid'] = $fid; $groupperms['gid'] = $gid;
|
return $groupperms; }
|
return $groupperms; }
|
|
|
$current_permissions = array(); foreach($groups as $gid)
|
$current_permissions = array(); foreach($groups as $gid)
|
{
| {
|
if($groupscache[$gid]) {
|
if($groupscache[$gid]) {
|
// If this forum has permissions set if($fpermcache[$fid][$gid])
| $level_permissions = $fpermcache[$fid][$gid]; // If our permissions arn't inherited we need to figure them out if(empty($level_permissions)) { $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents)) { foreach($parents as $parent_id) { if(!empty($fpermcache[$parent_id][$gid])) { $level_permissions = $fpermcache[$parent_id][$gid]; break; } } // If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions)) { $level_permissions = $groupscache[$gid]; } } } foreach($level_permissions as $permission => $access)
|
{
|
{
|
$level_permissions = $fpermcache[$fid][$gid]; foreach($level_permissions as $permission => $access)
| if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
|
{
|
{
|
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission]) { $current_permissions[$permission] = $access; }
| $current_permissions[$permission] = $access;
|
} } } } if(count($current_permissions) == 0)
|
} } } } if(count($current_permissions) == 0)
|
{
| {
|
$current_permissions = $groupperms; } return $current_permissions;
| $current_permissions = $groupperms; } return $current_permissions;
|
Zeile 871 | Zeile 962 |
---|
* Check the password given on a certain forum for validity * * @param int The forum ID
|
* Check the password given on a certain forum for validity * * @param int The forum ID
|
* @param string The plain text password for the forum
| * @param boolean The Parent ID
|
*/
|
*/
|
function check_forum_password($fid, $password="")
| function check_forum_password($fid, $pid=0)
|
{
|
{
|
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang; $showform = 1;
| global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache; $showform = true; if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache) { return false; } }
|
|
|
| // Loop through each of parent forums to ensure we have a password for them too $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents)) { foreach($parents as $parent_id) { if($parent_id == $fid || $parent_id == $pid) { continue; } if($forum_cache[$parent_id]['password'] != "") { check_forum_password($parent_id, $fid); } } } $password = $forum_cache[$fid]['password'];
|
if($password) { if($mybb->input['pwverify'])
| if($password) { if($mybb->input['pwverify'])
|
Zeile 885 | Zeile 1006 |
---|
if($password == $mybb->input['pwverify']) { my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
|
if($password == $mybb->input['pwverify']) { my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
|
$showform = 0; }
| $showform = false; }
|
else { eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
|
else { eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
|
$showform = 1;
| $showform = true;
|
} } else { if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid]))
|
} } else { if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid]))
|
{ $showform = 1; } else { $showform = 0; } } } else { $showform = 0; } if($showform) {
| { $showform = true; } else { $showform = false; } } } else { $showform = false; }
if($showform) {
|
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']); eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform);
| $_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']); eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform);
|
Zeile 934 | Zeile 1056 |
---|
if($uid < 1) { $uid = $mybb->user['uid'];
|
if($uid < 1) { $uid = $mybb->user['uid'];
|
} if(!isset($modpermscache[$uid][$fid]))
| } if(!isset($modpermscache[$fid][$uid]))
|
{ if(!$parentslist) { $parentslist = get_parent_list($fid); }
|
{ if(!$parentslist) { $parentslist = get_parent_list($fid); }
|
|
|
$sql = build_parent_list($fid, "fid", "OR", $parentslist);
|
$sql = build_parent_list($fid, "fid", "OR", $parentslist);
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."moderators WHERE uid='$uid' AND $sql ");
| $query = $db->simple_select(TABLE_PREFIX."moderators", "*", "uid='{$uid}' AND {$sql}");
|
$perms = $db->fetch_array($query);
|
$perms = $db->fetch_array($query);
|
$modpermscache[$uid][$fid] = $perms; }
| $modpermscache[$fid][$uid] = $perms; }
|
else {
|
else {
|
$perms = $modpermscache[$uid][$fid];
| $perms = $modpermscache[$fid][$uid];
|
}
|
}
|
|
|
return $perms;
|
return $perms;
|
}
| }
|
/** * Checks if a moderator has permissions to perform an action in a specific forum *
| /** * Checks if a moderator has permissions to perform an action in a specific forum *
|
Zeile 975 | Zeile 1095 |
---|
$uid = $mybb->user['uid']; }
|
$uid = $mybb->user['uid']; }
|
if($mybb->usergroup['issupermod'] == "yes")
| $user_perms = user_permissions($uid); if($user_perms['issupermod'] == "yes")
|
{ return "yes"; }
| { return "yes"; }
|
Zeile 983 | Zeile 1104 |
---|
{ if(!$fid) {
|
{ if(!$fid) {
|
$query = $db->simple_select(TABLE_PREFIX.'moderators', 'mid', "uid={$uid}", array('limit' => 1));
| $query = $db->simple_select(TABLE_PREFIX.'moderators', 'COUNT(*) as count', "uid={$uid}", array('limit' => 1));
|
$modcheck = $db->fetch_array($query);
|
$modcheck = $db->fetch_array($query);
|
if($modcheck['mid'])
| if($modcheck['count'] > 0)
|
{ return "yes"; }
| { return "yes"; }
|
Zeile 1056 | Zeile 1177 |
---|
} eval("\$posticons = \"".$templates->get("posticons")."\";"); return $posticons;
|
} eval("\$posticons = \"".$templates->get("posticons")."\";"); return $posticons;
|
}
/**
| }
/**
|
* MyBB setcookie() wrapper. * * @param string The cookie identifier.
| * MyBB setcookie() wrapper. * * @param string The cookie identifier.
|
Zeile 1156 | Zeile 1277 |
---|
/** * Set a serialised cookie array.
|
/** * Set a serialised cookie array.
|
*
| *
|
* @param string The cookie identifier. * @param int The cookie content id. * @param string The value to set the cookie to.
| * @param string The cookie identifier. * @param int The cookie content id. * @param string The value to set the cookie to.
|
Zeile 1168 | Zeile 1289 |
---|
$newcookie[$id] = $value; $newcookie = addslashes(serialize($newcookie)); my_setcookie("mybb[$name]", $newcookie);
|
$newcookie[$id] = $value; $newcookie = addslashes(serialize($newcookie)); my_setcookie("mybb[$name]", $newcookie);
|
}
| }
|
/** * Returns the serverload of the system. *
| /** * Returns the serverload of the system. *
|
Zeile 1178 | Zeile 1299 |
---|
function get_server_load() { global $lang;
|
function get_server_load() { global $lang;
|
if(strtolower(substr(PHP_OS, 0, 3)) === 'win') { return $lang->unknown; } elseif(@file_exists("/proc/loadavg")) { $load = @file_get_contents("/proc/loadavg"); $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4);
| $serverload = array();
if(my_strtolower(substr(PHP_OS, 0, 3)) !== 'win') { if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg")) { $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); }
|
if(!$serverload)
|
if(!$serverload)
|
{
| { if(@ini_get('safe_mode') == 'On') { return $lang->unknown; } // Suhosin likes to throw a warning if exec is disabled then die - weird if($func_blacklist = @ini_get('suhosin.executor.func.blacklist')) { if(strpos(",".$func_blacklist.",", 'exec') !== false) { return $lang->unknown; } } // PHP disabled functions? if($func_blacklist = @ini_get('disable_functions')) { if(strpos(",".$func_blacklist.",", 'exec') !== false) { return $lang->unknown; } }
|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
|
| if(!is_array($serverload)) { return $lang->unknown; } } } else { return $lang->unknown; }
$returnload = trim($serverload[0]);
return $returnload; }
/** * Updates the forum statistics with specific values (or addition/subtraction of the previous value) * * @param array Array of items being updated (numthreads,numposts,numusers,lastuser) */ function update_stats($changes=array()) { global $cache, $db;
$stats = $cache->read("stats");
$counters = array('numthreads', 'numposts', 'numusers'); $update = array(); foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $new_stats[$counter] = $stats[$counter] + $changes[$counter]; } else { $new_stats[$counter] = $changes[$counter]; } // Less than 0? That's bad if($new_stats[$counter] < 0) { $new_stats[$counter] = 0; }
|
}
|
}
|
| }
// Fetch latest user if the user count is changing if(array_key_exists('numusers', $changes) || array_key_exists('lastuser', $changes)) { $query = $db->simple_select(TABLE_PREFIX."users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1)); $lastmember = $db->fetch_array($query); $new_stats['lastuid'] = $lastmember['uid']; $new_stats['lastusername'] = $lastmember['username']; } if(is_array($stats)) { $stats = array_merge($stats, $new_stats);
|
} else {
|
} else {
|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
| $stats = $new_stats;
|
}
|
}
|
$returnload = trim($serverload[0]); if(!$returnload) { $returnload = $lang->unknown; } return $returnload;
| $cache->update("stats", $stats);
|
}
/**
|
}
/**
|
* Update the forum counters for a specific forum
| * Updates the forum counters with a specific value (or addition/subtraction of the previous value)
|
* * @param int The forum ID
|
* * @param int The forum ID
|
| * @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)
|
*/
|
*/
|
function update_forum_count($fid)
| function update_forum_counters($fid, $changes=array())
|
{ global $db, $cache;
|
{ global $db, $cache;
|
| $update_query = array();
$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts');
// Fetch above counters for this forum $query = $db->simple_select(TABLE_PREFIX."forums", implode(",", $counters), "fid='{$fid}'"); $forum = $db->fetch_array($query);
foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $update_query[$counter] = $forum[$counter] + $changes[$counter]; } else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if($update_query[$counter] < 0) { $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query(TABLE_PREFIX."forums", $update_query, "fid='".intval($fid)."'"); }
// Guess we should update the statistics too? if(isset($update_query['threads']) || isset($update_query['posts'])) { $new_stats = array(); if(array_key_exists('threads', $update_query)) { $threads_diff = $update_query['threads'] - $forum['threads']; if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}"; } else { $new_stats['numthreads'] = "{$threads_diff}"; } } if(array_key_exists('posts', $update_query)) { $posts_diff = $update_query['posts'] - $forum['posts']; if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}"; } else { $new_stats['numposts'] = "{$posts_diff}"; } } update_stats($new_stats); } // Update last post info update_forum_lastpost($fid); }
/** * Update the last post information for a specific forum * * @param int The forum ID */ function update_forum_lastpost($fid) { global $db;
|
// Fetch the last post for this forum $query = $db->query(" SELECT tid, lastpost, lastposter, lastposteruid, subject
| // Fetch the last post for this forum $query = $db->query(" SELECT tid, lastpost, lastposter, lastposteruid, subject
|
Zeile 1227 | Zeile 1505 |
---|
"); $lastpost = $db->fetch_array($query);
|
"); $lastpost = $db->fetch_array($query);
|
// Fetch the number of threads and replies in this forum (Approved only) $query = $db->query(" SELECT COUNT(*) AS threads, SUM(replies) AS replies FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%' "); $count = $db->fetch_array($query); $count['posts'] = $count['threads'] + $count['replies'];
// Fetch the number of threads and replies in this forum (Unapproved only) $query = $db->query(" SELECT COUNT(*) AS threads FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%' "); $unapproved_count['threads'] = $db->fetch_field($query, "threads"); $query = $db->query(" SELECT SUM(unapprovedposts) AS posts FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND closed NOT LIKE 'moved|%' "); $unapproved_count['posts'] = $db->fetch_field($query, "posts");
$update_count = array( "posts" => intval($count['posts']), "threads" => intval($count['threads']), "unapprovedposts" => intval($unapproved_count['posts']), "unapprovedthreads" => intval($unapproved_count['threads']),
| $updated_forum = array(
|
"lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']),
| "lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']),
|
Zeile 1262 | Zeile 1513 |
---|
"lastpostsubject" => $db->escape_string($lastpost['subject']) );
|
"lastpostsubject" => $db->escape_string($lastpost['subject']) );
|
$db->update_query(TABLE_PREFIX."forums", $update_count, "fid='{$fid}'");
| $db->update_query(TABLE_PREFIX."forums", $updated_forum, "fid='{$fid}'");
|
}
/**
|
}
/**
|
* Update the thread counters for a specific thread
| * Updates the thread counters with a specific value (or addition/subtraction of the previous value) * * @param int The thread ID * @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1) */ function update_thread_counters($tid, $changes=array()) { global $db;
$update_query = array(); $counters = array('replies', 'unapprovedposts', 'attachmentcount');
// Fetch above counters for this thread $query = $db->simple_select(TABLE_PREFIX."threads", implode(",", $counters), "tid='{$tid}'"); $thread = $db->fetch_array($query); foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $update_query[$counter] = $thread[$counter] + $changes[$counter]; } else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if($update_query[$counter] < 0) { $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query(TABLE_PREFIX."threads", $update_query, "tid='".intval($tid)."'"); }
update_thread_data($tid); }
/** * Update the first post and lastpost data for a specific thread
|
* * @param int The thread ID */
|
* * @param int The thread ID */
|
function update_thread_count($tid)
| function update_thread_data($tid)
|
{
|
{
|
global $db, $cache; $query = $db->query(" SELECT COUNT(*) AS replies FROM ".TABLE_PREFIX."posts WHERE tid='$tid' AND visible='1' "); $replies = $db->fetch_array($query); $treplies = $replies['replies'] - 1; if($treplies < 0) { $treplies = 0; }
| global $db;
|
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
| FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
|
WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline DESC LIMIT 1"
|
WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline DESC LIMIT 1"
|
);
| );
|
$lastpost = $db->fetch_array($query);
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
$lastpost = $db->fetch_array($query);
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) WHERE p.tid='$tid'
| FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) WHERE p.tid='$tid'
|
ORDER BY p.dateline ASC
|
ORDER BY p.dateline ASC
|
LIMIT 0,1
| LIMIT 1
|
"); $firstpost = $db->fetch_array($query);
|
"); $firstpost = $db->fetch_array($query);
|
|
|
if(!$firstpost['username']) { $firstpost['username'] = $firstpost['postusername']; }
|
if(!$firstpost['username']) { $firstpost['username'] = $firstpost['postusername']; }
|
|
|
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername']; }
|
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername']; }
|
|
|
if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username']; $lastpost['uid'] = $firstpost['uid']; $lastpost['dateline'] = $firstpost['dateline'];
|
if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username']; $lastpost['uid'] = $firstpost['uid']; $lastpost['dateline'] = $firstpost['dateline'];
|
}
| }
|
$lastpost['username'] = $db->escape_string($lastpost['username']); $firstpost['username'] = $db->escape_string($firstpost['username']);
|
$lastpost['username'] = $db->escape_string($lastpost['username']); $firstpost['username'] = $db->escape_string($firstpost['username']);
|
// Unapproved posts $query = $db->query(" SELECT COUNT(*) AS totunposts FROM ".TABLE_PREFIX."posts WHERE tid='$tid' AND visible='0' "); $nounposts = $db->fetch_field($query, "totunposts");
// Update the attachment count for this thread update_thread_attachment_count($tid); $db->query(" UPDATE ".TABLE_PREFIX."threads SET username='".$firstpost['username']."', uid='".intval($firstpost['uid'])."', lastpost='".intval($lastpost['dateline'])."', lastposter='".$lastpost['username']."', lastposteruid='".intval($lastpost['uid'])."', replies='$treplies', unapprovedposts='$nounposts' WHERE tid='$tid' ");
| $update_array = array( 'username' => $firstpost['username'], 'uid' => intval($firstpost['uid']), 'lastpost' => intval($lastpost['dateline']), 'lastposter' => $lastpost['username'], 'lastposteruid' => intval($lastpost['uid']), ); $db->update_query(TABLE_PREFIX."threads", $update_array, "tid='{$tid}'");
|
}
|
}
|
/** * Updates the number of attachments for a specific thread * * @param int The thread ID */
| function update_forum_count($fid) { die("Depreciated function call: update_forum_count"); } function update_thread_count($tid) { die("Depreciated function call: update_thread_count"); }
|
function update_thread_attachment_count($tid) {
|
function update_thread_attachment_count($tid) {
|
global $db; $query = $db->query(" SELECT COUNT(*) AS attachment_count FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid) WHERE p.tid='$tid' "); $attachment_count = $db->fetch_field($query, "attachment_count"); $db->query(" UPDATE ".TABLE_PREFIX."threads SET attachmentcount='{$attachment_count}' WHERE tid='$tid' ");
| die("Depreciated function call: update_thread_attachment_count");
|
}
/**
| }
/**
|
Zeile 1404 | Zeile 1681 |
---|
*/ function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid") {
|
*/ function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid") {
|
global $db, $forum_cache, $fjumpcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;
| global $db, $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;
|
$pid = intval($pid); if($permissions)
| $pid = intval($pid); if($permissions)
|
Zeile 1444 | Zeile 1721 |
---|
$optionselected = "selected=\"selected\""; $selecteddone = 1; }
|
$optionselected = "selected=\"selected\""; $selecteddone = 1; }
|
| $forum['name'] = htmlspecialchars_uni($forum['name']);
|
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";"); if($forum_cache[$forum['fid']]) {
| eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";"); if($forum_cache[$forum['fid']]) {
|
Zeile 1576 | Zeile 1856 |
---|
"editor_size_x_small", "editor_size_small", "editor_size_medium",
|
"editor_size_x_small", "editor_size_small", "editor_size_medium",
|
| "editor_size_large",
|
"editor_size_x_large", "editor_size_xx_large", "editor_color_white",
| "editor_size_x_large", "editor_size_xx_large", "editor_color_white",
|
Zeile 1860 | Zeile 2141 |
---|
$ip = $_SERVER['REMOTE_ADDR']; } }
|
$ip = $_SERVER['REMOTE_ADDR']; } }
|
global $db; $ip = $db->escape_string(preg_replace("#([^.0-9 ]*)#", $ip, ""));
| $ip = preg_replace("#([^.0-9 ]*)#", "", $ip);
|
return $ip; }
| return $ip; }
|
Zeile 1873 | Zeile 2154 |
---|
* @return string The friendly file size */ function get_friendly_size($size)
|
* @return string The friendly file size */ function get_friendly_size($size)
|
{
| {
|
global $lang;
if($size >= 1073741824) { $size = round(($size / 1073741824), 2) . " " . $lang->size_gb;
|
global $lang;
if($size >= 1073741824) { $size = round(($size / 1073741824), 2) . " " . $lang->size_gb;
|
}
| }
|
elseif($size >= 1048576)
|
elseif($size >= 1048576)
|
{
| {
|
$size = round(($size / 1048576), 2) . " " . $lang->size_mb; } elseif($size >= 1024)
|
$size = round(($size / 1048576), 2) . " " . $lang->size_mb; } elseif($size >= 1024)
|
{
| {
|
$size = round(($size / 1024), 2) . " " . $lang->size_kb;
|
$size = round(($size / 1024), 2) . " " . $lang->size_kb;
|
}
| }
|
elseif($size == 0) { $size = "0 ".$lang->size_bytes;
|
elseif($size == 0) { $size = "0 ".$lang->size_bytes;
|
}
| }
|
else { $size = $size . " " . $lang->size_bytes;
| else { $size = $size . " " . $lang->size_bytes;
|
Zeile 1910 | Zeile 2191 |
---|
global $cache, $attachtypes;
if(!$attachtypes)
|
global $cache, $attachtypes;
if(!$attachtypes)
|
{
| {
|
$attachtypes = $cache->read("attachtypes"); }
|
$attachtypes = $cache->read("attachtypes"); }
|
| $directory = ""; if(defined("IN_PORTAL")) { global $change_dir; $directory = $change_dir."/"; }
|
$ext = strtolower($ext); if($attachtypes[$ext]['icon']) {
|
$ext = strtolower($ext); if($attachtypes[$ext]['icon']) {
|
return "<img src=\"".$attachtypes[$ext]['icon']."\" border=\"0\" alt=\".$ext File\" />";
| return "<img src=\"{$directory}".$attachtypes[$ext]['icon']."\" border=\"0\" alt=\".$ext File\" />";
|
} else {
|
} else {
|
return "<img src=\"images/attachtypes/unknown.gif\" border=\"0\" alt=\".$ext File\" />";
| return "<img src=\"{$directory}images/attachtypes/unknown.gif\" border=\"0\" alt=\".$ext File\" />";
|
} }
| } }
|
Zeile 1961 | Zeile 2251 |
---|
if($forum['password'] != "") { if($_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
|
if($forum['password'] != "") { if($_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
|
{
| {
|
$pwverified = 0; } }
| $pwverified = 0; } }
|
Zeile 2107 | Zeile 2397 |
---|
$newnav[0]['url'] = $navbits[0]['url']; unset($GLOBALS['navbits']); $GLOBALS['navbits'] = $newnav;
|
$newnav[0]['url'] = $navbits[0]['url']; unset($GLOBALS['navbits']); $GLOBALS['navbits'] = $newnav;
|
}
/**
| }
/**
|
* Builds a URL to an archive mode page * * @param string The type of page (thread|announcement|forum)
| * Builds a URL to an archive mode page * * @param string The type of page (thread|announcement|forum)
|
Zeile 2169 | Zeile 2459 |
---|
$gzipen = "Disabled"; } echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
|
$gzipen = "Disabled"; } echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
|
echo "<html lang=\"en\">";
| echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">";
|
echo "<head>"; echo "<title>MyBB Debug Information</title>"; echo "</head>";
| echo "<head>"; echo "<title>MyBB Debug Information</title>"; echo "</head>";
|
Zeile 2243 | Zeile 2533 |
---|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
| echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
|
echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", $templates->uncached_templates)."</td>\n";
| echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", $templates->uncached_templates)."</td>\n";
|
Zeile 2258 | Zeile 2548 |
---|
/** * Outputs the correct page headers.
|
/** * Outputs the correct page headers.
|
*/
| */
|
function send_page_headers() { global $mybb;
| function send_page_headers() { global $mybb;
|
Zeile 2364 | Zeile 2654 |
---|
elseif($months > 1) { $nicetime['months'] = $months." ".$lang->months;
|
elseif($months > 1) { $nicetime['months'] = $months." ".$lang->months;
|
}
| }
|
if($weeks == 1) {
| if($weeks == 1) {
|
Zeile 2404 | Zeile 2694 |
---|
if($seconds == 1) {
|
if($seconds == 1) {
|
$nicetime['seconds'] = "1 ".$lang->seconds;
| $nicetime['seconds'] = "1 ".$lang->second;
|
} elseif($seconds > 1) {
| } elseif($seconds > 1) {
|
Zeile 2470 | Zeile 2760 |
---|
foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
|
foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
|
{ $groupslist .= $comma.$gid; $comma = ",";
| { $groupslist .= $comma.$gid; $comma = ",";
|
$donegroup[$gid] = 1; } }
| $donegroup[$gid] = 1; } }
|
Zeile 2493 | Zeile 2783 |
---|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb;
|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb;
|
|
|
if($uid == $mybb->user['uid'])
|
if($uid == $mybb->user['uid'])
|
{
| {
|
$user = $mybb->user; } else
|
$user = $mybb->user; } else
|
{
| {
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid' "); $user = $db->fetch_array($query);
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid' "); $user = $db->fetch_array($query);
|
}
| }
|
$usergroups = ""; $usergroups = $user['additionalgroups'].",";
| $usergroups = ""; $usergroups = $user['additionalgroups'].",";
|
Zeile 2526 | Zeile 2816 |
---|
if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
}
| }
|
$db->query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate
| $db->query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate
|
Zeile 2556 | Zeile 2846 |
---|
else { if(isset($_SERVER['PATH_INFO']))
|
else { if(isset($_SERVER['PATH_INFO']))
|
{ $location = $_SERVER['PATH_INFO']; }
| { $location = $_SERVER['PATH_INFO']; }
|
elseif(isset($_ENV['PATH_INFO'])) { $location = $_SERVER['PATH_INFO']; } elseif(isset($_ENV['PHP_SELF']))
|
elseif(isset($_ENV['PATH_INFO'])) { $location = $_SERVER['PATH_INFO']; } elseif(isset($_ENV['PHP_SELF']))
|
{
| {
|
$location = $_ENV['PHP_SELF']; } else
| $location = $_ENV['PHP_SELF']; } else
|
Zeile 2578 | Zeile 2868 |
---|
elseif(isset($_ENV['QUERY_STRING'])) { $location = "?".$_ENV['QUERY_STRING'];
|
elseif(isset($_ENV['QUERY_STRING'])) { $location = "?".$_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 2681 | Zeile 2971 |
---|
} }
|
} }
|
if(!$tid)
| if($tid == 0)
|
{ $themeselect .= "</select>"; } return $themeselect;
|
{ $themeselect .= "</select>"; } return $themeselect;
|
}
/**
| }
/**
|
* Custom function for htmlspecialchars which takes in to account unicode * * @param string The string to format
| * Custom function for htmlspecialchars which takes in to account unicode * * @param string The string to format
|
Zeile 2701 | Zeile 2991 |
---|
$message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("\"",""",$message);
|
$message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("\"",""",$message);
|
$message = str_replace(" ", " ", $message);
| |
return $message; }
| return $message; }
|
Zeile 2749 | Zeile 3038 |
---|
if($mybb->settings['wordwrap'] > 0) {
|
if($mybb->settings['wordwrap'] > 0) {
|
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0 ", $message);
| 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']}})#", "$0 ", $message); }
|
} return $message; }
| } return $message; }
|
Zeile 2827 | Zeile 3123 |
---|
*/ function get_age($birthday) {
|
*/ function get_age($birthday) {
|
$bday = explode("-", $birthday); if($bday[2] < 1970) { $years = 1970-$bday[2]; $year = $bday[2]+($years*2); $stamp = mktime(0, 0, 0, $bday[1], $bday[0], $year)-($years*31556926*2); } else { $stamp = mktime(0, 0, 0, $bday[1], $bday[0], $bday[2]); } $age = floor((time()-$stamp)/31556926); return $age;
| $bday = explode("-", $birthday); if(!$bday[2]) { return; }
list($day, $month, $year) = explode("-", my_date("j-n-Y", time(), 0, 0));
$age = $year-$bday[2];
if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1]) { --$age; } return $age;
|
}
/**
| }
/**
|
Zeile 2901 | Zeile 3199 |
---|
}
return $string_length;
|
}
return $string_length;
|
}
| }
|
/** * Cuts a string at a specified point, mb strings accounted for
| /** * Cuts a string at a specified point, mb strings accounted for
|
Zeile 2918 | Zeile 3216 |
---|
if($length != "") { $cut_string = mb_substr($string, $start, $length);
|
if($length != "") { $cut_string = mb_substr($string, $start, $length);
|
} else
| } else
|
{ $cut_string = mb_substr($string, $start);
|
{ $cut_string = mb_substr($string, $start);
|
} } else {
| } } else {
|
if($length != "") { $cut_string = substr($string, $start, $length);
| if($length != "") { $cut_string = substr($string, $start, $length);
|
Zeile 2950 | Zeile 3248 |
---|
if(function_exists("mb_strtolower")) { $string = mb_strtolower($string);
|
if(function_exists("mb_strtolower")) { $string = mb_strtolower($string);
|
} else
| } else
|
{ $string = strtolower($string); }
| { $string = strtolower($string); }
|
Zeile 3078 | Zeile 3376 |
---|
* @param string The Username of the profile. * @param int The user id of the profile. * @param string The target frame
|
* @param string The Username of the profile. * @param int The user id of the profile. * @param string The target frame
|
| * @param string Any onclick javascript.
|
* @return string The url to the profile. */
|
* @return string The url to the profile. */
|
function build_profile_link($username="", $uid=0, $target="")
| function build_profile_link($username="", $uid=0, $target="", $onclick="")
|
{ global $lang;
| { global $lang;
|
Zeile 3101 | Zeile 3400 |
---|
{ $target = " target=\"{$target}\""; }
|
{ $target = " target=\"{$target}\""; }
|
return "<a href=\"".get_profile_link($uid)."\"{$target}>{$username}</a>";
| if(!empty($onclick)) { $onclick = " onclick=\"{$onclick}\""; } return "<a href=\"".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
} }
| } }
|
Zeile 3146 | Zeile 3449 |
---|
}
/**
|
}
/**
|
* Get the username of a user id.
| * Get the user data of a user id.
|
* * @param int The user id of the user.
|
* * @param int The user id of the user.
|
* @return string The username of the user.
| * @return array The user data.
|
*/ function get_user($uid) {
| */ function get_user($uid) {
|
Zeile 3386 | Zeile 3689 |
---|
*/ function validate_email_format($email) {
|
*/ function validate_email_format($email) {
|
if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email) || strpos($email, ' ') !== false)
| if(strpos($email, ' ') !== false)
|
{ return false; }
|
{ return false; }
|
else { return true; }
| // 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.-]+$/si", $email);
|
}
/**
| }
/**
|
Zeile 3420 | Zeile 3721 |
---|
while($setting = $db->fetch_array($query)) {
|
while($setting = $db->fetch_array($query)) {
|
$setting['value'] = str_replace("\"", "\\\"", $setting['value']); $settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
| |
$mybb->settings[$setting['name']] = $setting['value'];
|
$mybb->settings[$setting['name']] = $setting['value'];
|
| $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
} $settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">"; $file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
| } $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);
|
Zeile 3436 | Zeile 3737 |
---|
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references) * * @param string Decimal value of a character reference
|
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references) * * @param string Decimal value of a character reference
|
*/
| */
|
function dec_to_utf8($src) { $dest = '';
| function dec_to_utf8($src) { $dest = '';
|
Zeile 3480 | Zeile 3781 |
---|
* @return array The array of banned usernames. */ function get_banned_usernames()
|
* @return array The array of banned usernames. */ function get_banned_usernames()
|
{ global $mybb;
| { global $mybb;
|
$banned_usernames = explode(",", $mybb->settings['bannedusernames']); $banned_usernames = array_map("trim", $banned_usernames); $banned_usernames = array_map("strtolower", $banned_usernames);
| $banned_usernames = explode(",", $mybb->settings['bannedusernames']); $banned_usernames = array_map("trim", $banned_usernames); $banned_usernames = array_map("strtolower", $banned_usernames);
|
Zeile 3526 | Zeile 3827 |
---|
* * @param string The email address. * @return boolean True if banned, false if not banned
|
* * @param string The email address. * @return boolean True if banned, false if not banned
|
*/
| */
|
function is_banned_email($email) { $banned_emails = get_banned_emails();
| function is_banned_email($email) { $banned_emails = get_banned_emails();
|
Zeile 3571 | Zeile 3872 |
---|
} } return false;
|
} } return false;
|
| }
/** * Fetch the contents of a remote fle. * * @param string The URL of the remote file * @return string The remote file contents. */ function fetch_remote_file($url) { if(function_exists("curl_init")) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); return $data; } else if(function_exists("fsockopen")) { $url = parse_url($url); if(!$url['host']) { return false; } if(!$url['port']) { $url['port'] = 80; } if(!$url['path']) { $url['path'] = "/"; } if($url['query']) { $url['path'] .= "?{$url['path']}"; } $fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10); @stream_set_timeout($fp, 10); if(!$fp) { return false; } $headers = "GET {$url['path']} HTTP/1.1\r\n"; $headers .= "Host: {$url['host']}\r\n"; $headers .= "Connection: Close\r\n\r\n"; if(!@fwrite($fp, $headers)) { return false; } while(!feof($fp)) { $data .= fgets($fp, 12800); } fclose($fp); $data = explode("\r\n\r\n", $data, 2); return $data[1]; } else { return @implode("", @file($url)); } }
/** * Unicode function for php function chr() * * @param string The character * @return mixed The unicoded chr() */ function unicode_chr($c) { if($c <= 0x7F) { return chr($c); } 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) . chr(0x80 | $c & 0x3F); } elseif($c <= 0x10FFFF) { return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); } else { return false; }
|
}
/**
| }
/**
|