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 44 | Zeile 45 |
---|
$phpversion = PHP_VERSION;
$serverload = get_server_load();
|
$phpversion = PHP_VERSION;
$serverload = get_server_load();
|
|
|
if(my_strpos(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1";
| if(my_strpos(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1";
|
Zeile 68 | Zeile 69 |
---|
if($memory_usage) { $memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage);
|
if($memory_usage) { $memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage);
|
}
| }
|
else
|
else
|
{
| {
|
$memory_usage = '';
|
$memory_usage = '';
|
}
| } // MySQLi is still MySQL, so present it that way to the user $database_server = $db->short_title;
|
|
|
| if($database_server == 'MySQLi') { $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 86 | 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");
|
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 false; }
|
return true; }
return false; }
|
|
|
/** * Runs the shutdown items after the page has been sent to the browser. *
| /** * Runs the shutdown items after the page has been sent to the browser. *
|
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 251 | Zeile 262 |
---|
{ // Delete the message from the queue $db->delete_query("mailqueue", "mid='{$email['mid']}'");
|
{ // Delete the message from the queue $db->delete_query("mailqueue", "mid='{$email['mid']}'");
|
|
|
if($db->affected_rows() == 1) {
|
if($db->affected_rows() == 1) {
|
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
| 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);
|
}
| }
|
$plugins->run_hooks("send_mail_queue_end"); }
| $plugins->run_hooks("send_mail_queue_end"); }
|
Zeile 276 | Zeile 287 |
---|
$contents = str_replace('<navigation>', build_breadcrumb(1), $contents); $contents = str_replace('<archive_url>', $archive_url, $contents);
|
$contents = str_replace('<navigation>', build_breadcrumb(1), $contents); $contents = str_replace('<archive_url>', $archive_url, $contents);
|
|
|
if($htmldoctype)
|
if($htmldoctype)
|
{
| {
|
$contents = $htmldoctype.$contents; } else { $contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
|
$contents = $htmldoctype.$contents; } else { $contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
|
} $contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);
| }
$contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);
|
if($lang->settings['rtl'] == 1) { $contents = str_replace("<html", "<html dir=\"rtl\"", $contents); }
if($lang->settings['htmllang'])
|
if($lang->settings['rtl'] == 1) { $contents = str_replace("<html", "<html dir=\"rtl\"", $contents); }
if($lang->settings['htmllang'])
|
{
| {
|
$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
|
$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
|
}
| }
|
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; }
| return $contents; }
|
Zeile 319 | 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 332 | Zeile 343 |
---|
{ $offset = $mybb->user['timezone']; $dstcorrection = $mybb->user['dst'];
|
{ $offset = $mybb->user['timezone']; $dstcorrection = $mybb->user['dst'];
|
}
| }
|
elseif(defined("IN_ADMINCP")) { $offset = $mybbadmin['timezone'];
| elseif(defined("IN_ADMINCP")) { $offset = $mybbadmin['timezone'];
|
Zeile 359 | Zeile 370 |
---|
{ $offset = 0; }
|
{ $offset = 0; }
|
|
|
if($adodb == true && function_exists('adodb_date')) { $date = adodb_date($format, $stamp + ($offset * 3600));
| if($adodb == true && function_exists('adodb_date')) { $date = adodb_date($format, $stamp + ($offset * 3600));
|
Zeile 368 | Zeile 379 |
---|
{ $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 419 | 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(); } else
|
require_once MYBB_ROOT."inc/mailhandlers/smtp.php"; $mail = new SmtpMail(); } else
|
{
| {
|
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 454 | 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 467 | 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 475 | 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 577 | 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 622 | Zeile 633 |
---|
{ return; }
|
{ return; }
|
|
|
foreach($forums_by_parent[$fid] as $forum) { $forums[] = $forum['fid'];
| foreach($forums_by_parent[$fid] as $forum) { $forums[] = $forum['fid'];
|
Zeile 649 | Zeile 660 |
---|
if(!$error) { $error = $lang->unknown_error;
|
if(!$error) { $error = $lang->unknown_error;
|
}
// AJAX error message? if($mybb->input['ajax']) { // Send our headers.
| }
// AJAX error message? if($mybb->input['ajax']) { // Send our headers.
|
@header("Content-type: text/html; charset={$lang->settings['charset']}"); echo "<error>{$error}</error>\n"; exit;
| @header("Content-type: text/html; charset={$lang->settings['charset']}"); echo "<error>{$error}</error>\n"; exit;
|
Zeile 687 | Zeile 698 |
---|
global $theme, $mybb, $db, $lang, $templates;
if(!$title)
|
global $theme, $mybb, $db, $lang, $templates;
if(!$title)
|
{
| {
|
$title = $lang->please_correct_errors;
|
$title = $lang->please_correct_errors;
|
}
| }
|
if(!is_array($errors))
|
if(!is_array($errors))
|
{
| {
|
$errors = array($errors); }
// AJAX error message? if($mybb->input['ajax'])
|
$errors = array($errors); }
// AJAX error message? if($mybb->input['ajax'])
|
{
| {
|
$error = implode("\n\n", $errors); // Send our headers. @header("Content-type: text/html; charset={$lang->settings['charset']}"); echo "<error>{$error}</error>\n"; exit;
|
$error = implode("\n\n", $errors); // Send our headers. @header("Content-type: text/html; charset={$lang->settings['charset']}"); echo "<error>{$error}</error>\n"; exit;
|
}
| }
|
foreach($errors as $error) { $errorlist .= "<li>".$error."</li>\n";
|
foreach($errors as $error) { $errorlist .= "<li>".$error."</li>\n";
|
}
eval("\$errors = \"".$templates->get("error_inline")."\";");
| }
eval("\$errors = \"".$templates->get("error_inline")."\";");
|
return $errors; }
| return $errors; }
|
Zeile 722 | Zeile 733 |
---|
function error_no_permission() { global $mybb, $theme, $templates, $db, $lang, $plugins, $session;
|
function error_no_permission() { global $mybb, $theme, $templates, $db, $lang, $plugins, $session;
|
|
|
$time = TIME_NOW; $plugins->run_hooks("no_permission");
|
$time = TIME_NOW; $plugins->run_hooks("no_permission");
|
|
|
$noperm_array = array ( "nopermission" => '1', "location1" => 0, "location2" => 0 );
|
$noperm_array = array ( "nopermission" => '1', "location1" => 0, "location2" => 0 );
|
$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
if($mybb->input['ajax']) {
| $db->update_query("sessions", $noperm_array, "sid='{$session->sid}'");
if($mybb->input['ajax']) {
|
// Send our headers. header("Content-type: text/html; charset={$lang->settings['charset']}"); echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";
| // Send our headers. header("Content-type: text/html; charset={$lang->settings['charset']}"); echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";
|
Zeile 757 | Zeile 768 |
---|
}
$redirect_url = htmlspecialchars_uni($redirect_url);
|
}
$redirect_url = htmlspecialchars_uni($redirect_url);
|
|
|
switch($mybb->settings['username_method']) { case 0:
| switch($mybb->settings['username_method']) { case 0:
|
Zeile 772 | Zeile 783 |
---|
default: $lang_username = $lang->username; break;
|
default: $lang_username = $lang->username; break;
|
}
| }
|
eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
| eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
|
Zeile 790 | Zeile 801 |
---|
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
|
|
$plugins->run_hooks("redirect", $redirect_args);
if($mybb->input['ajax'])
| $plugins->run_hooks("redirect", $redirect_args);
if($mybb->input['ajax'])
|
Zeile 807 | Zeile 818 |
---|
$url = str_replace(array("\n","\r",";"), "", $url); echo 'window.location = "'.addslashes($url).'";'."\n"; echo "</script>\n";
|
$url = str_replace(array("\n","\r",";"), "", $url); echo 'window.location = "'.addslashes($url).'";'."\n"; echo "</script>\n";
|
exit; }
| exit; }
|
if(!$message) {
| if(!$message) {
|
Zeile 822 | 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'])) {
|
Zeile 838 | 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://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/') { header("Location: {$mybb->settings['bburl']}/{$url}");
| if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/') { header("Location: {$mybb->settings['bburl']}/{$url}");
|
Zeile 868 | Zeile 879 |
---|
if($count <= $perpage) { return;
|
if($count <= $perpage) { return;
|
}
| }
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 903 | Zeile 914 |
---|
$to = $pages; $from = $pages-$mybb->settings['maxmultipagelinks']+1; if($from <= 0)
|
$to = $pages; $from = $pages-$mybb->settings['maxmultipagelinks']+1; if($from <= 0)
|
{
| {
|
$from = 1; } }
| $from = 1; } }
|
Zeile 923 | Zeile 934 |
---|
$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) {
| $mppage = ''; for($i = $from; $i <= $to; ++$i) {
|
Zeile 943 | Zeile 954 |
---|
else { eval("\$mppage .= \"".$templates->get("multipage_page")."\";");
|
else { eval("\$mppage .= \"".$templates->get("multipage_page")."\";");
|
} }
| } }
|
$end = ''; if($to < $pages) {
| $end = ''; if($to < $pages) {
|
Zeile 956 | Zeile 967 |
---|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";");
|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";");
|
}
| }
|
$nextpage = ''; if($page < $pages)
| $nextpage = ''; if($page < $pages)
|
Zeile 967 | Zeile 978 |
---|
}
$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 989 | Zeile 1000 |
---|
function fetch_page_url($url, $page) { if($page <= 1)
|
function fetch_page_url($url, $page) { if($page <= 1)
|
{
| {
|
$find = array( "-page-{page}", "&page={page}",
| $find = array( "-page-{page}", "&page={page}",
|
Zeile 1089 | Zeile 1100 |
---|
if(count($groups) == 1) { return $groupscache[$gid];
|
if(count($groups) == 1) { return $groupscache[$gid];
|
}
| }
|
foreach($groups as $gid) {
| foreach($groups as $gid) {
|
Zeile 1109 | Zeile 1120 |
---|
else { $permbit = "";
|
else { $permbit = "";
|
}
| }
|
// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account. if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0)) { $usergroup[$perm] = 0; continue;
|
// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account. if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0)) { $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 1253 | Zeile 1264 |
---|
{ return $groupperms; }
|
{ return $groupperms; }
|
|
|
$current_permissions = array(); $only_view_own_threads = 1;
|
$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)) {
|
Zeile 1277 | Zeile 1288 |
---|
$level_permissions = $fpermcache[$parent_id][$gid]; break; }
|
$level_permissions = $fpermcache[$parent_id][$gid]; break; }
|
}
| }
|
// If we STILL don't have forum permissions we use the usergroup itself if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
// 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])
| foreach($level_permissions as $permission => $access) { if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
|
Zeile 1295 | Zeile 1306 |
---|
} }
|
} }
|
if(!$level_permissions["canonlyviewownthreads"])
| if($level_permissions["canview"] && !$level_permissions["canonlyviewownthreads"])
|
{ $only_view_own_threads = 0;
|
{ $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;
|
}
// 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) { $current_permissions = $groupperms;
| if(count($current_permissions) == 0) { $current_permissions = $groupperms;
|
Zeile 1324 | Zeile 1335 |
---|
function check_forum_password($fid, $pid=0) { global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
|
function check_forum_password($fid, $pid=0) { global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
|
|
|
$showform = true;
|
$showform = true;
|
|
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache) { return false;
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums(); if(!$forum_cache) { return false;
|
} }
| } }
|
// Loop through each of parent forums to ensure we have a password for them too $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents);
| // Loop through each of parent forums to ensure we have a password for them too $parents = explode(',', $forum_cache[$fid]['parentlist']); rsort($parents);
|
Zeile 1344 | Zeile 1355 |
---|
foreach($parents as $parent_id) { if($parent_id == $fid || $parent_id == $pid)
|
foreach($parents as $parent_id) { if($parent_id == $fid || $parent_id == $pid)
|
{
| {
|
continue;
|
continue;
|
}
| }
|
if($forum_cache[$parent_id]['password'] != "") { check_forum_password($parent_id, $fid); } } }
|
if($forum_cache[$parent_id]['password'] != "") { check_forum_password($parent_id, $fid); } } }
|
|
|
$password = $forum_cache[$fid]['password']; if($password) {
| $password = $forum_cache[$fid]['password']; if($password) {
|
Zeile 1421 | Zeile 1432 |
---|
{ $uid = $mybb->user['uid']; }
|
{ $uid = $mybb->user['uid']; }
|
|
|
if($uid == 0) { return false;
|
if($uid == 0) { return false;
|
}
| }
|
if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid];
|
if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid];
|
}
| }
|
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
| if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
|
Zeile 1442 | Zeile 1453 |
---|
$user = get_user($uid);
$groups = array($user['usergroup']);
|
$user = get_user($uid);
$groups = array($user['usergroup']);
|
|
|
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
foreach($extra_groups as $extra_group)
|
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
foreach($extra_groups as $extra_group)
|
{
| {
|
$groups[] = $extra_group; } }
$mod_cache = $cache->read("moderators");
|
$groups[] = $extra_group; } }
$mod_cache = $cache->read("moderators");
|
foreach($mod_cache as $fid => $forum)
| foreach($mod_cache as $forumid => $forum)
|
{
|
{
|
if(!is_array($forum) || !in_array($fid, $parentslist))
| if(!is_array($forum) || !in_array($forumid, $parentslist))
|
{ // No perms or we're not after this forum continue;
| { // No perms or we're not after this forum continue;
|
Zeile 1467 | Zeile 1478 |
---|
if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid];
|
foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
| foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
|
// Figure out the user permissions if($value == 0)
| // Figure out the user permissions if($value == 0)
|
Zeile 1483 | Zeile 1494 |
---|
else { $perms[$action] = max($perm[$action], $perms[$action]);
|
else { $perms[$action] = max($perm[$action], $perms[$action]);
|
} }
| } }
|
}
foreach($groups as $group)
| }
foreach($groups as $group)
|
Zeile 1504 | Zeile 1515 |
---|
}
$perms[$action] = max($perm[$action], $perms[$action]);
|
}
$perms[$action] = max($perm[$action], $perms[$action]);
|
} } }
| } } }
|
$modpermscache[$fid][$uid] = $perms;
return $perms;
| $modpermscache[$fid][$uid] = $perms;
return $perms;
|
Zeile 1529 | Zeile 1540 |
---|
{ $uid = $mybb->user['uid']; }
|
{ $uid = $mybb->user['uid']; }
|
|
|
if($uid == 0) { return false;
| if($uid == 0) { return false;
|
Zeile 1538 | Zeile 1549 |
---|
$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 1565 | Zeile 1585 |
---|
else { $modperms = get_moderator_permissions($fid, $uid);
|
else { $modperms = get_moderator_permissions($fid, $uid);
|
|
|
if(!$action && $modperms) { return true;
| if(!$action && $modperms) { return true;
|
Zeile 1610 | Zeile 1630 |
---|
$posticons[$posticon['name']] = $posticon; } krsort($posticons);
|
$posticons[$posticon['name']] = $posticon; } krsort($posticons);
|
|
|
foreach($posticons as $dbicon) { $dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
| foreach($posticons as $dbicon) { $dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
|
Zeile 1622 | Zeile 1642 |
---|
$no_icons_checked = ""; } else
|
$no_icons_checked = ""; } else
|
{
| {
|
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
|
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
|
}
| }
|
++$listed; if($listed == 10) { $iconlist .= "<br />"; $listed = 0; }
|
++$listed; if($listed == 10) { $iconlist .= "<br />"; $listed = 0; }
|
}
eval("\$posticons = \"".$templates->get("posticons")."\";");
| }
eval("\$posticons = \"".$templates->get("posticons")."\";");
|
return $posticons; }
| return $posticons; }
|
Zeile 1657 | Zeile 1677 |
---|
}
if($expires == -1)
|
}
if($expires == -1)
|
{
| {
|
$expires = 0; } elseif($expires == "" || $expires == null)
| $expires = 0; } elseif($expires == "" || $expires == null)
|
Zeile 1679 | Zeile 1699 |
---|
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'])) { $cookie .= "; path={$mybb->settings['cookiepath']}";
| if(!empty($mybb->settings['cookiepath'])) { $cookie .= "; path={$mybb->settings['cookiepath']}";
|
Zeile 1695 | Zeile 1715 |
---|
{ $cookie .= "; HttpOnly"; }
|
{ $cookie .= "; HttpOnly"; }
|
|
|
$mybb->cookies[$name] = $value;
|
$mybb->cookies[$name] = $value;
|
|
|
header($cookie, false); }
/** * Unset a cookie set by MyBB.
|
header($cookie, false); }
/** * Unset a cookie set by MyBB.
|
* * @param string The cookie identifier.
| * * @param string The cookie identifier.
|
*/ 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]); }
/** * Get the contents from a serialised cookie array.
|
unset($mybb->cookies[$name]); }
/** * Get the contents from a serialised cookie array.
|
*
| *
|
* @param string The cookie identifier. * @param int The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
| * @param string The cookie identifier. * @param int The cookie content id. * @return array|boolean The cookie id's content array or false when non-existent.
|
Zeile 1726 | Zeile 1746 |
---|
function my_get_array_cookie($name, $id) { global $mybb;
|
function my_get_array_cookie($name, $id) { global $mybb;
|
|
|
if(!isset($mybb->cookies['mybb'][$name])) { return false;
|
if(!isset($mybb->cookies['mybb'][$name])) { return false;
|
}
| }
|
$cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id]))
| $cookie = my_unserialize($mybb->cookies['mybb'][$name]);
if(is_array($cookie) && isset($cookie[$id]))
|
Zeile 1741 | Zeile 1761 |
---|
else { return 0;
|
else { return 0;
|
} }
| } }
|
/** * Set a serialised cookie array.
| /** * Set a serialised cookie array.
|
Zeile 1754 | Zeile 1774 |
---|
function my_set_array_cookie($name, $id, $value, $expires="") { global $mybb;
|
function my_set_array_cookie($name, $id, $value, $expires="") { global $mybb;
|
|
|
$cookie = $mybb->cookies['mybb']; $newcookie = my_unserialize($cookie[$name]);
| $cookie = $mybb->cookies['mybb']; $newcookie = my_unserialize($cookie[$name]);
|
Zeile 1774 | Zeile 1794 |
---|
*/ function my_unserialize($data) {
|
*/ function my_unserialize($data) {
|
| // Do no unserialize objects if(substr($data, 0, 1) == 'O') { return array(); }
|
$array = unserialize($data);
if(!is_array($array))
| $array = unserialize($data);
if(!is_array($array))
|
Zeile 1782 | Zeile 1808 |
---|
}
return $array;
|
}
return $array;
|
}
| }
|
/** * Returns the serverload of the system.
| /** * Returns the serverload of the system.
|
Zeile 1802 | Zeile 1828 |
---|
{ // sys_getloadavg() will return an array with [0] being load within the last minute. $serverload = sys_getloadavg();
|
{ // sys_getloadavg() will return an array with [0] being load within the last minute. $serverload = sys_getloadavg();
|
$serverload[0] = round($serverload[0], 4);
| $serverload[0] = round($serverload[0], 4);
|
} else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
|
} else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
|
{
| {
|
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); } if(!is_numeric($serverload[0])) { if(@ini_get('safe_mode') == 'On')
|
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); } if(!is_numeric($serverload[0])) { if(@ini_get('safe_mode') == 'On')
|
{ 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')) {
|
Zeile 1845 | Zeile 1871 |
---|
else { return $lang->unknown;
|
else { return $lang->unknown;
|
}
$returnload = trim($serverload[0]);
| }
$returnload = trim($serverload[0]);
|
return $returnload; }
| return $returnload; }
|
Zeile 1858 | Zeile 1884 |
---|
* @return int The amount of memory allocated to the script. */ function get_memory_usage()
|
* @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);
| if(function_exists('memory_get_peak_usage')) { return memory_get_peak_usage(true);
|
Zeile 1891 | Zeile 1917 |
---|
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];
|
} } else {
| } } else {
|
$new_stats[$counter] = $changes[$counter]; } // Less than 0? That's bad
| $new_stats[$counter] = $changes[$counter]; } // Less than 0? That's bad
|
Zeile 1910 | Zeile 1936 |
---|
// 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 1971 | Zeile 1997 |
---|
} else {
|
} else {
|
$update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if(!$update_query[$counter]) { $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query("forums", $update_query, "fid='".intval($fid)."'"); }
// 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)) { $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}";
| $update_query[$counter] = $changes[$counter]; }
// Less than 0? That's bad if($update_query[$counter] < 0) { $update_query[$counter] = 0;
|
} }
|
} }
|
if(array_key_exists('unapprovedposts', $update_query))
| }
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query("forums", $update_query, "fid='".intval($fid)."'"); }
// Guess we should update the statistics too? $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) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}"; } else
|
{
|
{
|
$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(); }
/** * Update the last post information for a specific forum
|
$cache->update_forums(); }
/** * Update the last post information for a specific forum
|
*
| *
|
* @param int The forum ID */ function update_forum_lastpost($fid)
| * @param int The forum ID */ function update_forum_lastpost($fid)
|
Zeile 2093 | Zeile 2120 |
---|
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 2113 | Zeile 2140 |
---|
{ $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 2121 | Zeile 2148 |
---|
} } }
|
} } }
|
|
|
$db->free_result($query);
|
$db->free_result($query);
|
|
|
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query("threads", $update_query, "tid='".intval($tid)."'"); }
|
// Only update if we're actually doing something if(count($update_query) > 0) { $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 2150 | Zeile 2177 |
---|
if(strpos($thread['closed'], 'moved|') !== false) { return false;
|
if(strpos($thread['closed'], 'moved|') !== false) { return false;
|
}
$query = $db->query("
| }
$query = $db->query("
|
SELECT u.uid, u.username, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
| SELECT u.uid, u.username, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
|
Zeile 2161 | Zeile 2188 |
---|
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 2173 | Zeile 2200 |
---|
LIMIT 1 "); $firstpost = $db->fetch_array($query);
|
LIMIT 1 "); $firstpost = $db->fetch_array($query);
|
$db->free_result($query);
| $db->free_result($query);
|
if(!$firstpost['username'])
|
if(!$firstpost['username'])
|
{
| {
|
$firstpost['username'] = $firstpost['postusername'];
|
$firstpost['username'] = $firstpost['postusername'];
|
}
| }
|
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername'];
|
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername'];
|
}
| }
|
if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username'];
| if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username'];
|
Zeile 2195 | Zeile 2222 |
---|
$lastpost['username'] = $db->escape_string($lastpost['username']); $firstpost['username'] = $db->escape_string($firstpost['username']);
|
$lastpost['username'] = $db->escape_string($lastpost['username']); $firstpost['username'] = $db->escape_string($firstpost['username']);
|
|
|
$update_array = array( 'username' => $firstpost['username'], 'uid' => intval($firstpost['uid']),
| $update_array = array( 'username' => $firstpost['username'], 'uid' => intval($firstpost['uid']),
|
Zeile 2205 | Zeile 2232 |
---|
'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 2321 | Zeile 2348 |
---|
$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 2341 | Zeile 2368 |
---|
if(!$selecteddone) { if(!$selitem)
|
if(!$selecteddone) { if(!$selitem)
|
{
| {
|
$selitem = "default"; }
|
$selitem = "default"; }
|
|
|
$jumpsel[$selitem] = 'selected="selected"'; }
if($showextras == 0) { $template = "special";
|
$jumpsel[$selitem] = 'selected="selected"'; }
if($showextras == 0) { $template = "special";
|
}
| }
|
else { $template = "advanced";
| else { $template = "advanced";
|
Zeile 2370 | Zeile 2397 |
---|
}
return $forumjump;
|
}
return $forumjump;
|
}
| }
|
/** * Returns the extension of a file. *
| /** * Returns the extension of a file. *
|
Zeile 2401 | Zeile 2428 |
---|
}
return $str;
|
}
return $str;
|
}
| }
|
/** * Formats a username based on their display group
| /** * Formats a username based on their display group
|
Zeile 2423 | Zeile 2450 |
---|
if($displaygroup != 0) { $usergroup = $displaygroup;
|
if($displaygroup != 0) { $usergroup = $displaygroup;
|
}
| }
|
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
| $ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
|
Zeile 2435 | Zeile 2462 |
---|
}
$format = stripslashes($format);
|
}
$format = stripslashes($format);
|
|
|
return str_replace("{username}", $username, $format); }
| return str_replace("{username}", $username, $format); }
|
Zeile 2492 | Zeile 2519 |
---|
"editor_color" ); $editor_language = "var editor_language = {\n";
|
"editor_color" ); $editor_language = "var editor_language = {\n";
|
|
|
$editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);
foreach($editor_lang_strings as $key => $lang_string)
| $editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);
foreach($editor_lang_strings as $key => $lang_string)
|
Zeile 2592 | Zeile 2619 |
---|
$smilies .= "<td style=\"text-align: center\"><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n"; ++$i; ++$counter;
|
$smilies .= "<td style=\"text-align: center\"><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n"; ++$i; ++$counter;
|
|
|
if($counter == $mybb->settings['smilieinsertercols']) { $counter = 0;
| if($counter == $mybb->settings['smilieinsertercols']) { $counter = 0;
|
Zeile 2615 | Zeile 2642 |
---|
} } else
|
} } else
|
{
| {
|
$clickablesmilies = ""; }
|
$clickablesmilies = ""; }
|
|
|
return $clickablesmilies; }
/** * Builds thread prefixes and returns a selected prefix (or all)
|
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)
|
* @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;
| function build_prefixes($pid=0) { global $cache;
|
Zeile 2638 | Zeile 2665 |
---|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
}
| }
|
return $prefixes_cache; }
| return $prefixes_cache; }
|
Zeile 2649 | Zeile 2676 |
---|
{ // No cache $prefix_cache = $cache->read("threadprefixes", true);
|
{ // No cache $prefix_cache = $cache->read("threadprefixes", true);
|
|
|
if(!is_array($prefix_cache)) { return array();
| if(!is_array($prefix_cache)) { return array();
|
Zeile 2660 | Zeile 2687 |
---|
foreach($prefix_cache as $prefix) { $prefixes_cache[$prefix['pid']] = $prefix;
|
foreach($prefix_cache as $prefix) { $prefixes_cache[$prefix['pid']] = $prefix;
|
}
| }
|
if($pid != 0 && is_array($prefixes_cache[$pid])) {
| if($pid != 0 && is_array($prefixes_cache[$pid])) {
|
Zeile 2676 | Zeile 2703 |
---|
/** * 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
|
Zeile 2684 | Zeile 2711 |
---|
function build_prefix_select($fid, $selected_pid=0, $multiple=0) { global $cache, $db, $lang, $mybb;
|
function build_prefix_select($fid, $selected_pid=0, $multiple=0) { global $cache, $db, $lang, $mybb;
|
|
|
if($fid != 'all') { $fid = intval($fid);
| if($fid != 'all') { $fid = intval($fid);
|
Zeile 2749 | Zeile 2776 |
---|
}
$prefixselect = "";
|
}
$prefixselect = "";
|
$multipleselect = "";
| |
if($multiple != 0) {
|
if($multiple != 0) {
|
$multipleselect = " multiple=\"multiple\" size=\"5\"";
| $prefixselect = "<select name=\"threadprefix[]\" multiple=\"multiple\" size=\"5\">\n";
|
}
|
}
|
$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";
| else { $prefixselect = "<select name=\"threadprefix\">\n"; }
|
if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any') { $any_selected = " selected=\"selected\"";
|
if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any') { $any_selected = " selected=\"selected\"";
|
}
| }
|
$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n"; }
| $prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n"; }
|
Zeile 2772 | Zeile 2800 |
---|
if((intval($selected_pid) == 0) && $selected_pid != 'any') { $default_selected = " selected=\"selected\"";
|
if((intval($selected_pid) == 0) && $selected_pid != 'any') { $default_selected = " selected=\"selected\"";
|
}
| }
|
$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";
| $prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";
|
Zeile 2785 | Zeile 2813 |
---|
}
$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
|
}
$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
|
}
$prefixselect .= "</select>\n ";
| }
$prefixselect .= "</select>\n ";
|
return $prefixselect; }
| return $prefixselect; }
|
Zeile 2971 | Zeile 2999 |
---|
*/ function get_ip() {
|
*/ function get_ip() {
|
global $mybb, $plugins;
| global $mybb, $plugins;
|
|
|
$ip = 0;
| $ip = 0;
|
|
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; }
if($mybb->settings['ip_forwarded_check']) { if(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(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; }
if($mybb->settings['ip_forwarded_check']) { if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses); } elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses); }
|
if(is_array($addresses[0])) { foreach($addresses[0] as $key => $val)
|
if(is_array($addresses[0])) { foreach($addresses[0] as $key => $val)
|
{ 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(!$ip) { if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_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); }
return $ip; }
/**
| if(!$ip) { if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_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); }
return $ip; }
/**
|
* Fetch the friendly size (GB, MB, KB, B) for a specified file size. * * @param int The size in bytes
| * Fetch the friendly size (GB, MB, KB, B) for a specified file size. * * @param int The size in bytes
|
Zeile 3030 | Zeile 3058 |
---|
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 3083 | Zeile 3111 |
---|
else { $size = my_number_format($size)." ".$lang->size_bytes;
|
else { $size = my_number_format($size)." ".$lang->size_bytes;
|
}
| }
|
return $size; }
| return $size; }
|
Zeile 3106 | Zeile 3134 |
---|
$ext = my_strtolower($ext);
if($attachtypes[$ext]['icon'])
|
$ext = my_strtolower($ext);
if($attachtypes[$ext]['icon'])
|
{
| {
|
if(defined("IN_ADMINCP")) { $icon = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
| if(defined("IN_ADMINCP")) { $icon = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
|
Zeile 3124 | Zeile 3152 |
---|
{ $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 3135 | Zeile 3164 |
---|
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 3155 | Zeile 3184 |
---|
if(!is_array($forum_cache)) { cache_forums();
|
if(!is_array($forum_cache)) { cache_forums();
|
}
| }
|
if(!is_array($permissioncache))
|
if(!is_array($permissioncache))
|
{
| {
|
$permissioncache = forum_permissions(); }
| $permissioncache = forum_permissions(); }
|
Zeile 3168 | Zeile 3197 |
---|
if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
}
| }
|
else { $perms = $mybb->usergroup;
| else { $perms = $mybb->usergroup;
|
Zeile 3182 | Zeile 3211 |
---|
{ $pwverified = 0; }
|
{ $pwverified = 0; }
|
|
|
$password_forums[$forum['fid']] = $forum['password']; } else
| $password_forums[$forum['fid']] = $forum['password']; } else
|
Zeile 3203 | Zeile 3232 |
---|
if($unviewableforums) { $unviewableforums .= ",";
|
if($unviewableforums) { $unviewableforums .= ",";
|
}
| }
|
$unviewableforums .= "'".$forum['fid']."'"; } }
| $unviewableforums .= "'".$forum['fid']."'"; } }
|
Zeile 3242 | Zeile 3271 |
---|
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; $activesep = '';
|
$i = 0; $activesep = '';
|
|
|
if(is_array($navbits)) { reset($navbits);
| if(is_array($navbits)) { reset($navbits);
|
Zeile 3261 | Zeile 3290 |
---|
{ $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 3366 | Zeile 3400 |
---|
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']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED); }
| $navbits[$navsize]['multipage'] = $multipage; $navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED); }
|
Zeile 3398 | Zeile 3432 |
---|
/** * Builds a URL to an archive mode page
|
/** * Builds a URL to an archive mode page
|
*
| *
|
* @param string The type of page (thread|announcement|forum) * @param int The ID of the item * @return string The URL
| * @param string The type of page (thread|announcement|forum) * @param int The ID of the item * @return string The URL
|
Zeile 3406 | Zeile 3440 |
---|
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((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)
| // If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows //if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS")) if($mybb->settings['seourls_archive'] == 1)
|
Zeile 3435 | Zeile 3469 |
---|
return $url; }
|
return $url; }
|
|
|
/** * Prints a debug information page */
| /** * Prints a debug information page */
|
Zeile 3446 | Zeile 3480 |
---|
$totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $db->query_time); $query_time = $maintimer->format($db->query_time);
|
$totaltime = $maintimer->totaltime; $phptime = $maintimer->format($maintimer->totaltime - $db->query_time); $query_time = $maintimer->format($db->query_time);
|
|
|
$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2); $percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);
| $percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2); $percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);
|
Zeile 3492 | Zeile 3526 |
---|
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 3550 | Zeile 3584 |
---|
echo "<br />\n"; }
|
echo "<br />\n"; }
|
if(count($templates->uncached_templates > 0))
| 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 "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
Zeile 3873 | Zeile 3907 |
---|
$groupslist = ""; $usergroups = ""; $usergroups = $user['additionalgroups'].",";
|
$groupslist = ""; $usergroups = ""; $usergroups = $user['additionalgroups'].",";
|
|
|
$groups = explode(",", $user['additionalgroups']);
if(is_array($groups))
| $groups = explode(",", $user['additionalgroups']);
if(is_array($groups))
|
Zeile 3885 | Zeile 3919 |
---|
$groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1;
|
$groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1;
|
}
| }
|
} }
|
} }
|
|
|
$dispupdate = ""; if($leavegroup == $user['displaygroup']) {
| $dispupdate = ""; if($leavegroup == $user['displaygroup']) {
|
Zeile 3900 | Zeile 3934 |
---|
SET additionalgroups='$groupslist' $dispupdate WHERE uid='".intval($uid)."' ");
|
SET additionalgroups='$groupslist' $dispupdate WHERE uid='".intval($uid)."' ");
|
|
|
$cache->update_moderators(); }
| $cache->update_moderators(); }
|
Zeile 3933 | Zeile 3967 |
---|
else { $location = htmlspecialchars_uni($_SERVER['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);
|
Zeile 3953 | Zeile 3987 |
---|
{ continue; }
|
{ continue; }
|
|
|
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni((string)$name)."\" value=\"".htmlspecialchars_uni((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 3970 | Zeile 4004 |
---|
{ $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 3982 | Zeile 4016 |
---|
$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 4153 | Zeile 4187 |
---|
static $charset; static $use_mb; static $use_iconv;
|
static $charset; static $use_mb; static $use_iconv;
|
|
|
if(!isset($charset)) { $charset = my_strtolower($lang->settings['charset']); }
|
if(!isset($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";
|
Zeile 4200 | Zeile 4234 |
---|
if($to) { return utf8_encode($str);
|
if($to) { return utf8_encode($str);
|
}
| }
|
else { return utf8_decode($str); }
|
else { return utf8_decode($str); }
|
}
| }
|
else { return $str;
|
else { return $str;
|
} }
/**
| } }
/**
|
* Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references. * * @param string The string to be word wrapped
| * Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references. * * @param string The string to be word wrapped
|
Zeile 4225 | Zeile 4259 |
---|
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&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$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&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$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 4264 | Zeile 4298 |
---|
$h--;
if($i == $year && $l == $month && $m == $day)
|
$h--;
if($i == $year && $l == $month && $m == $day)
|
{
| {
|
return $h;
|
return $h;
|
}
| }
|
if($h == 0) { $h = 7; } }
|
if($h == 0) { $h = 7; } }
|
} } }
| } } }
|
/** * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
| /** * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
|
Zeile 4339 | Zeile 4373 |
---|
$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 4370 | Zeile 4404 |
---|
$bdays = str_replace($find, $html, $bdays); $bmonth = str_replace($find, $html, $bmonth);
|
$bdays = str_replace($find, $html, $bdays); $bmonth = str_replace($find, $html, $bmonth);
|
|
|
$replace = array( sprintf('%02s', $bm), sprintf('%02s', $bd),
| $replace = array( sprintf('%02s', $bm), sprintf('%02s', $bd),
|
Zeile 4383 | Zeile 4417 |
---|
$wd, ($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)), );
|
$wd, ($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 4391 | Zeile 4425 |
---|
array_pop($find); array_pop($replace); }
|
array_pop($find); array_pop($replace); }
|
return str_replace($find, $replace, $display); }
| return str_replace($find, $replace, $display); }
|
/** * Returns the age of a user with specified birthday.
| /** * Returns the age of a user with specified birthday.
|
Zeile 4412 | Zeile 4446 |
---|
list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));
$age = $year-$bday[2];
|
list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));
$age = $year-$bday[2];
|
|
|
if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1]) { --$age;
| if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1]) { --$age;
|
Zeile 4431 | Zeile 4465 |
---|
$query = $db->simple_select("posts", "pid,replyto", "tid='{$tid}'", array('order_by' => 'dateline', 'limit' => 1)); $post = $db->fetch_array($query);
|
$query = $db->simple_select("posts", "pid,replyto", "tid='{$tid}'", array('order_by' => 'dateline', 'limit' => 1)); $post = $db->fetch_array($query);
|
|
|
if($post['replyto'] != 0) { $replyto_update = array(
| if($post['replyto'] != 0) { $replyto_update = array(
|
Zeile 4454 | Zeile 4488 |
---|
*/ function my_strlen($string) {
|
*/ function my_strlen($string) {
|
global $lang;
$string = preg_replace("#&\#([0-9]+);#", "-", $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);
|
|
|
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); }
| // 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 4600 | Zeile 4634 |
---|
* @return int The un-htmlentitied' string. */ function unhtmlentities($string)
|
* @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 4620 | Zeile 4654 |
---|
*/ 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); }
| { return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F); }
|
else if($c <= 0xFFFF)
|
else if($c <= 0xFFFF)
|
{ return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); }
| { 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.
| * * @param array The event data array.
|
* @return string The link to the event poster. */ function get_event_poster($event)
| * @return string The link to the event poster. */ function get_event_poster($event)
|
Zeile 4667 | Zeile 4701 |
---|
function get_event_date($event) { global $mybb;
|
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);
|
Zeile 4734 | Zeile 4768 |
---|
{ $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 4749 | Zeile 4783 |
---|
function get_forum_link($fid, $page=0) { if($page > 0)
|
function get_forum_link($fid, $page=0) { if($page > 0)
|
{
| {
|
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
|
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
|
$link = str_replace("{page}", $page, $link); return htmlspecialchars_uni($link); } else { $link = str_replace("{fid}", $fid, FORUM_URL);
| $link = str_replace("{page}", $page, $link); return htmlspecialchars_uni($link); } else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
return htmlspecialchars_uni($link); } }
| return htmlspecialchars_uni($link); } }
|
Zeile 4772 | Zeile 4806 |
---|
function get_thread_link($tid, $page=0, $action='') { if($page > 1)
|
function get_thread_link($tid, $page=0, $action='') { if($page > 1)
|
{ if($action) { $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link); }
| { if($action) { $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link); }
|
else { $link = THREAD_URL_PAGED; }
|
else { $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 4792 | Zeile 4826 |
---|
{ $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link);
|
{ $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link);
|
}
| }
|
else { $link = THREAD_URL;
| else { $link = THREAD_URL;
|
Zeile 4914 | Zeile 4948 |
---|
{ return $user_cache[$uid]; }
|
{ return $user_cache[$uid]; }
|
else
| elseif(($uid > 0))
|
{ $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
return $user_cache[$uid]; }
|
{ $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
return $user_cache[$uid]; }
|
| return array();
|
}
/**
| }
/**
|
Zeile 5186 | Zeile 5221 |
---|
function email_already_in_use($email, $uid="") { global $db;
|
function email_already_in_use($email, $uid="") { global $db;
|
|
|
$uid_string = ""; if($uid) { $uid_string = " AND uid != '".intval($uid)."'"; } $query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
|
$uid_string = ""; if($uid) { $uid_string = " AND uid != '".intval($uid)."'"; } $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; }
/* * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
|
return false; }
/* * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
|
*/
| */
|
function rebuildsettings() { rebuild_settings(); }
|
function rebuildsettings() { rebuild_settings(); }
|
|
|
/** * Rebuilds settings.php *
| /** * Rebuilds settings.php *
|
Zeile 5230 | Zeile 5265 |
---|
$options = array( "order_by" => "title", "order_dir" => "ASC"
|
$options = array( "order_by" => "title", "order_dir" => "ASC"
|
);
| );
|
$query = $db->simple_select("settings", "value, name", "", $options);
while($setting = $db->fetch_array($query))
|
$query = $db->simple_select("settings", "value, name", "", $options);
while($setting = $db->fetch_array($query))
|
{
| {
|
$mybb->settings[$setting['name']] = $setting['value']; $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
$mybb->settings[$setting['name']] = $setting['value']; $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
}
| }
|
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">"; $file = @fopen(MYBB_ROOT."inc/settings.php", $mode); @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 5261 | Zeile 5296 |
---|
if($mybb->settings['minsearchword'] < 1) { $mybb->settings['minsearchword'] = 3;
|
if($mybb->settings['minsearchword'] < 1) { $mybb->settings['minsearchword'] = 3;
|
}
| }
|
if(is_array($terms)) {
| if(is_array($terms)) {
|
Zeile 5334 | Zeile 5369 |
---|
{ 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 5345 | Zeile 5380 |
---|
$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 5373 | Zeile 5408 |
---|
if($src < 0) {
|
if($src < 0) {
|
return false; } elseif($src <= 0x007f) {
| return false; } elseif($src <= 0x007f) {
|
$dest .= chr($src); } elseif($src <= 0x07ff) { $dest .= chr(0xc0 | ($src >> 6));
|
$dest .= chr($src); } elseif($src <= 0x07ff) { $dest .= chr(0xc0 | ($src >> 6));
|
$dest .= chr(0x80 | ($src & 0x003f)); }
| $dest .= chr(0x80 | ($src & 0x003f)); }
|
elseif($src <= 0xffff) { $dest .= chr(0xe0 | ($src >> 12));
| elseif($src <= 0xffff) { $dest .= chr(0xe0 | ($src >> 12));
|
Zeile 5410 | Zeile 5445 |
---|
* Checks if a username has been disallowed for registration/use. * * @param string The username
|
* Checks if a username has been disallowed for registration/use. * * @param string The username
|
* @param boolean True if the 'last used' dateline should be updated if a match is found.
| * @param boolean True if the 'last used' dateline should be updated if a match is found.
|
* @return boolean True if banned, false if not banned */ function is_banned_username($username, $update_lastuse=false)
| * @return boolean True if banned, false if not banned */ function is_banned_username($username, $update_lastuse=false)
|
Zeile 5432 | Zeile 5467 |
---|
} } // Still here - good username
|
} } // Still here - good username
|
return false;
| return false;
|
}
/**
| }
/**
|
Zeile 5443 | Zeile 5478 |
---|
* @return boolean True if banned, false if not banned */ function is_banned_email($email, $update_lastuse=false)
|
* @return boolean True if banned, false if not banned */ function is_banned_email($email, $update_lastuse=false)
|
{
| {
|
global $cache, $db;
|
global $cache, $db;
|
|
|
$banned_cache = $cache->read("bannedemails");
|
$banned_cache = $cache->read("bannedemails");
|
|
|
if($banned_cache === false) { // Failed to read cache, see if we can rebuild it
| if($banned_cache === false) { // Failed to read cache, see if we can rebuild it
|
Zeile 5477 | Zeile 5512 |
---|
// Still here - good email return false; }
|
// Still here - good email return false; }
|
|
|
/** * Checks if a specific IP address has been banned. *
| /** * Checks if a specific IP address has been banned. *
|
Zeile 5488 | Zeile 5523 |
---|
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'], '#')); if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))
| // Make regular expression * match $banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#')); if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))
|
Zeile 5619 | Zeile 5654 |
---|
} $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 5627 | Zeile 5662 |
---|
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 5636 | Zeile 5671 |
---|
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 5644 | Zeile 5679 |
---|
return false; } if(!$url['port'])
|
return false; } if(!$url['port'])
|
{
| {
|
$url['port'] = 80;
|
$url['port'] = 80;
|
}
| }
|
if(!$url['path']) { $url['path'] = "/"; } if($url['query'])
|
if(!$url['path']) { $url['path'] = "/"; } if($url['query'])
|
{
| {
|
$url['path'] .= "?{$url['query']}"; } $fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);
| $url['path'] .= "?{$url['query']}"; } $fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);
|
Zeile 5660 | Zeile 5695 |
---|
if(!$fp) { return false;
|
if(!$fp) { 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[] = '';
|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close"; $headers[] = '';
|
|
|
if(!empty($post_body))
|
if(!empty($post_body))
|
{
| {
|
$headers[] = $post_body;
|
$headers[] = $post_body;
|
}
| }
|
else { // If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts $headers[] = ''; }
|
else { // If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts $headers[] = ''; }
|
$headers = implode("\r\n", $headers);
| $headers = implode("\r\n", $headers);
|
if(!@fwrite($fp, $headers)) { return false;
| if(!@fwrite($fp, $headers)) { return false;
|
Zeile 5718 | Zeile 5753 |
---|
*/ 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 5767 | Zeile 5844 |
---|
} foreach($quoted_strings as $string) {
|
} foreach($quoted_strings as $string) {
|
if($string != "")
| if($string != "")
|
{ if($in_escape) {
| { if($in_escape) {
|
Zeile 5840 | Zeile 5917 |
---|
} return array(my_ip2long($ip_string1), my_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 5907 | Zeile 5984 |
---|
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 5922 | Zeile 5999 |
---|
"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 5932 | Zeile 6009 |
---|
$users[$warning['uid']] = $warning['warningpoints']-$warning['points']; } }
|
$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) );
| $updated_user = array( "warningpoints" => intval($warningpoints) );
|
Zeile 5961 | Zeile 6038 |
---|
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 5978 | Zeile 6055 |
---|
function my_rmdir_recursive($path, $ignore=array()) { global $orig_dir;
|
function my_rmdir_recursive($path, $ignore=array()) { global $orig_dir;
|
|
|
if(!isset($orig_dir)) { $orig_dir = $path; }
|
if(!isset($orig_dir)) { $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); } // Are we done? Don't delete the main folder too and return true if($path == $orig_dir)
| if(@is_dir($path) && !@is_link($path)) { if($dh = @opendir($path))
|
{
|
{
|
return true;
| while(($file = @readdir($dh)) !== false) { if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file)) { continue; } } @closedir($dh);
|
}
|
}
|
return @rmdir($path); } return @unlink($path); }
| |
|
|
/**
| // 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); }
/**
|
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid * * @param array The array of forums
| * Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid * * @param array The array of forums
|
Zeile 6023 | Zeile 6100 |
---|
{ $count += count($array2); }
|
{ $count += count($array2); }
|
|
|
return $count; }
| return $count; }
|
Zeile 6033 | Zeile 6110 |
---|
* * @param string The IP to convert * @return integer IP in 32-bit signed format
|
* * @param string The IP to convert * @return integer IP in 32-bit signed format
|
*/
| */
|
function my_ip2long($ip) { $ip_long = ip2long($ip);
|
function my_ip2long($ip) { $ip_long = ip2long($ip);
|
|
|
if(!$ip_long) { $ip_long = sprintf("%u", ip2long($ip));
|
if(!$ip_long) { $ip_long = sprintf("%u", ip2long($ip));
|
|
|
if(!$ip_long) { return 0;
| if(!$ip_long) { return 0;
|
Zeile 6054 | Zeile 6131 |
---|
}
return $ip_long;
|
}
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 6083 | Zeile 6160 |
---|
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)) { continue; }
|
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext)) { 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 6132 | Zeile 6209 |
---|
$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); } } if($count == 0)
| } @closedir($dh); } }
if($count == 0)
|
{ if(!empty($checksums)) {
| { if(!empty($checksums)) {
|
Zeile 6161 | Zeile 6238 |
---|
} } }
|
} } }
|
|
|
// uh oh if($count == 0) { return $bad_verify_files;
|
// uh oh if($count == 0) { return $bad_verify_files;
|
} }
| } }
|
/** * Returns a signed value equal to an integer *
| /** * Returns a signed value equal to an integer *
|
Zeile 6196 | Zeile 6273 |
---|
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 * @return int An integer equivalent of a secure hexadecimal seed */ function my_rand($min=null, $max=null, $force_seed=false)
|
* @param boolean True forces it to reseed the RNG first * @return int An integer equivalent of a secure hexadecimal seed */ function my_rand($min=null, $max=null, $force_seed=false)
|
{
| {
|
static $seeded = false; static $obfuscator = 0;
|
static $seeded = false; static $obfuscator = 0;
|
|
|
if($seeded == false || $force_seed == true) { mt_srand(secure_seed_rng()); $seeded = true;
|
if($seeded == false || $force_seed == true) { mt_srand(secure_seed_rng()); $seeded = true;
|
|
|
$obfuscator = abs((int) secure_seed_rng());
|
$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()) {
|
Zeile 6272 | Zeile 6391 |
---|
}
/**
|
}
/**
|
* 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 6282 | Zeile 6401 |
---|
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, 0xAD => 1, 0xA0 => 1, 0xAD => 1, 0xBF => 1, 0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160} 0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B} 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, 0xA0 => array(0xC2 => 1), 0xAD => array(0xC2 => 1), 0xBF => array(0xC2 => 1), 0x81 => array(0xC2 => 1), 0x8D => array(0xC2 => 1), 0x90 => array(0xC2 => 1), 0x9D => array(0xC2 => 1),
| 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 6337 | Zeile 6446 |
---|
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 6366 | Zeile 6475 |
---|
$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 6382 | Zeile 6491 |
---|
} 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 6414 | Zeile 6523 |
---|
} return $n; }
|
} return $n; }
|
|
|
return 0;
|
return 0;
|
}
| }
|
/** * Obtain the version of GD installed. *
| /** * Obtain the version of GD installed. *
|
Zeile 6426 | Zeile 6535 |
---|
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 6435 | Zeile 6544 |
---|
{ 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 6452 | Zeile 6561 |
---|
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); } } }
|
?>
| ?>
|