Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: functions.php 5490 2011-07-12 13:39:55Z Tomm $
| * $Id$
|
*/
/**
| */
/**
|
Zeile 47 | Zeile 47 |
---|
if(my_strpos(getenv("REQUEST_URI"), "?")) {
|
if(my_strpos(getenv("REQUEST_URI"), "?")) {
|
$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1";
| $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1";
|
} else {
|
} else {
|
$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1";
| $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1";
|
}
if($mybb->settings['gzipoutput'] != 0)
| }
if($mybb->settings['gzipoutput'] != 0)
|
Zeile 63 | Zeile 63 |
---|
$gzipen = "Disabled"; }
|
$gzipen = "Disabled"; }
|
if(function_exists("memory_get_usage"))
| $memory_usage = get_memory_usage();
if($memory_usage) { $memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage); } else
|
{
|
{
|
$memory_usage = " / Memory Usage: ".get_friendly_size(memory_get_peak_usage(true));
| $memory_usage = '';
|
}
$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen"; $debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% MySQL)<br />SQL Queries: $db->query_count / Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />"; $contents = str_replace("<debugstuff>", $debugstuff, $contents);
|
}
$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen"; $debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% MySQL)<br />SQL Queries: $db->query_count / Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />"; $contents = str_replace("<debugstuff>", $debugstuff, $contents);
|
}
| }
|
if($mybb->debug_mode == true) {
| if($mybb->debug_mode == true) {
|
Zeile 92 | Zeile 98 |
---|
echo $contents;
$plugins->run_hooks("post_output_page");
|
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'] == 0 && $mybb->use_shutdown != true) { run_shutdown(); } }
| }
|
/** * Adds a function or class to the list of code to run on shutdown.
| /** * Adds a function or class to the list of code to run on shutdown.
|
Zeile 119 | Zeile 119 |
---|
if(is_array($name) && method_exists($name[0], $name[1])) { $shutdown_functions["class_".get_class($name[0])."_".$name[1]] = array('function' => $name, 'arguments' => $arguments);
|
if(is_array($name) && method_exists($name[0], $name[1])) { $shutdown_functions["class_".get_class($name[0])."_".$name[1]] = array('function' => $name, 'arguments' => $arguments);
|
return true; }
| return true; }
|
else if(!is_array($name) && function_exists($name)) { $shutdown_functions[$name] = array('function' => $name, 'arguments' => $arguments);
| else if(!is_array($name) && function_exists($name)) { $shutdown_functions[$name] = array('function' => $name, 'arguments' => $arguments);
|
Zeile 141 | Zeile 141 |
---|
if($done_shutdown == true || !$config || $error_handler->has_errors) { return;
|
if($done_shutdown == true || !$config || $error_handler->has_errors) { return;
|
}
| }
|
// Missing the core? Build if(!is_object($mybb))
| // Missing the core? Build if(!is_object($mybb))
|
Zeile 152 | Zeile 152 |
---|
// Load the settings require MYBB_ROOT."inc/settings.php"; $mybb->settings = &$settings;
|
// Load the settings require MYBB_ROOT."inc/settings.php"; $mybb->settings = &$settings;
|
}
| }
|
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
|
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
|
Zeile 246 | Zeile 246 |
---|
// Fetch emails for this page view - and send them $query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));
|
// Fetch emails for this page view - and send them $query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));
|
$plugins->run_hooks_by_ref("send_mail_queue_mail", $query);
| |
while($email = $db->fetch_array($query)) { // Delete the message from the queue $db->delete_query("mailqueue", "mid='{$email['mid']}'");
|
while($email = $db->fetch_array($query)) { // Delete the message from the queue $db->delete_query("mailqueue", "mid='{$email['mid']}'");
|
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
| if($db->affected_rows() == 1) { my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']); }
|
} // Update the mailqueue cache and remove the lock $cache->update_mailqueue(TIME_NOW, 0);
| } // Update the mailqueue cache and remove the lock $cache->update_mailqueue(TIME_NOW, 0);
|
Zeile 275 | Zeile 276 |
---|
$contents = str_replace('<navigation>', build_breadcrumb(1), $contents); $contents = str_replace('<archive_url>', $archive_url, $contents);
|
$contents = str_replace('<navigation>', build_breadcrumb(1), $contents); $contents = str_replace('<archive_url>', $archive_url, $contents);
|
|
|
if($htmldoctype)
|
if($htmldoctype)
|
{
| {
|
$contents = $htmldoctype.$contents;
|
$contents = $htmldoctype.$contents;
|
}
| }
|
else { $contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
|
else { $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);
|
$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 xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents); }
| $contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents); }
|
Zeile 321 | Zeile 322 |
---|
// If the stamp isn't set, use TIME_NOW if(empty($stamp))
|
// If the stamp isn't set, use TIME_NOW if(empty($stamp))
|
{ $stamp = TIME_NOW; }
| { $stamp = TIME_NOW; }
|
if(!$offset && $offset != '0') {
|
if(!$offset && $offset != '0') {
|
if($mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
| if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
|
{ $offset = $mybb->user['timezone']; $dstcorrection = $mybb->user['dst'];
| { $offset = $mybb->user['timezone']; $dstcorrection = $mybb->user['dst'];
|
Zeile 395 | Zeile 396 |
---|
if(is_object($plugins)) {
|
if(is_object($plugins)) {
|
$plugins->run_hooks_by_ref("my_date", $date);
| $date = $plugins->run_hooks("my_date", $date);
|
}
return $date;
| }
return $date;
|
Zeile 581 | Zeile 582 |
---|
{ $forum_cache = $cache->read("forums", 1); return $forum_cache;
|
{ $forum_cache = $cache->read("forums", 1); return $forum_cache;
|
}
| }
|
if(!$forum_cache) { $forum_cache = $cache->read("forums");
| if(!$forum_cache) { $forum_cache = $cache->read("forums");
|
Zeile 644 | Zeile 645 |
---|
{ global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;
|
{ global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;
|
$plugins->run_hooks_by_ref("error", $error);
| $error = $plugins->run_hooks("error", $error);
|
if(!$error) { $error = $lang->unknown_error;
| if(!$error) { $error = $lang->unknown_error;
|
Zeile 748 | Zeile 749 |
---|
} else {
|
} else {
|
| // Redirect to where the user came from $redirect_url = $_SERVER['PHP_SELF']; if($_SERVER['QUERY_STRING']) { $redirect_url .= '?'.$_SERVER['QUERY_STRING']; }
$redirect_url = htmlspecialchars_uni($redirect_url); switch($mybb->settings['username_method']) { case 0: $lang_username = $lang->username; break; case 1: $lang_username = $lang->username1; break; case 2: $lang_username = $lang->username2; break; default: $lang_username = $lang->username; break; }
|
eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
error($errorpage);
|
eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
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 766 | Zeile 791 |
---|
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
$plugins->run_hooks_by_ref("redirect", $redirect_args);
| $plugins->run_hooks("redirect", $redirect_args);
|
if($mybb->input['ajax']) {
| if($mybb->input['ajax']) {
|
Zeile 802 | Zeile 827 |
---|
if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid'])) { $url = str_replace("&", "&", $url);
|
if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid'])) { $url = str_replace("&", "&", $url);
|
$url = htmlspecialchars($url);
| $url = htmlspecialchars_uni($url);
|
eval("\$redirectpage = \"".$templates->get("redirect")."\";"); output_page($redirectpage);
| eval("\$redirectpage = \"".$templates->get("redirect")."\";"); output_page($redirectpage);
|
Zeile 814 | Zeile 839 |
---|
run_shutdown();
|
run_shutdown();
|
if(my_substr($url, 0, 7) !== 'http://')
| if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/')
|
{ header("Location: {$mybb->settings['bburl']}/{$url}"); }
| { header("Location: {$mybb->settings['bburl']}/{$url}"); }
|
Zeile 850 | Zeile 875 |
---|
$pages = ceil($count / $perpage);
|
$pages = ceil($count / $perpage);
|
| $prevpage = '';
|
if($page > 1) { $prev = $page-1;
| if($page > 1) { $prev = $page-1;
|
Zeile 887 | Zeile 913 |
---|
$to = $pages; }
|
$to = $pages; }
|
| $start = '';
|
if($from > 1) { if($from-1 == 1)
| if($from > 1) { if($from-1 == 1)
|
Zeile 898 | Zeile 925 |
---|
eval("\$start = \"".$templates->get("multipage_start")."\";"); }
|
eval("\$start = \"".$templates->get("multipage_start")."\";"); }
|
| $mppage = '';
|
for($i = $from; $i <= $to; ++$i) { $page_url = fetch_page_url($url, $i);
| for($i = $from; $i <= $to; ++$i) { $page_url = fetch_page_url($url, $i);
|
Zeile 918 | Zeile 946 |
---|
} }
|
} }
|
| $end = '';
|
if($to < $pages) { if($to+1 == $pages)
| if($to < $pages) { if($to+1 == $pages)
|
Zeile 927 | Zeile 956 |
---|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";");
|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";");
|
}
| }
|
|
|
| $nextpage = '';
|
if($page < $pages) { $next = $page+1; $page_url = fetch_page_url($url, $next); eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";"); }
|
if($page < $pages) { $next = $page+1; $page_url = fetch_page_url($url, $next); eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";"); }
|
|
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages); if($breadcrumb == true)
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages); if($breadcrumb == true)
|
{
| {
|
eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
}
| }
|
else { eval("\$multipage = \"".$templates->get("multipage")."\";"); }
|
else { eval("\$multipage = \"".$templates->get("multipage")."\";"); }
|
|
|
return $multipage;
|
return $multipage;
|
}
/**
| }
/**
|
* Generate a page URL for use by the multipage function * * @param string The URL being passed
| * Generate a page URL for use by the multipage function * * @param string The URL being passed
|
Zeile 970 | Zeile 1001 |
---|
return $url; } else if(strpos($url, "{page}") === false)
|
return $url; } else if(strpos($url, "{page}") === false)
|
{
| {
|
// If no page identifier is specified we tack it on to the end of the URL if(strpos($url, "?") === false) {
| // If no page identifier is specified we tack it on to the end of the URL if(strpos($url, "?") === false) {
|
Zeile 1012 | Zeile 1043 |
---|
{ // 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 1032 | Zeile 1063 |
---|
} // 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 1050 | Zeile 1081 |
---|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
}
$groups = explode(",", $gid);
| }
$groups = explode(",", $gid);
|
if(count($groups) == 1) {
| if(count($groups) == 1) {
|
Zeile 1074 | Zeile 1105 |
---|
if(isset($usergroup[$perm])) { $permbit = $usergroup[$perm];
|
if(isset($usergroup[$perm])) { $permbit = $usergroup[$perm];
|
}
| }
|
else { $permbit = "";
| else { $permbit = "";
|
Zeile 1096 | Zeile 1127 |
---|
}
return $usergroup;
|
}
return $usergroup;
|
}
| }
|
/** * Fetch the display group properties for a specific display group *
| /** * Fetch the display group properties for a specific display group *
|
Zeile 1157 | Zeile 1188 |
---|
else { $gid = $mybb->user['usergroup'];
|
else { $gid = $mybb->user['usergroup'];
|
|
|
if(isset($mybb->user['additionalgroups'])) { $gid .= ",".$mybb->user['additionalgroups'];
| if(isset($mybb->user['additionalgroups'])) { $gid .= ",".$mybb->user['additionalgroups'];
|
Zeile 1179 | Zeile 1210 |
---|
if(!is_array($fpermcache)) {
|
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 {
|
if(!$cached_forum_permissions_permissions[$gid][$fid]) { $cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
| if(!$cached_forum_permissions_permissions[$gid][$fid]) { $cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
|
Zeile 1215 | Zeile 1246 |
---|
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 permissions so lets just return the group permissions
| if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions
|
{ return $groupperms; }
| { return $groupperms; }
|
Zeile 1267 | Zeile 1298 |
---|
if(!$level_permissions["canonlyviewownthreads"]) { $only_view_own_threads = 0;
|
if(!$level_permissions["canonlyviewownthreads"]) { $only_view_own_threads = 0;
|
} }
| } }
|
}
// Figure out if we can view more than our own threads
| }
// Figure out if we can view more than our own threads
|
Zeile 1300 | Zeile 1331 |
---|
{ $forum_cache = cache_forums(); if(!$forum_cache)
|
{ $forum_cache = cache_forums(); if(!$forum_cache)
|
{
| {
|
return false; } }
| return false; } }
|
Zeile 1311 | Zeile 1342 |
---|
if(!empty($parents)) { foreach($parents as $parent_id)
|
if(!empty($parents)) { foreach($parents as $parent_id)
|
{
| {
|
if($parent_id == $fid || $parent_id == $pid)
|
if($parent_id == $fid || $parent_id == $pid)
|
{
| {
|
continue;
|
continue;
|
}
| }
|
if($forum_cache[$parent_id]['password'] != "") { check_forum_password($parent_id, $fid);
|
if($forum_cache[$parent_id]['password'] != "") { check_forum_password($parent_id, $fid);
|
} } }
| } } }
|
$password = $forum_cache[$fid]['password']; if($password)
| $password = $forum_cache[$fid]['password']; if($password)
|
Zeile 1332 | Zeile 1363 |
---|
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 = false;
| $showform = false;
|
} else {
| } else {
|
Zeile 1343 | Zeile 1374 |
---|
else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))
|
else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))
|
{
| {
|
$showform = true;
|
$showform = true;
|
}
| }
|
else { $showform = false;
| else { $showform = false;
|
Zeile 1353 | Zeile 1384 |
---|
} } else
|
} } else
|
{
| {
|
$showform = false; }
| $showform = false; }
|
Zeile 1394 | Zeile 1425 |
---|
if($uid == 0) { return false;
|
if($uid == 0) { return false;
|
}
| }
|
if(isset($modpermscache[$fid][$uid]))
|
if(isset($modpermscache[$fid][$uid]))
|
{
| {
|
return $modpermscache[$fid][$uid]; }
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
|
return $modpermscache[$fid][$uid]; }
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
|
}
| }
|
// Get user groups $perms = array(); $user = get_user($uid);
|
// Get user groups $perms = array(); $user = get_user($uid);
|
|
|
$groups = array($user['usergroup']);
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
|
$groups = array($user['usergroup']);
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
|
|
|
foreach($extra_groups as $extra_group) { $groups[] = $extra_group;
| foreach($extra_groups as $extra_group) { $groups[] = $extra_group;
|
Zeile 1436 | Zeile 1467 |
---|
if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
foreach($perm as $action => $value) { if(strpos($action, "can") === false)
| foreach($perm as $action => $value) { if(strpos($action, "can") === false)
|
{ continue; }
| { continue; }
|
Zeile 1569 | Zeile 1600 |
---|
$icon = $mybb->input['icon']; }
|
$icon = $mybb->input['icon']; }
|
| $iconlist = '';
|
$no_icons_checked = " checked=\"checked\""; // read post icons from cache, and sort them accordingly $posticons_cache = $cache->read("posticons");
| $no_icons_checked = " checked=\"checked\""; // read post icons from cache, and sort them accordingly $posticons_cache = $cache->read("posticons");
|
Zeile 1675 | Zeile 1707 |
---|
* @param string The cookie identifier. */ function my_unsetcookie($name)
|
* @param string The cookie identifier. */ function my_unsetcookie($name)
|
{ global $mybb;
| { global $mybb;
|
$expires = -3600; my_setcookie($name, "", $expires); unset($mybb->cookies[$name]);
|
$expires = -3600; my_setcookie($name, "", $expires); unset($mybb->cookies[$name]);
|
}
/**
| }
/**
|
* Get the contents from a serialised cookie array. * * @param string The cookie identifier.
| * Get the contents from a serialised cookie array. * * @param string The cookie identifier.
|
Zeile 1698 | Zeile 1730 |
---|
if(!isset($mybb->cookies['mybb'][$name])) { return false;
|
if(!isset($mybb->cookies['mybb'][$name])) { return false;
|
}
$cookie = unserialize($mybb->cookies['mybb'][$name]);
| }
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
|
if(is_array($cookie) && isset($cookie[$id])) { return $cookie[$id];
|
if(is_array($cookie) && isset($cookie[$id])) { return $cookie[$id];
|
}
| }
|
else { return 0;
|
else { 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) {
| */ function my_set_array_cookie($name, $id, $value, $expires="") {
|
global $mybb; $cookie = $mybb->cookies['mybb'];
|
global $mybb; $cookie = $mybb->cookies['mybb'];
|
$newcookie = unserialize($cookie[$name]);
if(!is_array($newcookie)) { // Burnt / malformed cookie - reset $newcookie = array(); }
| $newcookie = my_unserialize($cookie[$name]);
|
$newcookie[$id] = $value; $newcookie = serialize($newcookie);
|
$newcookie[$id] = $value; $newcookie = serialize($newcookie);
|
my_setcookie("mybb[$name]", addslashes($newcookie));
| my_setcookie("mybb[$name]", addslashes($newcookie), $expires);
|
// Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie; }
|
// Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie; }
|
| /** * Verifies that data passed is an array * * @param array Data to unserialize * @return array Unserialized data array */ function my_unserialize($data) { $array = unserialize($data);
if(!is_array($array)) { $array = array(); }
return $array; }
|
/** * Returns the serverload of the system.
| /** * Returns the serverload of the system.
|
Zeile 1806 | Zeile 1850 |
---|
$returnload = trim($serverload[0]);
return $returnload;
|
$returnload = trim($serverload[0]);
return $returnload;
|
| }
/** * Returns the amount of memory allocated to the script. * * @return int The amount of memory allocated to the script. */ function get_memory_usage() { if(function_exists('memory_get_peak_usage')) { return memory_get_peak_usage(true); } elseif(function_exists('memory_get_usage')) { return memory_get_usage(true); } return false;
|
}
/**
| }
/**
|
Zeile 1834 | Zeile 1896 |
---|
} } else
|
} } else
|
{
| {
|
$new_stats[$counter] = $changes[$counter]; } // Less than 0? That's bad if($new_stats[$counter] < 0) { $new_stats[$counter] = 0;
|
$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
| }
// Fetch latest user if the user count is changing
|
Zeile 1904 | Zeile 1966 |
---|
{ // 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) == "-")
|
{
| {
|
$update_query[$counter] = $forum[$counter] + $changes[$counter];
|
$update_query[$counter] = $forum[$counter] + $changes[$counter];
|
}
| }
|
else
|
else
|
{
| {
|
$update_query[$counter] = $changes[$counter];
|
$update_query[$counter] = $changes[$counter];
|
}
| }
|
// Less than 0? That's bad if(!$update_query[$counter])
|
// Less than 0? That's bad if(!$update_query[$counter])
|
{ $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) {
| { $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) {
|
$db->update_query("forums", $update_query, "fid='".intval($fid)."'"); }
| $db->update_query("forums", $update_query, "fid='".intval($fid)."'"); }
|
Zeile 2081 | Zeile 2143 |
---|
function update_thread_data($tid) { global $db;
|
function update_thread_data($tid) { global $db;
|
| $thread = get_thread($tid);
// If this is a moved thread marker, don't update it - we need it to stay as it is if(strpos($thread['closed'], 'moved|') !== false) { return false; }
|
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p
| $query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p
|
Zeile 2205 | Zeile 2276 |
---|
global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;
$pid = intval($pid);
|
global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;
$pid = intval($pid);
|
| $jumpsel['default'] = '';
|
if($permissions) {
| if($permissions) {
|
Zeile 2232 | Zeile 2304 |
---|
$permissioncache = forum_permissions(); }
|
$permissioncache = forum_permissions(); }
|
if(is_array($jumpfcache[$pid]))
| if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
|
{ foreach($jumpfcache[$pid] as $main) {
| { foreach($jumpfcache[$pid] as $main) {
|
Zeile 2283 | Zeile 2355 |
---|
else { $template = "advanced";
|
else { $template = "advanced";
|
| if(strpos(FORUM_URL, '.html') !== false) { $forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'"; } else { $forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL); }
|
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";"); }
|
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";"); }
|
|
|
return $forumjump;
|
return $forumjump;
|
}
/**
| }
/**
|
* Returns the extension of a file. * * @param string The filename. * @return string The extension of the file.
|
* Returns the extension of a file. * * @param string The filename. * @return string The extension of the file.
|
*/
| */
|
function get_extension($file) { return my_strtolower(my_substr(strrchr($file, "."), 1));
| function get_extension($file) { return my_strtolower(my_substr(strrchr($file, "."), 1));
|
Zeile 2317 | Zeile 2398 |
---|
{ $ch = my_rand(0, count($set)-1); $str .= $set[$ch];
|
{ $ch = my_rand(0, count($set)-1); $str .= $set[$ch];
|
}
| }
|
return $str; }
|
return $str; }
|
|
|
/** * Formats a username based on their display group *
| /** * Formats a username based on their display group *
|
Zeile 2333 | Zeile 2414 |
---|
function format_name($username, $usergroup, $displaygroup="") { global $groupscache, $cache;
|
function format_name($username, $usergroup, $displaygroup="") { global $groupscache, $cache;
|
|
|
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;
|
}
| }
|
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle'];
| $ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle'];
|
Zeile 2351 | Zeile 2432 |
---|
if($userin == 0) { $format = "{username}";
|
if($userin == 0) { $format = "{username}";
|
}
| }
|
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
| $format = stripslashes($format);
return str_replace("{username}", $username, $format);
|
Zeile 2394 | Zeile 2475 |
---|
"editor_enter_image", "editor_enter_video_url", "editor_video_dailymotion",
|
"editor_enter_image", "editor_enter_video_url", "editor_video_dailymotion",
|
"editor_video_googlevideo",
| |
"editor_video_metacafe", "editor_video_myspacetv", "editor_video_vimeo",
| "editor_video_metacafe", "editor_video_myspacetv", "editor_video_vimeo",
|
Zeile 2413 | Zeile 2493 |
---|
); $editor_language = "var editor_language = {\n";
|
); $editor_language = "var editor_language = {\n";
|
$plugins->run_hooks_by_ref("mycode_add_codebuttons", $editor_lang_strings);
| $editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);
|
foreach($editor_lang_strings as $key => $lang_string) {
| foreach($editor_lang_strings as $key => $lang_string) {
|
Zeile 2422 | Zeile 2502 |
---|
$string = str_replace("\"", "\\\"", $lang->$lang_string); $editor_language .= "\t{$js_lang_string}: \"{$string}\"";
|
$string = str_replace("\"", "\\\"", $lang->$lang_string); $editor_language .= "\t{$js_lang_string}: \"{$string}\"";
|
if($editor_lang_strings[$key+1])
| if(isset($editor_lang_strings[$key+1]))
|
{ $editor_language .= ",";
|
{ $editor_language .= ",";
|
}
| }
|
$editor_language .= "\n"; }
| $editor_language .= "\n"; }
|
Zeile 2484 | Zeile 2564 |
---|
{ reset($smiliecache);
|
{ reset($smiliecache);
|
| $getmore = '';
|
if($mybb->settings['smilieinsertertot'] >= $smiliecount) { $mybb->settings['smilieinsertertot'] = $smiliecount;
| if($mybb->settings['smilieinsertertot'] >= $smiliecount) { $mybb->settings['smilieinsertertot'] = $smiliecount;
|
Zeile 2564 | Zeile 2645 |
---|
$prefix_cache = $cache->read("threadprefixes");
|
$prefix_cache = $cache->read("threadprefixes");
|
if($prefix_cache === false)
| if(!is_array($prefix_cache))
|
{
|
{
|
return false;
| // No cache $prefix_cache = $cache->read("threadprefixes", true);
if(!is_array($prefix_cache)) { return array(); }
|
}
$prefixes_cache = array();
| }
$prefixes_cache = array();
|
Zeile 2818 | Zeile 2905 |
---|
function get_reputation($reputation, $uid=0) { global $theme;
|
function get_reputation($reputation, $uid=0) { global $theme;
|
| $display_reputation = '';
|
if($uid != 0) {
| if($uid != 0) {
|
Zeile 2837 | Zeile 2926 |
---|
else { $display_reputation .= "reputation_neutral";
|
else { $display_reputation .= "reputation_neutral";
|
}
| }
|
$display_reputation .= "\">{$reputation}</strong>";
| $display_reputation .= "\">{$reputation}</strong>";
|
Zeile 2874 | Zeile 2963 |
---|
return $level."%"; } }
|
return $level."%"; } }
|
|
|
/** * Fetch the IP address of the current user. *
| /** * Fetch the IP address of the current user. *
|
Zeile 2884 | Zeile 2973 |
---|
{ global $mybb, $plugins;
|
{ global $mybb, $plugins;
|
$ip = 0;
| $ip = 0;
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; }
if($mybb->settings['ip_forwarded_check'])
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; }
if($mybb->settings['ip_forwarded_check'])
|
{
| {
|
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
| if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
|
Zeile 2900 | Zeile 2989 |
---|
elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
|
elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
|
}
| }
|
if(is_array($addresses[0])) { foreach($addresses[0] as $key => $val)
| if(is_array($addresses[0])) { foreach($addresses[0] as $key => $val)
|
Zeile 2925 | Zeile 3014 |
---|
if($plugins) {
|
if($plugins) {
|
$plugins->run_hooks("get_ip", array("ip" => &$ip));
| $ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function. $plugins->run_hooks("get_ip", $ip_array);
|
}
return $ip;
|
}
return $ip;
|
}
| }
|
/** * Fetch the friendly size (GB, MB, KB, B) for a specified file size.
| /** * Fetch the friendly size (GB, MB, KB, B) for a specified file size.
|
Zeile 3041 | Zeile 3131 |
---|
if(defined("IN_ADMINCP")) { $theme['imgdir'] = "../images";
|
if(defined("IN_ADMINCP")) { $theme['imgdir'] = "../images";
|
}
| }
|
else if(defined("IN_PORTAL")) { global $change_dir;
| else if(defined("IN_PORTAL")) { global $change_dir;
|
Zeile 3060 | Zeile 3150 |
---|
*/ function get_unviewable_forums($only_readable_threads=false) {
|
*/ function get_unviewable_forums($only_readable_threads=false) {
|
global $forum_cache, $permissioncache, $mybb, $unviewableforums, $unviewable, $templates, $forumpass;
$pid = intval($pid);
if(!$permissions) { $permissions = $mybb->usergroup; }
| global $forum_cache, $permissioncache, $mybb, $unviewable, $templates, $forumpass;
|
if(!is_array($forum_cache)) {
| if(!is_array($forum_cache)) {
|
Zeile 3126 | Zeile 3209 |
---|
} }
|
} }
|
return $unviewableforums;
| if(isset($unviewableforums)) { return $unviewableforums; }
|
}
/**
| }
/**
|
Zeile 3158 | Zeile 3244 |
---|
eval("\$navsep = \"".$templates->get("nav_sep")."\";"); $i = 0;
|
eval("\$navsep = \"".$templates->get("nav_sep")."\";"); $i = 0;
|
| $activesep = '';
|
if(is_array($navbits)) {
| if(is_array($navbits)) {
|
Zeile 3173 | Zeile 3260 |
---|
else { $sep = "";
|
else { $sep = "";
|
}
| }
|
$multipage = null; $multipage_dropdown = null;
| $multipage = null; $multipage_dropdown = null;
|
Zeile 3187 | Zeile 3274 |
---|
$sep = $multipage_dropdown.$sep; } }
|
$sep = $multipage_dropdown.$sep; } }
|
| // Replace page 1 URLs $navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']); $navbit['url'] = preg_replace("/&page=1$/", "", $navbit['url']);
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";");
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";");
|
} } }
| } } }
|
$navsize = count($navbits); $navbit = $navbits[$navsize-1];
| $navsize = count($navbits); $navbit = $navbits[$navsize-1];
|
Zeile 3251 | Zeile 3342 |
---|
{ if($fid == $forumnav['fid']) {
|
{ if($fid == $forumnav['fid']) {
|
if($pforumcache[$forumnav['pid']])
| if(!empty($pforumcache[$forumnav['pid']]))
|
{ build_forum_breadcrumb($forumnav['pid']); }
| { build_forum_breadcrumb($forumnav['pid']); }
|
Zeile 3260 | Zeile 3351 |
---|
// Convert & to & $navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&", $forumnav['name']);
|
// Convert & to & $navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&", $forumnav['name']);
|
if(IN_ARCHIVE == 1)
| if(defined("IN_ARCHIVE"))
|
{ // Set up link to forum in breadcrumb. if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
| { // Set up link to forum in breadcrumb. if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
|
Zeile 3317 | Zeile 3408 |
---|
global $mybb; // If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
|
global $mybb; // If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
|
if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
| //if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS")) if($mybb->settings['seourls_archive'] == 1) { $base_url = $mybb->settings['bburl']."/archive/index.php/"; } else
|
{ $base_url = $mybb->settings['bburl']."/archive/index.php?";
|
{ $base_url = $mybb->settings['bburl']."/archive/index.php?";
|
} else { $base_url = $mybb->settings['bburl']."/archive/index.php/"; }
| }
|
switch($type) { case "thread": $url = "{$base_url}thread-{$id}.html";
|
switch($type) { case "thread": $url = "{$base_url}thread-{$id}.html";
|
break;
| break;
|
case "announcement": $url = "{$base_url}announcement-{$id}.html";
|
case "announcement": $url = "{$base_url}announcement-{$id}.html";
|
break;
| break;
|
case "forum": $url = "{$base_url}forum-{$id}.html"; break;
| case "forum": $url = "{$base_url}forum-{$id}.html"; break;
|
Zeile 3343 | Zeile 3435 |
---|
return $url; }
|
return $url; }
|
|
|
/** * Prints a debug information page */ function debug_page() {
|
/** * Prints a debug information page */ function debug_page() {
|
global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime;
| global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime, $lang;
|
$totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $db->query_time); $query_time = $maintimer->format($db->query_time);
|
$totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $db->query_time); $query_time = $maintimer->format($db->query_time);
|
|
|
$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2); $percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);
|
$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2); $percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);
|
|
|
$phpversion = PHP_VERSION;
|
$phpversion = PHP_VERSION;
|
|
|
$serverload = get_server_load();
if($mybb->settings['gzipoutput'] != 0)
|
$serverload = get_server_load();
if($mybb->settings['gzipoutput'] != 0)
|
{
| {
|
$gzipen = "Enabled"; } else
| $gzipen = "Enabled"; } else
|
Zeile 3414 | Zeile 3506 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".count($templates->cache)." (".intval(count(explode(",", $templatelist)))." Cached / ".intval(count($templates->uncached_templates))." Manually Loaded)</font></td>\n"; echo "</tr>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".count($templates->cache)." (".intval(count(explode(",", $templatelist)))." Cached / ".intval(count($templates->uncached_templates))." Manually Loaded)</font></td>\n"; echo "</tr>\n";
|
if(function_exists("memory_get_usage"))
| $memory_usage = get_memory_usage(); if(!$memory_usage)
|
{
|
{
|
$memory_usage = memory_get_peak_usage(true); $memory_limit = @ini_get("memory_limit"); echo "<tr>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Usage:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".get_friendly_size($memory_usage)." ({$memory_usage} bytes)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n"; echo "</tr>\n";
| $memory_usage = $lang->unknown;
|
}
|
}
|
| else { $memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)"; } $memory_limit = @ini_get("memory_limit"); echo "<tr>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Usage:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_usage}</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n"; echo "</tr>\n";
|
echo "</table>\n";
| echo "</table>\n";
|
Zeile 3551 | Zeile 3648 |
---|
$hsecs = 60*60; $msecs = 60;
|
$hsecs = 60*60; $msecs = 60;
|
if($options['short'] == true)
| if(isset($options['short']))
|
{ $lang_year = $lang->year_short; $lang_years = $lang->years_short;
| { $lang_year = $lang->year_short; $lang_years = $lang->years_short;
|
Zeile 3636 | Zeile 3733 |
---|
$nicetime['days'] = $days.$lang_days; }
|
$nicetime['days'] = $days.$lang_days; }
|
if($options['hours'] !== false)
| if(!isset($options['hours']) || $options['hours'] !== false)
|
{ if($hours == 1) {
| { if($hours == 1) {
|
Zeile 3648 | Zeile 3745 |
---|
} }
|
} }
|
if($options['minutes'] !== false)
| if(!isset($options['minutes']) || $options['minutes'] !== false)
|
{ if($minutes == 1) {
| { if($minutes == 1) {
|
Zeile 3660 | Zeile 3757 |
---|
} }
|
} }
|
if($options['seconds'] !== false)
| if(!isset($options['seconds']) || $options['seconds'] !== false)
|
{ if($seconds == 1) {
| { if($seconds == 1) {
|
Zeile 3846 | Zeile 3943 |
---|
{ $ignore = array($ignore); }
|
{ $ignore = array($ignore); }
|
|
|
$form_html = "";
|
$form_html = "";
|
$field_parts = explode('&', $field_parts);
| |
if(!empty($mybb->input)) { foreach($mybb->input as $name => $value)
|
if(!empty($mybb->input)) { foreach($mybb->input as $name => $value)
|
{
| {
|
if(in_array($name, $ignore)) { continue; }
|
if(in_array($name, $ignore)) { continue; }
|
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars((string)$name)."\" value=\"".htmlspecialchars((string)$value)."\" />\n";
| $form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni((string)$name)."\" value=\"".htmlspecialchars_uni((string)$value)."\" />\n";
|
} }
| } }
|
Zeile 3891 | Zeile 3986 |
---|
if(isset($addloc) && is_array($addloc)) { if(strpos($location, "?") === false)
|
if(isset($addloc) && is_array($addloc)) { if(strpos($location, "?") === false)
|
{
| {
|
$location .= "?"; } else
| $location .= "?"; } else
|
Zeile 3977 | Zeile 4072 |
---|
if($theme['tid'] == $selected) { $sel = " selected=\"selected\"";
|
if($theme['tid'] == $selected) { $sel = " selected=\"selected\"";
|
}
| }
|
if($theme['pid'] != 0) {
|
if($theme['pid'] != 0) {
|
$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";
| $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.htmlspecialchars_uni($theme['name'])."</option>";
|
$depthit = $depth."--"; }
| $depthit = $depth."--"; }
|
Zeile 3999 | Zeile 4094 |
---|
}
return $themeselect;
|
}
return $themeselect;
|
}
/**
| }
/**
|
* Custom function for htmlspecialchars which takes in to account unicode * * @param string The string to format
| * Custom function for htmlspecialchars which takes in to account unicode * * @param string The string to format
|
Zeile 4023 | Zeile 4118 |
---|
* @return int The formatted number. */ function my_number_format($number)
|
* @return int The formatted number. */ function my_number_format($number)
|
{
| {
|
global $mybb;
if($number == "-")
| global $mybb;
if($number == "-")
|
Zeile 4038 | Zeile 4133 |
---|
else { $parts = explode('.', $number);
|
else { $parts = explode('.', $number);
|
|
|
if(isset($parts[1])) { $decimals = my_strlen($parts[1]);
| if(isset($parts[1])) { $decimals = my_strlen($parts[1]);
|
Zeile 4049 | Zeile 4144 |
---|
}
return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
}
return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
}
| }
|
}
function convert_through_utf8($str, $to=true)
| }
function convert_through_utf8($str, $to=true)
|
Zeile 4065 | Zeile 4160 |
---|
} if($charset == "utf-8")
|
} if($charset == "utf-8")
|
{ return $str; }
| { return $str; }
|
if(!isset($use_iconv)) { $use_iconv = function_exists("iconv");
|
if(!isset($use_iconv)) { $use_iconv = function_exists("iconv");
|
}
| }
|
if(!isset($use_mb)) { $use_mb = function_exists("mb_convert_encoding");
| if(!isset($use_mb)) { $use_mb = function_exists("mb_convert_encoding");
|
Zeile 4094 | Zeile 4189 |
---|
if($use_iconv) { return iconv($from_charset, $to_charset."//IGNORE", $str);
|
if($use_iconv) { return iconv($from_charset, $to_charset."//IGNORE", $str);
|
}
| }
|
else { return @mb_convert_encoding($str, $to_charset, $from_charset);
| else { return @mb_convert_encoding($str, $to_charset, $from_charset);
|
Zeile 4109 | Zeile 4204 |
---|
else { return utf8_decode($str);
|
else { return utf8_decode($str);
|
} }
| } }
|
else { return $str;
| else { return $str;
|
Zeile 4198 | Zeile 4293 |
---|
31, 30, 31,
|
31, 30, 31,
|
31, 30,
| 31, 30,
|
31, 30, 31
| 31, 30, 31
|
Zeile 4371 | Zeile 4466 |
---|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
}
| }
|
$string = trim($string);
if(function_exists("mb_strlen"))
| $string = trim($string);
if(function_exists("mb_strlen"))
|
Zeile 4571 | Zeile 4666 |
---|
*/ function get_event_date($event) {
|
*/ function get_event_date($event) {
|
| global $mybb;
|
$event_date = explode("-", $event['date']); $event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
return $event_date;
|
$event_date = explode("-", $event['date']); $event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
return $event_date;
|
}
| }
|
/** * Get the profile link. *
| /** * Get the profile link. *
|
Zeile 4587 | Zeile 4684 |
---|
function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL);
|
function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL);
|
return htmlspecialchars_uni($link); }
/**
| return htmlspecialchars_uni($link); }
/**
|
* Get the announcement link. * * @param int The announement id of the announcement. * @return string The url to the announcement. */ function get_announcement_link($aid=0)
|
* Get the announcement link. * * @param int The announement id of the announcement. * @return string The url to the announcement. */ function get_announcement_link($aid=0)
|
{
| {
|
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL); return htmlspecialchars_uni($link); }
| $link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL); return htmlspecialchars_uni($link); }
|
Zeile 4624 | Zeile 4721 |
---|
{ // Return the guest's nickname if user is a guest but has a nickname return $username;
|
{ // Return the guest's nickname if user is a guest but has a nickname return $username;
|
}
| }
|
else { // Build the profile link for the registered user
| else { // Build the profile link for the registered user
|
Zeile 4794 | Zeile 4891 |
---|
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
|
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
|
}
| }
|
/** * Get the user data of a user id.
| /** * Get the user data of a user id.
|
Zeile 4814 | Zeile 4911 |
---|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
{ return $user_cache[$uid]; }
| { return $user_cache[$uid]; }
|
else { $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
|
else { $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
|
|
|
return $user_cache[$uid];
|
return $user_cache[$uid];
|
} }
/**
| } }
/**
|
* Get the forum of a specific forum id. * * @param int The forum id of the forum.
| * Get the forum of a specific forum id. * * @param int The forum id of the forum.
|
Zeile 4846 | Zeile 4943 |
---|
if(!$forum_cache[$fid]) { return false;
|
if(!$forum_cache[$fid]) { return false;
|
}
| }
|
if($active_override != 1) { $parents = explode(",", $forum_cache[$fid]['parentlist']);
| if($active_override != 1) { $parents = explode(",", $forum_cache[$fid]['parentlist']);
|
Zeile 4879 | Zeile 4976 |
---|
static $thread_cache;
if(isset($thread_cache[$tid]) && !$recache)
|
static $thread_cache;
if(isset($thread_cache[$tid]) && !$recache)
|
{
| {
|
return $thread_cache[$tid]; } else
| return $thread_cache[$tid]; } else
|
Zeile 4986 | Zeile 5083 |
---|
// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.
// Use cookie if possible, otherwise use session
|
// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.
// Use cookie if possible, otherwise use session
|
// Session stops user clearing cookies to bypass the login // Also use the greater of the two numbers present, stops people using scripts with altered cookie data to stay the same $cookielogins = intval($mybb->cookies['loginattempts']); $cookietime = $mybb->cookies['failedlogin'];
| // Find better solution to prevent clearing cookies $loginattempts = 0; $failedlogin = 0;
|
|
|
if(empty($cookielogins) || $cookielogins < $session->logins)
| if(!empty($mybb->cookies['loginattempts']))
|
{
|
{
|
$loginattempts = $session->logins; } else { $loginattempts = $cookielogins;
| $loginattempts = $mybb->cookies['loginattempts'];
|
}
|
}
|
if(empty($cookietime) || $cookietime < $session->failedlogin) { $failedlogin = $session->failedlogin; } else
| if(!empty($mybb->cookies['failedlogin']))
|
{
|
{
|
$failedlogin = $cookietime;
| $failedlogin = $mybb->cookies['failedlogin'];
|
}
// Work out if the user has had more than the allowed number of login attempts
| }
// Work out if the user has had more than the allowed number of login attempts
|
Zeile 5032 | Zeile 5120 |
---|
// This value will be empty the first time the user doesn't login in, set it if(empty($failedlogin))
|
// This value will be empty the first time the user doesn't login in, set it if(empty($failedlogin))
|
{
| {
|
my_setcookie('failedlogin', $now); if($fatal) {
| my_setcookie('failedlogin', $now); if($fatal) {
|
Zeile 5060 | Zeile 5148 |
---|
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60)) { if($fatal)
|
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60)) { if($fatal)
|
{
| {
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
| error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
|
Zeile 5174 | Zeile 5262 |
---|
{ $mybb->settings['minsearchword'] = 3; }
|
{ $mybb->settings['minsearchword'] = 3; }
|
| if(is_array($terms)) { $terms = implode(' ', $terms); }
|
// Strip out any characters that shouldn't be included $bad_characters = array(
| // Strip out any characters that shouldn't be included $bad_characters = array(
|
Zeile 5191 | Zeile 5284 |
---|
$inquote = false; $terms = explode("\"", $terms); foreach($terms as $phrase)
|
$inquote = false; $terms = explode("\"", $terms); foreach($terms as $phrase)
|
{
| {
|
$phrase = htmlspecialchars_uni($phrase); if($phrase != "") {
| $phrase = htmlspecialchars_uni($phrase); if($phrase != "") {
|
Zeile 5217 | Zeile 5310 |
---|
} } $inquote = !$inquote;
|
} } $inquote = !$inquote;
|
}
| }
|
} // Otherwise just a simple search query with no phrases else { $terms = htmlspecialchars_uni($terms); $split_words = preg_split("#\s{1,}#", $terms, -1);
|
} // Otherwise just a simple search query with no phrases else { $terms = htmlspecialchars_uni($terms); $split_words = preg_split("#\s{1,}#", $terms, -1);
|
if(!is_array($split_words)) { continue; } foreach($split_words as $word) { if(!$word || strlen($word) < $mybb->settings['minsearchword']) { continue; } $words[] = trim($word);
| if(is_array($split_words)) { foreach($split_words as $word) { if(!$word || strlen($word) < $mybb->settings['minsearchword']) { continue; } $words[] = trim($word); }
|
}
|
}
|
| |
}
if(!is_array($words))
| }
if(!is_array($words))
|
Zeile 5262 | Zeile 5353 |
---|
}
// Now make PREG compatible
|
}
// Now make PREG compatible
|
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";
| $find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
|
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>"; $highlight_cache[$find] = $replacement; }
| $replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>"; $highlight_cache[$find] = $replacement; }
|
Zeile 5289 | Zeile 5380 |
---|
$dest .= chr($src); } elseif($src <= 0x07ff)
|
$dest .= chr($src); } elseif($src <= 0x07ff)
|
{
| {
|
$dest .= chr(0xc0 | ($src >> 6)); $dest .= chr(0x80 | ($src & 0x003f)); }
| $dest .= chr(0xc0 | ($src >> 6)); $dest .= chr(0x80 | ($src & 0x003f)); }
|
Zeile 5319 | Zeile 5410 |
---|
* Checks if a username has been disallowed for registration/use. * * @param string The username
|
* Checks if a username has been disallowed for registration/use. * * @param string The username
|
* @param boolean True if the 'last used' dateline should be updated if a match is found. * @return boolean True if banned, false if not banned
| * @param boolean True if the 'last used' dateline should be updated if a match is found. * @return boolean True if banned, false if not banned
|
*/ function is_banned_username($username, $update_lastuse=false) { global $db; $query = $db->simple_select('banfilters', 'filter, fid', "type='2'"); while($banned_username = $db->fetch_array($query))
|
*/ function is_banned_username($username, $update_lastuse=false) { global $db; $query = $db->simple_select('banfilters', 'filter, fid', "type='2'"); while($banned_username = $db->fetch_array($query))
|
{
| {
|
// Make regular expression * match $banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#')); if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
| // Make regular expression * match $banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#')); if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
|
Zeile 5357 | Zeile 5448 |
---|
$banned_cache = $cache->read("bannedemails");
|
$banned_cache = $cache->read("bannedemails");
|
if(!$banned_cache)
| if($banned_cache === false)
|
{
|
{
|
| // Failed to read cache, see if we can rebuild it
|
$cache->update_bannedemails(); $banned_cache = $cache->read("bannedemails"); }
|
$cache->update_bannedemails(); $banned_cache = $cache->read("bannedemails"); }
|
foreach($banned_cache as $banned_email)
| if(is_array($banned_cache) && !empty($banned_cache))
|
{
|
{
|
// Make regular expression * match $banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))
| foreach($banned_cache as $banned_email)
|
{
|
{
|
// Updating last use if($update_lastuse == true)
| // Make regular expression * match $banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))
|
{
|
{
|
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
| // Updating last use if($update_lastuse == true) { $db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'"); } return true;
|
}
|
}
|
return true;
| |
} }
|
} }
|
|
|
// Still here - good email return false; }
| // Still here - good email return false; }
|
Zeile 5408 | Zeile 5504 |
---|
// Make regular expression * match $banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));
|
// Make regular expression * match $banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));
|
if(preg_match("#{$banned_ip['filter']}#i", $ip_address))
| if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))
|
{ // Updating last use if($update_lastuse == true)
| { // Updating last use if($update_lastuse == true)
|
Zeile 5418 | Zeile 5514 |
---|
return true; } }
|
return true; } }
|
|
|
// Still here - good ip return false; }
| // Still here - good ip return false; }
|
Zeile 5578 | Zeile 5675 |
---|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close";
|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close";
|
$headers[] = "\r\n";
| $headers[] = '';
|
if(!empty($post_body)) { $headers[] = $post_body;
|
if(!empty($post_body)) { $headers[] = $post_body;
|
| } else { // If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts $headers[] = '';
|
} $headers = implode("\r\n", $headers);
| } $headers = implode("\r\n", $headers);
|
Zeile 5703 | Zeile 5805 |
---|
if($ip == "*") {
|
if($ip == "*") {
|
return array(ip2long('0.0.0.0'), ip2long('255.255.255.255'));
| return array(my_ip2long('128.0.0.0'), my_ip2long('127.255.255.255'));
|
}
if(strpos($ip, ".*") === false)
| }
if(strpos($ip, ".*") === false)
|
Zeile 5711 | Zeile 5813 |
---|
$ip = str_replace("*", "", $ip); if(count($ip_bits) == 4) {
|
$ip = str_replace("*", "", $ip); if(count($ip_bits) == 4) {
|
return ip2long($ip);
| return my_ip2long($ip);
|
} else {
|
} else {
|
return array(ip2long($ip.".0"), ip2long($ip.".255"));
| return array(my_ip2long($ip.".0"), my_ip2long($ip.".255"));
|
} } // Wildcard based IP provided
| } } // Wildcard based IP provided
|
Zeile 5736 | Zeile 5838 |
---|
} $sep = "."; }
|
} $sep = "."; }
|
return array(ip2long($ip_string1), ip2long($ip_string2));
| return array(my_ip2long($ip_string1), my_ip2long($ip_string2));
|
} }
| } }
|
Zeile 5770 | Zeile 5872 |
---|
"0-0-2" => "2 {$lang->years}" );
|
"0-0-2" => "2 {$lang->years}" );
|
$plugins->run_hooks_by_ref("functions_fetch_ban_times", $ban_times);
| $ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);
|
$ban_times['---'] = $lang->permanent; return $ban_times;
| $ban_times['---'] = $lang->permanent; return $ban_times;
|
Zeile 6185 | Zeile 6287 |
---|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
| 0xAD => 1, 0xA0 => 1, 0xAD => 1, 0xBF => 1, 0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1,
|
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160} 0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}
| 0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160} 0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}
|
Zeile 6203 | Zeile 6313 |
---|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
| 0xA0 => array(0xC2 => 1), 0xAD => array(0xC2 => 1), 0xBF => array(0xC2 => 1), 0x81 => array(0xC2 => 1), 0x8D => array(0xC2 => 1), 0x90 => array(0xC2 => 1), 0x9D => array(0xC2 => 1),
|
0xB8 => array(0xCC => 1), // \x{0338} 0xB7 => array(0xCC => 1), // \x{0337} 0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}
| 0xB8 => array(0xCC => 1), // \x{0338} 0xB7 => array(0xCC => 1), // \x{0337} 0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}
|