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 5172 2010-08-02 23:13:03Z RyanGordon $
| * $Id$
|
*/
/**
| */
/**
|
Zeile 21 | Zeile 21 |
---|
$contents = parse_page($contents); $totaltime = $maintimer->stop();
|
$contents = parse_page($contents); $totaltime = $maintimer->stop();
|
| $contents = $plugins->run_hooks("pre_output_page", $contents);
|
if($mybb->usergroup['cancp'] == 1) {
| if($mybb->usergroup['cancp'] == 1) {
|
Zeile 46 | Zeile 47 |
---|
$serverload = get_server_load();
if(my_strpos(getenv("REQUEST_URI"), "?"))
|
$serverload = get_server_load();
if(my_strpos(getenv("REQUEST_URI"), "?"))
|
{ $debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1"; } else { $debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1"; }
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled"; } else {
| { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1"; } else { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1"; }
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled"; } else {
|
$gzipen = "Disabled";
|
$gzipen = "Disabled";
|
}
| }
$memory_usage = get_memory_usage();
if($memory_usage) { $memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage); } else { $memory_usage = ''; } // MySQLi is still MySQL, so present it that way to the user $database_server = $db->short_title;
|
|
|
if(function_exists("memory_get_usage"))
| if($database_server == 'MySQLi')
|
{
|
{
|
$memory_usage = " / Memory Usage: ".get_friendly_size(memory_get_peak_usage(true));
| $database_server = 'MySQL';
|
}
|
}
|
| |
$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";
|
$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 />";
| $debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% ".$database_server.")<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); }
| $contents = str_replace("<debugstuff>", $debugstuff, $contents); }
|
Zeile 80 | Zeile 93 |
---|
}
$contents = str_replace("<debugstuff>", "", $contents);
|
}
$contents = str_replace("<debugstuff>", "", $contents);
|
$contents = $plugins->run_hooks("pre_output_page", $contents);
|
|
if($mybb->settings['gzipoutput'] == 1) { $contents = gzip_encode($contents, $mybb->settings['gziplevel']); }
|
if($mybb->settings['gzipoutput'] == 1) { $contents = gzip_encode($contents, $mybb->settings['gziplevel']); }
|
|
|
@header("Content-type: text/html; charset={$lang->settings['charset']}");
|
@header("Content-type: text/html; charset={$lang->settings['charset']}");
|
|
|
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(); }
| |
}
/**
| }
/**
|
Zeile 110 | Zeile 116 |
---|
function add_shutdown($name, $arguments=array()) { global $shutdown_functions;
|
function add_shutdown($name, $arguments=array()) { global $shutdown_functions;
|
| if(!is_array($shutdown_functions)) { $shutdown_functions = array(); }
|
if(!is_array($arguments)) { $arguments = array($arguments); }
if(is_array($name) && method_exists($name[0], $name[1]))
|
if(!is_array($arguments)) { $arguments = array($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; }
| { $shutdown_functions[] = array('function' => $name, 'arguments' => $arguments); return true; }
|
else if(!is_array($name) && function_exists($name)) {
|
else if(!is_array($name) && function_exists($name)) {
|
$shutdown_functions[$name] = array('function' => $name, 'arguments' => $arguments);
| $shutdown_functions[] = array('function' => $name, 'arguments' => $arguments);
|
return true; }
| return true; }
|
Zeile 152 | Zeile 163 |
---|
// 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(!is_object($db)) {
| // If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct if(!is_object($db)) {
|
Zeile 162 | Zeile 173 |
---|
{ require MYBB_ROOT."inc/config.php"; }
|
{ require MYBB_ROOT."inc/config.php"; }
|
|
|
if(isset($config)) { require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
| if(isset($config)) { require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
|
Zeile 180 | Zeile 191 |
---|
default: $db = new DB_MySQL; }
|
default: $db = new DB_MySQL; }
|
|
|
$db->connect($config['database']); define("TABLE_PREFIX", $config['database']['table_prefix']); $db->set_table_prefix(TABLE_PREFIX);
| $db->connect($config['database']); define("TABLE_PREFIX", $config['database']['table_prefix']); $db->set_table_prefix(TABLE_PREFIX);
|
Zeile 190 | Zeile 201 |
---|
// Cache object deconstructed? reconstruct if(!is_object($cache))
|
// Cache object deconstructed? reconstruct if(!is_object($cache))
|
{
| {
|
require_once MYBB_ROOT."inc/class_datacache.php"; $cache = new datacache; $cache->cache(); }
// And finally.. plugins
|
require_once MYBB_ROOT."inc/class_datacache.php"; $cache = new datacache; $cache->cache(); }
// And finally.. plugins
|
if(!is_object($plugins) && !defined("NO_PLUGINS"))
| if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))
|
{ require_once MYBB_ROOT."inc/class_plugins.php"; $plugins = new pluginSystem;
| { require_once MYBB_ROOT."inc/class_plugins.php"; $plugins = new pluginSystem;
|
Zeile 211 | Zeile 222 |
---|
foreach($shutdown_queries as $query) { $db->query($query);
|
foreach($shutdown_queries as $query) { $db->query($query);
|
} }
| } }
|
// Run any shutdown functions if we have them if(is_array($shutdown_functions)) {
| // Run any shutdown functions if we have them if(is_array($shutdown_functions)) {
|
Zeile 224 | Zeile 235 |
---|
}
$done_shutdown = true;
|
}
$done_shutdown = true;
|
}
| }
|
/** * Sends a specified amount of messages from the mail queue
| /** * Sends a specified amount of messages from the mail queue
|
Zeile 246 | Zeile 257 |
---|
// 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'], true); }
|
} // 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 284 | Zeile 296 |
---|
{ $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);
| $contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);
|
if($lang->settings['rtl'] == 1)
|
if($lang->settings['rtl'] == 1)
|
{
| {
|
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents); }
if($lang->settings['htmllang']) { $contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
|
$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);
|
}
| }
|
if($error_handler->warnings) { $contents = str_replace("<body>", "<body>\n".$error_handler->show_warnings(), $contents); }
|
if($error_handler->warnings) { $contents = str_replace("<body>", "<body>\n".$error_handler->show_warnings(), $contents); }
|
|
|
return $contents; }
/** * Turn a unix timestamp in to a "friendly" date/time format for the user.
|
return $contents; }
/** * Turn a unix timestamp in to a "friendly" date/time format for the user.
|
*
| *
|
* @param string A date format according to PHP's date structure. * @param int The unix timestamp the date should be generated for. * @param int The offset in hours that should be applied to times. (timezones)
| * @param string A date format according to PHP's date structure. * @param int The unix timestamp the date should be generated for. * @param int The offset in hours that should be applied to times. (timezones)
|
Zeile 318 | Zeile 330 |
---|
function my_date($format, $stamp="", $offset="", $ty=1, $adodb=false) { global $mybb, $lang, $mybbadmin, $plugins;
|
function my_date($format, $stamp="", $offset="", $ty=1, $adodb=false) { global $mybb, $lang, $mybbadmin, $plugins;
|
|
|
// If the stamp isn't set, use TIME_NOW if(empty($stamp)) {
| // If the stamp isn't set, use TIME_NOW if(empty($stamp)) {
|
Zeile 327 | Zeile 339 |
---|
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 341 | Zeile 353 |
---|
{ $offset = $mybb->settings['timezoneoffset']; $dstcorrection = $mybb->settings['dstcorrection'];
|
{ $offset = $mybb->settings['timezoneoffset']; $dstcorrection = $mybb->settings['dstcorrection'];
|
}
| }
|
// If DST correction is enabled, add an additional hour to the timezone. if($dstcorrection == 1)
| // If DST correction is enabled, add an additional hour to the timezone. if($dstcorrection == 1)
|
Zeile 351 | Zeile 363 |
---|
{ $offset = "+".$offset; }
|
{ $offset = "+".$offset; }
|
} }
| } }
|
if($offset == "-")
|
if($offset == "-")
|
{
| {
|
$offset = 0;
|
$offset = 0;
|
}
| }
|
if($adodb == true && function_exists('adodb_date')) { $date = adodb_date($format, $stamp + ($offset * 3600)); } else
|
if($adodb == true && function_exists('adodb_date')) { $date = adodb_date($format, $stamp + ($offset * 3600)); } else
|
{
| {
|
$date = gmdate($format, $stamp + ($offset * 3600)); }
|
$date = gmdate($format, $stamp + ($offset * 3600)); }
|
|
|
if($mybb->settings['dateformat'] == $format && $ty) { $stamp = TIME_NOW;
|
if($mybb->settings['dateformat'] == $format && $ty) { $stamp = TIME_NOW;
|
|
|
if($adodb == true && function_exists('adodb_date')) { $todaysdate = adodb_date($format, $stamp + ($offset * 3600));
| if($adodb == true && function_exists('adodb_date')) { $todaysdate = adodb_date($format, $stamp + ($offset * 3600));
|
Zeile 395 | Zeile 407 |
---|
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;
|
}
| }
|
/** * Sends an email using PHP's mail function, formatting it appropriately. *
| /** * Sends an email using PHP's mail function, formatting it appropriately. *
|
Zeile 418 | Zeile 430 |
---|
{ global $mybb; static $mail;
|
{ global $mybb; static $mail;
|
|
|
// Does our object not exist? Create it if(!is_object($mail)) { require_once MYBB_ROOT."inc/class_mailhandler.php";
|
// Does our object not exist? Create it if(!is_object($mail)) { require_once MYBB_ROOT."inc/class_mailhandler.php";
|
|
|
if($mybb->settings['mail_handler'] == 'smtp')
|
if($mybb->settings['mail_handler'] == 'smtp')
|
{
| {
|
require_once MYBB_ROOT."inc/mailhandlers/smtp.php"; $mail = new SmtpMail(); }
| require_once MYBB_ROOT."inc/mailhandlers/smtp.php"; $mail = new SmtpMail(); }
|
Zeile 433 | Zeile 445 |
---|
{ require_once MYBB_ROOT."inc/mailhandlers/php.php"; $mail = new PhpMail();
|
{ require_once MYBB_ROOT."inc/mailhandlers/php.php"; $mail = new PhpMail();
|
}
| }
|
}
|
}
|
|
|
// Using SMTP based mail if($mybb->settings['mail_handler'] == 'smtp') { if($keep_alive == true) { $mail->keep_alive = true;
|
// Using SMTP based mail if($mybb->settings['mail_handler'] == 'smtp') { if($keep_alive == true) { $mail->keep_alive = true;
|
}
| }
|
}
|
}
|
|
|
// Using PHP based mail() else {
| // Using PHP based mail() else {
|
Zeile 453 | Zeile 465 |
---|
$mail->additional_parameters = $mybb->settings['mail_parameters']; } }
|
$mail->additional_parameters = $mybb->settings['mail_parameters']; } }
|
|
|
// Build and send $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); return $mail->send();
| // Build and send $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); return $mail->send();
|
Zeile 466 | Zeile 478 |
---|
*/ function generate_post_check() {
|
*/ function generate_post_check() {
|
global $mybb;
| global $mybb, $session;
|
if($mybb->user['uid']) { return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
| if($mybb->user['uid']) { return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
|
Zeile 474 | Zeile 486 |
---|
// Guests get a special string else {
|
// Guests get a special string else {
|
return md5($mybb->settings['bburl'].$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
| return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
|
} }
| } }
|
Zeile 576 | Zeile 588 |
---|
function cache_forums($force=false) { global $forum_cache, $cache;
|
function cache_forums($force=false) { global $forum_cache, $cache;
|
|
|
if($force == true) { $forum_cache = $cache->read("forums", 1);
| if($force == true) { $forum_cache = $cache->read("forums", 1);
|
Zeile 584 | Zeile 596 |
---|
}
if(!$forum_cache)
|
}
if(!$forum_cache)
|
{
| {
|
$forum_cache = $cache->read("forums"); if(!$forum_cache) {
| $forum_cache = $cache->read("forums"); if(!$forum_cache) {
|
Zeile 593 | Zeile 605 |
---|
} } return $forum_cache;
|
} } return $forum_cache;
|
}
| }
|
/** * Generate an array of all child and descendant forums for a specific forum. *
| /** * Generate an array of all child and descendant forums for a specific forum. *
|
Zeile 615 | Zeile 627 |
---|
{ $forums_by_parent[$forum['pid']][$forum['fid']] = $forum; }
|
{ $forums_by_parent[$forum['pid']][$forum['fid']] = $forum; }
|
} }
| } }
|
if(!is_array($forums_by_parent[$fid])) { return; }
|
if(!is_array($forums_by_parent[$fid])) { return; }
|
|
|
foreach($forums_by_parent[$fid] as $forum) { $forums[] = $forum['fid'];
| foreach($forums_by_parent[$fid] as $forum) { $forums[] = $forum['fid'];
|
Zeile 644 | Zeile 656 |
---|
{ 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 672 | Zeile 684 |
---|
output_page($errorpage);
exit;
|
output_page($errorpage);
exit;
|
}
/**
| }
/**
|
* Produce an error message for displaying inline on a page * * @param array Array of errors to be shown
| * Produce an error message for displaying inline on a page * * @param array Array of errors to be shown
|
Zeile 696 | Zeile 708 |
---|
}
// AJAX error message?
|
}
// AJAX error message?
|
if($mybb->input['ajax'])
| if($mybb->input['ajax'])
|
{ $error = implode("\n\n", $errors); // Send our headers.
| { $error = implode("\n\n", $errors); // Send our headers.
|
Zeile 731 | Zeile 743 |
---|
"location2" => 0 );
|
"location2" => 0 );
|
$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1); $url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
| $db->update_query("sessions", $noperm_array, "sid='{$session->sid}'");
|
if($mybb->input['ajax']) {
| if($mybb->input['ajax']) {
|
Zeile 749 | Zeile 760 |
---|
} 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")."\";"); }
| eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
|
Zeile 764 | Zeile 799 |
---|
function redirect($url, $message="", $title="") { global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
|
function redirect($url, $message="", $title="") { global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
|
|
|
$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 789 | Zeile 824 |
---|
if(!$message) { $message = $lang->redirect;
|
if(!$message) { $message = $lang->redirect;
|
}
| }
|
$time = TIME_NOW; $timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);
| $time = TIME_NOW; $timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);
|
Zeile 798 | Zeile 833 |
---|
{ $title = $mybb->settings['bbname']; }
|
{ $title = $mybb->settings['bbname']; }
|
|
|
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest. if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))
|
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest. if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))
|
{
| {
|
$url = str_replace("&", "&", $url);
|
$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 849 |
---|
$url = str_replace(array("\n","\r",";"), "", $url);
run_shutdown();
|
$url = str_replace(array("\n","\r",";"), "", $url);
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 845 | Zeile 880 |
---|
{ return; }
|
{ return; }
|
|
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
$pages = ceil($count / $perpage);
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
$pages = ceil($count / $perpage);
|
| $prevpage = '';
|
if($page > 1) { $prev = $page-1;
| if($page > 1) { $prev = $page-1;
|
Zeile 860 | Zeile 896 |
---|
// Maximum number of "page bits" to show if(!$mybb->settings['maxmultipagelinks'])
|
// Maximum number of "page bits" to show if(!$mybb->settings['maxmultipagelinks'])
|
{
| {
|
$mybb->settings['maxmultipagelinks'] = 5; }
|
$mybb->settings['maxmultipagelinks'] = 5; }
|
|
|
$from = $page-floor($mybb->settings['maxmultipagelinks']/2); $to = $page+floor($mybb->settings['maxmultipagelinks']/2);
| $from = $page-floor($mybb->settings['maxmultipagelinks']/2); $to = $page+floor($mybb->settings['maxmultipagelinks']/2);
|
Zeile 871 | Zeile 907 |
---|
{ $from = 1; $to = $from+$mybb->settings['maxmultipagelinks']-1;
|
{ $from = 1; $to = $from+$mybb->settings['maxmultipagelinks']-1;
|
}
| }
|
if($to > $pages) { $to = $pages;
| if($to > $pages) { $to = $pages;
|
Zeile 880 | Zeile 916 |
---|
if($from <= 0) { $from = 1;
|
if($from <= 0) { $from = 1;
|
} }
| } }
|
if($to == 0)
|
if($to == 0)
|
{
| {
|
$to = $pages; }
|
$to = $pages; }
|
| $start = '';
|
if($from > 1) { if($from-1 == 1) { $lang->multipage_link_start = '';
|
if($from > 1) { if($from-1 == 1) { $lang->multipage_link_start = '';
|
}
| }
|
$page_url = fetch_page_url($url, 1); eval("\$start = \"".$templates->get("multipage_start")."\";"); }
|
$page_url = fetch_page_url($url, 1); 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 919 | Zeile 957 |
---|
} }
|
} }
|
| $end = '';
|
if($to < $pages) { if($to+1 == $pages)
| if($to < $pages) { if($to+1 == $pages)
|
Zeile 930 | Zeile 969 |
---|
eval("\$end = \"".$templates->get("multipage_end")."\";"); }
|
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);
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
|
|
|
if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
| if($breadcrumb == true) { eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");
|
Zeile 948 | Zeile 989 |
---|
}
return $multipage;
|
}
return $multipage;
|
}
| }
|
/** * Generate a page URL for use by the multipage function *
| /** * Generate a page URL for use by the multipage function *
|
Zeile 958 | Zeile 999 |
---|
*/ function fetch_page_url($url, $page) {
|
*/ function fetch_page_url($url, $page) {
|
// If no page identifier is specified we tack it on to the end of the URL if(strpos($url, "{page}") === false)
| if($page <= 1)
|
{
|
{
|
| $find = array( "-page-{page}", "&page={page}", "{page}" );
// Remove "Page 1" to the defacto URL $url = str_replace($find, array("", "", $page), $url); 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(strpos($url, "?") === false)
|
{
| {
|
$url .= "?";
|
$url .= "?";
|
}
| }
|
else { $url .= "&"; }
|
else { $url .= "&"; }
|
|
|
$url .= "page=$page"; } else { $url = str_replace("{page}", $page, $url); }
|
$url .= "page=$page"; } else { $url = str_replace("{page}", $page, $url); }
|
|
|
return $url; }
| return $url; }
|
Zeile 1034 | Zeile 1089 |
---|
{ global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
{ global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
$groups = explode(",", $gid);
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
$groups = explode(",", $gid);
|
if(count($groups) == 1) {
| if(count($groups) == 1) {
|
Zeile 1072 | Zeile 1127 |
---|
{ $usergroup[$perm] = 0; continue;
|
{ $usergroup[$perm] = 0; continue;
|
}
| }
|
if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility? {
| if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility? {
|
Zeile 1205 | Zeile 1260 |
---|
$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; }
|
|
|
$current_permissions = array();
|
$current_permissions = array();
|
| $only_view_own_threads = 1;
|
foreach($groups as $gid) { if($groupscache[$gid]) { $level_permissions = $fpermcache[$fid][$gid];
|
foreach($groups as $gid) { if($groupscache[$gid]) { $level_permissions = $fpermcache[$fid][$gid];
|
|
|
// If our permissions arn't inherited we need to figure them out if(empty($level_permissions))
|
// If our permissions arn't inherited we need to figure them out if(empty($level_permissions))
|
{
| {
|
$parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents))
| $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents); if(!empty($parents))
|
Zeile 1233 | Zeile 1289 |
---|
break; } }
|
break; } }
|
|
|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
}
| }
|
} }
|
} }
|
|
|
foreach($level_permissions as $permission => $access) { if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission]) { $current_permissions[$permission] = $access; }
|
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($level_permissions["canview"] && !$level_permissions["canonlyviewownthreads"]) { $only_view_own_threads = 0;
|
} }
|
} }
|
| }
// Figure out if we can view more than our own threads if($only_view_own_threads == 0) { $current_permissions["canonlyviewownthreads"] = 0;
|
}
if(count($current_permissions) == 0)
| }
if(count($current_permissions) == 0)
|
Zeile 1262 | Zeile 1329 |
---|
/** * 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 boolean The Parent ID
| * @param int $fid The forum ID * @param int $pid The Parent ID * @param bool $return * @return bool
|
*/
|
*/
|
function check_forum_password($fid, $pid=0)
| function check_forum_password($fid, $pid=0, $return=false)
|
{ global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
|
{ global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
|
|
|
$showform = true;
|
$showform = true;
|
|
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums();
| if(!is_array($forum_cache)) { $forum_cache = cache_forums();
|
Zeile 1291 | Zeile 1360 |
---|
{ 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 1312 | Zeile 1381 |
---|
else { eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
|
else { eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
|
$showform = true; } } else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))
| $showform = true; } } 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 1328 | Zeile 1397 |
---|
} } else
|
} } else
|
{
| {
|
$showform = false;
|
$showform = false;
|
| }
if($return) { return $showform;
|
}
if($showform)
| }
if($showform)
|
Zeile 1339 | Zeile 1413 |
---|
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid)); } else
|
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid)); } else
|
{
| {
|
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']); eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform);
| $_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']); eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform);
|
Zeile 1358 | Zeile 1432 |
---|
*/ function get_moderator_permissions($fid, $uid="0", $parentslist="") {
|
*/ function get_moderator_permissions($fid, $uid="0", $parentslist="") {
|
global $mybb, $db;
| global $mybb, $cache, $db;
|
static $modpermscache;
|
static $modpermscache;
|
|
|
if($uid < 1)
|
if($uid < 1)
|
{
| {
|
$uid = $mybb->user['uid']; }
|
$uid = $mybb->user['uid']; }
|
|
|
if($uid == 0)
|
if($uid == 0)
|
{
| {
|
return false;
|
return false;
|
} if(!isset($modpermscache[$fid][$uid])) { if(!$parentslist)
| }
if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid]; }
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid)); }
// Get user groups $perms = array(); $user = get_user($uid);
$groups = array($user['usergroup']);
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
foreach($extra_groups as $extra_group)
|
{
|
{
|
$parentslist = get_parent_list($fid);
| $groups[] = $extra_group;
|
}
|
}
|
// Get user groups $query = $db->simple_select("users", "usergroup,additionalgroups", "uid='{$uid}'"); $usergroups = $db->fetch_array($query); $groups = "'{$usergroups['usergroup']}'"; if(!empty($usergroups['additionalgroups']))
| }
$mod_cache = $cache->read("moderators");
foreach($mod_cache as $forumid => $forum) { if(!is_array($forum) || !in_array($forumid, $parentslist))
|
{
|
{
|
$groups .= ",'{$usergroups['additionalgroups']}'";
| // No perms or we're not after this forum continue; }
// User settings override usergroup settings if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid]; foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
// Figure out the user permissions if($value == 0) { // The user doesn't have permission to set this action $perms[$action] = 0; } else { $perms[$action] = max($perm[$action], $perms[$action]); } }
|
}
|
}
|
$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND fid='$fid'"); while($results = $db->fetch_array($query))
| foreach($groups as $group)
|
{
|
{
|
$perms['caneditposts'] = max($perms['caneditposts'], $results['caneditposts']); $perms['candeleteposts'] = max($perms['candeleteposts'], $results['candeleteposts']); $perms['canviewips'] = max($perms['canviewips'], $results['canviewips']); $perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $results['canopenclosethreads']); $perms['canmanagethreads'] = max($perms['canmanagethreads'], $results['canmanagethreads']); $perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $results['canmovetononmodforum']);
| if(!is_array($forum['usergroups'][$group])) { // There are no permissions set for this group continue; }
$perm = $forum['usergroups'][$group]; foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
$perms[$action] = max($perm[$action], $perms[$action]); }
|
}
|
}
|
$sql = build_parent_list($fid, "fid", "OR", $parentslist); $query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND {$sql}"); $uperms = $db->fetch_array($query); if(!$uperms && !$perms) { return false; } //Join the group permissions with the user permissions $perms['caneditposts'] = max($perms['caneditposts'], $uperms['caneditposts']); $perms['candeleteposts'] = max($perms['candeleteposts'], $uperms['candeleteposts']); $perms['canviewips'] = max($perms['canviewips'], $uperms['canviewips']); $perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $uperms['canopenclosethreads']); $perms['canmanagethreads'] = max($perms['canmanagethreads'], $uperms['canmanagethreads']); $perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $uperms['canmovetononmodforum']); $modpermscache[$fid][$uid] = $perms; } else { $perms = $modpermscache[$fid][$uid];
| |
}
|
}
|
| $modpermscache[$fid][$uid] = $perms;
|
return $perms; }
| return $perms; }
|
Zeile 1441 | Zeile 1547 |
---|
{ $uid = $mybb->user['uid']; }
|
{ $uid = $mybb->user['uid']; }
|
|
|
if($uid == 0) { return false;
| if($uid == 0) { return false;
|
Zeile 1450 | Zeile 1556 |
---|
$user_perms = user_permissions($uid); if($user_perms['issupermod'] == 1) {
|
$user_perms = user_permissions($uid); if($user_perms['issupermod'] == 1) {
|
| if($fid) { $forumpermissions = forum_permissions($fid); if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads']) { return true; } return false; }
|
return true; } else
| return true; } else
|
Zeile 1460 | Zeile 1575 |
---|
if(!empty($modcache)) { foreach($modcache as $modusers)
|
if(!empty($modcache)) { foreach($modcache as $modusers)
|
{
| {
|
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid']) {
|
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid']) {
|
| return true; } elseif(isset($modusers['usergroups'][$user_perms['gid']])) { // Moderating usergroup
|
return true; } } } return false;
|
return true; } } } return false;
|
} else {
| } else {
|
$modperms = get_moderator_permissions($fid, $uid);
|
$modperms = get_moderator_permissions($fid, $uid);
|
|
|
if(!$action && $modperms)
|
if(!$action && $modperms)
|
{
| {
|
return true; } else
| return true; } else
|
Zeile 1482 | Zeile 1602 |
---|
if($modperms[$action] == 1) { return true;
|
if($modperms[$action] == 1) { return true;
|
}
| }
|
else { return false;
| else { return false;
|
Zeile 1507 | Zeile 1627 |
---|
$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 1516 | Zeile 1637 |
---|
$posticons[$posticon['name']] = $posticon; } krsort($posticons);
|
$posticons[$posticon['name']] = $posticon; } krsort($posticons);
|
|
|
foreach($posticons as $dbicon) {
|
foreach($posticons as $dbicon) {
|
| $dbicon['path'] = htmlspecialchars_uni($dbicon['path']); $dbicon['name'] = htmlspecialchars_uni($dbicon['name']);
|
if($icon == $dbicon['iid']) { $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
| if($icon == $dbicon['iid']) { $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
|
Zeile 1534 | Zeile 1658 |
---|
{ $iconlist .= "<br />"; $listed = 0;
|
{ $iconlist .= "<br />"; $listed = 0;
|
}
| }
|
}
|
}
|
|
|
eval("\$posticons = \"".$templates->get("posticons")."\";");
|
eval("\$posticons = \"".$templates->get("posticons")."\";");
|
|
|
return $posticons; }
/** * MyBB setcookie() wrapper.
|
return $posticons; }
/** * MyBB setcookie() wrapper.
|
*
| *
|
* @param string The cookie identifier. * @param string The cookie value. * @param int The timestamp of the expiry date.
| * @param string The cookie identifier. * @param string The cookie value. * @param int The timestamp of the expiry date.
|
Zeile 1564 | Zeile 1688 |
---|
$expires = 0; } elseif($expires == "" || $expires == null)
|
$expires = 0; } elseif($expires == "" || $expires == null)
|
{
| {
|
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time } else
| $expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time } else
|
Zeile 1582 | Zeile 1706 |
---|
if($expires > 0) { $cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
|
if($expires > 0) { $cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
|
}
| }
|
if(!empty($mybb->settings['cookiepath']))
|
if(!empty($mybb->settings['cookiepath']))
|
{
| {
|
$cookie .= "; path={$mybb->settings['cookiepath']}"; }
if(!empty($mybb->settings['cookiedomain'])) { $cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
$cookie .= "; path={$mybb->settings['cookiepath']}"; }
if(!empty($mybb->settings['cookiedomain'])) { $cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
}
| }
|
if($httponly == true) { $cookie .= "; HttpOnly"; }
|
if($httponly == true) { $cookie .= "; HttpOnly"; }
|
|
|
$mybb->cookies[$name] = $value;
header($cookie, false);
| $mybb->cookies[$name] = $value;
header($cookie, false);
|
Zeile 1612 | Zeile 1736 |
---|
function my_unsetcookie($name) { global $mybb;
|
function my_unsetcookie($name) { global $mybb;
|
|
|
$expires = -3600; my_setcookie($name, "", $expires);
|
$expires = -3600; my_setcookie($name, "", $expires);
|
|
|
unset($mybb->cookies[$name]); }
| unset($mybb->cookies[$name]); }
|
Zeile 1629 | Zeile 1753 |
---|
function my_get_array_cookie($name, $id) { global $mybb;
|
function my_get_array_cookie($name, $id) { global $mybb;
|
|
|
if(!isset($mybb->cookies['mybb'][$name]))
|
if(!isset($mybb->cookies['mybb'][$name]))
|
{
| {
|
return false;
|
return false;
|
}
$cookie = unserialize($mybb->cookies['mybb'][$name]);
| }
|
|
|
if(isset($cookie[$id]))
| $cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id]))
|
{ return $cookie[$id]; } else
|
{ return $cookie[$id]; } else
|
{
| {
|
return 0; } }
| return 0; } }
|
Zeile 1653 | Zeile 1777 |
---|
* @param string The cookie identifier. * @param int The cookie content id. * @param string The value to set the cookie to.
|
* @param string The cookie identifier. * @param int The cookie content id. * @param string The value to set the cookie to.
|
*/ function my_set_array_cookie($name, $id, $value) {
| */ function my_set_array_cookie($name, $id, $value, $expires="") {
|
global $mybb;
|
global $mybb;
|
|
|
$cookie = $mybb->cookies['mybb'];
|
$cookie = $mybb->cookies['mybb'];
|
$newcookie = unserialize($cookie[$name]);
| $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) { // Do no unserialize objects if(substr($data, 0, 1) == 'O') { return array(); }
$array = unserialize($data);
if(!is_array($array)) { $array = array(); }
return $array;
|
}
/**
| }
/**
|
Zeile 1699 | Zeile 1848 |
---|
{ return $lang->unknown; }
|
{ return $lang->unknown; }
|
|
|
// Suhosin likes to throw a warning if exec is disabled then die - weird if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
|
// 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;
| if(strpos(",".$func_blacklist.",", 'exec') !== false) { return $lang->unknown;
|
Zeile 1723 | Zeile 1872 |
---|
if(!is_array($serverload)) { return $lang->unknown;
|
if(!is_array($serverload)) { return $lang->unknown;
|
}
| }
|
}
|
}
|
}
| }
|
else { return $lang->unknown; }
|
else { return $lang->unknown; }
|
|
|
$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; }
|
/** * Updates the forum statistics with specific values (or addition/subtraction of the previous value)
| /** * Updates the forum statistics with specific values (or addition/subtraction of the previous value)
|
Zeile 1757 | Zeile 1924 |
---|
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { if(intval($changes[$counter]) != 0)
|
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { if(intval($changes[$counter]) != 0)
|
{
| {
|
$new_stats[$counter] = $stats[$counter] + $changes[$counter]; } }
| $new_stats[$counter] = $stats[$counter] + $changes[$counter]; } }
|
Zeile 1776 | Zeile 1943 |
---|
// Fetch latest user if the user count is changing if(array_key_exists('numusers', $changes)) {
|
// Fetch latest user if the user count is changing if(array_key_exists('numusers', $changes)) {
|
$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
| $query = $db->simple_select("users", "uid, username", "", array('order_by' => 'regdate', 'order_dir' => 'DESC', 'limit' => 1));
|
$lastmember = $db->fetch_array($query); $new_stats['lastuid'] = $lastmember['uid']; $new_stats['lastusername'] = $lastmember['username'];
|
$lastmember = $db->fetch_array($query); $new_stats['lastuid'] = $lastmember['uid']; $new_stats['lastusername'] = $lastmember['username'];
|
}
| }
|
if(empty($new_stats)) { return; }
|
if(empty($new_stats)) { return; }
|
|
|
if(is_array($stats)) { $stats = array_merge($stats, $new_stats);
| if(is_array($stats)) { $stats = array_merge($stats, $new_stats);
|
Zeile 1804 | Zeile 1971 |
---|
"numposts" => $stats['numposts'] ); $db->replace_query("stats", $todays_stats, "dateline");
|
"numposts" => $stats['numposts'] ); $db->replace_query("stats", $todays_stats, "dateline");
|
|
|
$cache->update("stats", $stats, "dateline"); }
| $cache->update("stats", $stats, "dateline"); }
|
Zeile 1815 | Zeile 1982 |
---|
* @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())
|
* @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();
| global $db, $cache;
$update_query = array();
|
Zeile 1839 | Zeile 2006 |
---|
{ $update_query[$counter] = $changes[$counter]; }
|
{ $update_query[$counter] = $changes[$counter]; }
|
|
|
// Less than 0? That's bad if($update_query[$counter] < 0) {
| // Less than 0? That's bad if($update_query[$counter] < 0) {
|
Zeile 1852 | Zeile 2019 |
---|
if(count($update_query) > 0) { $db->update_query("forums", $update_query, "fid='".intval($fid)."'");
|
if(count($update_query) > 0) { $db->update_query("forums", $update_query, "fid='".intval($fid)."'");
|
}
| }
|
// Guess we should update the statistics too?
|
// Guess we should update the statistics too?
|
if(isset($update_query['threads']) || isset($update_query['posts']) || isset($update_query['unapprovedthreads']) || isset($update_query['unapprovedposts'])) { $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('unapprovedthreads', $update_query))
| $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('unapprovedthreads', $update_query)) { $unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads']; if($unapprovedthreads_diff > -1) { $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}"; } else { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_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}"; } }
if(array_key_exists('unapprovedposts', $update_query)) { $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts']; if($unapprovedposts_diff > -1)
|
{
|
{
|
$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads']; if($unapprovedthreads_diff > -1) { $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}"; } else { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}"; }
| $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
|
}
|
}
|
if(array_key_exists('posts', $update_query))
| else
|
{
|
{
|
$posts_diff = $update_query['posts'] - $forum['posts']; if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}"; } else { $new_stats['numposts'] = "{$posts_diff}"; } } if(array_key_exists('unapprovedposts', $update_query)) { $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts']; if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}"; } else { $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; }
| $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
|
}
|
}
|
| }
if(!empty($new_stats)) {
|
update_stats($new_stats); }
|
update_stats($new_stats); }
|
|
|
// Update last post info update_forum_lastpost($fid);
|
// Update last post info update_forum_lastpost($fid);
|
|
|
$cache->update_forums(); }
| $cache->update_forums(); }
|
Zeile 1959 | Zeile 2127 |
---|
global $db;
$update_query = array();
|
global $db;
$update_query = array();
|
|
|
$counters = array('replies','unapprovedposts','attachmentcount', 'attachmentcount');
|
$counters = array('replies','unapprovedposts','attachmentcount', 'attachmentcount');
|
|
|
// Fetch above counters for this thread $query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'"); $thread = $db->fetch_array($query);
|
// Fetch above counters for this thread $query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'"); $thread = $db->fetch_array($query);
|
|
|
foreach($counters as $counter) { if(array_key_exists($counter, $changes))
| foreach($counters as $counter) { if(array_key_exists($counter, $changes))
|
Zeile 1979 | Zeile 2147 |
---|
{ $update_query[$counter] = $changes[$counter]; }
|
{ $update_query[$counter] = $changes[$counter]; }
|
|
|
// Less than 0? That's bad if($update_query[$counter] < 0) {
| // Less than 0? That's bad if($update_query[$counter] < 0) {
|
Zeile 1987 | Zeile 2155 |
---|
} } }
|
} } }
|
|
|
$db->free_result($query);
// Only update if we're actually doing something
| $db->free_result($query);
// Only update if we're actually doing something
|
Zeile 1995 | Zeile 2163 |
---|
{ $db->update_query("threads", $update_query, "tid='".intval($tid)."'"); }
|
{ $db->update_query("threads", $update_query, "tid='".intval($tid)."'"); }
|
|
|
unset($update_query, $thread);
update_thread_data($tid);
| unset($update_query, $thread);
update_thread_data($tid);
|
Zeile 2009 | Zeile 2177 |
---|
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 2018 | Zeile 2195 |
---|
LIMIT 1" ); $lastpost = $db->fetch_array($query);
|
LIMIT 1" ); $lastpost = $db->fetch_array($query);
|
|
|
$db->free_result($query);
|
$db->free_result($query);
|
|
|
$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 2030 | Zeile 2207 |
---|
LIMIT 1 "); $firstpost = $db->fetch_array($query);
|
LIMIT 1 "); $firstpost = $db->fetch_array($query);
|
|
|
$db->free_result($query);
if(!$firstpost['username'])
|
$db->free_result($query);
if(!$firstpost['username'])
|
{
| {
|
$firstpost['username'] = $firstpost['postusername']; }
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername'];
|
$firstpost['username'] = $firstpost['postusername']; }
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername'];
|
}
| }
|
if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username'];
| if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username'];
|
Zeile 2062 | Zeile 2239 |
---|
'lastposteruid' => intval($lastpost['uid']), ); $db->update_query("threads", $update_array, "tid='{$tid}'");
|
'lastposteruid' => intval($lastpost['uid']), ); $db->update_query("threads", $update_array, "tid='{$tid}'");
|
|
|
unset($firstpost, $lastpost, $update_array); }
| unset($firstpost, $lastpost, $update_array); }
|
Zeile 2133 | Zeile 2310 |
---|
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 2160 | Zeile 2338 |
---|
$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 2177 | Zeile 2355 |
---|
$optionselected = "selected=\"selected\""; $selecteddone = 1; }
|
$optionselected = "selected=\"selected\""; $selecteddone = 1; }
|
|
|
$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
| $forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));
eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
|
Zeile 2211 | Zeile 2389 |
---|
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; }
/** * Returns the extension of a file.
|
return $forumjump; }
/** * Returns the extension of a file.
|
*
| *
|
* @param string The filename. * @return string The extension of the file. */
| * @param string The filename. * @return string The extension of the file. */
|
Zeile 2242 | Zeile 2429 |
---|
$str = '';
for($i = 1; $i <= $length; ++$i)
|
$str = '';
for($i = 1; $i <= $length; ++$i)
|
{
| {
|
$ch = my_rand(0, count($set)-1); $str .= $set[$ch]; }
|
$ch = my_rand(0, count($set)-1); $str .= $set[$ch]; }
|
|
|
return $str; }
/** * Formats a username based on their display group
|
return $str; }
/** * Formats a username based on their display group
|
*
| *
|
* @param string The username * @param int The usergroup for the user (if not specified, will be fetched) * @param int The display group for the user (if not specified, will be fetched)
| * @param string The username * @param int The usergroup for the user (if not specified, will be fetched) * @param int The display group for the user (if not specified, will be fetched)
|
Zeile 2263 | Zeile 2450 |
---|
global $groupscache, $cache;
if(!is_array($groupscache))
|
global $groupscache, $cache;
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups"); }
| $groupscache = $cache->read("usergroups"); }
|
Zeile 2294 | Zeile 2481 |
---|
function build_mycode_inserter($bind="message") { global $db, $mybb, $theme, $templates, $lang, $plugins;
|
function build_mycode_inserter($bind="message") { global $db, $mybb, $theme, $templates, $lang, $plugins;
|
|
|
if($mybb->settings['bbcodeinserter'] != 0) { $editor_lang_strings = array(
| if($mybb->settings['bbcodeinserter'] != 0) { $editor_lang_strings = array(
|
Zeile 2322 | Zeile 2509 |
---|
"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 2340 | Zeile 2526 |
---|
"editor_color" ); $editor_language = "var editor_language = {\n";
|
"editor_color" ); $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 2350 | Zeile 2536 |
---|
$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 .= ","; }
|
Zeile 2412 | Zeile 2598 |
---|
{ reset($smiliecache);
|
{ reset($smiliecache);
|
| $getmore = '';
|
if($mybb->settings['smilieinsertertot'] >= $smiliecount) { $mybb->settings['smilieinsertertot'] = $smiliecount;
| if($mybb->settings['smilieinsertertot'] >= $smiliecount) { $mybb->settings['smilieinsertertot'] = $smiliecount;
|
Zeile 2459 | Zeile 2646 |
---|
else { $clickablesmilies = "";
|
else { $clickablesmilies = "";
|
} } else { $clickablesmilies = ""; }
| } } else { $clickablesmilies = ""; }
|
return $clickablesmilies;
|
return $clickablesmilies;
|
| }
/** * Builds thread prefixes and returns a selected prefix (or all) * * @param int The prefix ID (0 to return all) * @return array The thread prefix's values (or all thread prefixes) */ function build_prefixes($pid=0) { global $cache; static $prefixes_cache;
if(is_array($prefixes_cache)) { if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid]; }
return $prefixes_cache; }
$prefix_cache = $cache->read("threadprefixes");
if(!is_array($prefix_cache)) { // No cache $prefix_cache = $cache->read("threadprefixes", true);
if(!is_array($prefix_cache)) { return array(); } }
$prefixes_cache = array(); foreach($prefix_cache as $prefix) { $prefixes_cache[$prefix['pid']] = $prefix; }
if($pid != 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid]; } else if(!empty($prefixes_cache)) { return $prefixes_cache; }
return false;
|
}
/** * Build the thread prefix selection menu
|
}
/** * Build the thread prefix selection menu
|
*
| *
|
* @param mixed The forum ID (integer ID or string all) * @param mixed The selected prefix ID (integer ID or string any) * @return string The thread prefix selection menu
|
* @param mixed The forum ID (integer ID or string all) * @param mixed The selected prefix ID (integer ID or string any) * @return string The thread prefix selection menu
|
*/
| */
|
function build_prefix_select($fid, $selected_pid=0, $multiple=0) {
|
function build_prefix_select($fid, $selected_pid=0, $multiple=0) {
|
global $db, $lang, $mybb;
| global $cache, $db, $lang, $mybb;
|
if($fid != 'all')
|
if($fid != 'all')
|
{
| {
|
$fid = intval($fid); }
|
$fid = intval($fid); }
|
// Does this user have additional groups?
| $prefix_cache = build_prefixes(0); if(!$prefix_cache) { return false; // We've got no prefixes to show }
$groups = array($mybb->user['usergroup']);
|
if($mybb->user['additionalgroups']) { $exp = explode(",", $mybb->user['additionalgroups']);
|
if($mybb->user['additionalgroups']) { $exp = explode(",", $mybb->user['additionalgroups']);
|
// Because we like apostrophes... $imps = array();
| |
foreach($exp as $group)
|
foreach($exp as $group)
|
{ $imps[] = "'{$group}'"; }
$additional_groups = implode(",", $imps); $extra_sql = "groups IN ({$additional_groups}) OR "; } else { $extra_sql = ''; }
switch($db->type)
| { $groups[] = $group; } }
// Go through each of our prefixes and decide which ones we can use $prefixes = array(); foreach($prefix_cache as $prefix)
|
{
|
{
|
case "pgsql": case "sqlite": $whereforum = ""; if($fid != 'all')
| if($fid != "all" && $prefix['forums'] != "-1") { // Decide whether this prefix can be used in our forum $forums = explode(",", $prefix['forums']);
if(!in_array($fid, $forums))
|
{
|
{
|
$whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')";
| // This prefix is not in our forum list continue;
|
}
|
}
|
$query = $db->query(" SELECT pid, prefix FROM ".TABLE_PREFIX."threadprefixes WHERE ({$extra_sql}','||groups||',' LIKE '%,{$mybb->user['usergroup']},%' OR ','||groups||',' LIKE '%,-1,%' OR groups='') {$whereforum} "); break; default: $whereforum = ""; if($fid != 'all') { $whereforum = " AND (CONCAT(',',forums,',') LIKE '%,{$fid},%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='')"; } $query = $db->query(" SELECT pid, prefix FROM ".TABLE_PREFIX."threadprefixes WHERE ({$extra_sql}CONCAT(',',groups,',') LIKE '%,{$mybb->user['usergroup']},%' OR CONCAT(',',groups,',') LIKE '%,-1,%' OR groups='') {$whereforum} "); } $prefixselect = ""; if($db->num_rows($query) > 0) { $multipleselect = ""; if($multiple != 0) { $multipleselect = " multiple=\"multiple\" size=\"5\""; } $prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n"; if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any') { $any_selected = " selected=\"selected\""; } $prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n"; } $default_selected = ""; if((intval($selected_pid) == 0) && $selected_pid != 'any') { $default_selected = " selected=\"selected\"";
| |
}
|
}
|
$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n"; while($prefix = $db->fetch_array($query))
| if($prefix['groups'] != "-1")
|
{
|
{
|
$selected = ""; if($prefix['pid'] == $selected_pid)
| $prefix_groups = explode(",", $prefix['groups']);
foreach($groups as $group)
|
{
|
{
|
$selected = " selected=\"selected\"";
| if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']])) { // Our group can use this prefix! $prefixes[$prefix['pid']] = $prefix; }
|
}
|
}
|
$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
| |
}
|
}
|
$prefixselect .= "</select>\n ";
| else { // This prefix is for anybody to use... $prefixes[$prefix['pid']] = $prefix; } }
if(empty($prefixes)) { return false; }
$prefixselect = ""; if($multiple != 0) { $prefixselect = "<select name=\"threadprefix[]\" multiple=\"multiple\" size=\"5\">\n"; } else { $prefixselect = "<select name=\"threadprefix\">\n"; }
if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any') { $any_selected = " selected=\"selected\""; }
$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n"; }
$default_selected = ""; if((intval($selected_pid) == 0) && $selected_pid != 'any') { $default_selected = " selected=\"selected\""; }
$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";
foreach($prefixes as $prefix) { $selected = ""; if($prefix['pid'] == $selected_pid) { $selected = " selected=\"selected\""; }
$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
|
}
|
}
|
| $prefixselect .= "</select>\n ";
|
return $prefixselect; }
| return $prefixselect; }
|
Zeile 2599 | Zeile 2841 |
---|
$httpaccept_encoding = '';
if(isset($_SERVER['HTTP_ACCEPT_ENCODING']))
|
$httpaccept_encoding = '';
if(isset($_SERVER['HTTP_ACCEPT_ENCODING']))
|
{
| {
|
$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
|
$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
|
}
| }
|
if(my_strpos(" ".$httpaccept_encoding, "x-gzip")) { $encoding = "x-gzip"; }
if(my_strpos(" ".$httpaccept_encoding, "gzip"))
|
if(my_strpos(" ".$httpaccept_encoding, "x-gzip")) { $encoding = "x-gzip"; }
if(my_strpos(" ".$httpaccept_encoding, "gzip"))
|
{
| {
|
$encoding = "gzip"; }
| $encoding = "gzip"; }
|
Zeile 2698 | Zeile 2940 |
---|
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 2717 | Zeile 2961 |
---|
else { $display_reputation .= "reputation_neutral";
|
else { $display_reputation .= "reputation_neutral";
|
}
| }
|
$display_reputation .= "\">{$reputation}</strong>";
|
$display_reputation .= "\">{$reputation}</strong>";
|
|
|
if($uid != 0) { $display_reputation .= "</a>"; }
return $display_reputation;
|
if($uid != 0) { $display_reputation .= "</a>"; }
return $display_reputation;
|
}
| }
|
/** * Fetch a color coded version of a warning level (based on it's percentage)
| /** * Fetch a color coded version of a warning level (based on it's percentage)
|
Zeile 2736 | Zeile 2980 |
---|
* @return string Formatted warning level */ function get_colored_warning_level($level)
|
* @return string Formatted warning level */ function get_colored_warning_level($level)
|
{
| {
|
if($level >= 80)
|
if($level >= 80)
|
{
| {
|
return "<span class=\"high_warning\">{$level}%</span>";
|
return "<span class=\"high_warning\">{$level}%</span>";
|
}
| }
|
else if($level >= 50) { return "<span class=\"moderate_warning\">{$level}%</span>"; } else if($level >= 25)
|
else if($level >= 50) { return "<span class=\"moderate_warning\">{$level}%</span>"; } else if($level >= 25)
|
{
| {
|
return "<span class=\"low_warning\">{$level}%</span>"; } else
| return "<span class=\"low_warning\">{$level}%</span>"; } else
|
Zeile 2762 | Zeile 3006 |
---|
*/ function get_ip() {
|
*/ function get_ip() {
|
if(isset($_SERVER['REMOTE_ADDR']))
| global $mybb, $plugins;
$ip = 0;
if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
|
{ $ip = $_SERVER['REMOTE_ADDR']; }
|
{ $ip = $_SERVER['REMOTE_ADDR']; }
|
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
| if($mybb->settings['ip_forwarded_check'])
|
{
|
{
|
if(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); } 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) {
|
{ foreach($addresses[0] as $key => $val) {
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))
| if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $val))
|
{ $ip = $val; break;
|
{ $ip = $val; break;
|
} } }
| } } }
|
}
|
}
|
if(!isset($ip))
| if(!$ip)
|
{ if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; }
|
{ if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; }
|
else { $ip = ''; } }
| }
if($plugins) { $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); }
|
|
|
$ip = preg_replace("#([^.0-9 ]*)#", "", $ip);
| |
return $ip; }
| return $ip; }
|
Zeile 2806 | Zeile 3065 |
---|
function get_friendly_size($size) { global $lang;
|
function get_friendly_size($size) { global $lang;
|
|
|
if(!is_numeric($size)) { return $lang->na; }
|
if(!is_numeric($size)) { return $lang->na; }
|
|
|
// Yottabyte (1024 Zettabytes) if($size >= 1208925819614629174706176) {
| // Yottabyte (1024 Zettabytes) if($size >= 1208925819614629174706176) {
|
Zeile 2900 | Zeile 3159 |
---|
{ $icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); }
|
{ $icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); }
|
| $icon = htmlspecialchars_uni($icon);
|
return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />"; } else
| return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />"; } else
|
Zeile 2911 | Zeile 3171 |
---|
else if(defined("IN_PORTAL")) { global $change_dir;
|
else if(defined("IN_PORTAL")) { global $change_dir;
|
$theme['imgdir'] = "{$change_dir}/images";
| $theme['imgdir'] = htmlspecialchars_uni("{$change_dir}/images");
|
}
|
}
|
|
|
return "<img src=\"{$theme['imgdir']}/attachtypes/unknown.gif\" border=\"0\" alt=\".{$ext}\" />"; } }
| return "<img src=\"{$theme['imgdir']}/attachtypes/unknown.gif\" border=\"0\" alt=\".{$ext}\" />"; } }
|
Zeile 2926 | Zeile 3186 |
---|
*/ 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)) { cache_forums();
|
if(!is_array($forum_cache)) { cache_forums();
|
}
| }
|
if(!is_array($permissioncache)) { $permissioncache = forum_permissions(); }
|
if(!is_array($permissioncache)) { $permissioncache = forum_permissions(); }
|
| $password_forums = array();
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
} else
| } else
|
{ $perms = $mybb->usergroup; }
| { $perms = $mybb->usergroup; }
|
Zeile 2963 | Zeile 3217 |
---|
if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
| }
$password_forums[$forum['fid']] = $forum['password']; } else { // Check parents for passwords $parents = explode(",", $forum['parentlist']); foreach($parents as $parent) { if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent])) { $pwverified = 0; }
|
} }
| } }
|
Zeile 2972 | Zeile 3240 |
---|
{ $unviewableforums .= ","; }
|
{ $unviewableforums .= ","; }
|
|
|
$unviewableforums .= "'".$forum['fid']."'"; }
|
$unviewableforums .= "'".$forum['fid']."'"; }
|
}
| }
|
|
|
return $unviewableforums;
| if(isset($unviewableforums)) { return $unviewableforums; }
|
}
/**
| }
/**
|
Zeile 2993 | Zeile 3264 |
---|
// -2 idea provided by Matt Light (http://www.mephex.com) $format = str_replace("Y", $year, $format); $format = str_replace("y", my_substr($year, -2), $format);
|
// -2 idea provided by Matt Light (http://www.mephex.com) $format = str_replace("Y", $year, $format); $format = str_replace("y", my_substr($year, -2), $format);
|
|
|
return $format; }
| return $format; }
|
Zeile 3007 | Zeile 3278 |
---|
global $nav, $navbits, $templates, $theme, $lang, $mybb;
eval("\$navsep = \"".$templates->get("nav_sep")."\";");
|
global $nav, $navbits, $templates, $theme, $lang, $mybb;
eval("\$navsep = \"".$templates->get("nav_sep")."\";");
|
|
|
$i = 0;
|
$i = 0;
|
| $activesep = '';
|
if(is_array($navbits)) { reset($navbits);
| if(is_array($navbits)) { reset($navbits);
|
Zeile 3025 | Zeile 3297 |
---|
{ $sep = ""; }
|
{ $sep = ""; }
|
|
|
$multipage = null; $multipage_dropdown = null; if(!empty($navbit['multipage'])) {
|
$multipage = null; $multipage_dropdown = null; if(!empty($navbit['multipage'])) {
|
| if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1) { $mybb->settings['threadsperpage'] = 20; }
|
$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true); if($multipage) {
| $multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true); if($multipage) {
|
Zeile 3038 | Zeile 3315 |
---|
$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")."\";"); } }
|
Zeile 3102 | Zeile 3383 |
---|
{ 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 3111 | Zeile 3392 |
---|
// 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 3126 | Zeile 3407 |
---|
elseif(!empty($multipage)) { $navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);
|
elseif(!empty($multipage)) { $navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);
|
|
|
$navbits[$navsize]['multipage'] = $multipage;
|
$navbits[$navsize]['multipage'] = $multipage;
|
$navbits[$navsize]['multipage']['url'] = get_forum_link($forumnav['fid']);
| $navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED);
|
} else {
| } else {
|
Zeile 3166 | Zeile 3447 |
---|
function build_archive_link($type, $id="") { global $mybb;
|
function build_archive_link($type, $id="") { 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 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")) { $base_url = $mybb->settings['bburl']."/archive/index.php?"; }
| //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 {
|
else {
|
$base_url = $mybb->settings['bburl']."/archive/index.php/";
| $base_url = $mybb->settings['bburl']."/archive/index.php?";
|
}
switch($type)
| }
switch($type)
|
Zeile 3200 | Zeile 3482 |
---|
*/ function debug_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);
| $totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $db->query_time);
|
Zeile 3214 | Zeile 3496 |
---|
$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 3233 | Zeile 3515 |
---|
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
|
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
|
echo "</tr>\n";
| echo "</tr>\n";
|
echo "<tr>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$totaltime seconds</font></td>\n";
| echo "<tr>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$totaltime seconds</font></td>\n";
|
Zeile 3251 | Zeile 3533 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['database']['type']}, 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=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['database']['type']}, 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 3263 | Zeile 3545 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$gzipen</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. Templates Used:</font></b></td>\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 "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$gzipen</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. Templates Used:</font></b></td>\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 = 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"; }
| echo "</tr>\n";
$memory_usage = get_memory_usage(); if(!$memory_usage) { $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 "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
| echo "</table>\n";
echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
|
Zeile 3286 | Zeile 3573 |
---|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
|
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain; echo "<h2>Template Statistics</h2>\n";
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain; echo "<h2>Template Statistics</h2>\n";
|
|
|
if(count($templates->cache) > 0)
|
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 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 "</table>\n"; echo "<br />\n"; }
if(count($templates->uncached_templates > 0)) {
| echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\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 style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
| echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
|
Zeile 3328 | Zeile 3615 |
---|
{ global $mybb;
|
{ global $mybb;
|
if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)
| if($mybb->settings['nocacheheaders'] == 1)
|
{ header("Expires: Sat, 1 Jan 2000 01:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
| { header("Expires: Sat, 1 Jan 2000 01:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
Zeile 3358 | Zeile 3645 |
---|
} break; case "post":
|
} break; case "post":
|
$db->update_query("reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
| $db->update_query("reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
|
case "threads": if(is_array($id)) {
| case "threads": if(is_array($id)) {
|
Zeile 3390 | Zeile 3677 |
---|
* @param int The timestamp * @param array Array of options * @return string The friendly formatted timestamp
|
* @param int The timestamp * @param array Array of options * @return string The friendly formatted timestamp
|
*/
| */
|
function nice_time($stamp, $options=array()) { global $lang;
| function nice_time($stamp, $options=array()) { global $lang;
|
Zeile 3401 | Zeile 3688 |
---|
$dsecs = 24*60*60; $hsecs = 60*60; $msecs = 60;
|
$dsecs = 24*60*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 3454 | Zeile 3741 |
---|
if($years == 1) { $nicetime['years'] = "1".$lang_year;
|
if($years == 1) { $nicetime['years'] = "1".$lang_year;
|
}
| }
|
else if($years > 1) { $nicetime['years'] = $years.$lang_years;
| else if($years > 1) { $nicetime['years'] = $years.$lang_years;
|
Zeile 3474 | Zeile 3761 |
---|
$nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1)
|
$nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1)
|
{
| {
|
$nicetime['weeks'] = $weeks.$lang_weeks;
|
$nicetime['weeks'] = $weeks.$lang_weeks;
|
}
| }
|
if($days == 1)
|
if($days == 1)
|
{
| {
|
$nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days;
|
$nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days;
|
}
| }
|
|
|
if($options['hours'] !== false)
| if(!isset($options['hours']) || $options['hours'] !== false)
|
{ if($hours == 1)
|
{ if($hours == 1)
|
{
| {
|
$nicetime['hours'] = "1".$lang_hour; } else if($hours > 1) { $nicetime['hours'] = $hours.$lang_hours;
|
$nicetime['hours'] = "1".$lang_hour; } else if($hours > 1) { $nicetime['hours'] = $hours.$lang_hours;
|
}
| }
|
}
|
}
|
if($options['minutes'] !== false)
| if(!isset($options['minutes']) || $options['minutes'] !== false)
|
{ if($minutes == 1)
|
{ if($minutes == 1)
|
{
| {
|
$nicetime['minutes'] = "1".$lang_minute; } else if($minutes > 1) { $nicetime['minutes'] = $minutes.$lang_minutes;
|
$nicetime['minutes'] = "1".$lang_minute; } else if($minutes > 1) { $nicetime['minutes'] = $minutes.$lang_minutes;
|
}
| }
|
}
|
}
|
if($options['seconds'] !== false)
| if(!isset($options['seconds']) || $options['seconds'] !== false)
|
{ if($seconds == 1) {
| { if($seconds == 1) {
|
Zeile 3526 | Zeile 3813 |
---|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
} }
/**
| } }
/**
|
* Select an alternating row colour based on the previous call to this function * * @param int 1 to reset the row to trow1.
| * Select an alternating row colour based on the previous call to this function * * @param int 1 to reset the row to trow1.
|
Zeile 3540 | Zeile 3827 |
---|
global $alttrow;
if($alttrow == "trow1" && !$reset)
|
global $alttrow;
if($alttrow == "trow1" && !$reset)
|
{
| {
|
$trow = "trow2"; } else
| $trow = "trow2"; } else
|
Zeile 3560 | Zeile 3847 |
---|
* @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)
|
{
| {
|
global $db, $mybb;
if($uid == $mybb->user['uid'])
|
global $db, $mybb;
if($uid == $mybb->user['uid'])
|
{
| {
|
$user = $mybb->user;
|
$user = $mybb->user;
|
}
| }
|
else { $query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".intval($uid)."'");
|
else { $query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".intval($uid)."'");
|
$user = $db->fetch_array($query); }
| $user = $db->fetch_array($query); }
|
// Build the new list of additional groups for this user and make sure they're in the right format $usergroups = ""; $usergroups = $user['additionalgroups'].",".$joingroup;
|
// Build the new list of additional groups for this user and make sure they're in the right format $usergroups = ""; $usergroups = $user['additionalgroups'].",".$joingroup;
|
$groupslist = ""; $groups = explode(",", $usergroups);
if(is_array($groups)) { foreach($groups as $gid)
| $groupslist = ""; $groups = explode(",", $usergroups);
if(is_array($groups)) { foreach($groups as $gid)
|
{ if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid]) {
| { if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid]) {
|
Zeile 3601 | Zeile 3888 |
---|
else { return false;
|
else { return false;
|
} }
| } }
|
/** * Remove a user from a specific additional user group
| /** * Remove a user from a specific additional user group
|
Zeile 3613 | Zeile 3900 |
---|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
|
|
if($uid == $mybb->user['uid'])
|
if($uid == $mybb->user['uid'])
|
{
| {
|
$user = $mybb->user;
|
$user = $mybb->user;
|
}
| }
|
else { $query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query);
|
else { $query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query);
|
}
| }
|
$groupslist = ""; $usergroups = ""; $usergroups = $user['additionalgroups'].",";
| $groupslist = ""; $usergroups = ""; $usergroups = $user['additionalgroups'].",";
|
Zeile 3642 | Zeile 3929 |
---|
} } }
|
} } }
|
|
|
$dispupdate = ""; if($leavegroup == $user['displaygroup'])
|
$dispupdate = ""; if($leavegroup == $user['displaygroup'])
|
{
| {
|
$dispupdate = ", displaygroup=usergroup"; }
|
$dispupdate = ", displaygroup=usergroup"; }
|
|
|
$db->write_query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate WHERE uid='".intval($uid)."' ");
|
$db->write_query(" UPDATE ".TABLE_PREFIX."users SET additionalgroups='$groupslist' $dispupdate WHERE uid='".intval($uid)."' ");
|
|
|
$cache->update_moderators(); }
|
$cache->update_moderators(); }
|
|
|
/** * Get the current location taking in to account different web serves and systems *
| /** * Get the current location taking in to account different web serves and systems *
|
Zeile 3677 | Zeile 3964 |
---|
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']); } elseif(!empty($_ENV['PATH_INFO']))
|
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']); } elseif(!empty($_ENV['PATH_INFO']))
|
{
| {
|
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
}
| }
|
elseif(!empty($_ENV['PHP_SELF']))
|
elseif(!empty($_ENV['PHP_SELF']))
|
{
| {
|
$location = htmlspecialchars_uni($_ENV['PHP_SELF']); } else { $location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
$location = htmlspecialchars_uni($_ENV['PHP_SELF']); } else { $location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
|
}
| }
|
if($fields == true) { global $mybb;
|
if($fields == true) { global $mybb;
|
|
|
if(!is_array($ignore)) { $ignore = array($ignore); }
|
if(!is_array($ignore)) { $ignore = array($ignore); }
|
|
|
$form_html = "";
|
$form_html = "";
|
$field_parts = explode('&', $field_parts);
| |
if(!empty($mybb->input))
|
if(!empty($mybb->input))
|
{
| {
|
foreach($mybb->input as $name => $value) { if(in_array($name, $ignore)) { continue; }
|
foreach($mybb->input as $name => $value) { 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";
|
} }
|
} }
|
|
|
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else
| return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else
|
Zeile 3726 | Zeile 4011 |
---|
{ $location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']); }
|
{ $location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']); }
|
|
|
if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST")) { $post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');
|
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) { if(isset($_POST[$var]))
| foreach($post_array as $var) { if(isset($_POST[$var]))
|
Zeile 3738 | Zeile 4023 |
---|
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]); } }
|
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]); } }
|
|
|
if(isset($addloc) && is_array($addloc)) { if(strpos($location, "?") === false)
| if(isset($addloc) && is_array($addloc)) { if(strpos($location, "?") === false)
|
Zeile 3752 | Zeile 4037 |
---|
$location .= implode("&", $addloc); } }
|
$location .= implode("&", $addloc); } }
|
| if(strlen($location) > 150) { $location = substr($location, 0, 150); }
|
return $location; } }
| return $location; } }
|
Zeile 3770 | Zeile 4060 |
---|
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=false) { global $db, $themeselect, $tcache, $lang, $mybb, $limit;
|
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=false) { global $db, $themeselect, $tcache, $lang, $mybb, $limit;
|
|
|
if($tid == 0) { $themeselect = "<select name=\"$name\">";
| if($tid == 0) { $themeselect = "<select name=\"$name\">";
|
Zeile 3788 | Zeile 4078 |
---|
$tcache[$theme['pid']][$theme['tid']] = $theme; } }
|
$tcache[$theme['pid']][$theme['tid']] = $theme; } }
|
|
|
if(is_array($tcache[$tid])) { // Figure out what groups this user is in
| if(is_array($tcache[$tid])) { // Figure out what groups this user is in
|
Zeile 3797 | Zeile 4087 |
---|
$in_groups = explode(",", $mybb->user['additionalgroups']); } $in_groups[] = $mybb->user['usergroup'];
|
$in_groups = explode(",", $mybb->user['additionalgroups']); } $in_groups[] = $mybb->user['usergroup'];
|
|
|
foreach($tcache[$tid] as $theme) { $sel = "";
| foreach($tcache[$tid] as $theme) { $sel = "";
|
Zeile 3823 | Zeile 4113 |
---|
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."--";
|
}
| }
|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override); } }
|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override); } }
|
} }
| } }
|
if($tid == 1) { $themeselect .= "</select>"; }
|
if($tid == 1) { $themeselect .= "</select>"; }
|
|
|
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 3869 | Zeile 4159 |
---|
* @return int The formatted number. */ function my_number_format($number)
|
* @return int The formatted number. */ function my_number_format($number)
|
{
| {
|
global $mybb;
|
global $mybb;
|
|
|
if($number == "-") { return $number;
| if($number == "-") { return $number;
|
Zeile 3880 | Zeile 4170 |
---|
if(is_int($number)) { return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
if(is_int($number)) { return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
}
| }
|
else { $parts = explode('.', $number);
| else { $parts = explode('.', $number);
|
Zeile 3904 | Zeile 4194 |
---|
static $charset; static $use_mb; static $use_iconv;
|
static $charset; static $use_mb; static $use_iconv;
|
|
|
if(!isset($charset))
|
if(!isset($charset))
|
{
| {
|
$charset = my_strtolower($lang->settings['charset']);
|
$charset = my_strtolower($lang->settings['charset']);
|
}
| }
|
if($charset == "utf-8") { return $str; }
|
if($charset == "utf-8") { return $str; }
|
|
|
if(!isset($use_iconv))
|
if(!isset($use_iconv))
|
{
| {
|
$use_iconv = function_exists("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"); }
|
|
|
if($use_iconv || $use_mb)
|
if($use_iconv || $use_mb)
|
{
| {
|
if($to)
|
if($to)
|
{
| {
|
$from_charset = $lang->settings['charset']; $to_charset = "UTF-8";
|
$from_charset = $lang->settings['charset']; $to_charset = "UTF-8";
|
} else {
| } else {
|
$from_charset = "UTF-8"; $to_charset = $lang->settings['charset']; } if($use_iconv) { return iconv($from_charset, $to_charset."//IGNORE", $str);
|
$from_charset = "UTF-8"; $to_charset = $lang->settings['charset']; } if($use_iconv) { return iconv($from_charset, $to_charset."//IGNORE", $str);
|
} else
| } else
|
{ return @mb_convert_encoding($str, $to_charset, $from_charset); }
| { return @mb_convert_encoding($str, $to_charset, $from_charset); }
|
Zeile 3955 | Zeile 4245 |
---|
else { return utf8_decode($str);
|
else { return utf8_decode($str);
|
} }
| } }
|
else { return $str;
| else { return $str;
|
Zeile 3976 | Zeile 4266 |
---|
if($mybb->settings['wordwrap'] > 0) { $message = convert_through_utf8($message);
|
if($mybb->settings['wordwrap'] > 0) { $message = convert_through_utf8($message);
|
if(!($new_message = @preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0​", $message)))
| if(!($new_message = @preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#u", "$0​", $message)))
|
{
|
{
|
$new_message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0​", $message);
| $new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0​", $message);
|
}
|
}
|
|
|
$new_message = convert_through_utf8($new_message, false);
|
$new_message = convert_through_utf8($new_message, false);
|
|
|
return $new_message; }
| return $new_message; }
|
Zeile 4090 | Zeile 4380 |
---|
$lang->month_11, $lang->month_12 );
|
$lang->month_11, $lang->month_12 );
|
|
|
// This needs to be in this specific order $find = array(
| // This needs to be in this specific order $find = array(
|
Zeile 4101 | Zeile 4391 |
---|
'Y', 'j', 'S',
|
'Y', 'j', 'S',
|
'l',
| |
'F',
|
'F',
|
| 'l',
|
'M', );
|
'M', );
|
| $html = array( 'm', 'c', 'D', 'y', 'Y', 'j', 'S', 'F', 'l', 'M', );
$bdays = str_replace($find, $html, $bdays); $bmonth = str_replace($find, $html, $bmonth);
|
$replace = array( sprintf('%02s', $bm),
| $replace = array( sprintf('%02s', $bm),
|
Zeile 4114 | Zeile 4420 |
---|
$by, ($bd[0] == 0 ? my_substr($bd, 1) : $bd), ($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
|
$by, ($bd[0] == 0 ? my_substr($bd, 1) : $bd), ($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
|
$wd,
| |
$bmonth[$bm-1],
|
$bmonth[$bm-1],
|
| $wd,
|
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)), );
|
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)), );
|
|
|
// Do we have the full month in our output? // If so there's no need for the short month if(strpos($display, 'F') !== false)
| // Do we have the full month in our output? // If so there's no need for the short month if(strpos($display, 'F') !== false)
|
Zeile 4126 | Zeile 4432 |
---|
array_pop($find); array_pop($replace); }
|
array_pop($find); array_pop($replace); }
|
|
|
return str_replace($find, $replace, $display); }
| return str_replace($find, $replace, $display); }
|
Zeile 4135 | Zeile 4441 |
---|
* * @param string The birthday of a user. * @return float The age of a user with that birthday.
|
* * @param string The birthday of a user. * @return float The age of a user with that birthday.
|
*/
| */
|
function get_age($birthday) { $bday = explode("-", $birthday);
| function get_age($birthday) { $bday = explode("-", $birthday);
|
Zeile 4157 | Zeile 4463 |
---|
/** * Updates the first posts in a thread.
|
/** * Updates the first posts in a thread.
|
*
| *
|
* @param int The thread id for which to update the first post id. */ function update_first_post($tid)
| * @param int The thread id for which to update the first post id. */ function update_first_post($tid)
|
Zeile 4188 | Zeile 4494 |
---|
* @return int The length of the string. */ function my_strlen($string)
|
* @return int The length of the string. */ function my_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 whitespaces $string = str_replace(chr(0xCA), "", $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 whitespaces $string = str_replace(chr(0xCA), "", $string); }
|
$string = trim($string);
|
$string = trim($string);
|
if(function_exists("mb_strlen")) { $string_length = mb_strlen($string); } else { $string_length = strlen($string); }
| if(function_exists("mb_strlen")) { $string_length = mb_strlen($string); } else { $string_length = strlen($string); }
|
|
|
return $string_length;
| return $string_length;
|
}
/**
| }
/**
|
Zeile 4240 | Zeile 4546 |
---|
else { $cut_string = mb_substr($string, $start);
|
else { $cut_string = mb_substr($string, $start);
|
} } else
| } } else
|
{ if($length != "")
|
{ if($length != "")
|
{
| {
|
$cut_string = substr($string, $start, $length);
|
$cut_string = substr($string, $start, $length);
|
}
| }
|
else { $cut_string = substr($string, $start); }
|
else { $cut_string = substr($string, $start); }
|
}
| }
|
if($handle_entities) { $cut_string = htmlspecialchars_uni($cut_string);
| if($handle_entities) { $cut_string = htmlspecialchars_uni($cut_string);
|
Zeile 4297 | Zeile 4603 |
---|
}
if(function_exists("mb_strpos"))
|
}
if(function_exists("mb_strpos"))
|
{
| {
|
$position = mb_strpos($haystack, $needle, $offset);
|
$position = mb_strpos($haystack, $needle, $offset);
|
}
| }
|
else { $position = strpos($haystack, $needle, $offset); }
|
else { $position = strpos($haystack, $needle, $offset); }
|
|
|
return $position;
|
return $position;
|
}
/**
| }
/**
|
* ups the case of a string, mb strings accounted for * * @param string The string to up.
| * ups the case of a string, mb strings accounted for * * @param string The string to up.
|
Zeile 4319 | Zeile 4625 |
---|
if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string);
|
if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string);
|
}
| }
|
else { $string = strtoupper($string); }
|
else { $string = strtoupper($string); }
|
|
|
return $string; }
/** * Returns any html entities to their original character
|
return $string; }
/** * Returns any html entities to their original character
|
*
| *
|
* @param string The string to un-htmlentitize. * @return int The un-htmlentitied' string. */ function unhtmlentities($string)
|
* @param string The string to un-htmlentitize. * @return int The un-htmlentitied' string. */ function unhtmlentities($string)
|
{
| {
|
// Replace numeric entities
|
// Replace numeric entities
|
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'unichr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'unichr("\\1")', $string);
| $string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string); $string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
|
return strtr($string, $trans_tbl); }
| return strtr($string, $trans_tbl); }
|
/** * Returns any ascii to it's character (utf-8 safe).
| /** * Returns any ascii to it's character (utf-8 safe).
|
Zeile 4355 | Zeile 4661 |
---|
*/ function unichr($c) {
|
*/ function unichr($c) {
|
if($c <= 0x7F)
| if($c <= 0x7F)
|
{
|
{
|
return chr($c); }
| return chr($c); }
|
else if($c <= 0x7FF) {
|
else if($c <= 0x7FF) {
|
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F); } else if($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); }
| return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F); } else if($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); }
|
else if($c <= 0x10FFFF) {
|
else if($c <= 0x10FFFF) {
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); }
| return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); }
|
else {
|
else {
|
return false; }
| return false; }
|
}
/** * Get the event poster.
|
}
/** * Get the event poster.
|
*
| *
|
* @param array The event data array. * @return string The link to the event poster. */
| * @param array The event data array. * @return string The link to the event poster. */
|
Zeile 4401 | Zeile 4707 |
---|
*/ 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);
|
$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; }
| return $event_date; }
|
Zeile 4425 | Zeile 4733 |
---|
* * @param int The announement id of the announcement. * @return string The url to the announcement.
|
* * @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);
| function get_announcement_link($aid=0) { $link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);
|
Zeile 4446 | Zeile 4754 |
---|
global $mybb, $lang;
if(!$username && $uid == 0)
|
global $mybb, $lang;
if(!$username && $uid == 0)
|
{
| {
|
// Return Guest phrase for no UID, no guest nickname return $lang->guest; }
| // Return Guest phrase for no UID, no guest nickname return $lang->guest; }
|
Zeile 4467 | Zeile 4775 |
---|
{ $onclick = " onclick=\"{$onclick}\""; }
|
{ $onclick = " onclick=\"{$onclick}\""; }
|
|
|
return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>"; } }
| return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>"; } }
|
Zeile 4490 | Zeile 4798 |
---|
else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
return htmlspecialchars_uni($link); } }
| return htmlspecialchars_uni($link); } }
|
/** * Build the thread link. *
| /** * Build the thread link. *
|
Zeile 4515 | Zeile 4823 |
---|
{ $link = THREAD_URL_PAGED; }
|
{ $link = THREAD_URL_PAGED; }
|
$link = str_replace("{tid}", $tid, $link);
| $link = str_replace("{tid}", $tid, $link);
|
$link = str_replace("{page}", $page, $link); return htmlspecialchars_uni($link); }
| $link = str_replace("{page}", $page, $link); return htmlspecialchars_uni($link); }
|
Zeile 4582 | Zeile 4890 |
---|
if($day > 0) { $link = str_replace("{month}", $month, CALENDAR_URL_DAY);
|
if($day > 0) { $link = str_replace("{month}", $month, CALENDAR_URL_DAY);
|
$link = str_replace("{year}", $year, $link);
| $link = str_replace("{year}", $year, $link);
|
$link = str_replace("{day}", $day, $link); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
| $link = str_replace("{day}", $day, $link); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
|
Zeile 4598 | Zeile 4906 |
---|
{ $link = str_replace("{year}", $year, CALENDAR_URL_YEAR); $link = str_replace("{calendar}", $calendar, $link);
|
{ $link = str_replace("{year}", $year, CALENDAR_URL_YEAR); $link = str_replace("{calendar}", $calendar, $link);
|
return htmlspecialchars_uni($link); }
| return htmlspecialchars_uni($link); }
|
else { $link = str_replace("{calendar}", $calendar, CALENDAR_URL);
| else { $link = str_replace("{calendar}", $calendar, CALENDAR_URL);
|
Zeile 4644 | Zeile 4952 |
---|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
{ return $user_cache[$uid]; } else
| { return $user_cache[$uid]; } elseif(($uid > 0))
|
{ $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
|
{ $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
|
|
|
return $user_cache[$uid]; }
|
return $user_cache[$uid]; }
|
| return array();
|
}
|
}
|
| |
/** * Get the forum of a specific forum id.
| /** * Get the forum of a specific forum id.
|
Zeile 4759 | Zeile 5067 |
---|
else { $post_cache[$pid] = false;
|
else { $post_cache[$pid] = false;
|
return false;
| return false;
|
} } }
/** * Get inactivate forums.
|
} } }
/** * Get inactivate forums.
|
*
| *
|
* @return string The comma separated values of the inactivate forum. */ function get_inactive_forums()
| * @return string The comma separated values of the inactivate forum. */ function get_inactive_forums()
|
Zeile 4774 | Zeile 5082 |
---|
global $forum_cache, $cache, $inactiveforums;
if(!$forum_cache)
|
global $forum_cache, $cache, $inactiveforums;
if(!$forum_cache)
|
{
| {
|
cache_forums(); }
| cache_forums(); }
|
Zeile 4813 | Zeile 5121 |
---|
if($mybb->settings['failedlogincount'] == 0) { return 1;
|
if($mybb->settings['failedlogincount'] == 0) { return 1;
|
}
| }
|
// 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.
|
// 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
|
// 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) { $loginattempts = $session->logins; } else { $loginattempts = $cookielogins; }
if(empty($cookietime) || $cookietime < $session->failedlogin)
| if(!empty($mybb->cookies['loginattempts']))
|
{
|
{
|
$failedlogin = $session->failedlogin;
| $loginattempts = $mybb->cookies['loginattempts'];
|
}
|
}
|
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 4929 | Zeile 5228 |
---|
function email_already_in_use($email, $uid="") { global $db;
|
function email_already_in_use($email, $uid="") { global $db;
|
|
|
$uid_string = ""; if($uid)
|
$uid_string = ""; if($uid)
|
{
| {
|
$uid_string = " AND uid != '".intval($uid)."'";
|
$uid_string = " AND uid != '".intval($uid)."'";
|
} $query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string(my_strtolower($email))."'{$uid_string}");
| } $query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
|
if($db->fetch_field($query, "emails") > 0) { return true; }
|
if($db->fetch_field($query, "emails") > 0) { return true; }
|
|
|
return false; }
| return false; }
|
Zeile 4949 | Zeile 5248 |
---|
* DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES. */ function rebuildsettings()
|
* DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES. */ function rebuildsettings()
|
{
| {
|
rebuild_settings(); }
/** * Rebuilds settings.php
|
rebuild_settings(); }
/** * Rebuilds settings.php
|
* */
| * */
|
function rebuild_settings() { global $db, $mybb;
| function rebuild_settings() { global $db, $mybb;
|
Zeile 4964 | Zeile 5263 |
---|
if(!file_exists(MYBB_ROOT."inc/settings.php")) { $mode = "x";
|
if(!file_exists(MYBB_ROOT."inc/settings.php")) { $mode = "x";
|
} else { $mode = "w"; }
| } else { $mode = "w"; }
|
$options = array( "order_by" => "title", "order_dir" => "ASC"
| $options = array( "order_by" => "title", "order_dir" => "ASC"
|
Zeile 4982 | Zeile 5281 |
---|
$setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n"; }
|
$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); @fwrite($file, $settings);
| $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); @fwrite($file, $settings);
|
Zeile 4990 | Zeile 5289 |
---|
$GLOBALS['settings'] = &$mybb->settings; }
|
$GLOBALS['settings'] = &$mybb->settings; }
|
|
|
/** * Build a PREG compatible array of search highlight terms to replace in posts. *
| /** * Build a PREG compatible array of search highlight terms to replace in posts. *
|
Zeile 5004 | Zeile 5303 |
---|
if($mybb->settings['minsearchword'] < 1) { $mybb->settings['minsearchword'] = 3;
|
if($mybb->settings['minsearchword'] < 1) { $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 5055 | Zeile 5359 |
---|
{ $terms = htmlspecialchars_uni($terms); $split_words = preg_split("#\s{1,}#", $terms, -1);
|
{ $terms = htmlspecialchars_uni($terms); $split_words = preg_split("#\s{1,}#", $terms, -1);
|
if(!is_array($split_words))
| if(is_array($split_words))
|
{
|
{
|
continue; } foreach($split_words as $word) { if(!$word || strlen($word) < $mybb->settings['minsearchword'])
| foreach($split_words as $word)
|
{
|
{
|
continue;
| if(!$word || strlen($word) < $mybb->settings['minsearchword']) { continue; } $words[] = trim($word);
|
}
|
}
|
$words[] = trim($word); }
| }
|
}
if(!is_array($words))
|
}
if(!is_array($words))
|
{ return false;
| { return false;
|
}
|
}
|
|
|
// Sort the word array by length. Largest terms go first and work their way down to the smallest term. // This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html usort($words, create_function('$a,$b', 'return strlen($b) - strlen($a);'));
| // Sort the word array by length. Largest terms go first and work their way down to the smallest term. // This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html usort($words, create_function('$a,$b', 'return strlen($b) - strlen($a);'));
|
Zeile 5085 | Zeile 5387 |
---|
$word = trim($word);
$word = my_strtolower($word);
|
$word = trim($word);
$word = my_strtolower($word);
|
|
|
// Special boolean operators should be stripped if($word == "" || $word == "or" || $word == "not" || $word == "and") {
| // Special boolean operators should be stripped if($word == "" || $word == "or" || $word == "not" || $word == "and") {
|
Zeile 5093 | Zeile 5395 |
---|
}
// 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 5102 | Zeile 5404 |
---|
}
/**
|
}
/**
|
* Converts a decimal reference of a character to its UTF-8 equivilant
| * Converts a decimal reference of a character to its UTF-8 equivalent
|
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references) * * @param string Decimal value of a character reference
| * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references) * * @param string Decimal value of a character reference
|
Zeile 5113 | Zeile 5415 |
---|
if($src < 0) {
|
if($src < 0) {
|
return false; }
| return false; }
|
elseif($src <= 0x007f) { $dest .= chr($src);
| elseif($src <= 0x007f) { $dest .= chr($src);
|
Zeile 5184 | Zeile 5486 |
---|
*/ function is_banned_email($email, $update_lastuse=false) {
|
*/ function is_banned_email($email, $update_lastuse=false) {
|
global $db; $query = $db->simple_select("banfilters", "*", "type='3'"); while($banned_email = $db->fetch_array($query)) { // Make regular expression * match $banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#')); if(preg_match("#{$banned_email['filter']}#i", $email)) { // Updating last use if($update_lastuse == true)
| global $cache, $db;
$banned_cache = $cache->read("bannedemails");
if($banned_cache === false) { // Failed to read cache, see if we can rebuild it $cache->update_bannedemails(); $banned_cache = $cache->read("bannedemails"); }
if(is_array($banned_cache) && !empty($banned_cache)) { foreach($banned_cache as $banned_email) { // 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 5214 | Zeile 5530 |
---|
function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
|
function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
|
|
|
$banned_ips = $cache->read("bannedips"); if(!is_array($banned_ips)) { return false; }
|
$banned_ips = $cache->read("bannedips"); if(!is_array($banned_ips)) { return false; }
|
|
|
foreach($banned_ips as $banned_ip) { if(!$banned_ip['filter']) { continue; }
|
foreach($banned_ips as $banned_ip) { if(!$banned_ip['filter']) { continue; }
|
|
|
// 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)
|
{
| {
|
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_ip['fid']}'"); } return true; } }
|
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_ip['fid']}'"); } return true; } }
|
|
|
// Still here - good ip return false; }
| // Still here - good ip return false; }
|
Zeile 5322 | Zeile 5639 |
---|
$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone); } $select .= "<option value=\"{$timezone}\"{$selected_add}>{$label}</option>\n";
|
$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone); } $select .= "<option value=\"{$timezone}\"{$selected_add}>{$label}</option>\n";
|
}
| }
|
$select .= "</select>"; return $select; }
| $select .= "</select>"; return $select; }
|
Zeile 5344 | Zeile 5661 |
---|
} $post_body = ltrim($post_body, '&'); }
|
} $post_body = ltrim($post_body, '&'); }
|
|
|
if(function_exists("curl_init")) { $ch = curl_init();
| if(function_exists("curl_init")) { $ch = curl_init();
|
Zeile 5352 | Zeile 5669 |
---|
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
if(!empty($post_body)) {
| if(!empty($post_body)) {
|
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); }
| curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); }
|
Zeile 5361 | Zeile 5678 |
---|
curl_close($ch); return $data; }
|
curl_close($ch); return $data; }
|
else if(function_exists("fsockopen"))
| else if(function_exists("fsockopen"))
|
{ $url = @parse_url($url); if(!$url['host'])
| { $url = @parse_url($url); if(!$url['host'])
|
Zeile 5373 | Zeile 5690 |
---|
$url['port'] = 80; } if(!$url['path'])
|
$url['port'] = 80; } if(!$url['path'])
|
{
| {
|
$url['path'] = "/";
|
$url['path'] = "/";
|
}
| }
|
if($url['query']) { $url['path'] .= "?{$url['query']}";
| if($url['query']) { $url['path'] .= "?{$url['query']}";
|
Zeile 5383 | Zeile 5700 |
---|
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10); @stream_set_timeout($fp, 10); if(!$fp)
|
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10); @stream_set_timeout($fp, 10); if(!$fp)
|
{
| {
|
return false;
|
return false;
|
}
| }
|
$headers = array(); if(!empty($post_body)) { $headers[] = "POST {$url['path']} HTTP/1.0"; $headers[] = "Content-Length: ".strlen($post_body); $headers[] = "Content-Type: application/x-www-form-urlencoded";
|
$headers = array(); if(!empty($post_body)) { $headers[] = "POST {$url['path']} HTTP/1.0"; $headers[] = "Content-Length: ".strlen($post_body); $headers[] = "Content-Type: application/x-www-form-urlencoded";
|
} else
| } else
|
{ $headers[] = "GET {$url['path']} HTTP/1.0";
|
{ $headers[] = "GET {$url['path']} HTTP/1.0";
|
}
| }
|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close";
|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close";
|
$headers[] = "\r\n";
| $headers[] = '';
|
if(!empty($post_body))
|
if(!empty($post_body))
|
{
| {
|
$headers[] = $post_body; }
|
$headers[] = $post_body; }
|
$headers = implode("\r\n", $headers);
| 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);
|
if(!@fwrite($fp, $headers)) { return false;
| if(!@fwrite($fp, $headers)) { return false;
|
Zeile 5438 | Zeile 5760 |
---|
*/ function is_super_admin($uid) {
|
*/ function is_super_admin($uid) {
|
global $mybb; $mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']); if(my_strpos(",{$mybb->config['super_admins']},", ",{$uid},") === false) {
| static $super_admins;
if(!isset($super_admins)) { global $mybb; $super_admins = str_replace(" ", "", $mybb->config['super_admins']); }
if(my_strpos(",{$super_admins},", ",{$uid},") === false) {
|
return false;
|
return false;
|
}
| }
|
else
|
else
|
{
| {
|
return true; }
|
return true; }
|
| }
/** * Prevents super administrators being selected in a SELECT. * * @param boolean Prefix with an AND? * @param string The prefix to add to uid when used in a JOIN (e.g. SELECTing users u would mean using 'u' in this argument). * @return string An addition to the WHERE statement */ function not_super_admins($use_and = false, $uid_prefix = '') { static $super_admins;
if(!isset($super_admins)) { global $mybb, $db; $super_admins = $db->escape_string(str_replace(" ", "", $mybb->config['super_admins'])); }
if($super_admins) { $sql_where = ''; if($use_and) { $sql_where .= ' AND '; }
if($uid_prefix != '') { $sql_where .= $uid_prefix.'.'; }
$sql_where .= "uid NOT IN({$super_admins})";
return $sql_where; } return '';
|
}
/**
| }
/**
|
Zeile 5466 | Zeile 5830 |
---|
$original = $string; $in_escape = false; if($escape)
|
$original = $string; $in_escape = false; if($escape)
|
{
| {
|
if(is_array($escape)) { function escaped_explode_escape($string)
| if(is_array($escape)) { function escaped_explode_escape($string)
|
Zeile 5484 | Zeile 5848 |
---|
else { $quoted_strings = array($string);
|
else { $quoted_strings = array($string);
|
}
| }
|
foreach($quoted_strings as $string) {
|
foreach($quoted_strings as $string) {
|
if($string != "")
| if($string != "")
|
{ if($in_escape) {
| { if($in_escape) {
|
Zeile 5510 | Zeile 5874 |
---|
return $original; } return $strings;
|
return $original; } return $strings;
|
}
| }
|
/** * Fetch an IPv4 long formatted range for searching IPv4 IP addresses. * * @param string The IP address to convert to a range based LONG
|
/** * Fetch an IPv4 long formatted range for searching IPv4 IP addresses. * * @param string The IP address to convert to a range based LONG
|
* @rturn mixed If a full IP address is provided, the ip2long equivilent, otherwise an array of the upper & lower extremities of the IP
| * @rturn mixed If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP
|
*/ function fetch_longipv4_range($ip) { $ip_bits = explode(".", $ip); $ip_string1 = $ip_string2 = "";
|
*/ function fetch_longipv4_range($ip) { $ip_bits = explode(".", $ip); $ip_string1 = $ip_string2 = "";
|
|
|
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)
|
{
| {
|
$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 5547 | Zeile 5911 |
---|
foreach($ip_bits as $piece) { if($piece == "*")
|
foreach($ip_bits as $piece) { if($piece == "*")
|
{
| {
|
$ip_string1 .= $sep."0"; $ip_string2 .= $sep."255"; }
| $ip_string1 .= $sep."0"; $ip_string2 .= $sep."255"; }
|
Zeile 5558 | Zeile 5922 |
---|
} $sep = "."; }
|
} $sep = "."; }
|
return array(ip2long($ip_string1), ip2long($ip_string2));
| return array(my_ip2long($ip_string1), my_ip2long($ip_string2));
|
}
|
}
|
}
| }
|
/** * Fetch a list of ban times for a user account.
| /** * Fetch a list of ban times for a user account.
|
Zeile 5592 | Zeile 5956 |
---|
"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 5627 | Zeile 5991 |
---|
function expire_warnings() { global $db;
|
function expire_warnings() { global $db;
|
|
|
$users = array();
|
$users = array();
|
|
|
$query = $db->query(" SELECT w.wid, w.uid, w.points, u.warningpoints FROM ".TABLE_PREFIX."warnings w
| $query = $db->query(" SELECT w.wid, w.uid, w.points, u.warningpoints FROM ".TABLE_PREFIX."warnings w
|
Zeile 5642 | Zeile 6006 |
---|
"expired" => 1 ); $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
"expired" => 1 ); $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
|
|
if(array_key_exists($warning['uid'], $users)) { $users[$warning['uid']] -= $warning['points'];
| if(array_key_exists($warning['uid'], $users)) { $users[$warning['uid']] -= $warning['points'];
|
Zeile 5650 | Zeile 6014 |
---|
else { $users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
|
else { $users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
|
}
| }
|
}
|
}
|
|
|
foreach($users as $uid => $warningpoints) { if($warningpoints < 0) { $warningpoints = 0; }
|
foreach($users as $uid => $warningpoints) { if($warningpoints < 0) { $warningpoints = 0; }
|
|
|
$updated_user = array( "warningpoints" => intval($warningpoints) ); $db->update_query("users", $updated_user, "uid='".intval($uid)."'"); }
|
$updated_user = array( "warningpoints" => intval($warningpoints) ); $db->update_query("users", $updated_user, "uid='".intval($uid)."'"); }
|
}
/** * 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; }
| |
}
/**
| }
/**
|
Zeile 5714 | Zeile 6045 |
---|
return false; } $old_umask = umask(0);
|
return false; } $old_umask = umask(0);
|
|
|
// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod // and type casting subsequently removes the prepended 0 which is needed for octal numbers $result = chmod($file, octdec($mode));
| // We convert the octal string to a decimal number because passing a octal string doesn't work with chmod // and type casting subsequently removes the prepended 0 which is needed for octal numbers $result = chmod($file, octdec($mode));
|
Zeile 5731 | Zeile 6062 |
---|
function my_rmdir_recursive($path, $ignore=array()) { global $orig_dir;
|
function my_rmdir_recursive($path, $ignore=array()) { global $orig_dir;
|
|
|
if(!isset($orig_dir))
|
if(!isset($orig_dir))
|
{
| {
|
$orig_dir = $path; }
|
$orig_dir = $path; }
|
if(@is_dir($path) && !@is_link($path)) { if($dh = @opendir($path)) { while(($file = @readdir($dh)) !== false) { if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file)) { continue; } } @closedir($dh); }
| if(@is_dir($path) && !@is_link($path)) { if($dh = @opendir($path)) { while(($file = @readdir($dh)) !== false) { if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file)) { continue; } } @closedir($dh); }
|
// Are we done? Don't delete the main folder too and return true if($path == $orig_dir) { return true;
|
// Are we done? Don't delete the main folder too and return true if($path == $orig_dir) { return true;
|
} return @rmdir($path); } return @unlink($path); }
| }
return @rmdir($path); }
return @unlink($path); }
|
/** * Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid *
| /** * Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid *
|
Zeile 5776 | Zeile 6107 |
---|
{ $count += count($array2); }
|
{ $count += count($array2); }
|
|
|
return $count; }
| return $count; }
|
Zeile 5788 | Zeile 6119 |
---|
* @return integer IP in 32-bit signed format */ function my_ip2long($ip)
|
* @return integer IP in 32-bit signed format */ function my_ip2long($ip)
|
{ $ip = ip2long($ip); if($ip >= 2147483648) // Won't occur on 32-bit PHP { $ip -= 4294967296; } return $ip; }
/**
| { $ip_long = ip2long($ip);
if(!$ip_long) { $ip_long = sprintf("%u", ip2long($ip));
if(!$ip_long) { return 0; } }
if($ip_long >= 2147483648) // Won't occur on 32-bit PHP { $ip_long -= 4294967296; }
return $ip_long; }
/**
|
* As above, fix for PHP's long2ip on 64-bit versions * * @param integer The IP to convert (will accept 64-bit IPs as well)
| * As above, fix for PHP's long2ip on 64-bit versions * * @param integer The IP to convert (will accept 64-bit IPs as well)
|
Zeile 5824 | Zeile 6167 |
---|
function verify_files($path=MYBB_ROOT, $count=0) { global $mybb, $checksums, $bad_verify_files;
|
function verify_files($path=MYBB_ROOT, $count=0) { global $mybb, $checksums, $bad_verify_files;
|
|
|
// We don't need to check these types of files $ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif"); $ignore_ext = array("attach");
|
// We don't need to check these types of files $ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif"); $ignore_ext = array("attach");
|
|
|
if(substr($path, -1, 1) == "/") { $path = substr($path, 0, -1); }
|
if(substr($path, -1, 1) == "/") { $path = substr($path, 0, -1); }
|
|
|
if(!is_array($bad_verify_files))
|
if(!is_array($bad_verify_files))
|
{
| {
|
$bad_verify_files = array(); }
|
$bad_verify_files = array(); }
|
|
|
// Make sure that we're in a directory and it's not a symbolic link
|
// Make sure that we're in a directory and it's not a symbolic link
|
if(@is_dir($path) && !@is_link($path)) { if($dh = @opendir($path)) {
| if(@is_dir($path) && !@is_link($path)) { if($dh = @opendir($path)) {
|
// Loop through all the files/directories in this directory
|
// Loop through all the files/directories in this directory
|
while(($file = @readdir($dh)) !== false) {
| while(($file = @readdir($dh)) !== false) {
|
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))
|
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))
|
{ continue;
| { continue;
|
}
|
}
|
|
|
// Recurse through the directory tree if(is_dir($path."/".$file)) { verify_files($path."/".$file, ($count+1)); continue; }
|
// Recurse through the directory tree if(is_dir($path."/".$file)) { verify_files($path."/".$file, ($count+1)); continue; }
|
|
|
// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php) $file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;
|
// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php) $file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;
|
|
|
// Does this file even exist in our official list? Perhaps it's a plugin if(array_key_exists($file_path, $checksums)) {
| // Does this file even exist in our official list? Perhaps it's a plugin if(array_key_exists($file_path, $checksums)) {
|
Zeile 5873 | Zeile 6216 |
---|
$contents .= fread($handle, 8192); } fclose($handle);
|
$contents .= fread($handle, 8192); } fclose($handle);
|
|
|
$md5 = md5($contents);
|
$md5 = md5($contents);
|
|
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes) if(!in_array($md5, $checksums[$file_path]))
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes) if(!in_array($md5, $checksums[$file_path]))
|
{
| {
|
$bad_verify_files[] = array("status" => "changed", "path" => $file_path); } } unset($checksums[$file_path]);
|
$bad_verify_files[] = array("status" => "changed", "path" => $file_path); } } unset($checksums[$file_path]);
|
} @closedir($dh); } }
| } @closedir($dh); } }
|
if($count == 0) { if(!empty($checksums)) { foreach($checksums as $file_path => $hashes)
|
if($count == 0) { if(!empty($checksums)) { foreach($checksums as $file_path => $hashes)
|
{
| {
|
if(in_array(basename($file_path), $ignore)) { continue;
| if(in_array(basename($file_path), $ignore)) { continue;
|
Zeile 5902 | Zeile 6245 |
---|
} } }
|
} } }
|
|
|
// uh oh if($count == 0)
|
// uh oh if($count == 0)
|
{
| {
|
return $bad_verify_files; } }
| return $bad_verify_files; } }
|
Zeile 5914 | Zeile 6257 |
---|
* Returns a signed value equal to an integer * * @param int The integer
|
* Returns a signed value equal to an integer * * @param int The integer
|
* @return string The signed equivallent
| * @return string The signed equivalent
|
*/ function signed($int)
|
*/ function signed($int)
|
{
| {
|
if($int < 0) { return "$int";
| if($int < 0) { return "$int";
|
Zeile 5932 | Zeile 6275 |
---|
* Returns a securely generated seed for PHP's RNG (Random Number Generator) * * @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)
|
* Returns a securely generated seed for PHP's RNG (Random Number Generator) * * @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)
|
* @return int An integer equivilent of a secure hexadecimal seed
| * @return int An integer equivalent of a secure hexadecimal seed
|
*/ function secure_seed_rng($count=8) { $output = '';
|
*/ function secure_seed_rng($count=8) { $output = '';
|
// Try the unix/linux method if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
| // DIRECTORY_SEPARATOR checks if running windows if(DIRECTORY_SEPARATOR != '\\') { // Unix/Linux // Use OpenSSL when available if(function_exists('openssl_random_pseudo_bytes')) { $output = openssl_random_pseudo_bytes($count); } // Try mcrypt elseif(function_exists('mcrypt_create_iv')) { $output = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM); } // Try /dev/urandom elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb'))) { $output = @fread($handle, $count); @fclose($handle); } } else
|
{
|
{
|
$output = @fread($handle, $count); @fclose($handle);
| // Windows // Use OpenSSL when available // PHP <5.3.4 had a bug which makes that function unusable on Windows if(function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>=')) { $output = openssl_random_pseudo_bytes($count); } // Try mcrypt elseif(function_exists('mcrypt_create_iv')) { $output = mcrypt_create_iv($count, MCRYPT_RAND); } // Try Windows CAPICOM before using our own generator elseif(class_exists('COM')) { try { $CAPI_Util = new COM('CAPICOM.Utilities.1'); if(is_callable(array($CAPI_Util, 'GetRandom'))) { $output = $CAPI_Util->GetRandom($count, 0); } } catch (Exception $e) { } }
|
}
|
}
|
|
|
// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator if(strlen($output) < $count) { $output = '';
|
// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator if(strlen($output) < $count) { $output = '';
|
|
|
// Close to what PHP basically uses internally to seed, but not quite. $unique_state = microtime().@getmypid();
|
// Close to what PHP basically uses internally to seed, but not quite. $unique_state = microtime().@getmypid();
|
|
|
for($i = 0; $i < $count; $i += 16) { $unique_state = md5(microtime().$unique_state); $output .= pack('H*', md5($unique_state)); } }
|
for($i = 0; $i < $count; $i += 16) { $unique_state = md5(microtime().$unique_state); $output .= pack('H*', md5($unique_state)); } }
|
|
|
// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters $output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));
|
// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters $output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));
|
|
|
return $output; }
/** * Wrapper function for mt_rand. Automatically seeds using a secure seed once. *
|
return $output; }
/** * Wrapper function for mt_rand. Automatically seeds using a secure seed once. *
|
* @param int Optional lowest value to be returned (default: 0) * @param int Optional highest value to be returned (default: mt_getrandmax())
| * @param int Optional lowest value to be returned (default: 0) * @param int Optional highest value to be returned (default: mt_getrandmax())
|
* @param boolean True forces it to reseed the RNG first
|
* @param boolean True forces it to reseed the RNG first
|
* @return int An integer equivilent of a secure hexadecimal seed
| * @return int An integer equivalent of a secure hexadecimal seed
|
*/ function my_rand($min=null, $max=null, $force_seed=false) {
| */ function my_rand($min=null, $max=null, $force_seed=false) {
|
Zeile 5985 | Zeile 6370 |
---|
$seeded = true;
$obfuscator = abs((int) secure_seed_rng());
|
$seeded = true;
$obfuscator = abs((int) secure_seed_rng());
|
|
|
// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems. if($obfuscator > mt_getrandmax())
|
// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems. if($obfuscator > mt_getrandmax())
|
{
| {
|
$obfuscator -= mt_getrandmax(); } }
| $obfuscator -= mt_getrandmax(); } }
|
Zeile 5999 | Zeile 6384 |
---|
if ($distance > 0) { return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
|
if ($distance > 0) { return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
|
}
| }
|
else { return mt_rand($min, $max);
| else { return mt_rand($min, $max);
|
Zeile 6013 | Zeile 6398 |
---|
}
/**
|
}
/**
|
* More robust version of PHP's trim() function. It includes a list of UTF-16 blank characters
| * More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters
|
* from http://kb.mozillazine.org/Network.IDN.blacklist_chars * * @param string The string to trim from
| * from http://kb.mozillazine.org/Network.IDN.blacklist_chars * * @param string The string to trim from
|
Zeile 6023 | Zeile 6408 |
---|
function trim_blank_chrs($string, $charlist=false) { $hex_chrs = array(
|
function trim_blank_chrs($string, $charlist=false) { $hex_chrs = array(
|
0x20 => 1, 0x09 => 1, 0x0A => 1, 0x0D => 1, 0x0B => 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} 0xA8 => 1, 0xA9 => 1, 0xAA => 1, 0xAB => 1, 0xAC => 1, 0xAD => 1, 0xAE => 1, 0xAF => 1), // \x{2028} to \x{202F} 0x81 => array(0x9F => 1)), // \x{205F}
| 0x09 => 1, // \x{0009} 0x0A => 1, // \x{000A} 0x0B => 1, // \x{000B} 0x0D => 1, // \x{000D} 0x20 => 1, // \x{0020} 0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD} 0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1), 0x9A => array(0x80 => 1), 0xA0 => array(0x8E => 1)), // \x{115F}, \x{1160}, \x{1680}, \x{180E} 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, 0x8C => 1, 0x8D => 1, 0x8E => 1, 0x8F => 1, // \x{2000} - \x{200F} 0xA8 => 1, 0xA9 => 1, 0xAA => 1, 0xAB => 1, 0xAC => 1, 0xAD => 1, 0xAE => 1, 0xAF => 1), // \x{2028} - \x{202F} 0x81 => array(0x9F => 1)), // \x{205F}
|
0xE3 => array(0x80 => array(0x80 => 1), // \x{3000}
|
0xE3 => array(0x80 => array(0x80 => 1), // \x{3000}
|
0x85 => array(0xA4 => 1)), // \x{3164}
| 0x85 => array(0xA4 => 1)), // \x{3164}
|
0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF}
|
0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF}
|
0xBE => array(0xA0 => 1), // \x{FFA0} 0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} to \x{FFFB}
| 0xBE => array(0xA0 => 1), // \x{FFA0} 0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} - \x{FFFB}
|
);
|
);
|
|
|
$hex_chrs_rev = array(
|
$hex_chrs_rev = array(
|
0x20 => 1, 0x09 => 1, 0x0A => 1, 0x0D => 1, 0x0B => 1,
| 0x09 => 1, // \x{0009} 0x0A => 1, // \x{000A} 0x0B => 1, // \x{000B} 0x0D => 1, // \x{000D} 0x20 => 1, // \x{0020} 0x81 => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{0081}, \x{2001} 0x8D => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{008D}, \x{200D} 0x90 => array(0xC2 => 1), // \x{0090} 0x9D => array(0xC2 => 1), // \x{009D} 0xA0 => array(0xC2 => 1, 0x85 => array(0xE1 => 1), 0x81 => array(0xE2 => 1), 0xBE => array(0xEF => 1)), // \x{00A0}, \x{1160}, \x{2060}, \x{FFA0} 0xAD => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{00AD}, \x{202D}
|
0xB8 => array(0xCC => 1), // \x{0338} 0xB7 => array(0xCC => 1), // \x{0337}
|
0xB8 => array(0xCC => 1), // \x{0338} 0xB7 => array(0xCC => 1), // \x{0337}
|
0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160} 0x9F => array(0x85 => array(0xE1 => 1), // \x{115F} 0x81 => array(0xE2 => 1)), // \x{205F} 0x80 => array(0x80 => array(0xE3 => 1, 0xE2 => 1)), // \x{3000}, \x{2000} 0x81 => array(0x80 => array(0xE2 => 1)), // \x{2001}
| 0x9F => array(0x85 => array(0xE1 => 1), 0x81 => array(0xE2 => 1)), // \x{115F}, \x{205F} 0x80 => array(0x9A => array(0xE1 => 1), 0x80 => array(0xE2 => 1, 0xE3 => 1)), // \x{1680}, \x{2000}, \x{3000} 0x8E => array(0xA0 => array(0xE1 => 1), 0x80 => array(0xE2 => 1)), // \x{180E}, \x{200E}
|
0x82 => array(0x80 => array(0xE2 => 1)), // \x{2002} 0x83 => array(0x80 => array(0xE2 => 1)), // \x{2003} 0x84 => array(0x80 => array(0xE2 => 1)), // \x{2004}
| 0x82 => array(0x80 => array(0xE2 => 1)), // \x{2002} 0x83 => array(0x80 => array(0xE2 => 1)), // \x{2003} 0x84 => array(0x80 => array(0xE2 => 1)), // \x{2004}
|
Zeile 6063 | Zeile 6453 |
---|
0x89 => array(0x80 => array(0xE2 => 1)), // \x{2009} 0x8A => array(0x80 => array(0xE2 => 1)), // \x{200A} 0x8B => array(0x80 => array(0xE2 => 1)), // \x{200B}
|
0x89 => array(0x80 => array(0xE2 => 1)), // \x{2009} 0x8A => array(0x80 => array(0xE2 => 1)), // \x{200A} 0x8B => array(0x80 => array(0xE2 => 1)), // \x{200B}
|
| 0x8C => array(0x80 => array(0xE2 => 1)), // \x{200C} 0x8F => array(0x80 => array(0xE2 => 1)), // \x{200F}
|
0xA8 => array(0x80 => array(0xE2 => 1)), // \x{2028} 0xA9 => array(0x80 => array(0xE2 => 1)), // \x{2029} 0xAA => array(0x80 => array(0xE2 => 1)), // \x{202A} 0xAB => array(0x80 => array(0xE2 => 1)), // \x{202B} 0xAC => array(0x80 => array(0xE2 => 1)), // \x{202C}
|
0xA8 => array(0x80 => array(0xE2 => 1)), // \x{2028} 0xA9 => array(0x80 => array(0xE2 => 1)), // \x{2029} 0xAA => array(0x80 => array(0xE2 => 1)), // \x{202A} 0xAB => array(0x80 => array(0xE2 => 1)), // \x{202B} 0xAC => array(0x80 => array(0xE2 => 1)), // \x{202C}
|
0xAD => array(0x80 => array(0xE2 => 1)), // \x{202D}
| |
0xAE => array(0x80 => array(0xE2 => 1)), // \x{202E} 0xAF => array(0x80 => array(0xE2 => 1)), // \x{202F} 0xA4 => array(0x85 => array(0xE3 => 1)), // \x{3164} 0xBF => array(0xBB => array(0xEF => 1)), // \x{FEFF}
|
0xAE => array(0x80 => array(0xE2 => 1)), // \x{202E} 0xAF => array(0x80 => array(0xE2 => 1)), // \x{202F} 0xA4 => array(0x85 => array(0xE3 => 1)), // \x{3164} 0xBF => array(0xBB => array(0xEF => 1)), // \x{FEFF}
|
0xA0 => array(0xBE => array(0xEF => 1)), // \x{FFA0}
| |
0xB9 => array(0xBF => array(0xEF => 1)), // \x{FFF9} 0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA} 0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB} );
|
0xB9 => array(0xBF => array(0xEF => 1)), // \x{FFF9} 0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA} 0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB} );
|
|
|
// Start from the beginning and work our way in
|
// Start from the beginning and work our way in
|
do { // Check to see if we have matched a first character in our utf-16 array
| do { // Check to see if we have matched a first character in our utf-8 array
|
$offset = match_sequence($string, $hex_chrs); if(!$offset) {
| $offset = match_sequence($string, $hex_chrs); if(!$offset) {
|
Zeile 6092 | Zeile 6482 |
---|
$string = substr($string, $offset); } while(++$i);
|
$string = substr($string, $offset); } while(++$i);
|
|
|
// Start from the end and work our way in
|
// Start from the end and work our way in
|
$string = strrev($string);
| $string = strrev($string);
|
do {
|
do {
|
// Check to see if we have matched a first character in our utf-16 array
| // Check to see if we have matched a first character in our utf-8 array
|
$offset = match_sequence($string, $hex_chrs_rev); if(!$offset) {
| $offset = match_sequence($string, $hex_chrs_rev); if(!$offset) {
|
Zeile 6108 | Zeile 6498 |
---|
} while(++$i); $string = strrev($string);
|
} while(++$i); $string = strrev($string);
|
|
|
if($charlist !== false)
|
if($charlist !== false)
|
{
| {
|
$string = trim($string, $charlist);
|
$string = trim($string, $charlist);
|
}
| }
|
else { $string = trim($string); }
|
else { $string = trim($string); }
|
|
|
return $string;
|
return $string;
|
}
| }
|
function match_sequence($string, $array, $i=0, $n=0) { if($string === "") { return 0; }
|
function match_sequence($string, $array, $i=0, $n=0) { if($string === "") { return 0; }
|
|
|
$ord = ord($string[$i]); if(array_key_exists($ord, $array)) {
| $ord = ord($string[$i]); if(array_key_exists($ord, $array)) {
|
Zeile 6140 | Zeile 6530 |
---|
} return $n; }
|
} return $n; }
|
|
|
return 0;
|
return 0;
|
}
| }
|
/** * Obtain the version of GD installed. *
| /** * Obtain the version of GD installed. *
|
Zeile 6152 | Zeile 6542 |
---|
function gd_version() { static $gd_version;
|
function gd_version() { static $gd_version;
|
|
|
if($gd_version) { return $gd_version;
| if($gd_version) { return $gd_version;
|
Zeile 6161 | Zeile 6551 |
---|
{ return; }
|
{ return; }
|
|
|
if(function_exists("gd_info"))
|
if(function_exists("gd_info"))
|
{
| {
|
$gd_info = gd_info();
|
$gd_info = gd_info();
|
preg_match('/\d/', $gd_info['GD Version'], $gd); $gd_version = $gd[0]; } else {
| preg_match('/\d/', $gd_info['GD Version'], $gd); $gd_version = $gd[0]; } else {
|
ob_start(); phpinfo(8); $info = ob_get_contents();
| ob_start(); phpinfo(8); $info = ob_get_contents();
|
Zeile 6178 | Zeile 6568 |
---|
preg_match('/\d/', $info, $gd); $gd_version = $gd[0]; }
|
preg_match('/\d/', $info, $gd); $gd_version = $gd[0]; }
|
|
|
return $gd_version;
|
return $gd_version;
|
}
| }
|
|
|
| /** * Validates an UTF-8 string. * * @param string The string to be checked * @param boolean Allow 4 byte UTF-8 characters? * @param boolean Return the cleaned string? * @return string/boolean Cleaned string or boolean */ function validate_utf8_string($input, $allow_mb4=true, $return=true) { // Valid UTF-8 sequence? if(!preg_match('##u', $input)) { $string = ''; $len = strlen($input); for($i = 0; $i < $len; $i++) { $c = ord($input[$i]); if($c > 128) { if($c > 247 || $c <= 191) { if($return) { $string .= '?'; continue; } else { return false; } } elseif($c > 239) { $bytes = 4; } elseif($c > 223) { $bytes = 3; } elseif($c > 191) { $bytes = 2; } if(($i + $bytes) > $len) { if($return) { $string .= '?'; break; } else { return false; } } $valid = true; $multibytes = $input[$i]; while($bytes > 1) { $i++; $b = ord($input[$i]); if($b < 128 || $b > 191) { if($return) { $valid = false; $string .= '?'; break; } else { return false; } } else { $multibytes .= $input[$i]; } $bytes--; } if($valid) { $string .= $multibytes; } } else { $string .= $input[$i]; } } $input = $string; } if($return) { if($allow_mb4) { return $input; } else { return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input); } } else { if($allow_mb4) { return true; } else { return !preg_match("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", $input); } } }
|
?>
| ?>
|