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 2277 2006-09-27 10:26:56Z chris $
| * $Id: functions.php 3508 2007-11-23 16:10:16Z 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;
|
echo $contents;
|
|
|
$plugins->run_hooks("post_output_page");
// If the use shutdown functionality is turned off, run any shutdown related items now.
|
$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();
|
} }
/**
| } }
/**
|
* Adds a function to the list of functions to run on shutdown. * * @param string The name of the function. */ function add_shutdown($name)
|
* 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;
if(function_exists($name))
| global $shutdown_functions;
if(function_exists($name))
|
Zeile 106 | Zeile 108 |
---|
*/ function run_shutdown() {
|
*/ function run_shutdown() {
|
global $db, $cache, $shutdown_functions, $done_shutdown;
| global $db, $cache, $plugins, $shutdown_functions, $done_shutdown;
|
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)) { require MYBB_ROOT."inc/config.php"; if(isset($config)) { require_once MYBB_ROOT."inc/db_".$config['dbtype'].".php"; $db = new databaseEngine; $db->connect($config['hostname'], $config['username'], $config['password']); $db->select_db($config['database']); } } // Cache object deconstructed? reconstruct if(!is_object($cache)) { 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")) { require_once MYBB_ROOT."inc/class_plugins.php"; $plugins = new pluginSystem; $plugins->load(); }
|
// We have some shutdown queries needing to be run if(is_array($db->shutdown_queries)) { // Loop through and run them all foreach($db->shutdown_queries as $query)
|
// We have some shutdown queries needing to be run if(is_array($db->shutdown_queries)) { // Loop through and run them all foreach($db->shutdown_queries as $query)
|
{
| {
|
$db->query($query); } }
// Run any shutdown functions if we have them if(is_array($shutdown_functions))
|
$db->query($query); } }
// Run any shutdown functions if we have them if(is_array($shutdown_functions))
|
{
| {
|
foreach($shutdown_functions as $function) { $function();
| foreach($shutdown_functions as $function) { $function();
|
Zeile 142 | Zeile 172 |
---|
function send_mail_queue($count=10) { global $db, $cache, $plugins;
|
function send_mail_queue($count=10) { global $db, $cache, $plugins;
|
|
|
$plugins->run_hooks("send_mail_queue_start");
// Check to see if the mail queue has messages needing to be sent
| $plugins->run_hooks("send_mail_queue_start");
// Check to see if the mail queue has messages needing to be sent
|
Zeile 168 | Zeile 198 |
---|
$cache->updatemailqueue(time(), 0); } $plugins->run_hooks("send_mail_queue_end");
|
$cache->updatemailqueue(time(), 0); } $plugins->run_hooks("send_mail_queue_end");
|
}
| }
|
/** * Parses the contents of a page before outputting it.
| /** * Parses the contents of a page before outputting it.
|
Zeile 191 | 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) { $contents = str_replace("<html", "<html dir=\"rtl\"", $contents); } if($lang->settings['htmllang']) {
|
if($lang->settings['rtl'] == 1) { $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 218 | Zeile 251 |
---|
* @param int The offset in hours that should be applied to times. (timezones) * @param int Whether or not to use today/yesterday formatting. * @return string The formatted timestamp.
|
* @param int The offset in hours that should be applied to times. (timezones) * @param int Whether or not to use today/yesterday formatting. * @return string The formatted timestamp.
|
*/
| */
|
function my_date($format, $stamp="", $offset="", $ty=1) { global $mybb, $lang, $mybbadmin, $plugins;
// If the stamp isn't set, use time() if(empty($stamp))
|
function my_date($format, $stamp="", $offset="", $ty=1) { global $mybb, $lang, $mybbadmin, $plugins;
// If the stamp isn't set, use time() if(empty($stamp))
|
{
| {
|
$stamp = time(); }
| $stamp = time(); }
|
Zeile 237 | Zeile 270 |
---|
$dstcorrection = $mybb->user['dst']; } elseif(defined("IN_ADMINCP"))
|
$dstcorrection = $mybb->user['dst']; } elseif(defined("IN_ADMINCP"))
|
{
| {
|
$offset = $mybbadmin['timezone']; $dstcorrection = $mybbadmin['dst']; }
| $offset = $mybbadmin['timezone']; $dstcorrection = $mybbadmin['dst']; }
|
Zeile 255 | Zeile 288 |
---|
$offset = "+".$offset; } }
|
$offset = "+".$offset; } }
|
}
| }
|
if($offset == "-") { $offset = 0;
| if($offset == "-") { $offset = 0;
|
Zeile 267 | Zeile 300 |
---|
$todaysdate = gmdate($format, $stamp + ($offset * 3600)); $yesterdaysdate = gmdate($format, ($stamp - 86400) + ($offset * 3600)); if($todaysdate == $date)
|
$todaysdate = gmdate($format, $stamp + ($offset * 3600)); $yesterdaysdate = gmdate($format, ($stamp - 86400) + ($offset * 3600)); if($todaysdate == $date)
|
{
| {
|
$date = $lang->today;
|
$date = $lang->today;
|
}
| }
|
elseif($yesterdaysdate == $date) { $date = $lang->yesterday; }
|
elseif($yesterdaysdate == $date) { $date = $lang->yesterday; }
|
}
| }
|
$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 311 | Zeile 344 |
---|
$http_host = $_SERVER['SERVER_NAME']; } else if($_SERVER['HTTP_HOST'])
|
$http_host = $_SERVER['SERVER_NAME']; } else if($_SERVER['HTTP_HOST'])
|
{
| {
|
$http_host = $_SERVER['HTTP_HOST']; } else { $http_host = "unknown.local";
|
$http_host = $_SERVER['HTTP_HOST']; } 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 325 | 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 354 | Zeile 392 |
---|
static $forumarraycache;
if($forumarraycache[$fid])
|
static $forumarraycache;
if($forumarraycache[$fid])
|
{
| {
|
return $forumarraycache[$fid]['parentlist']; } elseif($forum_cache[$fid])
| return $forumarraycache[$fid]['parentlist']; } elseif($forum_cache[$fid])
|
Zeile 365 | Zeile 403 |
---|
{ 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
| /** * Build a parent list of a specific forum, suitable for querying
|
Zeile 397 | Zeile 435 |
---|
/** * Load the forum cache in to memory
|
/** * Load the forum cache in to memory
|
| * * @param boolean True to force a reload of the cache
|
*/
|
*/
|
function cache_forums()
| function cache_forums($force=false)
|
{ global $forum_cache, $db, $cache;
|
{ global $forum_cache, $db, $cache;
|
| if($force == true) { $forum_cache = $cache->read("forums", 1); return $forum_cache; }
|
if(!$forum_cache) {
| if(!$forum_cache) {
|
Zeile 416 | Zeile 462 |
---|
/** * Produce a friendly error message page
|
/** * Produce a friendly error message page
|
*
| *
|
* @param string The error message to be shown * @param string The title of the message shown in the title of the page and the error table */ function error($error="", $title="")
|
* @param string The error message to be shown * @param string The title of the message shown in the title of the page and the error table */ function error($error="", $title="")
|
{
| {
|
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb;
if(!$error) { $error = $lang->unknown_error;
|
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb;
if(!$error) { $error = $lang->unknown_error;
|
}
| }
|
if(!$title) { $title = $mybb->settings['bbname'];
| if(!$title) { $title = $mybb->settings['bbname'];
|
Zeile 438 | Zeile 484 |
---|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage); exit;
|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage); exit;
|
}
| }
|
/** * Produce an error message for displaying inline on a page *
| /** * Produce an error message for displaying inline on a page *
|
Zeile 451 | Zeile 497 |
---|
{ global $theme, $mybb, $db, $lang, $templates; if(!$title)
|
{ global $theme, $mybb, $db, $lang, $templates; if(!$title)
|
{
| {
|
$title = $lang->please_correct_errors;
|
$title = $lang->please_correct_errors;
|
}
| }
|
if(!is_array($errors)) { $errors = array($errors);
|
if(!is_array($errors)) { $errors = array($errors);
|
}
| }
|
foreach($errors as $error) { $errorlist .= "<li>".$error."</li>\n"; } eval("\$errors = \"".$templates->get("error_inline")."\";"); return $errors;
|
foreach($errors as $error) { $errorlist .= "<li>".$error."</li>\n"; } eval("\$errors = \"".$templates->get("error_inline")."\";"); return $errors;
|
}
/**
| }
/**
|
* Presents the user with a "no permission" page */ function error_no_permission()
| * Presents the user with a "no permission" page */ function error_no_permission()
|
Zeile 480 | Zeile 526 |
---|
"location1" => 0, "location2" => 0 );
|
"location1" => 0, "location2" => 0 );
|
$db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'"); $url = $_SERVER['REQUEST_URI']; $url = str_replace("&", "&", $url);
| $db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'", 1); $url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
|
if($mybb->user['uid']) { $lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']);
| if($mybb->user['uid']) { $lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']);
|
Zeile 494 | Zeile 539 |
---|
} error($errorpage); }
|
} error($errorpage); }
|
|
|
/** * Redirect the user to a given URL with a given message *
| /** * Redirect the user to a given URL with a given message *
|
Zeile 517 | Zeile 562 |
---|
$title = $mybb->settings['bbname']; } if($mybb->settings['redirects'] == "on" && $mybb->user['showredirect'] != "no")
|
$title = $mybb->settings['bbname']; } if($mybb->settings['redirects'] == "on" && $mybb->user['showredirect'] != "no")
|
{ $url = str_replace("&", "&", $url);
| { $url = str_replace("&", "&", $url);
|
$url = htmlspecialchars($url); eval("\$redirectpage = \"".$templates->get("redirect")."\";"); output_page($redirectpage);
| $url = htmlspecialchars($url); eval("\$redirectpage = \"".$templates->get("redirect")."\";"); output_page($redirectpage);
|
Zeile 555 | Zeile 600 |
---|
{ $prev = $page - 1; eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");
|
{ $prev = $page - 1; eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");
|
}
| }
|
if($page < $pages) { $next = $page + 1;
| if($page < $pages) { $next = $page + 1;
|
Zeile 567 | Zeile 612 |
---|
$to = $pages; } elseif($page == $pages-1)
|
$to = $pages; } elseif($page == $pages-1)
|
{
| {
|
$to = $page+1; } elseif($page == $pages-2)
| $to = $page+1; } elseif($page == $pages-2)
|
Zeile 592 | Zeile 637 |
---|
eval("\$end = \"".$templates->get("multipage_end")."\";"); eval("\$multipage = \"".$templates->get("multipage")."\";"); return $multipage;
|
eval("\$end = \"".$templates->get("multipage_end")."\";"); eval("\$multipage = \"".$templates->get("multipage")."\";"); return $multipage;
|
}
| }
|
}
/**
| }
/**
|
Zeile 604 | Zeile 649 |
---|
function user_permissions($uid=0) { global $mybb, $cache, $groupscache, $user_cache;
|
function user_permissions($uid=0) { global $mybb, $cache, $groupscache, $user_cache;
|
|
|
// If no user id is specified, assume it is the current user if($uid == 0) {
| // If no user id is specified, assume it is the current user if($uid == 0) {
|
Zeile 616 | Zeile 661 |
---|
{ // We've already cached permissions for this user, return them. if($user_cache[$uid]['permissions'])
|
{ // We've already cached permissions for this user, return them. if($user_cache[$uid]['permissions'])
|
{
| {
|
return $user_cache[$uid]['permissions']; }
| return $user_cache[$uid]['permissions']; }
|
Zeile 627 | Zeile 672 |
---|
}
// 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 636 | Zeile 685 |
---|
} // This user is the current user, return their permissions else
|
} // This user is the current user, return their permissions else
|
{
| {
|
return $mybb->usergroup; } }
| return $mybb->usergroup; } }
|
Zeile 655 | Zeile 704 |
---|
{ $groupscache = $cache->read("usergroups"); }
|
{ $groupscache = $cache->read("usergroups"); }
|
|
|
$groups = explode(",", $gid); if(count($groups) == 1) {
| $groups = explode(",", $gid); if(count($groups) == 1) {
|
Zeile 667 | Zeile 717 |
---|
continue; } foreach($groupscache[$gid] as $perm => $access)
|
continue; } foreach($groupscache[$gid] as $perm => $access)
|
{
| {
|
if(!in_array($perm, $grouppermignore)) { if(isset($usergroup[$perm]))
| if(!in_array($perm, $grouppermignore)) { if(isset($usergroup[$perm]))
|
Zeile 678 | Zeile 728 |
---|
{ $permbit = ""; }
|
{ $permbit = ""; }
|
$zerogreater = 0;
|
|
if(in_array($perm, $groupzerogreater)) { if($access == 0) { $usergroup[$perm] = 0;
|
if(in_array($perm, $groupzerogreater)) { if($access == 0) { $usergroup[$perm] = 0;
|
$zerogreater = 1;
| continue;
|
} }
|
} }
|
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 718 | Zeile 769 |
---|
$displaygroup[$field] = $group[$field]; } return $displaygroup;
|
$displaygroup[$field] = $group[$field]; } return $displaygroup;
|
}
| }
|
/** * Build the forum permissions for a specific forum, user or group *
| /** * Build the forum permissions for a specific forum, user or group *
|
Zeile 731 | Zeile 782 |
---|
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($uid == 0) { $uid = $mybb->user['uid'];
|
Zeile 772 | Zeile 823 |
---|
} 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); } else { foreach($forum_cache as $forum)
| if(!$cached_forum_permissions[$gid][$fid])
|
{
|
{
|
$permissions[$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
| $cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
|
}
|
}
|
| return $cached_forum_permissions_permissions[$gid][$fid]; } else { if(!$cached_forum_permissions[$gid]) { 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 796 | Zeile 854 |
---|
function fetch_forum_permissions($fid, $gid, $groupperms) { global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
|
function fetch_forum_permissions($fid, $gid, $groupperms) { global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
|
|
|
$groups = explode(",", $gid);
|
$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
|
{
| {
|
return $groupperms; }
|
return $groupperms; }
|
| $current_permissions = array();
|
foreach($groups as $gid) {
|
foreach($groups as $gid) {
|
if($gid && $groupscache[$gid])
| if($groupscache[$gid])
|
{
|
{
|
if(!is_array($fpermcache[$fid][$gid]))
| // If this forum has permissions set if($fpermcache[$fid][$gid])
|
{
|
{
|
continue; } foreach($fpermcache[$fid][$gid] as $perm => $access) { if($perm == "fid" || $perm == "gid" || $perm == "pid") { continue; } $permission = $forumpermissions[$perm]; if((is_numeric($access) && $access > $permission) || ($access == "yes" && $permission == "no") || !$permission) { $forumpermissions[$perm] = $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]) { $current_permissions[$permission] = $access; }
|
} } } }
|
} } } }
|
if(!isset($forumpermissions))
| if(count($current_permissions) == 0)
|
{
|
{
|
$forumpermissions = $groupperms;
| $current_permissions = $groupperms;
|
}
|
}
|
return $forumpermissions;
| return $current_permissions;
|
}
/** * Check the password given on a certain forum for validity
|
}
/** * Check the password given on a certain forum for validity
|
*
| *
|
* @param int The forum ID
|
* @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'])
|
{
| {
|
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;
| $showform = true;
|
} else {
|
} else {
|
$showform = 0;
| $showform = false;
|
} }
|
} }
|
}
| }
|
else {
|
else {
|
$showform = 0;
| $showform = false;
|
}
|
}
|
|
|
if($showform) {
|
if($showform) {
|
| $_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
|
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform); exit;
| eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform); exit;
|
Zeile 897 | Zeile 989 |
---|
{ $uid = $mybb->user['uid']; }
|
{ $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; } else
| $modpermscache[$fid][$uid] = $perms; } else
|
{
|
{
|
$perms = $modpermscache[$uid][$fid];
| $perms = $modpermscache[$fid][$uid];
|
}
|
}
|
|
|
return $perms; }
| return $perms; }
|
Zeile 937 | Zeile 1027 |
---|
$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 945 | Zeile 1036 |
---|
{ 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";
|
}
| }
|
else { return "no";
|
else { return "no";
|
} }
| } }
|
else { $modperms = get_moderator_permissions($fid, $uid);
| else { $modperms = get_moderator_permissions($fid, $uid);
|
Zeile 997 | Zeile 1088 |
---|
SELECT * FROM ".TABLE_PREFIX."icons ORDER BY name DESC
|
SELECT * FROM ".TABLE_PREFIX."icons ORDER BY name DESC
|
");
| ");
|
while($dbicon = $db->fetch_array($query)) { if($icon == $dbicon['iid'])
| while($dbicon = $db->fetch_array($query)) { if($icon == $dbicon['iid'])
|
Zeile 1008 | Zeile 1099 |
---|
else { $iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" />";
|
else { $iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" />";
|
}
| }
|
$listed++; if($listed == 9) { $iconlist .= "<br />"; $listed = 0;
|
$listed++; if($listed == 9) { $iconlist .= "<br />"; $listed = 0;
|
}
| }
|
} eval("\$posticons = \"".$templates->get("posticons")."\";"); return $posticons; }
|
} eval("\$posticons = \"".$templates->get("posticons")."\";"); return $posticons; }
|
| /** * MyBB setcookie() wrapper. * * @param string The cookie identifier. * @param string The cookie value. * @param int The timestamp of the expiry date. * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror) */
|
function my_setcookie($name, $value="", $expires="", $httponly=false) {
|
function my_setcookie($name, $value="", $expires="", $httponly=false) {
|
global $mybb, $sent_header; if($sent_header || headers_sent()) { return false; }
| global $mybb;
|
if(!$mybb->settings['cookiepath']) {
| if(!$mybb->settings['cookiepath']) {
|
Zeile 1045 | Zeile 1140 |
---|
else { $expires = time() + (60*60*24*365); // Make the cookie expire in a years time
|
else { $expires = time() + (60*60*24*365); // Make the cookie expire in a years time
|
} } else {
| } } else {
|
$expires = time() + intval($expires);
|
$expires = time() + intval($expires);
|
}
| }
|
$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']); $mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);
| $mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']); $mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);
|
Zeile 1062 | Zeile 1157 |
---|
$cookie .= "; expires=".gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires); } if(!empty($mybb->settings['cookiepath']))
|
$cookie .= "; expires=".gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires); } if(!empty($mybb->settings['cookiepath']))
|
{
| {
|
$cookie .= "; path={$mybb->settings['cookiepath']}";
|
$cookie .= "; path={$mybb->settings['cookiepath']}";
|
}
| }
|
if(!empty($mybb->settings['cookiedomain'])) { $cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
if(!empty($mybb->settings['cookiedomain'])) { $cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
}
| }
|
if($httponly == true) { $cookie .= "; HttpOnly"; } header($cookie, false);
|
if($httponly == true) { $cookie .= "; HttpOnly"; } header($cookie, false);
|
}
| }
|
/** * Unset a cookie set by MyBB.
|
/** * Unset a cookie set by MyBB.
|
* * @param string The cookie identifier. */
| * * @param string The cookie identifier. */
|
function my_unsetcookie($name) {
|
function my_unsetcookie($name) {
|
global $mybb, $sent_header; if($sent_header) { return false; }
$expires = time()-3600;
| global $mybb; $expires = -3600;
|
my_setcookie($name, "", $expires); }
| my_setcookie($name, "", $expires); }
|
Zeile 1101 | Zeile 1189 |
---|
* @param string The cookie identifier. * @param int The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
|
* @param string The cookie identifier. * @param int The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
|
*/
| */
|
function my_get_array_cookie($name, $id) { if(!isset($_COOKIE['mybb'][$name])) { return false;
|
function my_get_array_cookie($name, $id) { if(!isset($_COOKIE['mybb'][$name])) { return false;
|
}
| }
|
$cookie = unserialize($_COOKIE['mybb'][$name]); if(isset($cookie[$id])) {
| $cookie = unserialize($_COOKIE['mybb'][$name]); if(isset($cookie[$id])) {
|
Zeile 1117 | Zeile 1205 |
---|
{ return 0; }
|
{ return 0; }
|
}
/**
| }
/**
|
* 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.
|
* 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.
|
*/
| */
|
function my_set_array_cookie($name, $id, $value) { $cookie = $_COOKIE['mybb'];
| function my_set_array_cookie($name, $id, $value) { $cookie = $_COOKIE['mybb'];
|
Zeile 1143 | Zeile 1231 |
---|
function get_server_load() { global $lang;
|
function get_server_load() { global $lang;
|
if(strtolower(substr(PHP_OS, 0, 3)) === 'win')
| $serverload = array();
if(my_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);
| if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg")) { $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); }
|
if(!$serverload) {
|
if(!$serverload) {
|
| // 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('disabled_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; } $cache->update("stats", $stats); }
/** * Updates the forum counters with a specific value (or addition/subtraction of the previous value) * * @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_counters($fid, $changes=array()) { 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);
|
}
|
}
|
$returnload = trim($serverload[0]); if(!$returnload) { $returnload = $lang->unknown; } return $returnload;
| // Update last post info update_forum_lastpost($fid);
|
}
/**
|
}
/**
|
* Update the forum counters for a specific forum
| * Update the last post information for a specific forum
|
* * @param int The forum ID */
|
* * @param int The forum ID */
|
function update_forum_count($fid)
| function update_forum_lastpost($fid)
|
{
|
{
|
global $db, $cache;
| global $db;
|
// Fetch the last post for this forum $query = $db->query("
| // Fetch the last post for this forum $query = $db->query("
|
Zeile 1192 | Zeile 1432 |
---|
"); $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']), "lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject'])
|
"lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']), "lastposttid" => intval($lastpost['tid']), "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}'"); }
/** * 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 thread counters for a specific thread
| * 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"
|
Zeile 1261 | Zeile 1511 |
---|
$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' ORDER BY p.dateline ASC
|
WHERE p.tid='$tid' ORDER BY p.dateline ASC
|
LIMIT 0,1
| LIMIT 1
|
"); $firstpost = $db->fetch_array($query);
|
"); $firstpost = $db->fetch_array($query);
|
|
|
if(!$firstpost['username'])
|
if(!$firstpost['username'])
|
{
| {
|
$firstpost['username'] = $firstpost['postusername']; }
|
$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='".$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 1369 | Zeile 1608 |
---|
*/ 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 1409 | Zeile 1648 |
---|
$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 1416 | Zeile 1658 |
---|
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras); } }
|
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras); } }
|
}
| }
|
} } if($addselect)
| } } if($addselect)
|
Zeile 1451 | Zeile 1693 |
---|
function get_extension($file) { return strtolower(my_substr(strrchr($file, "."), 1));
|
function get_extension($file) { return strtolower(my_substr(strrchr($file, "."), 1));
|
}
| }
|
/** * Generates a random string.
|
/** * Generates a random string.
|
*
| *
|
* @param int The length of the string to generate. * @return string The random string. */
| * @param int The length of the string to generate. * @return string The random string. */
|
Zeile 1464 | Zeile 1706 |
---|
$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9"); $str; for($i = 1; $i <= $length; $i++)
|
$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9"); $str; for($i = 1; $i <= $length; $i++)
|
{
| {
|
$ch = rand(0, count($set)-1); $str .= $set[$ch]; }
| $ch = rand(0, count($set)-1); $str .= $set[$ch]; }
|
Zeile 1486 | Zeile 1728 |
---|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
| }
|
if($displaygroup != 0) { $usergroup = $displaygroup;
| if($displaygroup != 0) { $usergroup = $displaygroup;
|
Zeile 1541 | Zeile 1783 |
---|
"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 1588 | Zeile 1831 |
---|
*/ function build_clickable_smilies() {
|
*/ function build_clickable_smilies() {
|
global $db, $smiliecache, $theme, $templates, $lang, $mybb;
| global $db, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;
|
if($mybb->settings['smilieinserter'] != "off" && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) {
|
if($mybb->settings['smilieinserter'] != "off" && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) {
|
$smiliecount = 0;
| if(!$smiliecount) { $query = $db->simple_select(TABLE_PREFIX."smilies", "COUNT(*) as smilies"); $smiliecount = $db->fetch_field($query, "smilies"); }
|
if(!$smiliecache) {
|
if(!$smiliecache) {
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."smilies WHERE showclickable != 'no' ORDER BY disporder ");
| $query = $db->simple_select(TABLE_PREFIX."smilies", "*", "showclickable != 'no'", array('order_by' => 'disporder'));
|
while($smilie = $db->fetch_array($query)) { $smiliecache[$smilie['find']] = $smilie['image'];
|
while($smilie = $db->fetch_array($query)) { $smiliecache[$smilie['find']] = $smilie['image'];
|
$smiliecount++;
| |
} } unset($smilie);
| } } unset($smilie);
|
Zeile 1632 | Zeile 1874 |
---|
{ $smilies .= "<tr>\n"; }
|
{ $smilies .= "<tr>\n"; }
|
$find = $db->escape_string(htmlspecialchars($find));
| $find = htmlspecialchars_uni($find);
|
$smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n"; $i++; $counter++;
| $smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n"; $i++; $counter++;
|
Zeile 1753 | Zeile 1995 |
---|
"tid" => $tid, "action" => $db->escape_string($action), "data" => $db->escape_string($data),
|
"tid" => $tid, "action" => $db->escape_string($action), "data" => $db->escape_string($data),
|
"ipaddress" => $session->ipaddress
| "ipaddress" => $db->escape_string($session->ipaddress)
|
); $db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array); }
| ); $db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array); }
|
Zeile 1826 | Zeile 2068 |
---|
$ip = $_SERVER['REMOTE_ADDR']; } }
|
$ip = $_SERVER['REMOTE_ADDR']; } }
|
| $ip = preg_replace("#([^.0-9 ]*)#", "", $ip);
|
return $ip; }
| return $ip; }
|
Zeile 1852 | Zeile 2097 |
---|
$size = round(($size / 1024), 2) . " " . $lang->size_kb; } elseif($size == 0)
|
$size = round(($size / 1024), 2) . " " . $lang->size_kb; } elseif($size == 0)
|
{
| {
|
$size = "0 ".$lang->size_bytes; } else
| $size = "0 ".$lang->size_bytes; } else
|
Zeile 1860 | Zeile 2105 |
---|
$size = $size . " " . $lang->size_bytes; } return $size;
|
$size = $size . " " . $lang->size_bytes; } return $size;
|
}
| }
|
/** * Get the attachment icon for a specific file extension
| /** * Get the attachment icon for a specific file extension
|
Zeile 1869 | Zeile 2114 |
---|
* @return string The attachment icon */ function get_attachment_icon($ext)
|
* @return string The attachment icon */ function get_attachment_icon($ext)
|
{
| {
|
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 1896 | Zeile 2150 |
---|
{ global $db, $forum_cache, $permissioncache, $mybb, $unviewableforums, $unviewable, $templates, $forumpass;
|
{ global $db, $forum_cache, $permissioncache, $mybb, $unviewableforums, $unviewable, $templates, $forumpass;
|
$pid = intval($pid);
| $pid = intval($pid);
|
if(!$permissions) { $permissions = $mybb->usergroup;
| if(!$permissions) { $permissions = $mybb->usergroup;
|
Zeile 1919 | Zeile 2173 |
---|
else { $perms = $mybb->usergroup;
|
else { $perms = $mybb->usergroup;
|
}
| }
|
$pwverified = 1; if($forum['password'] != "") {
| $pwverified = 1; if($forum['password'] != "") {
|
Zeile 1931 | Zeile 2185 |
---|
if($perms['canview'] == "no" || $pwverified == 0) { if($unviewableforums)
|
if($perms['canview'] == "no" || $pwverified == 0) { if($unviewableforums)
|
{
| {
|
$unviewableforums .= ","; } $unviewableforums .= "'".$forum['fid']."'"; } } return $unviewableforums;
|
$unviewableforums .= ","; } $unviewableforums .= "'".$forum['fid']."'"; } } return $unviewableforums;
|
}
| }
|
/** * Fixes mktime() for dates earlier than 1970 *
| /** * Fixes mktime() for dates earlier than 1970 *
|
Zeile 1954 | Zeile 2208 |
---|
$format = str_replace("y", my_substr($year, -2), $format); return $format; }
|
$format = str_replace("y", my_substr($year, -2), $format); return $format; }
|
|
|
/** * Build the breadcrumb navigation trail from the specified items *
| /** * Build the breadcrumb navigation trail from the specified items *
|
Zeile 1963 | Zeile 2217 |
---|
function build_breadcrumb() { global $nav, $navbits, $templates, $theme, $lang;
|
function build_breadcrumb() { global $nav, $navbits, $templates, $theme, $lang;
|
eval("\$navsep = \"".$templates->get("nav_sep")."\";");
| eval("\$navsep = \"".$templates->get("nav_sep")."\";");
|
if(is_array($navbits)) { reset($navbits);
| if(is_array($navbits)) { reset($navbits);
|
Zeile 2034 | Zeile 2288 |
---|
if($pforumcache[$forumnav['pid']]) { build_forum_breadcrumb($forumnav['pid'], $archive);
|
if($pforumcache[$forumnav['pid']]) { build_forum_breadcrumb($forumnav['pid'], $archive);
|
}
| }
|
$navsize = count($navbits); $navbits[$navsize]['name'] = $forumnav['name']; if($archive == 1)
| $navsize = count($navbits); $navbits[$navsize]['name'] = $forumnav['name']; if($archive == 1)
|
Zeile 2102 | Zeile 2356 |
---|
break; case "forum": $url = "{$base_url}forum-{$id}.html";
|
break; case "forum": $url = "{$base_url}forum-{$id}.html";
|
break;
| break;
|
default: $url = $mybb->setings['bburl']."/archive/index.php"; }
| default: $url = $mybb->setings['bburl']."/archive/index.php"; }
|
Zeile 2132 | Zeile 2386 |
---|
$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 2150 | Zeile 2404 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n"; echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n"; echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Proccessing Time:</font></b></td>\n";
| echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">MySQL Processing Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">MySQL Processing Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";
|
echo "</tr>\n"; echo "<tr>\n";
| echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Extensions Used:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['dbtype']}, xml</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Global.php Processing Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$globaltime seconds</font></td>\n";
|
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Extensions Used:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['dbtype']}, xml</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Global.php Processing Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$globaltime seconds</font></td>\n";
|
echo "</tr>\n"; echo "<tr>\n";
| echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Version:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phpversion</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Server Load:</font></b></td>\n";
| echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Version:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phpversion</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Server Load:</font></b></td>\n";
|
Zeile 2190 | Zeile 2444 |
---|
echo "<h2>Template Statistics</h2>\n";
if(count($templates->cache) > 0)
|
echo "<h2>Template Statistics</h2>\n";
if(count($templates->cache) > 0)
|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
| { echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
echo "<tr>\n";
|
echo "<tr>\n";
|
echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\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 "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
| echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
|
Zeile 2205 | Zeile 2459 |
---|
if(count($templates->uncached_templates > 0)) { echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
if(count($templates->uncached_templates > 0)) { 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 "</tr>\n";
| echo "<tr>\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"; echo "</tr>\n";
|
Zeile 2217 | Zeile 2471 |
---|
echo "</body>"; echo "</html>"; exit;
|
echo "</body>"; echo "</html>"; exit;
|
}
/**
| }
/**
|
* Outputs the correct page headers. */ function send_page_headers() { global $mybb;
|
* Outputs the correct page headers. */ function send_page_headers() { global $mybb;
|
|
|
if($mybb->settings['nocacheheaders'] == "yes" && $mybb->settings['standardheaders'] != "yes") { header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
| if($mybb->settings['nocacheheaders'] == "yes" && $mybb->settings['standardheaders'] != "yes") { header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
|
Zeile 2253 | Zeile 2507 |
---|
$rids = implode($id, "','"); $rids = "'0','$rids'"; $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid IN($rids) AND reportstatus='0'");
|
$rids = implode($id, "','"); $rids = "'0','$rids'"; $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid IN($rids) AND reportstatus='0'");
|
} break;
| } break;
|
case "post": $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
| case "post": $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
|
Zeile 2367 | Zeile 2621 |
---|
if($seconds == 1) {
|
if($seconds == 1) {
|
$nicetime['seconds'] = "1 ".$lang->seconds;
| $nicetime['seconds'] = "1 ".$lang->second;
|
} elseif($seconds > 1) {
| } elseif($seconds > 1) {
|
Zeile 2402 | Zeile 2656 |
---|
/** * Add a user to a specific additional user group.
|
/** * Add a user to a specific additional user group.
|
* * @param int The user ID
| * * @param int The user ID
|
* @param int The user group ID to join */ function join_usergroup($uid, $joingroup)
| * @param int The user group ID to join */ function join_usergroup($uid, $joingroup)
|
Zeile 2501 | Zeile 2755 |
---|
* Get the current location taking in to account different web serves and systems * * @return string The current URL being accessed
|
* Get the current location taking in to account different web serves and systems * * @return string The current URL being accessed
|
*/
| */
|
function get_current_location() { if(defined("MYBB_LOCATION")) { return MYBB_LOCATION;
|
function get_current_location() { if(defined("MYBB_LOCATION")) { return MYBB_LOCATION;
|
}
| }
|
if(isset($_SERVER['REQUEST_URI'])) { $location = $_SERVER['REQUEST_URI'];
| if(isset($_SERVER['REQUEST_URI'])) { $location = $_SERVER['REQUEST_URI'];
|
Zeile 2523 | Zeile 2777 |
---|
$location = $_SERVER['PATH_INFO']; } elseif(isset($_ENV['PATH_INFO']))
|
$location = $_SERVER['PATH_INFO']; } elseif(isset($_ENV['PATH_INFO']))
|
{
| {
|
$location = $_SERVER['PATH_INFO']; } elseif(isset($_ENV['PHP_SELF'])) { $location = $_ENV['PHP_SELF'];
|
$location = $_SERVER['PATH_INFO']; } elseif(isset($_ENV['PHP_SELF'])) { $location = $_ENV['PHP_SELF'];
|
}
| }
|
else { $location = $_SERVER['PHP_SELF'];
| else { $location = $_SERVER['PHP_SELF'];
|
Zeile 2545 | Zeile 2799 |
---|
}
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"))
|
{
| {
|
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid'); foreach($post_array as $var) {
| $post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid'); foreach($post_array as $var) {
|
Zeile 2555 | Zeile 2809 |
---|
} } if(isset($addlock) && is_array($addloc))
|
} } if(isset($addlock) && is_array($addloc))
|
{
| {
|
$location .= "?".implode("&", $addloc); } }
| $location .= "?".implode("&", $addloc); } }
|
Zeile 2574 | Zeile 2828 |
---|
*/ function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0) {
|
*/ function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0) {
|
global $db, $themeselect, $tcache, $lang, $mybb;
| global $db, $themeselect, $tcache, $lang, $mybb, $limit;
|
if($tid == 0) { $themeselect = "<select name=\"$name\">"; $themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n"; $themeselect .= "<option value=\"0\">-----------</option>\n";
|
if($tid == 0) { $themeselect = "<select name=\"$name\">"; $themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n"; $themeselect .= "<option value=\"0\">-----------</option>\n";
|
}
| $tid = 1; }
|
if(!is_array($tcache))
|
if(!is_array($tcache))
|
{ $query = $db->query(" SELECT name, pid, tid, allowedgroups FROM ".TABLE_PREFIX."themes WHERE pid != 0 ORDER BY pid, name ");
| { $query = $db->simple_select(TABLE_PREFIX."themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));
|
while($theme = $db->fetch_array($query))
|
while($theme = $db->fetch_array($query))
|
{ $tcache[$theme['pid']][] = $theme; } } if(is_array($tcache)) {
| { $tcache[$theme['pid']][$theme['tid']] = $theme; } } if(is_array($tcache[$tid])) {
|
// Figure out what groups this user is in if($mybb->user['additionalgroups']) {
| // Figure out what groups this user is in if($mybb->user['additionalgroups']) {
|
Zeile 2603 | Zeile 2857 |
---|
} $in_groups[] = $mybb->user['usergroup'];
|
} $in_groups[] = $mybb->user['usergroup'];
|
foreach($tcache as $misc)
| foreach($tcache[$tid] as $theme)
|
{
|
{
|
foreach($misc as $theme)
| $sel = ""; // Make theme allowed groups into array $is_allowed = false; if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")
|
{
|
{
|
$sel = ""; // Make theme allowed groups into array $is_allowed = false; if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")
| $allowed_groups = explode(",", $theme['allowedgroups']); // See if groups user is in is allowed foreach($allowed_groups as $agid)
|
{
|
{
|
$allowed_groups = explode(",", $theme['allowedgroups']); // See if groups user is in is allowed foreach($allowed_groups as $agid)
| if(in_array($agid, $in_groups))
|
{
|
{
|
if(in_array($agid, $in_groups)) { $is_allowed = true; break; }
| $is_allowed = true; break;
|
} }
|
} }
|
// Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == 1)
| } // Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1) { if($theme['tid'] == $selected) { $sel = " selected=\"selected\""; } if($theme['pid'] != 0) { $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--"; } if(array_key_exists($theme['tid'], $tcache))
|
{
|
{
|
if($theme['tid'] == $selected) { $sel = " selected=\"selected\""; } 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); }
| build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
|
} } } }
|
} } } }
|
if(!$tid)
| if($tid == 0)
|
{ $themeselect .= "</select>"; }
|
{ $themeselect .= "</select>"; }
|
|
|
return $themeselect; }
|
return $themeselect; }
|
| |
/** * Custom function for htmlspecialchars which takes in to account unicode
| /** * Custom function for htmlspecialchars which takes in to account unicode
|
Zeile 2663 | Zeile 2918 |
---|
$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 2789 | Zeile 3043 |
---|
*/ 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[1]) || $month < $bday[1]) { --$age; } return $age;
|
}
/**
| }
/**
|
Zeile 2838 | Zeile 3094 |
---|
*/ function my_strlen($string) {
|
*/ function my_strlen($string) {
|
$string = preg_replace("#&\#(0-9]+);#", "-", $string); if(function_exists("mb_strlen")) { $string_length = mb_strlen($string); } else { $string_length = strlen($string); }
| global $lang;
$string = preg_replace("#&\#(0-9]+);#", "-", $string);
if(strtolower($lang->settings['charset']) == "utf-8") { // Get rid of any excess RTL and LTR override for they are the workings of the devil $string = str_replace(dec_to_utf8(8238), "", $string); $string = str_replace(dec_to_utf8(8237), "", $string);
// Remove dodgy whitspaces $string = str_replace(chr(0xCA), "", $string); } $string = trim($string);
if(function_exists("mb_strlen")) { $string_length = mb_strlen($string); } else { $string_length = strlen($string); }
|
|
|
return $string_length;
| return $string_length;
|
}
/**
| }
/**
|
Zeile 2885 | Zeile 3155 |
---|
}
return $cut_string;
|
}
return $cut_string;
|
| }
/** * lowers the case of a string, mb strings accounted for * * @param string The string to lower. * @return int The lowered string. */ function my_strtolower($string) { if(function_exists("mb_strtolower")) { $string = mb_strtolower($string); } else { $string = strtolower($string); }
return $string; }
/** * Finds a needle in a haystack and returns it position, mb strings accounted for * * @param string String to look in (haystack) * @param string What to look for (needle) * @param int (optional) How much to offset * @return int false on needle not found, integer position if found */ function my_strpos($haystack, $needle, $offset=0) { if($needle == '') { return false; }
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset); } else { $position = strpos($haystack, $needle, $offset); }
return $position; }
/** * ups the case of a string, mb strings accounted for * * @param string The string to up. * @return int The uped string. */ function my_strtoupper($string) { if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string); } else { $string = strtoupper($string); }
return $string;
|
}
/**
| }
/**
|
Zeile 2895 | Zeile 3232 |
---|
*/ function unhtmlentities($string) {
|
*/ function unhtmlentities($string) {
|
// replace numeric entities
| // Replace numeric entities
|
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
// replace literal entities
| // Replace literal entities
|
$trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
|
$trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
|
|
|
return strtr($string, $trans_tbl); }
| return strtr($string, $trans_tbl); }
|
Zeile 2957 | Zeile 3296 |
---|
* @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 2980 | Zeile 3320 |
---|
{ $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 3025 | Zeile 3369 |
---|
}
/**
|
}
/**
|
* 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 3072 | Zeile 3416 |
---|
$forum_cache = $cache->read("forums"); } if(!$forum_cache[$fid])
|
$forum_cache = $cache->read("forums"); } if(!$forum_cache[$fid])
|
{ return false;
| { return false;
|
} if($active_override != 1) {
| } if($active_override != 1) {
|
Zeile 3164 | Zeile 3508 |
---|
* @return string The comma seperated values of the inactivate forum. */ function get_inactive_forums()
|
* @return string The comma seperated values of the inactivate forum. */ function get_inactive_forums()
|
{
| {
|
global $forum_cache, $db, $cache, $inactiveforums;
if(!$forum_cache)
| global $forum_cache, $db, $cache, $inactiveforums;
if(!$forum_cache)
|
Zeile 3179 | Zeile 3523 |
---|
$inactive[] = $fid; foreach($forum_cache as $fid1 => $forum1) {
|
$inactive[] = $fid; foreach($forum_cache as $fid1 => $forum1) {
|
if(strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false)
| if(strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
|
{
|
{
|
$inactive[] = $fid;
| $inactive[] = $fid1;
|
} } }
| } } }
|
Zeile 3255 | Zeile 3599 |
---|
} // User can attempt another login return $loginattempts;
|
} // User can attempt another login return $loginattempts;
|
}
/**
| }
/**
|
* Validates the format of an email address. * * @param string The string to check.
| * Validates the format of an email address. * * @param string The string to check.
|
Zeile 3265 | Zeile 3609 |
---|
*/ function validate_email_format($email) {
|
*/ function validate_email_format($email) {
|
if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email)) {
| 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 3299 | Zeile 3641 |
---|
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 3351 | Zeile 3693 |
---|
return false; } return $dest;
|
return false; } return $dest;
|
| }
/** * Return a list of banned usernames. * * @return array The array of banned usernames. */ function get_banned_usernames() { global $mybb; $banned_usernames = explode(",", $mybb->settings['bannedusernames']); $banned_usernames = array_map("trim", $banned_usernames); $banned_usernames = array_map("strtolower", $banned_usernames); return $banned_usernames; }
/** * Checks if a username has been disallowed for registration/use. * * @param string The username * @return boolean True if banned, false if not banned */ function is_banned_username($username) { $banned_usernames = get_banned_usernames(); if(in_array(strtolower($username), $banned_usernames)) { return true; } else { return false; } }
/** * Return a list of banned email addresses. * * @return array The array of banned email addresses. */ function get_banned_emails() { global $mybb; $banned_emails = explode(",", $mybb->settings['bannedemails']); $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. * * @param string The email address. * @return boolean True if banned, false if not banned */ function is_banned_email($email) { $banned_emails = get_banned_emails(); $email = strtolower($email); foreach($banned_emails as $banned_email) { if($banned_email != "" && strpos($email, $banned_email) !== false) { return true; } } return false; }
/** * Return a list of banned IP addresses. * * @return array The array of banned IP addresses. */ function get_banned_ips() { global $mybb; $banned_ips = explode(",", $mybb->settings['bannedips']); $banned_ips = array_map("trim", $banned_ips); return $banned_ips; }
/** * Checks if a specific IP address has been banned. * * @param string The IP address. * @return boolean True if banned, false if not banned. */ function is_banned_ip($ip_address) { $banned_ips = get_banned_ips(); foreach($banned_ips as $banned_ip) { if($banned_ip != "" && strpos($ip_address, $banned_ip) !== false) { return true; } } 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; }
|
}
/**
| }
/**
|