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 33 | Zeile 34 |
---|
{ $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);
|
}
| }
|
else { // if we've got a super fast script... all we can do is assume something
| else { // if we've got a super fast script... all we can do is assume something
|
Zeile 57 | Zeile 58 |
---|
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled";
|
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled";
|
} else
| } else
|
{ $gzipen = "Disabled";
|
{ $gzipen = "Disabled";
|
}
| }
|
$memory_usage = get_memory_usage();
| $memory_usage = get_memory_usage();
|
Zeile 70 | Zeile 71 |
---|
$memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage); } else
|
$memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage); } else
|
{
| {
|
$memory_usage = ''; } // MySQLi is still MySQL, so present it that way to the user
| $memory_usage = ''; } // MySQLi is still MySQL, so present it that way to the user
|
Zeile 92 | 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)
|
if($mybb->settings['gzipoutput'] == 1)
|
{
| {
|
$contents = gzip_encode($contents, $mybb->settings['gziplevel']); }
| $contents = gzip_encode($contents, $mybb->settings['gziplevel']); }
|
Zeile 120 | Zeile 120 |
---|
if(!is_array($shutdown_functions)) { $shutdown_functions = array();
|
if(!is_array($shutdown_functions)) { $shutdown_functions = array();
|
}
| }
|
if(!is_array($arguments)) {
| if(!is_array($arguments)) {
|
Zeile 220 | Zeile 220 |
---|
{ // Loop through and run them all foreach($shutdown_queries as $query)
|
{ // Loop through and run them all foreach($shutdown_queries as $query)
|
{
| {
|
$db->query($query); } }
| $db->query($query); } }
|
Zeile 514 | Zeile 514 |
---|
else { error($lang->invalid_post_code);
|
else { error($lang->invalid_post_code);
|
} } } else { return true; }
| } } } else { return true; }
|
}
/**
| }
/**
|
Zeile 718 | Zeile 718 |
---|
}
foreach($errors as $error)
|
}
foreach($errors as $error)
|
{ $errorlist .= "<li>".$error."</li>\n"; }
| { $errorlist .= "<li>".$error."</li>\n"; }
|
eval("\$errors = \"".$templates->get("error_inline")."\";");
| eval("\$errors = \"".$templates->get("error_inline")."\";");
|
Zeile 733 | 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 757 |
---|
{ $lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, $mybb->user['username']); eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
|
{ $lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, $mybb->user['username']); eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
|
} else {
| } else {
|
// Redirect to where the user came from $redirect_url = $_SERVER['PHP_SELF']; if($_SERVER['QUERY_STRING'])
| // Redirect to where the user came from $redirect_url = $_SERVER['PHP_SELF']; if($_SERVER['QUERY_STRING'])
|
Zeile 822 | Zeile 822 |
---|
}
if(!$message)
|
}
if(!$message)
|
{
| {
|
$message = $lang->redirect; }
| $message = $lang->redirect; }
|
Zeile 1089 | Zeile 1089 |
---|
{ global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
{ global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
$groups = explode(",", $gid);
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
$groups = explode(",", $gid);
|
if(count($groups) == 1)
|
if(count($groups) == 1)
|
{
| {
|
return $groupscache[$gid]; }
| return $groupscache[$gid]; }
|
Zeile 1107 | Zeile 1107 |
---|
if(trim($gid) == "" || !$groupscache[$gid]) { continue;
|
if(trim($gid) == "" || !$groupscache[$gid]) { continue;
|
}
| }
|
foreach($groupscache[$gid] as $perm => $access) {
| foreach($groupscache[$gid] as $perm => $access) {
|
Zeile 1118 | Zeile 1118 |
---|
$permbit = $usergroup[$perm]; } else
|
$permbit = $usergroup[$perm]; } else
|
{
| {
|
$permbit = ""; }
| $permbit = ""; }
|
Zeile 1138 | Zeile 1138 |
---|
}
return $usergroup;
|
}
return $usergroup;
|
}
/**
| }
/**
|
* Fetch the display group properties for a specific display group * * @param int The group ID to fetch the display properties for
| * Fetch the display group properties for a specific display group * * @param int The group ID to fetch the display properties for
|
Zeile 1151 | Zeile 1151 |
---|
global $cache, $groupscache, $displaygroupfields;
if(!is_array($groupscache))
|
global $cache, $groupscache, $displaygroupfields;
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups");
|
$groupscache = $cache->read("usergroups");
|
}
| }
|
$displaygroup = array(); $group = $groupscache[$gid];
|
$displaygroup = array(); $group = $groupscache[$gid];
|
|
|
foreach($displaygroupfields as $field) { $displaygroup[$field] = $group[$field];
|
foreach($displaygroupfields as $field) { $displaygroup[$field] = $group[$field];
|
}
| }
|
return $displaygroup; }
| return $displaygroup; }
|
Zeile 1184 | Zeile 1184 |
---|
}
if(!$gid || $gid == 0) // If no group, we need to fetch it
|
}
if(!$gid || $gid == 0) // If no group, we need to fetch it
|
{
| {
|
if($uid != 0 && $uid != $mybb->user['uid']) { if(!$usercache[$uid])
| if($uid != 0 && $uid != $mybb->user['uid']) { if(!$usercache[$uid])
|
Zeile 1362 | Zeile 1362 |
---|
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 1466 | Zeile 1466 |
---|
$mod_cache = $cache->read("moderators");
|
$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 1549 | 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 1785 | Zeile 1794 |
---|
*/ function my_unserialize($data) {
|
*/ function my_unserialize($data) {
|
$array = unserialize($data);
| // Do no unserialize objects if(substr($data, 0, 1) == 'O') { return array(); }
$array = unserialize($data);
|
if(!is_array($array)) {
| if(!is_array($array)) {
|
Zeile 1793 | Zeile 1808 |
---|
}
return $array;
|
}
return $array;
|
}
/**
| }
/**
|
* Returns the serverload of the system. * * @return int The serverload of the system.
| * Returns the serverload of the system. * * @return int The serverload of the system.
|
Zeile 1805 | Zeile 1820 |
---|
global $lang;
$serverload = array();
|
global $lang;
$serverload = array();
|
|
|
// DIRECTORY_SEPARATOR checks if running windows if(DIRECTORY_SEPARATOR != '\\') {
| // DIRECTORY_SEPARATOR checks if running windows if(DIRECTORY_SEPARATOR != '\\') {
|
Zeile 1823 | Zeile 1838 |
---|
if(!is_numeric($serverload[0])) { if(@ini_get('safe_mode') == 'On')
|
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 1865 | Zeile 1880 |
---|
/** * Returns the amount of memory allocated to the script.
|
/** * Returns the amount of memory allocated to the script.
|
*
| *
|
* @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()
|
Zeile 1986 | Zeile 2001 |
---|
}
// Less than 0? That's bad
|
}
// Less than 0? That's bad
|
if(!$update_query[$counter]) {
| if($update_query[$counter] < 0) {
|
$update_query[$counter] = 0;
|
$update_query[$counter] = 0;
|
} } }
| } } }
|
// Only update if we're actually doing something if(count($update_query) > 0)
|
// Only update if we're actually doing something if(count($update_query) > 0)
|
{
| {
|
$db->update_query("forums", $update_query, "fid='".intval($fid)."'");
|
$db->update_query("forums", $update_query, "fid='".intval($fid)."'");
|
}
// 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}"; } }
if(array_key_exists('unapprovedposts', $update_query)) { $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts']; if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}"; } else { $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; }
| }
// 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 { $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
|
}
|
}
|
| }
if(!empty($new_stats)) {
|
update_stats($new_stats); }
| update_stats($new_stats); }
|
Zeile 2288 | Zeile 2304 |
---|
$pid = intval($pid); $jumpsel['default'] = '';
|
$pid = intval($pid); $jumpsel['default'] = '';
|
|
|
if($permissions) { $permissions = $mybb->usergroup;
| if($permissions) { $permissions = $mybb->usergroup;
|
Zeile 2306 | Zeile 2322 |
---|
if($forum['active'] != 0) { $jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
|
if($forum['active'] != 0) { $jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
|
} } }
| } } }
|
if(!is_array($permissioncache))
|
if(!is_array($permissioncache))
|
{
| {
|
$permissioncache = forum_permissions(); }
if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid])) { foreach($jumpfcache[$pid] as $main)
|
$permissioncache = forum_permissions(); }
if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid])) { foreach($jumpfcache[$pid] as $main)
|
{
| {
|
foreach($main as $forum) { $perms = $permissioncache[$forum['fid']];
|
foreach($main as $forum) { $perms = $permissioncache[$forum['fid']];
|
|
|
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true)) { $optionselected = "";
if($selitem == $forum['fid'])
|
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true)) { $optionselected = "";
if($selitem == $forum['fid'])
|
{
| {
|
$optionselected = "selected=\"selected\""; $selecteddone = 1; }
| $optionselected = "selected=\"selected\""; $selecteddone = 1; }
|
Zeile 2357 | Zeile 2373 |
---|
}
$jumpsel[$selitem] = 'selected="selected"';
|
}
$jumpsel[$selitem] = 'selected="selected"';
|
}
| }
|
if($showextras == 0)
|
if($showextras == 0)
|
{
| {
|
$template = "special"; } else
| $template = "special"; } else
|
Zeile 2368 | Zeile 2384 |
---|
$template = "advanced";
if(strpos(FORUM_URL, '.html') !== false)
|
$template = "advanced";
if(strpos(FORUM_URL, '.html') !== false)
|
{
| {
|
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";
|
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";
|
}
| }
|
else { $forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);
| else { $forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);
|
Zeile 2378 | Zeile 2394 |
---|
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");
|
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");
|
}
| }
|
return $forumjump; }
| return $forumjump; }
|
Zeile 2388 | Zeile 2404 |
---|
* * @param string The filename. * @return string The extension of the file.
|
* * @param string The filename. * @return string The extension of the file.
|
*/
| */
|
function get_extension($file) { return my_strtolower(my_substr(strrchr($file, "."), 1));
| function get_extension($file) { return my_strtolower(my_substr(strrchr($file, "."), 1));
|
Zeile 2448 | Zeile 2464 |
---|
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
|
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
|
}
| }
|
/** * Build the javascript based MyCode inserter
| /** * Build the javascript based MyCode inserter
|
Zeile 2527 | Zeile 2543 |
---|
{ global $page; $codeinsert = $page->build_codebuttons_editor($bind, $editor_language);
|
{ global $page; $codeinsert = $page->build_codebuttons_editor($bind, $editor_language);
|
}
| }
|
else { eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
|
else { eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
|
}
| }
|
}
|
}
|
|
|
return $codeinsert; }
|
return $codeinsert; }
|
|
|
/** * Build the javascript clickable smilie inserter *
| /** * Build the javascript clickable smilie inserter *
|
Zeile 2545 | Zeile 2561 |
---|
function build_clickable_smilies() { global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;
|
function build_clickable_smilies() { global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;
|
|
|
if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) { if(!$smiliecount)
| if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) { if(!$smiliecount)
|
Zeile 2565 | Zeile 2581 |
---|
if($smilie['showclickable'] != 0) { $smiliecache[$smilie['find']] = $smilie['image'];
|
if($smilie['showclickable'] != 0) { $smiliecache[$smilie['find']] = $smilie['image'];
|
} } }
| } } }
|
unset($smilie);
| unset($smilie);
|
Zeile 2645 | Zeile 2661 |
---|
static $prefixes_cache;
if(is_array($prefixes_cache))
|
static $prefixes_cache;
if(is_array($prefixes_cache))
|
{
| {
|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
| if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
Zeile 2760 | 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"; } else { $prefixselect = "<select name=\"threadprefix\">\n";
|
}
|
}
|
$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";
| |
if($multiple == 1) {
| if($multiple == 1) {
|
Zeile 2986 | Zeile 3003 |
---|
$ip = 0;
|
$ip = 0;
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
| if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
|
{ $ip = $_SERVER['REMOTE_ADDR']; }
| { $ip = $_SERVER['REMOTE_ADDR']; }
|
Zeile 3006 | Zeile 3023 |
---|
{ foreach($addresses[0] as $key => $val) {
|
{ foreach($addresses[0] as $key => $val) {
|
if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))
| if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $val))
|
{ $ip = $val; break;
| { $ip = $val; break;
|
Zeile 3135 | 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 3146 | 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 3277 | Zeile 3295 |
---|
$multipage_dropdown = null; if(!empty($navbit['multipage'])) {
|
$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 5730 | 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 6003 | Zeile 6068 |
---|
while(($file = @readdir($dh)) !== false) { if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file))
|
while(($file = @readdir($dh)) !== false) { if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file))
|
{ continue;
| { continue;
|
} } @closedir($dh);
| } } @closedir($dh);
|
Zeile 6208 | 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'))) { $output = @fread($handle, $count); @fclose($handle);
| // 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 { // 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();
|
Zeile 6228 | Zeile 6335 |
---|
{ $unique_state = md5(microtime().$unique_state); $output .= pack('H*', md5($unique_state));
|
{ $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));
|
Zeile 6280 | Zeile 6387 |
---|
{ $val = mt_rand() ^ $obfuscator; return $val;
|
{ $val = mt_rand() ^ $obfuscator; return $val;
|
}
| }
|
}
/**
|
}
/**
|
* 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 6294 | 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 6349 | 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}
|
Zeile 6368 | Zeile 6465 |
---|
// Start from the beginning and work our way in do {
|
// 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
| // 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 6383 | Zeile 6480 |
---|
$string = strrev($string); do {
|
$string = strrev($string); 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 6469 | Zeile 6566 |
---|
}
/**
|
}
/**
|
* Handles 4 byte UTF-8 characters.
| * Validates an UTF-8 string.
|
*
|
*
|
* This can be used to either reject strings which contain 4 byte UTF-8 * characters, or replace them with question marks. This is limited to UTF-8 * collated databases using MySQL. * * Original: http://www.avidheap.org/2013/a-quick-way-to-normalize-a-utf8-string-when-your-mysql-database-is-not-utf8mb4 * * @param string The string to be checked. * @param bool If false don't return the string, only the boolean result. * @return mixed Return a string if the second parameter is true, boolean otherwise.
| * @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 utf8_handle_4byte_string($input, $return=true)
| function validate_utf8_string($input, $allow_mb4=true, $return=true)
|
{
|
{
|
global $config;
if($config['database']['type'] != 'mysql' && $config['database']['type'] != 'mysqli') { if($return == true) { return $input; } return true; }
$contains_4bytes = false; if(!empty($input)) { $utf8_2byte = 0xC0 /*1100 0000*/; $utf8_2byte_bmask = 0xE0 /*1110 0000*/;
$utf8_3byte = 0xE0 /*1110 0000*/; $utf8_3byte_bmask = 0XF0 /*1111 0000*/;
$utf8_4byte = 0xF0 /*1111 0000*/; $utf8_4byte_bmask = 0xF8 /*1111 1000*/;
$sanitized = "";
| // Valid UTF-8 sequence? if(!preg_match('##u', $input)) { $string = '';
|
$len = strlen($input);
|
$len = strlen($input);
|
for($i = 0; $i < $len; ++$i) { $mb_char = $input[$i]; // Potentially a multibyte sequence $byte = ord($mb_char); if(($byte & $utf8_2byte_bmask) == $utf8_2byte)
| for($i = 0; $i < $len; $i++) { $c = ord($input[$i]); if($c > 128)
|
{
|
{
|
$mb_char .= $input[++$i]; } elseif(($byte & $utf8_3byte_bmask) == $utf8_3byte) { $mb_char .= $input[++$i]; $mb_char .= $input[++$i];
| 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; }
|
}
|
}
|
elseif(($byte & $utf8_4byte_bmask) == $utf8_4byte) { $contains_4bytes = true; // Replace with ? to avoid MySQL exception $mb_char = '?'; $i += 3;
| else { $string .= $input[$i];
|
}
|
}
|
$sanitized .= $mb_char;
if($contains_4bytes == true && $return == false) { return false; } }
$input = $sanitized;
| } $input = $string; } if($return) { if($allow_mb4) { return $input; } else { return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input); }
|
}
|
}
|
if($contains_4bytes == false && $return == false)
| else
|
{
|
{
|
return true;
| if($allow_mb4) { return true; } else { return !preg_match("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", $input); }
|
}
|
}
|
return $input;
| |
} ?>
| } ?>
|