Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/eula.html *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/eula.html *
|
* $Id: functions.php 3177 2007-06-29 07:51:12Z 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 32 | Zeile 31 |
---|
if(strstr(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1";
|
if(strstr(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1";
|
}
| }
|
else
|
else
|
{
| {
|
$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1"; } if($mybb->settings['gzipoutput'] != "no")
|
$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1"; } if($mybb->settings['gzipoutput'] != "no")
|
{
| {
|
$gzipen = "Enabled"; } else
| $gzipen = "Enabled"; } else
|
Zeile 58 | Zeile 57 |
---|
if(isset($mybb->input['debug'])) { debug_page();
|
if(isset($mybb->input['debug'])) { debug_page();
|
}
| }
|
} $contents = str_replace("<debugstuff>", "", $contents); $contents = $plugins->run_hooks("pre_output_page", $contents);
| } $contents = str_replace("<debugstuff>", "", $contents); $contents = $plugins->run_hooks("pre_output_page", $contents);
|
Zeile 72 | Zeile 71 |
---|
else { $contents = gzip_encode($contents);
|
else { $contents = gzip_encode($contents);
|
} }
header("Content-type: text/html; charset={$lang->settings['charset']}");
echo $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. if(($mybb->settings['useshutdownfunc'] == "no"|| phpversion() >= '5.0.5') && $mybb->use_shutdown != true) { run_shutdown();
|
$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) { run_shutdown();
|
}
| }
|
}
/** * Adds a function to the list of functions to run on shutdown. * * @param string The name of the function.
|
}
/** * Adds a function to the list of functions to run on shutdown. * * @param string The name of the function.
|
*/
| */
|
function add_shutdown($name) { global $shutdown_functions;
| function add_shutdown($name) { global $shutdown_functions;
|
Zeile 114 | Zeile 113 |
---|
if($done_shutdown == true) { return;
|
if($done_shutdown == true) { return;
|
}
| }
|
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct if(!is_object($db))
| // If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct if(!is_object($db))
|
Zeile 134 | Zeile 133 |
---|
{ require_once MYBB_ROOT."inc/class_datacache.php"; $cache = new datacache;
|
{ require_once MYBB_ROOT."inc/class_datacache.php"; $cache = new datacache;
|
}
| }
|
// And finaly.. we have the PHP developers to thank for this "hack" which fixes a problem THEY created if(!is_object($plugins) && !defined("NO_PLUGINS")) {
| // And finaly.. we have the PHP developers to thank for this "hack" which fixes a problem THEY created if(!is_object($plugins) && !defined("NO_PLUGINS")) {
|
Zeile 143 | Zeile 142 |
---|
$plugins = new pluginSystem; $plugins->load(); }
|
$plugins = new pluginSystem; $plugins->load(); }
|
|
|
// We have some shutdown queries needing to be run if(is_array($db->shutdown_queries)) {
| // We have some shutdown queries needing to be run if(is_array($db->shutdown_queries)) {
|
Zeile 158 | Zeile 157 |
---|
if(is_array($shutdown_functions)) { foreach($shutdown_functions as $function)
|
if(is_array($shutdown_functions)) { foreach($shutdown_functions as $function)
|
{
| {
|
$function(); } }
| $function(); } }
|
Zeile 194 | Zeile 193 |
---|
$db->delete_query(TABLE_PREFIX."mailqueue", "mid='{$email['mid']}'");
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
|
$db->delete_query(TABLE_PREFIX."mailqueue", "mid='{$email['mid']}'");
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
|
}
| }
|
// Update the mailqueue cache and remove the lock $cache->updatemailqueue(time(), 0); }
| // Update the mailqueue cache and remove the lock $cache->updatemailqueue(time(), 0); }
|
Zeile 222 | 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); } if($lang->settings['htmllang']) {
|
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents); } 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 253 | Zeile 255 |
---|
function my_date($format, $stamp="", $offset="", $ty=1) { global $mybb, $lang, $mybbadmin, $plugins;
|
function my_date($format, $stamp="", $offset="", $ty=1) { global $mybb, $lang, $mybbadmin, $plugins;
|
|
|
// If the stamp isn't set, use time() if(empty($stamp)) {
| // If the stamp isn't set, use time() if(empty($stamp)) {
|
Zeile 288 | Zeile 290 |
---|
} } if($offset == "-")
|
} } if($offset == "-")
|
{
| {
|
$offset = 0; } $date = gmdate($format, $stamp + ($offset * 3600));
| $offset = 0; } $date = gmdate($format, $stamp + ($offset * 3600));
|
Zeile 310 | Zeile 312 |
---|
$plugins->run_hooks_by_ref("my_date", $date);
return $date;
|
$plugins->run_hooks_by_ref("my_date", $date);
return $date;
|
}
| }
|
/** * Sends an email using PHP's mail function, formatting it appropriately. *
| /** * Sends an email using PHP's mail function, formatting it appropriately. *
|
Zeile 326 | Zeile 328 |
---|
global $db, $mybb, $lang;
if(empty($charset))
|
global $db, $mybb, $lang;
if(empty($charset))
|
{
| {
|
$charset = $lang->settings['charset']; }
| $charset = $lang->settings['charset']; }
|
Zeile 334 | Zeile 336 |
---|
if(my_strlen(trim($from)) == 0) { $from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";
|
if(my_strlen(trim($from)) == 0) { $from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";
|
}
| }
|
$headers .= "From: {$from}\n"; $headers .= "Return-Path: {$mybb->settings['adminemail']}\n"; if($_SERVER['SERVER_NAME'])
| $headers .= "From: {$from}\n"; $headers .= "Return-Path: {$mybb->settings['adminemail']}\n"; if($_SERVER['SERVER_NAME'])
|
Zeile 348 | Zeile 350 |
---|
else { $http_host = "unknown.local";
|
else { $http_host = "unknown.local";
|
}
| }
|
$headers .= "Message-ID: <". md5(uniqid(time()))."@{$http_host}>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/plain; charset=\"{$charset}\"\n";
| $headers .= "Message-ID: <". md5(uniqid(time()))."@{$http_host}>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/plain; charset=\"{$charset}\"\n";
|
Zeile 356 | 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
| $headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}\n";
// For some reason sendmail/qmail doesn't like \r\n
|
Zeile 369 | Zeile 375 |
---|
{ $headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers); $message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);
|
{ $headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers); $message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);
|
}
| }
|
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 486 | Zeile 537 |
---|
* @param array Array of errors to be shown * @param string The title of the error message * @return string The inline error HTML
|
* @param array Array of errors to be shown * @param string The title of the error message * @return string The inline error HTML
|
*/
| */
|
function inline_error($errors, $title="") { global $theme, $mybb, $db, $lang, $templates;
| function inline_error($errors, $title="") { global $theme, $mybb, $db, $lang, $templates;
|
Zeile 520 | 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 693 | Zeile 744 |
---|
function usergroup_permissions($gid=0) { global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
function usergroup_permissions($gid=0) { global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
$groups = explode(",", $gid); if(count($groups) == 1) { return $groupscache[$gid];
|
}
$groups = explode(",", $gid); if(count($groups) == 1) { return $groupscache[$gid];
|
}
| }
|
foreach($groups as $gid) { if(trim($gid) == "" || !$groupscache[$gid])
| foreach($groups as $gid) { if(trim($gid) == "" || !$groupscache[$gid])
|
Zeile 722 | 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;
|
| continue;
|
}
|
}
|
$zerogreater = 1;
| |
}
|
}
|
if(($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) && $zerogreater != 1)
| if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit)
|
{ $usergroup[$perm] = $access; }
| { $usergroup[$perm] = $access; }
|
Zeile 752 | Zeile 804 |
---|
global $cache, $groupscache, $displaygroupfields;
if(!is_array($groupscache))
|
global $cache, $groupscache, $displaygroupfields;
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups"); } $displaygroup = array();
| $groupscache = $cache->read("usergroups"); } $displaygroup = array();
|
Zeile 781 | Zeile 833 |
---|
$uid = $mybb->user['uid']; } if(!$gid || $gid == 0) // If no group, we need to fetch it
|
$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]) { $query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid'"); $usercache[$uid] = $db->fetch_array($query);
|
{ if($usercache[$uid]) { $query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid'"); $usercache[$uid] = $db->fetch_array($query);
|
}
| }
|
$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid); }
| $gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid); }
|
Zeile 800 | Zeile 852 |
---|
$gid .= ",".$mybb->user['additionalgroups']; } $groupperms = $mybb->usergroup;
|
$gid .= ",".$mybb->user['additionalgroups']; } $groupperms = $mybb->usergroup;
|
} } if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache)
| } } if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache)
|
{ return false; } } if(!is_array($fpermcache))
|
{ return false; } } if(!is_array($fpermcache))
|
{
| {
|
$fpermcache = $cache->read("forumpermissions"); } if($fid) // Fetch the permissions for a single forum
| $fpermcache = $cache->read("forumpermissions"); } if($fid) // Fetch the permissions for a single forum
|
Zeile 849 | 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; }
|
Zeile 861 | Zeile 915 |
---|
{ 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) { $current_permissions = $groupperms;
|
} if(count($current_permissions) == 0) { $current_permissions = $groupperms;
|
}
| }
|
return $current_permissions; }
| return $current_permissions; }
|
Zeile 887 | 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; } }
|
|
|
if($password)
| // 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 == $mybb->input['pwverify']) { my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
|
{ if($mybb->input['pwverify']) { 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;
| $showform = true;
|
} else {
|
} else {
|
$showform = 0;
| $showform = false;
|
} } } else {
|
} } } else {
|
$showform = 0;
| $showform = false;
|
}
|
}
|
|
|
if($showform) { $_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
| if($showform) { $_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
|
Zeile 1205 | Zeile 1311 |
---|
} 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]);
|
Zeile 1224 | Zeile 1351 |
---|
return $returnload; }
|
return $returnload; }
|
|
|
/** * 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) *
|
* @param array Array of items being updated (numthreads,numposts,numusers)
| * @param array Array of items being updated (numthreads,numposts,numusers,lastuser)
|
*/ function update_stats($changes=array()) { global $cache, $db;
$stats = $cache->read("stats");
|
*/ function update_stats($changes=array()) { global $cache, $db;
$stats = $cache->read("stats");
|
$counters = array('numthreads','numposts','numusers');
| $counters = array('numthreads', 'numposts', 'numusers');
|
$update = array(); foreach($counters as $counter) {
| $update = array(); foreach($counters as $counter) {
|
Zeile 1244 | Zeile 1371 |
---|
{ // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
|
{ // 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] = $stats[$counter] + $changes[$counter]; } else
|
Zeile 1260 | Zeile 1387 |
---|
}
// Fetch latest user if the user count is changing
|
}
// Fetch latest user if the user count is changing
|
if(array_key_exists('numusers', $changes))
| 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'];
|
{ $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);
| if(is_array($stats)) { $stats = array_merge($stats, $new_stats);
|
Zeile 1287 | Zeile 1414 |
---|
function update_forum_counters($fid, $changes=array()) { global $db, $cache;
|
function update_forum_counters($fid, $changes=array()) { global $db, $cache;
|
|
|
$update_query = array();
|
$update_query = array();
|
|
|
$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts');
|
$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);
|
// 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)
| foreach($counters as $counter)
|
{ if(array_key_exists($counter, $changes)) {
| { if(array_key_exists($counter, $changes)) {
|
Zeile 1324 | Zeile 1451 |
---|
}
// Guess we should update the statistics too?
|
}
// Guess we should update the statistics too?
|
if($update_query['threads'] || $update_query['posts'])
| if(isset($update_query['threads']) || isset($update_query['posts']))
|
{ $new_stats = array(); if(array_key_exists('threads', $update_query))
| { $new_stats = array(); if(array_key_exists('threads', $update_query))
|
Zeile 1350 | Zeile 1477 |
---|
{ $new_stats['numposts'] = "{$posts_diff}"; }
|
{ $new_stats['numposts'] = "{$posts_diff}"; }
|
}
| }
|
update_stats($new_stats); }
|
update_stats($new_stats); }
|
|
|
// Update last post info update_forum_lastpost($fid);
|
// Update last post info update_forum_lastpost($fid);
|
}
| }
|
/** * Update the last post information for a specific forum
| /** * Update the last post information for a specific forum
|
Zeile 1442 | Zeile 1570 |
---|
* @param int The thread ID */ function update_thread_data($tid)
|
* @param int The thread ID */ function update_thread_data($tid)
|
{ global $db; $query = $db->query("
| { global $db; $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)
| 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)
|
Zeile 1553 | 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 1593 | 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 2063 | Zeile 2194 |
---|
{ $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 2094 | Zeile 2234 |
---|
cache_forums(); } if(!is_array($permissioncache))
|
cache_forums(); } if(!is_array($permissioncache))
|
{
| {
|
$permissioncache = forum_permissions(); } foreach($forum_cache as $fid => $forum)
| $permissioncache = forum_permissions(); } foreach($forum_cache as $fid => $forum)
|
Zeile 2104 | Zeile 2244 |
---|
$perms = $permissioncache[$forum['fid']]; } else
|
$perms = $permissioncache[$forum['fid']]; } else
|
{
| {
|
$perms = $mybb->usergroup; } $pwverified = 1; if($forum['password'] != "")
|
$perms = $mybb->usergroup; } $pwverified = 1; if($forum['password'] != "")
|
{
| {
|
if($_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
if($_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
} }
| } }
|
if($perms['canview'] == "no" || $pwverified == 0) { if($unviewableforums)
| if($perms['canview'] == "no" || $pwverified == 0) { if($unviewableforums)
|
Zeile 2144 | Zeile 2284 |
---|
/** * Build the breadcrumb navigation trail from the specified items
|
/** * Build the breadcrumb navigation trail from the specified items
|
*
| *
|
* @return The formatted breadcrumb navigation trail */ function build_breadcrumb()
| * @return The formatted breadcrumb navigation trail */ function build_breadcrumb()
|
Zeile 2154 | Zeile 2294 |
---|
eval("\$navsep = \"".$templates->get("nav_sep")."\";");
if(is_array($navbits))
|
eval("\$navsep = \"".$templates->get("nav_sep")."\";");
if(is_array($navbits))
|
{
| {
|
reset($navbits); foreach($navbits as $key => $navbit) {
| reset($navbits); foreach($navbits as $key => $navbit) {
|
Zeile 2164 | Zeile 2304 |
---|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
}
| }
|
$navsize = count($navbits); $navbit = $navbits[$navsize-1]; if($nav)
| $navsize = count($navbits); $navbit = $navbits[$navsize-1]; if($nav)
|
Zeile 2183 | Zeile 2323 |
---|
* @param string The URL of the item to add */ function add_breadcrumb($name, $url="")
|
* @param string The URL of the item to add */ function add_breadcrumb($name, $url="")
|
{
| {
|
global $navbits;
$navsize = count($navbits);
| global $navbits;
$navsize = count($navbits);
|
Zeile 2302 | Zeile 2442 |
---|
function debug_page() { global $db, $querytime, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime;
|
function debug_page() { global $db, $querytime, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime;
|
|
|
$totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $querytime); $querytime = $maintimer->format($querytime);
| $totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $querytime); $querytime = $maintimer->format($querytime);
|
Zeile 2319 | 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 2381 | Zeile 2521 |
---|
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";
|
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";
|
echo "</tr>\n"; echo "<tr>\n";
| echo "</tr>\n"; echo "<tr>\n";
|
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n"; echo "</tr>\n"; echo "</table>\n";
| echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n"; echo "</tr>\n"; echo "</table>\n";
|
Zeile 2847 | Zeile 2987 |
---|
*/ function htmlspecialchars_uni($message) {
|
*/ function htmlspecialchars_uni($message) {
|
$message = preg_replace("#&([^\#])(?![a-z1-4]{1,10};)#i", "&$1", $message); // Fix & but allow unicode
| $message = preg_replace("#&(?!\#[0-9]+;)#si", "&", $message); // Fix & but allow unicode
|
$message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("\"",""",$message);
| $message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("\"",""",$message);
|
Zeile 2898 | 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 2986 | Zeile 3133 |
---|
$age = $year-$bday[2];
|
$age = $year-$bday[2];
|
if(($month == $bday[1] && $day < $bday[1]) || $month < $bday[1])
| if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
|
{ --$age; }
| { --$age; }
|
Zeile 3105 | Zeile 3252 |
---|
else { $string = strtolower($string);
|
else { $string = strtolower($string);
|
}
return $string; }
| }
return $string; }
|
/** * Finds a needle in a haystack and returns it position, mb strings accounted for *
| /** * Finds a needle in a haystack and returns it position, mb strings accounted for *
|
Zeile 3123 | Zeile 3270 |
---|
if($needle == '') { return false;
|
if($needle == '') { return false;
|
}
| }
|
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset);
|
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset);
|
} else
| } else
|
{ $position = strpos($haystack, $needle, $offset); }
return $position;
|
{ $position = strpos($haystack, $needle, $offset); }
return $position;
|
}
| }
|
/** * ups the case of a string, mb strings accounted for *
| /** * ups the case of a string, mb strings accounted for *
|
Zeile 3162 | Zeile 3309 |
---|
* * @param string The string to un-htmlentitize. * @return int The un-htmlentitied' string.
|
* * @param string The string to un-htmlentitize. * @return int The un-htmlentitied' string.
|
*/
| */
|
function unhtmlentities($string) { // Replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
function unhtmlentities($string) { // Replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
|
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
}
| }
|
/** * Get the event poster. * * @param array The event data array. * @return string The link to the event poster.
|
/** * Get the event poster. * * @param array The event data array. * @return string The link to the event poster.
|
*/
| */
|
function get_event_poster($event) { if($event['username']) { $event_poster = "<a href=\"member.php?action=profile&uid=".$event['author']."\">" . format_name($event['username'], $event['usergroup'], $event['displaygroup']) . "</a>";
|
function get_event_poster($event) { if($event['username']) { $event_poster = "<a href=\"member.php?action=profile&uid=".$event['author']."\">" . format_name($event['username'], $event['usergroup'], $event['displaygroup']) . "</a>";
|
}
| }
|
else { $event_poster = $lang->guest;
| else { $event_poster = $lang->guest;
|
Zeile 3213 | Zeile 3360 |
---|
/** * Get the profile link.
|
/** * Get the profile link.
|
* * @param int The user id of the profile.
| * * @param int The user id of the profile.
|
* @return string The url to the profile. */ function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL); return $link;
|
* @return string The url to the profile. */ function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL); return $link;
|
}
| }
|
/** * Build the profile link.
| /** * Build the profile link.
|
Zeile 3267 | Zeile 3414 |
---|
* @param int The forum id of the forum. * @param int (Optional) The page number of the forum. * @return string The url to the forum.
|
* @param int The forum id of the forum. * @param int (Optional) The page number of the forum. * @return string The url to the forum.
|
*/
| */
|
function get_forum_link($fid, $page=0) { if($page > 0)
| function get_forum_link($fid, $page=0) { if($page > 0)
|
Zeile 3278 | Zeile 3425 |
---|
else { return str_replace("{fid}", $fid, FORUM_URL);
|
else { return str_replace("{fid}", $fid, FORUM_URL);
|
}
| }
|
}
/**
| }
/**
|
Zeile 3294 | Zeile 3441 |
---|
{ $thread_link = str_replace("{tid}", $tid, THREAD_URL_PAGED); return str_replace("{page}", $page, $thread_link);
|
{ $thread_link = str_replace("{tid}", $tid, THREAD_URL_PAGED); return str_replace("{page}", $page, $thread_link);
|
} else {
| } else {
|
return str_replace("{tid}", $tid, THREAD_URL); } }
/**
|
return str_replace("{tid}", $tid, THREAD_URL); } }
/**
|
* 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 3317 | Zeile 3464 |
---|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
{ return $user_cache[$uid]; } else {
| { return $user_cache[$uid]; } else {
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."users
| $query = $db->query(" SELECT * FROM ".TABLE_PREFIX."users
|
Zeile 3547 | Zeile 3694 |
---|
return false; } // Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
|
return false; } // Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
|
return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^?=\/]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email);
| return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email);
|
}
/**
| }
/**
|
Zeile 3614 | Zeile 3761 |
---|
$dest .= chr(0x80 | ($src & 0x003f)); } elseif($src <= 0x10ffff)
|
$dest .= chr(0x80 | ($src & 0x003f)); } elseif($src <= 0x10ffff)
|
{
| {
|
$dest .= chr(0xf0 | ($src >> 18)); $dest .= chr(0x80 | (($src >> 12) & 0x3f)); $dest .= chr(0x80 | (($src >> 6) & 0x3f));
| $dest .= chr(0xf0 | ($src >> 18)); $dest .= chr(0x80 | (($src >> 12) & 0x3f)); $dest .= chr(0x80 | (($src >> 6) & 0x3f));
|
Zeile 3644 | Zeile 3791 |
---|
/** * Checks if a username has been disallowed for registration/use.
|
/** * Checks if a username has been disallowed for registration/use.
|
*
| *
|
* @param string The username * @return boolean True if banned, false if not banned */
| * @param string The username * @return boolean True if banned, false if not banned */
|
Zeile 3673 | Zeile 3820 |
---|
$banned_emails = array_map("trim", $banned_emails); $banned_emails = array_map("strtolower", $banned_emails); return $banned_emails;
|
$banned_emails = array_map("trim", $banned_emails); $banned_emails = array_map("strtolower", $banned_emails); return $banned_emails;
|
}
| }
|
/** * Check if a specific email address has been banned.
| /** * Check if a specific email address has been banned.
|
Zeile 3790 | Zeile 3937 |
---|
{ return @implode("", @file($url)); }
|
{ 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; }
|
}
/**
| }
/**
|