Zeile 18 | Zeile 18 |
---|
global $db, $lang, $theme, $templates, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
|
global $db, $lang, $theme, $templates, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
|
| $contents = $plugins->run_hooks("pre_parse_page", $contents);
|
$contents = parse_page($contents); $totaltime = format_time_duration($maintimer->stop()); $contents = $plugins->run_hooks("pre_output_page", $contents);
| $contents = parse_page($contents); $totaltime = format_time_duration($maintimer->stop()); $contents = $plugins->run_hooks("pre_output_page", $contents);
|
Zeile 322 | Zeile 323 |
---|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
/** * Turn a unix timestamp in to a "friendly" date/time format for the user. *
|
* @param string $format A date format according to PHP's date structure.
| * @param string $format A date format (either relative, normal or PHP's date() structure).
|
* @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
| * @param int $stamp The unix timestamp the date should be generated for. * @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically * @param int $ty Whether or not to use today/yesterday formatting.
|
Zeile 380 | Zeile 381 |
---|
}
$todaysdate = $yesterdaysdate = '';
|
}
$todaysdate = $yesterdaysdate = '';
|
if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))
| if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))
|
{ $_stamp = TIME_NOW; if($adodb == true)
| { $_stamp = TIME_NOW; if($adodb == true)
|
Zeile 400 | Zeile 401 |
---|
if($format == 'relative') { // Relative formats both date and time
|
if($format == 'relative') { // Relative formats both date and time
|
| $real_date = $real_time = ''; if($adodb == true) { $real_date = adodb_date($mybb->settings['dateformat'], $stamp + ($offset * 3600)); $real_time = $mybb->settings['datetimesep']; $real_time .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600)); } else { $real_date = gmdate($mybb->settings['dateformat'], $stamp + ($offset * 3600)); $real_time = $mybb->settings['datetimesep']; $real_time .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);
|
if($ty != 2 && abs(TIME_NOW - $stamp) < 3600) { $diff = TIME_NOW - $stamp; $relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);
|
if($diff < 0) { $diff = abs($diff); $relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
| if($diff < 0) { $diff = abs($diff); $relative['suffix'] = ''; $relative['prefix'] = $lang->rel_in; }
|
$relative['minute'] = floor($diff / 60);
if($relative['minute'] <= 1)
| $relative['minute'] = floor($diff / 60);
if($relative['minute'] <= 1)
|
Zeile 426 | Zeile 441 |
---|
$relative['prefix'] = $lang->rel_less_than; }
|
$relative['prefix'] = $lang->rel_less_than; }
|
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);
| $date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix'], $real_date, $real_time);
|
} elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) {
| } elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200) {
|
Zeile 446 | Zeile 461 |
---|
{ $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
{ $relative['hour'] = 1; $relative['plural'] = $lang->rel_hours_single;
|
}
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix']); }
| }
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time); }
|
else { if($ty) { if($todaysdate == $date)
|
else { if($ty) { if($todaysdate == $date)
|
{ $date = $lang->today;
| { $date = $lang->sprintf($lang->today_rel, $real_date);
|
} else if($yesterdaysdate == $date) {
|
} else if($yesterdaysdate == $date) {
|
$date = $lang->yesterday;
| $date = $lang->sprintf($lang->yesterday_rel, $real_date);
|
}
|
}
|
}
| }
|
$date .= $mybb->settings['datetimesep']; if($adodb == true)
|
$date .= $mybb->settings['datetimesep']; if($adodb == true)
|
{
| {
|
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
}
| }
|
else
|
else
|
{
| {
|
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600)); }
|
| } } elseif($format == 'normal') { // Normal format both date and time if($ty != 2) { if($todaysdate == $date) { $date = $lang->today; } else if($yesterdaysdate == $date) { $date = $lang->yesterday; } }
$date .= $mybb->settings['datetimesep']; if($adodb == true) { $date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600)); } else { $date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
|
} } else
| } } else
|
Zeile 497 | Zeile 537 |
---|
else { $date = gmdate($format, $stamp + ($offset * 3600));
|
else { $date = gmdate($format, $stamp + ($offset * 3600));
|
} } }
| } } }
|
if(is_object($plugins)) {
| if(is_object($plugins)) {
|
Zeile 690 | Zeile 730 |
---|
global $forum_cache, $cache;
if($force == true)
|
global $forum_cache, $cache;
if($force == true)
|
{
| {
|
$forum_cache = $cache->read("forums", 1); return $forum_cache; }
| $forum_cache = $cache->read("forums", 1); return $forum_cache; }
|
Zeile 712 | Zeile 752 |
---|
* * @param int $fid The forum ID * @return Array of descendants
|
* * @param int $fid The forum ID * @return Array of descendants
|
*/
| */
|
function get_child_list($fid) { static $forums_by_parent;
| function get_child_list($fid) { static $forums_by_parent;
|
Zeile 735 | Zeile 775 |
---|
}
foreach($forums_by_parent[$fid] as $forum)
|
}
foreach($forums_by_parent[$fid] as $forum)
|
{
| {
|
$forums[] = $forum['fid']; $children = get_child_list($forum['fid']); if(is_array($children))
| $forums[] = $forum['fid']; $children = get_child_list($forum['fid']); if(is_array($children))
|
Zeile 758 | Zeile 798 |
---|
$error = $plugins->run_hooks("error", $error); if(!$error)
|
$error = $plugins->run_hooks("error", $error); if(!$error)
|
{
| {
|
$error = $lang->unknown_error;
|
$error = $lang->unknown_error;
|
}
| }
|
// AJAX error message? if($mybb->get_input('ajax', MyBB::INPUT_INT))
| // AJAX error message? if($mybb->get_input('ajax', MyBB::INPUT_INT))
|
Zeile 769 | Zeile 809 |
---|
@header("Content-type: application/json; charset={$lang->settings['charset']}"); echo json_encode(array("errors" => array($error))); exit;
|
@header("Content-type: application/json; charset={$lang->settings['charset']}"); echo json_encode(array("errors" => array($error))); exit;
|
}
| }
|
if(!$title) { $title = $mybb->settings['bbname']; }
|
if(!$title) { $title = $mybb->settings['bbname']; }
|
|
|
$timenow = my_date('relative', TIME_NOW); reset_breadcrumb(); add_breadcrumb($lang->error);
|
$timenow = my_date('relative', TIME_NOW); reset_breadcrumb(); add_breadcrumb($lang->error);
|
|
|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
exit; }
/**
| exit; }
/**
|
* Produce an error message for displaying inline on a page * * @param array $errors Array of errors to be shown
| * Produce an error message for displaying inline on a page * * @param array $errors Array of errors to be shown
|
Zeile 809 | Zeile 849 |
---|
}
// AJAX error message?
|
}
// AJAX error message?
|
if($mybb->get_input('ajax', MyBB::INPUT_INT)) {
| if($mybb->get_input('ajax', MyBB::INPUT_INT)) {
|
// Send our headers. @header("Content-type: application/json; charset={$lang->settings['charset']}");
if(empty($json_data))
|
// Send our headers. @header("Content-type: application/json; charset={$lang->settings['charset']}");
if(empty($json_data))
|
{
| {
|
echo json_encode(array("errors" => $errors)); } else { echo json_encode(array_merge(array("errors" => $errors), $json_data));
|
echo json_encode(array("errors" => $errors)); } else { echo json_encode(array_merge(array("errors" => $errors), $json_data));
|
} exit;
| } exit;
|
}
$errorlist = '';
foreach($errors as $error) {
|
}
$errorlist = '';
foreach($errors as $error) {
|
$errorlist .= "<li>".$error."</li>\n";
| eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";");
|
}
eval("\$errors = \"".$templates->get("error_inline")."\";");
| }
eval("\$errors = \"".$templates->get("error_inline")."\";");
|
Zeile 882 | Zeile 922 |
---|
switch($mybb->settings['username_method']) { case 0:
|
switch($mybb->settings['username_method']) { case 0:
|
$lang_username = $lang->username; break;
| $lang_username = $lang->username; break;
|
case 1: $lang_username = $lang->username1;
|
case 1: $lang_username = $lang->username1;
|
break;
| break;
|
case 2: $lang_username = $lang->username2;
|
case 2: $lang_username = $lang->username2;
|
break;
| break;
|
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 917 | Zeile 957 |
---|
$plugins->run_hooks("redirect", $redirect_args);
if($mybb->get_input('ajax', MyBB::INPUT_INT))
|
$plugins->run_hooks("redirect", $redirect_args);
if($mybb->get_input('ajax', MyBB::INPUT_INT))
|
{
| {
|
// Send our headers. //@header("Content-type: text/html; charset={$lang->settings['charset']}"); $data = "<script type=\"text/javascript\">\n";
| // Send our headers. //@header("Content-type: text/html; charset={$lang->settings['charset']}"); $data = "<script type=\"text/javascript\">\n";
|
Zeile 940 | Zeile 980 |
---|
if(!$message) { $message = $lang->redirect;
|
if(!$message) { $message = $lang->redirect;
|
}
| }
|
$time = TIME_NOW; $timenow = my_date('relative', $time);
|
$time = TIME_NOW; $timenow = my_date('relative', $time);
|
|
|
if(!$title) { $title = $mybb->settings['bbname'];
| if(!$title) { $title = $mybb->settings['bbname'];
|
Zeile 952 | Zeile 992 |
---|
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest, or they are forced. if($force_redirect == true || ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] == 1 || !$mybb->user['uid'])))
|
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest, or they are forced. if($force_redirect == true || ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] == 1 || !$mybb->user['uid'])))
|
{
| {
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 966 | Zeile 1006 |
---|
run_shutdown();
|
run_shutdown();
|
if(!my_validate_url($url, true))
| if(!my_validate_url($url, true, true))
|
{ header("Location: {$mybb->settings['bburl']}/{$url}"); }
| { header("Location: {$mybb->settings['bburl']}/{$url}"); }
|
Zeile 977 | Zeile 1017 |
---|
}
exit;
|
}
exit;
|
}
/**
| }
/**
|
* Generate a listing of page - pagination * * @param int $count The number of items
| * Generate a listing of page - pagination * * @param int $count The number of items
|
Zeile 992 | Zeile 1032 |
---|
function multipage($count, $perpage, $page, $url, $breadcrumb=false) { global $theme, $templates, $lang, $mybb;
|
function multipage($count, $perpage, $page, $url, $breadcrumb=false) { global $theme, $templates, $lang, $mybb;
|
|
|
if($count <= $perpage) { return ''; }
|
if($count <= $perpage) { return ''; }
|
| $page = (int)$page;
|
$url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
| $url = str_replace("&", "&", $url); $url = htmlspecialchars_uni($url);
|
Zeile 1102 | Zeile 1144 |
---|
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";"); }
|
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";"); }
|
$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
| $multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);
|
if($breadcrumb == true) {
| if($breadcrumb == true) {
|
Zeile 1162 | Zeile 1204 |
---|
/** * Fetch the permissions for a specific user *
|
/** * Fetch the permissions for a specific user *
|
* @param int $uid The user ID
| * @param int $uid The user ID, if no user ID is provided then current user's ID will be considered.
|
* @return array Array of user permissions for the specified user */
|
* @return array Array of user permissions for the specified user */
|
function user_permissions($uid=0)
| function user_permissions($uid=null)
|
{ global $mybb, $cache, $groupscache, $user_cache;
// If no user id is specified, assume it is the current user
|
{ global $mybb, $cache, $groupscache, $user_cache;
// If no user id is specified, assume it is the current user
|
| if($uid === null) { $uid = $mybb->user['uid']; }
// Its a guest. Return the group permissions directly from cache
|
if($uid == 0) {
|
if($uid == 0) {
|
$uid = $mybb->user['uid'];
| return $groupscache[1];
|
}
// User id does not match current user, fetch permissions if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
}
// User id does not match current user, fetch permissions if($uid != $mybb->user['uid']) { // We've already cached permissions for this user, return them.
|
if($user_cache[$uid]['permissions'])
| if(!empty($user_cache[$uid]['permissions']))
|
{ return $user_cache[$uid]['permissions']; }
// This user was not already cached, fetch their user information.
|
{ return $user_cache[$uid]['permissions']; }
// This user was not already cached, fetch their user information.
|
if(!$user_cache[$uid])
| if(empty($user_cache[$uid]))
|
{ $user_cache[$uid] = get_user($uid); }
| { $user_cache[$uid] = get_user($uid); }
|
Zeile 1774 | Zeile 1822 |
---|
$iconlist = ''; $no_icons_checked = " checked=\"checked\""; // read post icons from cache, and sort them accordingly
|
$iconlist = ''; $no_icons_checked = " checked=\"checked\""; // read post icons from cache, and sort them accordingly
|
$posticons_cache = $cache->read("posticons");
| $posticons_cache = (array)$cache->read("posticons");
|
$posticons = array(); foreach($posticons_cache as $posticon) {
| $posticons = array(); foreach($posticons_cache as $posticon) {
|
Zeile 1820 | Zeile 1868 |
---|
* @param string $value The cookie value. * @param int|string $expires The timestamp of the expiry date. * @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)
|
* @param string $value The cookie value. * @param int|string $expires The timestamp of the expiry date. * @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)
|
| * @param string $samesite The samesite attribute to prevent CSRF.
|
*/
|
*/
|
function my_setcookie($name, $value="", $expires="", $httponly=false)
| function my_setcookie($name, $value="", $expires="", $httponly=false, $samesite="")
|
{ global $mybb;
| { global $mybb;
|
Zeile 1868 | Zeile 1917 |
---|
if($httponly == true) { $cookie .= "; HttpOnly";
|
if($httponly == true) { $cookie .= "; HttpOnly";
|
| }
if($samesite != "" && $mybb->settings['cookiesamesiteflag']) { $samesite = strtolower($samesite);
if($samesite == "lax" || $samesite == "strict") { $cookie .= "; SameSite=".$samesite; }
|
}
if($mybb->settings['cookiesecureflag'])
| }
if($mybb->settings['cookiesecureflag'])
|
Zeile 1983 | Zeile 2042 |
---|
return false; }
|
return false; }
|
$stack = array(); $expected = array();
| $stack = $list = $expected = array();
|
/* * states:
| /* * states:
|
Zeile 3011 | Zeile 3069 |
---|
*/ function format_name($username, $usergroup, $displaygroup=0) {
|
*/ function format_name($username, $usergroup, $displaygroup=0) {
|
global $groupscache, $cache;
| global $groupscache, $cache, $plugins;
|
|
|
if(!is_array($groupscache))
| static $formattednames = array();
if(!isset($formattednames[$username]))
|
{
|
{
|
$groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups"); }
if($displaygroup != 0) { $usergroup = $displaygroup; }
$format = "{username}";
if(isset($groupscache[$usergroup])) { $ugroup = $groupscache[$usergroup];
if(strpos($ugroup['namestyle'], "{username}") !== false) { $format = $ugroup['namestyle']; } }
$format = stripslashes($format);
$parameters = compact('username', 'usergroup', 'displaygroup', 'format');
$parameters = $plugins->run_hooks('format_name', $parameters);
|
|
|
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
| $format = $parameters['format'];
|
|
|
if($userin == 0) { $format = "{username}";
| $formattednames[$username] = str_replace("{username}", $username, $format);
|
}
|
}
|
$format = stripslashes($format);
return str_replace("{username}", $username, $format);
| return $formattednames[$username];
|
}
/**
| }
/**
|
Zeile 3099 | Zeile 3173 |
---|
if($dimensions) {
|
if($dimensions) {
|
$dimensions = explode("|", $dimensions);
| $dimensions = preg_split('/[|x]/', $dimensions);
|
if($dimensions[0] && $dimensions[1]) {
|
if($dimensions[0] && $dimensions[1]) {
|
list($max_width, $max_height) = explode('x', $max_dimensions);
| list($max_width, $max_height) = preg_split('/[|x]/', $max_dimensions);
|
if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height)) {
| if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height)) {
|
Zeile 3200 | Zeile 3274 |
---|
"editor_invalidyoutube" => "Invalid YouTube video", "editor_dailymotion" => "Dailymotion", "editor_metacafe" => "MetaCafe",
|
"editor_invalidyoutube" => "Invalid YouTube video", "editor_dailymotion" => "Dailymotion", "editor_metacafe" => "MetaCafe",
|
"editor_veoh" => "Veoh",
| "editor_mixer" => "Mixer",
|
"editor_vimeo" => "Vimeo", "editor_youtube" => "Youtube", "editor_facebook" => "Facebook",
| "editor_vimeo" => "Vimeo", "editor_youtube" => "Youtube", "editor_facebook" => "Facebook",
|
Zeile 3283 | Zeile 3357 |
---|
$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['find'])); $image = htmlspecialchars_uni($mybb->get_asset_url($smilie['image'])); $image = str_replace(array('\\', '"'), array('\\\\', '\"'), $image);
|
$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['find'])); $image = htmlspecialchars_uni($mybb->get_asset_url($smilie['image'])); $image = str_replace(array('\\', '"'), array('\\\\', '\"'), $image);
|
|
|
if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable']) { $hiddensmilies .= '"'.$find.'": "'.$image.'",'; } elseif($i < $mybb->settings['smilieinsertertot'])
|
if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable']) { $hiddensmilies .= '"'.$find.'": "'.$image.'",'; } elseif($i < $mybb->settings['smilieinsertertot'])
|
{
| {
|
$dropdownsmilies .= '"'.$find.'": "'.$image.'",'; ++$i; } else
|
$dropdownsmilies .= '"'.$find.'": "'.$image.'",'; ++$i; } else
|
{
| {
|
$moresmilies .= '"'.$find.'": "'.$image.'",'; }
| $moresmilies .= '"'.$find.'": "'.$image.'",'; }
|
Zeile 3305 | Zeile 3379 |
---|
} } }
|
} } }
|
}
| }
|
$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";
if($mybb->settings['allowbasicmycode'] == 1)
|
$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";
if($mybb->settings['allowbasicmycode'] == 1)
|
{
| {
|
$basic1 = "bold,italic,underline,strike|"; $basic2 = "horizontalrule,"; }
if($mybb->settings['allowalignmycode'] == 1)
|
$basic1 = "bold,italic,underline,strike|"; $basic2 = "horizontalrule,"; }
if($mybb->settings['allowalignmycode'] == 1)
|
{
| {
|
$align = "left,center,right,justify|"; }
| $align = "left,center,right,justify|"; }
|
Zeile 3326 | Zeile 3400 |
---|
}
if($mybb->settings['allowsizemycode'] == 1)
|
}
if($mybb->settings['allowsizemycode'] == 1)
|
{
| {
|
$size = "size,"; }
| $size = "size,"; }
|
Zeile 3343 | Zeile 3417 |
---|
if($mybb->settings['allowemailmycode'] == 1) { $email = "email,";
|
if($mybb->settings['allowemailmycode'] == 1) { $email = "email,";
|
}
| }
|
if($mybb->settings['allowlinkmycode'] == 1) { $link = "link,unlink";
|
if($mybb->settings['allowlinkmycode'] == 1) { $link = "link,unlink";
|
}
| }
|
if($mybb->settings['allowlistmycode'] == 1) { $list = "bulletlist,orderedlist|";
|
if($mybb->settings['allowlistmycode'] == 1) { $list = "bulletlist,orderedlist|";
|
}
| }
|
if($mybb->settings['allowcodemycode'] == 1) { $code = "code,php,";
|
if($mybb->settings['allowcodemycode'] == 1) { $code = "code,php,";
|
}
| }
|
if($mybb->user['sourceeditor'] == 1) { $sourcemode = "MyBBEditor.sourceMode(true);"; }
|
if($mybb->user['sourceeditor'] == 1) { $sourcemode = "MyBBEditor.sourceMode(true);"; }
|
|
|
eval("\$codeinsert = \"".$templates->get("codebuttons")."\";"); } }
|
eval("\$codeinsert = \"".$templates->get("codebuttons")."\";"); } }
|
return $codeinsert;
| return $codeinsert; }
/** * @param int $tid * @param array $postoptions The options carried with form submit * * @return string Predefined / updated subscription method of the thread for the user */ function get_subscription_method($tid = 0, $postoptions = array()) { global $mybb;
$subscription_methods = array('', 'none', 'email', 'pm'); // Define methods $subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default
// If no user default method available then reset method if(!$subscription_method) { $subscription_method = 0; }
// Return user default if no thread id available, in case if(!(int)$tid || (int)$tid <= 0) { return $subscription_methods[$subscription_method]; }
// If method not predefined set using data from database if(isset($postoptions['subscriptionmethod'])) { $method = trim($postoptions['subscriptionmethod']); return (in_array($method, $subscription_methods)) ? $method : $subscription_methods[0]; } else { global $db;
$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1)); $subscription = $db->fetch_array($query);
if($subscription['tid']) { $subscription_method = (int)$subscription['notification'] + 1; } } return $subscription_methods[$subscription_method];
|
}
/**
| }
/**
|
Zeile 3781 | Zeile 3902 |
---|
{ $pid = (int)$data['pid']; unset($data['pid']);
|
{ $pid = (int)$data['pid']; unset($data['pid']);
|
| }
$tids = array(); if(isset($data['tids'])) { $tids = (array)$data['tids']; unset($data['tids']);
|
}
// Any remaining extra data - we my_serialize and insert in to its own column if(is_array($data)) { $data = my_serialize($data);
|
}
// Any remaining extra data - we my_serialize and insert in to its own column if(is_array($data)) { $data = my_serialize($data);
|
}
| }
|
$sql_array = array( "uid" => (int)$mybb->user['uid'], "dateline" => TIME_NOW,
| $sql_array = array( "uid" => (int)$mybb->user['uid'], "dateline" => TIME_NOW,
|
Zeile 3799 | Zeile 3927 |
---|
"data" => $db->escape_string($data), "ipaddress" => $db->escape_binary($session->packedip) );
|
"data" => $db->escape_string($data), "ipaddress" => $db->escape_binary($session->packedip) );
|
$db->insert_query("moderatorlog", $sql_array);
| if($tids) { $multiple_sql_array = array();
foreach($tids as $tid) { $sql_array['tid'] = (int)$tid; $multiple_sql_array[] = $sql_array; }
$db->insert_query_multiple("moderatorlog", $multiple_sql_array); } else { $db->insert_query("moderatorlog", $sql_array); }
|
}
/**
| }
/**
|
Zeile 3940 | Zeile 4084 |
---|
global $lang;
if(!is_numeric($size))
|
global $lang;
if(!is_numeric($size))
|
{
| {
|
return $lang->na; }
| return $lang->na; }
|
Zeile 3989 | Zeile 4133 |
---|
$size = "0 ".$lang->size_bytes; } else
|
$size = "0 ".$lang->size_bytes; } else
|
{
| {
|
$size = my_number_format($size)." ".$lang->size_bytes; }
| $size = my_number_format($size)." ".$lang->size_bytes; }
|
Zeile 4009 | Zeile 4153 |
---|
if(!is_numeric($time)) { return $lang->na;
|
if(!is_numeric($time)) { return $lang->na;
|
}
| }
|
if(round(1000000 * $time, 2) < 1000)
|
if(round(1000000 * $time, 2) < 1000)
|
{
| {
|
$time = number_format(round(1000000 * $time, 2))." μs"; } elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000) { $time = number_format(round((1000 * $time), 2))." ms";
|
$time = number_format(round(1000000 * $time, 2))." μs"; } elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000) { $time = number_format(round((1000 * $time), 2))." ms";
|
}
| }
|
else { $time = round($time, 3)." seconds";
| else { $time = round($time, 3)." seconds";
|
Zeile 4240 | Zeile 4384 |
---|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
| $navsize = count($navbits); $navbit = $navbits[$navsize-1];
|
}
|
}
|
$activesep = ''; $navsize = count($navbits); $navbit = $navbits[$navsize-1];
| |
if($nav) {
| if($nav) {
|
Zeile 4410 | Zeile 4552 |
---|
$phptime = $maintimer->totaltime - $db->query_time; $query_time = $db->query_time; $globaltime = format_time_duration($globaltime);
|
$phptime = $maintimer->totaltime - $db->query_time; $query_time = $db->query_time; $globaltime = format_time_duration($globaltime);
|
|
|
$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 4659 | Zeile 4801 |
---|
$lang_minutes = " ".$lang->minutes; $lang_second = " ".$lang->second; $lang_seconds = " ".$lang->seconds;
|
$lang_minutes = " ".$lang->minutes; $lang_second = " ".$lang->second; $lang_seconds = " ".$lang->seconds;
|
}
| }
|
$years = floor($stamp/$ysecs); $stamp %= $ysecs;
| $years = floor($stamp/$ysecs); $stamp %= $ysecs;
|
Zeile 4674 | Zeile 4816 |
---|
$minutes = floor($stamp/$msecs); $stamp %= $msecs; $seconds = $stamp;
|
$minutes = floor($stamp/$msecs); $stamp %= $msecs; $seconds = $stamp;
|
if($years == 1) { $nicetime['years'] = "1".$lang_year; } else if($years > 1) { $nicetime['years'] = $years.$lang_years; }
if($months == 1) { $nicetime['months'] = "1".$lang_month;
| // Prevent gross over accuracy ($options parameter will override these) if($years > 0) { $options = array_merge(array( 'days' => false, 'hours' => false, 'minutes' => false, 'seconds' => false ), $options); } elseif($months > 0) { $options = array_merge(array( 'hours' => false, 'minutes' => false, 'seconds' => false ), $options); } elseif($weeks > 0) { $options = array_merge(array( 'minutes' => false, 'seconds' => false ), $options); } elseif($days > 0) { $options = array_merge(array( 'seconds' => false ), $options); }
if(!isset($options['years']) || $options['years'] !== false) { if($years == 1) { $nicetime['years'] = "1".$lang_year; } else if($years > 1) { $nicetime['years'] = $years.$lang_years; }
|
}
|
}
|
else if($months > 1)
| if(!isset($options['months']) || $options['months'] !== false)
|
{
|
{
|
$nicetime['months'] = $months.$lang_months;
| if($months == 1) { $nicetime['months'] = "1".$lang_month; } else if($months > 1) { $nicetime['months'] = $months.$lang_months; }
|
}
|
}
|
if($weeks == 1)
| if(!isset($options['weeks']) || $options['weeks'] !== false)
|
{
|
{
|
$nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks;
| if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; }
|
}
|
}
|
if($days == 1)
| if(!isset($options['days']) || $options['days'] !== false)
|
{
|
{
|
$nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days;
| if($days == 1) { $nicetime['days'] = "1".$lang_day; } else if($days > 1) { $nicetime['days'] = $days.$lang_days; }
|
}
if(!isset($options['hours']) || $options['hours'] !== false)
| }
if(!isset($options['hours']) || $options['hours'] !== false)
|
Zeile 4924 | Zeile 5110 |
---|
if(!is_array($ignore)) { $ignore = array($ignore);
|
if(!is_array($ignore)) { $ignore = array($ignore);
|
}
| }
|
$form_html = ''; if(!empty($mybb->input))
| $form_html = ''; if(!empty($mybb->input))
|
Zeile 4935 | Zeile 5121 |
---|
{ continue; }
|
{ continue; }
|
|
|
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";
|
$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";
|
} }
| } }
|
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else { if(isset($_SERVER['QUERY_STRING']))
|
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method); } else { if(isset($_SERVER['QUERY_STRING']))
|
{
| {
|
$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
}
| }
|
else if(isset($_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"))
|
else if(isset($_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');
foreach($post_array as $var)
| $post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');
foreach($post_array as $var)
|
Zeile 5012 | Zeile 5198 |
---|
}
if(!is_array($tcache))
|
}
if(!is_array($tcache))
|
{ $query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
| { $query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
|
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
| while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
|
Zeile 5045 | Zeile 5231 |
---|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
|
if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
|
} } } }
| } } } }
|
if($tid == 1 && ($num_themes > 1 || $count_override == true)) { if($footer == true)
| if($tid == 1 && ($num_themes > 1 || $count_override == true)) { if($footer == true)
|
Zeile 5299 | Zeile 5485 |
---|
31, 30, 31,
|
31, 30, 31,
|
30,
| 30,
|
31 ); }
| 31 ); }
|
Zeile 5315 | Zeile 5501 |
---|
* @param int $by The year of the birthday * @param int $wd The weekday of the birthday * @return string The formatted birthday
|
* @param int $by The year of the birthday * @param int $wd The weekday of the birthday * @return string The formatted birthday
|
*/
| */
|
function format_bdays($display, $bm, $bd, $by, $wd) { global $lang;
| function format_bdays($display, $bm, $bd, $by, $wd) { global $lang;
|
Zeile 5344 | Zeile 5530 |
---|
$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 5391 | Zeile 5576 |
---|
$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 5422 | Zeile 5607 |
---|
$age = $year-$bday[2];
if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
|
$age = $year-$bday[2];
if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
|
{
| {
|
--$age; } return $age; }
|
--$age; } return $age; }
|
|
|
/** * Updates the first posts in a thread. * * @param int $tid The thread id for which to update the first post id. */ function update_first_post($tid)
|
/** * Updates the first posts in a thread. * * @param int $tid The thread id for which to update the first post id. */ function update_first_post($tid)
|
{ global $db;
| { global $db;
|
$query = $db->query(" SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p
| $query = $db->query(" SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p
|
Zeile 5450 | Zeile 5635 |
---|
if(empty($firstpost['username'])) { $firstpost['username'] = $firstpost['postusername'];
|
if(empty($firstpost['username'])) { $firstpost['username'] = $firstpost['postusername'];
|
}
| }
|
$firstpost['username'] = $db->escape_string($firstpost['username']);
|
$firstpost['username'] = $db->escape_string($firstpost['username']);
|
|
|
$update_array = array( 'firstpost' => (int)$firstpost['pid'], 'username' => $firstpost['username'],
| $update_array = array( 'firstpost' => (int)$firstpost['pid'], 'username' => $firstpost['username'],
|
Zeile 5464 | Zeile 5649 |
---|
/** * Updates the last posts in a thread.
|
/** * Updates the last posts in a thread.
|
*
| *
|
* @param int $tid The thread id for which to update the last post id. */ function update_last_post($tid)
| * @param int $tid The thread id for which to update the last post id. */ function update_last_post($tid)
|
Zeile 5478 | Zeile 5663 |
---|
WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline DESC LIMIT 1"
|
WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline DESC LIMIT 1"
|
);
| );
|
$lastpost = $db->fetch_array($query);
if(empty($lastpost['username']))
| $lastpost = $db->fetch_array($query);
if(empty($lastpost['username']))
|
Zeile 5533 | Zeile 5718 |
---|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
}
| }
|
$string = trim($string);
if(function_exists("mb_strlen"))
| $string = trim($string);
if(function_exists("mb_strlen"))
|
Zeile 5669 | Zeile 5854 |
---|
function unhtmlentities($string) { // Replace numeric entities
|
function unhtmlentities($string) { // Replace numeric entities
|
$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);
| $string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string); $string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);
|
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
| // Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES);
|
Zeile 5710 | Zeile 5895 |
---|
{ return false; }
|
{ return false; }
|
| }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches. * @return string|bool The characterized ascii. False on failure */ function unichr_callback1($matches) { return unichr(hexdec($matches[1])); }
/** * Returns any ascii to it's character (utf-8 safe). * * @param array $matches Matches. * @return string|bool The characterized ascii. False on failure */ function unichr_callback2($matches) { return unichr($matches[1]);
|
}
/**
| }
/**
|
Zeile 5724 | Zeile 5931 |
---|
$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']); $event_poster = build_profile_link($event['username'], $event['author']); return $event_poster;
|
$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']); $event_poster = build_profile_link($event['username'], $event['author']); return $event_poster;
|
}
| }
|
/** * Get the event date.
| /** * Get the event date.
|
Zeile 5735 | Zeile 5942 |
---|
function get_event_date($event) { global $mybb;
|
function get_event_date($event) { global $mybb;
|
|
|
$event_date = explode("-", $event['date']); $event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
return $event_date;
|
$event_date = explode("-", $event['date']); $event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
return $event_date;
|
}
| }
|
/** * Get the profile link.
| /** * Get the profile link.
|
Zeile 5757 | Zeile 5964 |
---|
/** * Get the announcement link.
|
/** * Get the announcement link.
|
*
| *
|
* @param int $aid The announement id of the announcement. * @return string The url to the announcement. */
| * @param int $aid The announement id of the announcement. * @return string The url to the announcement. */
|
Zeile 5783 | Zeile 5990 |
---|
if(!$username && $uid == 0) { // Return Guest phrase for no UID, no guest nickname
|
if(!$username && $uid == 0) { // Return Guest phrase for no UID, no guest nickname
|
return $lang->guest; }
| return htmlspecialchars_uni($lang->guest); }
|
elseif($uid == 0) { // Return the guest's nickname if user is a guest but has a nickname
| elseif($uid == 0) { // Return the guest's nickname if user is a guest but has a nickname
|
Zeile 5825 | Zeile 6032 |
---|
else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
} }
| } }
|
Zeile 5852 | Zeile 6059 |
---|
} $link = str_replace("{tid}", $tid, $link); $link = str_replace("{page}", $page, $link);
|
} $link = str_replace("{tid}", $tid, $link); $link = str_replace("{page}", $page, $link);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
} else { if($action)
|
} else { if($action)
|
{
| {
|
$link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link); }
| $link = THREAD_URL_ACTION; $link = str_replace("{action}", $action, $link); }
|
Zeile 5866 | Zeile 6073 |
---|
$link = THREAD_URL; } $link = str_replace("{tid}", $tid, $link);
|
$link = THREAD_URL; } $link = str_replace("{tid}", $tid, $link);
|
return htmlspecialchars_uni($link); } }
| return htmlspecialchars_uni($link); } }
|
/** * Build the post link. *
| /** * Build the post link. *
|
Zeile 6202 | Zeile 6409 |
---|
* * @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True * @return bool|int Number of logins when success, false if failed.
|
* * @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True * @return bool|int Number of logins when success, false if failed.
|
*/ function login_attempt_check($fatal = true)
| */ function login_attempt_check($uid = 0, $fatal = true)
|
{
|
{
|
global $mybb, $lang, $session, $db;
| global $mybb, $lang, $db;
$attempts = array(); $uid = (int)$uid; $now = TIME_NOW;
// Get this user's login attempts and eventual lockout, if a uid is provided if($uid > 0) { $query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1); $attempts = $db->fetch_array($query);
|
|
|
if($mybb->settings['failedlogincount'] == 0) { return 1; } // Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.
// Use cookie if possible, otherwise use session // Find better solution to prevent clearing cookies $loginattempts = 0; $failedlogin = 0;
if(!empty($mybb->cookies['loginattempts'])) { $loginattempts = $mybb->cookies['loginattempts']; }
if(!empty($mybb->cookies['failedlogin'])) { $failedlogin = $mybb->cookies['failedlogin']; }
// Work out if the user has had more than the allowed number of login attempts if($loginattempts > $mybb->settings['failedlogincount']) { // If so, then we need to work out if they can try to login again // Some maths to work out how long they have left and display it to them $now = TIME_NOW;
if(empty($mybb->cookies['failedlogin'])) { $failedtime = $now; } else { $failedtime = $mybb->cookies['failedlogin']; }
$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now; $hoursleft = floor($secondsleft / 3600); $minsleft = floor(($secondsleft / 60) % 60); $secsleft = floor($secondsleft % 60);
// This value will be empty the first time the user doesn't login in, set it if(empty($failedlogin)) { my_setcookie('failedlogin', $now); if($fatal) { error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false;
| if($attempts['loginattempts'] <= 0) { return 0;
|
}
|
}
|
| } // This user has a cookie lockout, show waiting time elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now) { if($fatal) { $secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now); $hoursleft = floor($secsleft / 3600); $minsleft = floor(($secsleft / 60) % 60); $secsleft = floor($secsleft % 60);
|
|
|
// Work out if the user has waited long enough before letting them login again if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60)) { my_setcookie('loginattempts', 1); my_unsetcookie('failedlogin'); if($mybb->user['uid'] != 0) { $update_array = array( 'loginattempts' => 1 ); $db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'"); } return 1; } // Not waited long enough else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
| error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false; }
if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount']) { // Set the expiry dateline if not set yet if($attempts['loginlockoutexpiry'] == 0) { $attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);
// Add a cookie lockout. This is used to prevent access to the login page immediately. // A deep lockout is issued if he tries to login into a locked out account my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);
$db->update_query("users", array( "loginlockoutexpiry" => $attempts['loginlockoutexpiry'] ), "uid='{$uid}'"); }
if(empty($mybb->cookies['lockoutexpiry']))
|
{
|
{
|
| $failedtime = $attempts['loginlockoutexpiry']; } else { $failedtime = $mybb->cookies['lockoutexpiry']; }
// Are we still locked out? if($attempts['loginlockoutexpiry'] > $now) {
|
if($fatal) {
|
if($fatal) {
|
| $secsleft = (int)($attempts['loginlockoutexpiry'] - $now); $hoursleft = floor($secsleft / 3600); $minsleft = floor(($secsleft / 60) % 60); $secsleft = floor($secsleft % 60);
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
|
|
|
return false;
|
return false;
|
| } // Unlock if enough time has passed else {
if($uid > 0) { $db->update_query("users", array( "loginattempts" => 0, "loginlockoutexpiry" => 0 ), "uid='{$uid}'"); }
// Wipe the cookie, no matter if a guest or a member my_unsetcookie('lockoutexpiry');
return 0;
|
} }
// User can attempt another login
|
} }
// User can attempt another login
|
return $loginattempts;
| return $attempts['loginattempts'];
|
}
/**
| }
/**
|
Zeile 6299 | Zeile 6515 |
---|
*/ function validate_email_format($email) {
|
*/ function validate_email_format($email) {
|
if(strpos($email, ' ') !== false) { return false; } // Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);
| return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
|
}
/**
| }
/**
|
Zeile 6324 | Zeile 6535 |
---|
$uid_string = " AND uid != '".(int)$uid."'"; } $query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
|
$uid_string = " AND uid != '".(int)$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;
|
Zeile 6341 | Zeile 6552 |
---|
{ global $db, $mybb;
|
{ global $db, $mybb;
|
if(!file_exists(MYBB_ROOT."inc/settings.php")) { $mode = "x"; } else { $mode = "w"; }
$options = array( "order_by" => "title", "order_dir" => "ASC" ); $query = $db->simple_select("settings", "value, name", "", $options);
| $query = $db->simple_select("settings", "value, name", "", array( 'order_by' => 'title', 'order_dir' => 'ASC', ));
|
|
|
$settings = null;
| $settings = '';
|
while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
| while($setting = $db->fetch_array($query)) { $mybb->settings[$setting['name']] = $setting['value'];
|
Zeile 6365 | Zeile 6566 |
---|
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\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); @fclose($file);
| file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);
|
$GLOBALS['settings'] = &$mybb->settings; }
| $GLOBALS['settings'] = &$mybb->settings; }
|
Zeile 6462 | Zeile 6662 |
---|
// 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
|
// 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);'));
| usort($words, 'build_highlight_array_sort');
|
// Loop through our words to build the PREG compatible strings foreach($words as $word)
| // Loop through our words to build the PREG compatible strings foreach($words as $word)
|
Zeile 6484 | Zeile 6684 |
---|
}
return $highlight_cache;
|
}
return $highlight_cache;
|
| }
/** * Sort the word array by length. Largest terms go first and work their way down to the smallest term. * * @param string $a First word. * @param string $b Second word. * @return integer Result of comparison function. */ function build_highlight_array_sort($a, $b) { return strlen($b) - strlen($a);
|
}
/**
| }
/**
|
Zeile 6502 | Zeile 6714 |
---|
return false; } elseif($src <= 0x007f)
|
return false; } elseif($src <= 0x007f)
|
{
| {
|
$dest .= chr($src);
|
$dest .= chr($src);
|
}
| }
|
elseif($src <= 0x07ff)
|
elseif($src <= 0x07ff)
|
{
| {
|
$dest .= chr(0xc0 | ($src >> 6));
|
$dest .= chr(0xc0 | ($src >> 6));
|
$dest .= chr(0x80 | ($src & 0x003f));
| $dest .= chr(0x80 | ($src & 0x003f));
|
} elseif($src <= 0xffff) {
| } elseif($src <= 0xffff) {
|
Zeile 6517 | Zeile 6729 |
---|
$dest .= chr(0x80 | ($src & 0x003f)); } elseif($src <= 0x10ffff)
|
$dest .= chr(0x80 | ($src & 0x003f)); } elseif($src <= 0x10ffff)
|
{
| {
|
$dest .= chr(0xf0 | ($src >> 18)); $dest .= chr(0x80 | (($src >> 12) & 0x3f)); $dest .= chr(0x80 | (($src >> 6) & 0x3f));
| $dest .= chr(0xf0 | ($src >> 18)); $dest .= chr(0x80 | (($src >> 12) & 0x3f)); $dest .= chr(0x80 | (($src >> 6) & 0x3f));
|
Zeile 6548 | Zeile 6760 |
---|
// Make regular expression * match $banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#')); if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
|
// Make regular expression * match $banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#')); if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
|
{
| {
|
// Updating last use if($update_lastuse == true) {
| // Updating last use if($update_lastuse == true) {
|
Zeile 6579 | Zeile 6791 |
---|
// Failed to read cache, see if we can rebuild it $cache->update_bannedemails(); $banned_cache = $cache->read("bannedemails");
|
// Failed to read cache, see if we can rebuild it $cache->update_bannedemails(); $banned_cache = $cache->read("bannedemails");
|
}
| }
|
if(is_array($banned_cache) && !empty($banned_cache)) {
| if(is_array($banned_cache) && !empty($banned_cache)) {
|
Zeile 6610 | Zeile 6822 |
---|
* @param string $ip_address The IP address. * @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found. * @return boolean True if banned, false if not banned.
|
* @param string $ip_address The IP address. * @param boolean $update_lastuse 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_ip($ip_address, $update_lastuse=false) { global $db, $cache;
| function is_banned_ip($ip_address, $update_lastuse=false) { global $db, $cache;
|
Zeile 6656 | Zeile 6868 |
---|
// Still here - good ip return false;
|
// Still here - good ip return false;
|
}
| }
|
/** * Returns an array of supported timezones *
| /** * Returns an array of supported timezones *
|
Zeile 6733 | Zeile 6945 |
---|
if($selected == $timezone) { $selected_add = " selected=\"selected\"";
|
if($selected == $timezone) { $selected_add = " selected=\"selected\"";
|
}
| }
|
if($short == true) { $label = '';
| if($short == true) { $label = '';
|
Zeile 6741 | Zeile 6953 |
---|
{ $label = $timezone; if($timezone > 0)
|
{ $label = $timezone; if($timezone > 0)
|
{
| {
|
$label = "+{$label}"; } if(strpos($timezone, ".") !== false)
| $label = "+{$label}"; } if(strpos($timezone, ".") !== false)
|
Zeile 6749 | Zeile 6961 |
---|
$label = str_replace(".", ":", $label); $label = str_replace(":5", ":30", $label); $label = str_replace(":75", ":45", $label);
|
$label = str_replace(".", ":", $label); $label = str_replace(":5", ":30", $label); $label = str_replace(":75", ":45", $label);
|
}
| }
|
else { $label .= ":00";
| else { $label .= ":00";
|
Zeile 6777 | Zeile 6989 |
---|
function fetch_remote_file($url, $post_data=array(), $max_redirects=20) { global $mybb, $config;
|
function fetch_remote_file($url, $post_data=array(), $max_redirects=20) { global $mybb, $config;
|
| if(!my_validate_url($url, true)) { return false; }
|
$url_components = @parse_url($url);
|
$url_components = @parse_url($url);
|
| if(!isset($url_components['scheme'])) { $url_components['scheme'] = 'https'; } if(!isset($url_components['port'])) { $url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80; }
|
if( !$url_components || empty($url_components['host']) || (!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
|
if( !$url_components || empty($url_components['host']) || (!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
|
(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||
| (!in_array($url_components['port'], array(80, 8080, 443))) ||
|
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts'])) ) { return false; }
|
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts'])) ) { return false; }
|
| $addresses = get_ip_by_hostname($url_components['host']); $destination_address = $addresses[0];
|
if(!empty($config['disallowed_remote_addresses']))
|
if(!empty($config['disallowed_remote_addresses']))
|
{ $addresses = gethostbynamel($url_components['host']); if($addresses) { foreach($config['disallowed_remote_addresses'] as $disallowed_address) { $ip_range = fetch_ip_range($disallowed_address); foreach($addresses as $address) { $packed_address = my_inet_pton($address);
if(is_array($ip_range)) { if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0) { return false; } } elseif($address == $disallowed_address) { return false; }
| { foreach($config['disallowed_remote_addresses'] as $disallowed_address) { $ip_range = fetch_ip_range($disallowed_address);
$packed_address = my_inet_pton($destination_address);
if(is_array($ip_range)) { if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0) { return false;
|
}
|
}
|
| } elseif($destination_address == $disallowed_address) { return false;
|
} } }
$post_body = ''; if(!empty($post_data))
|
} } }
$post_body = ''; if(!empty($post_data))
|
{
| {
|
foreach($post_data as $key => $val)
|
foreach($post_data as $key => $val)
|
{
| {
|
$post_body .= '&'.urlencode($key).'='.urlencode($val);
|
$post_body .= '&'.urlencode($key).'='.urlencode($val);
|
}
| }
|
$post_body = ltrim($post_body, '&'); }
|
$post_body = ltrim($post_body, '&'); }
|
|
|
if(function_exists("curl_init")) {
|
if(function_exists("curl_init")) {
|
$can_followlocation = @ini_get('open_basedir') === '' && !$mybb->safemode;
$request_header = $max_redirects != 0 && !$can_followlocation;
| $fetch_header = $max_redirects > 0;
|
$ch = curl_init();
|
$ch = curl_init();
|
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $request_header); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if($max_redirects != 0 && $can_followlocation) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects); }
| $curlopt = array( CURLOPT_URL => $url, CURLOPT_HEADER => $fetch_header, CURLOPT_TIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 0, );
if($ca_bundle_path = get_ca_bundle_path()) { $curlopt[CURLOPT_SSL_VERIFYPEER] = 1; $curlopt[CURLOPT_CAINFO] = $ca_bundle_path; } else { $curlopt[CURLOPT_SSL_VERIFYPEER] = 0; }
$curl_version_info = curl_version(); $curl_version = $curl_version_info['version'];
if(version_compare(PHP_VERSION, '7.0.7', '>=') && version_compare($curl_version, '7.49', '>=')) { // CURLOPT_CONNECT_TO $curlopt[10243] = array( $url_components['host'].':'.$url_components['port'].':'.$destination_address ); } elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>=')) { // CURLOPT_RESOLVE $curlopt[10203] = array( $url_components['host'].':'.$url_components['port'].':'.$destination_address ); }
|
if(!empty($post_body)) {
|
if(!empty($post_body)) {
|
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
| $curlopt[CURLOPT_POST] = 1; $curlopt[CURLOPT_POSTFIELDS] = $post_body;
|
}
|
}
|
| curl_setopt_array($ch, $curlopt);
|
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
if($request_header)
| if($fetch_header)
|
{ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size);
| { $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size);
|
Zeile 6874 | Zeile 7122 |
---|
else { $data = $body;
|
else { $data = $body;
|
} } else { $data = $response; }
| } } else { $data = $response; }
|
curl_close($ch); return $data; } else if(function_exists("fsockopen")) {
|
curl_close($ch); return $data; } else if(function_exists("fsockopen")) {
|
if(!isset($url_components['port'])) { $url_components['port'] = 80; }
| |
if(!isset($url_components['path'])) { $url_components['path'] = "/";
| if(!isset($url_components['path'])) { $url_components['path'] = "/";
|
Zeile 6897 | Zeile 7141 |
---|
if(isset($url_components['query'])) { $url_components['path'] .= "?{$url_components['query']}";
|
if(isset($url_components['query'])) { $url_components['path'] .= "?{$url_components['query']}";
|
}
$scheme = '';
| }
$scheme = '';
|
if($url_components['scheme'] == 'https')
|
if($url_components['scheme'] == 'https')
|
{
| {
|
$scheme = 'ssl://'; if($url_components['port'] == 80) {
| $scheme = 'ssl://'; if($url_components['port'] == 80) {
|
Zeile 6910 | Zeile 7154 |
---|
} }
|
} }
|
$fp = @fsockopen($scheme.$url_components['host'], $url_components['port'], $error_no, $error, 10);
| if(function_exists('stream_context_create')) { if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path()) { $context = stream_context_create(array( 'ssl' => array( 'verify_peer' => true, 'verify_peer_name' => true, 'peer_name' => $url_components['host'], 'cafile' => $ca_bundle_path, ), )); } else { $context = stream_context_create(array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, ), )); }
$fp = @stream_socket_client($scheme.$destination_address.':'.(int)$url_components['port'], $error_no, $error, 10, STREAM_CLIENT_CONNECT, $context); } else { $fp = @fsockopen($scheme.$url_components['host'], (int)$url_components['port'], $error_no, $error, 10); }
|
@stream_set_timeout($fp, 10); if(!$fp)
|
@stream_set_timeout($fp, 10); if(!$fp)
|
{ return false;
| { return false;
|
} $headers = array(); if(!empty($post_body))
| } $headers = array(); if(!empty($post_body))
|
Zeile 6944 | Zeile 7217 |
---|
$headers = implode("\r\n", $headers); if(!@fwrite($fp, $headers))
|
$headers = implode("\r\n", $headers); if(!@fwrite($fp, $headers))
|
{ return false;
| { return false;
|
}
$data = null;
| }
$data = null;
|
Zeile 6962 | Zeile 7235 |
---|
$status_line = current(explode("\n\n", $header, 1)); $body = $data[1];
|
$status_line = current(explode("\n\n", $header, 1)); $body = $data[1];
|
if($max_redirects != 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
| if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
|
{ preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
| { preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);
|
Zeile 6978 | Zeile 7251 |
---|
return $data; }
|
return $data; }
|
else if(empty($post_data))
| else { return false; } }
/** * Resolves a hostname into a set of IP addresses. * * @param string $hostname The hostname to be resolved * @return array|bool The resulting IP addresses. False on failure */ function get_ip_by_hostname($hostname) { $addresses = @gethostbynamel($hostname);
if(!$addresses) { $result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);
if($result_set) { $addresses = array_column($result_set, 'ip'); } else { return false; } }
return $addresses; }
/** * Returns the location of the CA bundle defined in the PHP configuration. * * @return string|bool The location of the CA bundle, false if not set */ function get_ca_bundle_path() { if($path = ini_get('openssl.cafile')) { return $path; } if($path = ini_get('curl.cainfo'))
|
{
|
{
|
return @implode("", @file($url)); } else { return false;
| return $path;
|
}
|
}
|
| return false;
|
}
/**
| }
/**
|
Zeile 7002 | Zeile 7317 |
---|
{ global $mybb; $super_admins = str_replace(" ", "", $mybb->config['super_admins']);
|
{ global $mybb; $super_admins = str_replace(" ", "", $mybb->config['super_admins']);
|
}
if(my_strpos(",{$super_admins},", ",{$uid},") === false) { return false; } else {
| }
if(my_strpos(",{$super_admins},", ",{$uid},") === false) { return false; } else {
|
return true; } }
| return true; } }
|
Zeile 7256 | Zeile 7571 |
---|
}
return $warningshandler->expire_warnings();
|
}
return $warningshandler->expire_warnings();
|
}
| }
|
/** * Custom chmod function to fix problems with hosts who's server configurations screw up umasks
| /** * Custom chmod function to fix problems with hosts who's server configurations screw up umasks
|
Zeile 7287 | Zeile 7602 |
---|
* @param string $path The path to the directory * @param array $ignore Any files you wish to ignore (optional) * @return bool
|
* @param string $path The path to the directory * @param array $ignore Any files you wish to ignore (optional) * @return bool
|
*/
| */
|
function my_rmdir_recursive($path, $ignore=array()) { global $orig_dir;
| function my_rmdir_recursive($path, $ignore=array()) { global $orig_dir;
|
Zeile 7318 | Zeile 7633 |
---|
}
return @rmdir($path);
|
}
return @rmdir($path);
|
}
| }
|
return @unlink($path); }
| return @unlink($path); }
|
Zeile 7329 | Zeile 7644 |
---|
* @param array $array The array of forums * @return integer The number of sub forums */
|
* @param array $array The array of forums * @return integer The number of sub forums */
|
function subforums_count($array)
| function subforums_count($array=array())
|
{ $count = 0; foreach($array as $array2)
| { $count = 0; foreach($array as $array2)
|
Zeile 7380 | Zeile 7695 |
---|
* @return string IP in IPv4 format */ function my_long2ip($long)
|
* @return string IP in IPv4 format */ function my_long2ip($long)
|
{
| {
|
// On 64-bit machines is_int will return true. On 32-bit it will return false if($long < 0 && is_int(2147483648)) {
| // On 64-bit machines is_int will return true. On 32-bit it will return false if($long < 0 && is_int(2147483648)) {
|
Zeile 7406 | Zeile 7721 |
---|
{ /** * Replace inet_pton()
|
{ /** * Replace inet_pton()
|
* * @category PHP * @package PHP_Compat * @license LGPL - http://www.gnu.org/licenses/lgpl.html
| * * @category PHP * @package PHP_Compat * @license LGPL - http://www.gnu.org/licenses/lgpl.html
|
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net> * @link http://php.net/inet_pton * @author Arpad Ray <arpad@php.net>
| * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net> * @link http://php.net/inet_pton * @author Arpad Ray <arpad@php.net>
|
Zeile 7454 | Zeile 7769 |
---|
if(function_exists('inet_ntop')) { return @inet_ntop($ip);
|
if(function_exists('inet_ntop')) { return @inet_ntop($ip);
|
}
| }
|
else { /**
| else { /**
|
Zeile 7469 | Zeile 7784 |
---|
* @version $Revision: 269597 $ */ switch(strlen($ip))
|
* @version $Revision: 269597 $ */ switch(strlen($ip))
|
{
| {
|
case 4: list(,$r) = unpack('N', $ip); return long2ip($r);
| case 4: list(,$r) = unpack('N', $ip); return long2ip($r);
|
Zeile 7500 | Zeile 7815 |
---|
{ // IPv6 $upper = str_replace('*', 'ffff', $ipaddress);
|
{ // IPv6 $upper = str_replace('*', 'ffff', $ipaddress);
|
$lower = str_replace('*', '0', $ipaddress); } else {
| $lower = str_replace('*', '0', $ipaddress); } else {
|
// IPv4 $ip_bits = count(explode('.', $ipaddress)); if($ip_bits < 4)
| // IPv4 $ip_bits = count(explode('.', $ipaddress)); if($ip_bits < 4)
|
Zeile 7592 | Zeile 7907 |
---|
}
return array($ip_lower_pack, $ip_higher_pack);
|
}
return array($ip_lower_pack, $ip_higher_pack);
|
}
| }
|
// Just on IP address else { return my_inet_pton($ipaddress); } }
|
// Just on IP address else { return my_inet_pton($ipaddress); } }
|
|
|
/** * Time how long it takes for a particular piece of code to run. Place calls above & below the block of code. *
| /** * Time how long it takes for a particular piece of code to run. Place calls above & below the block of code. *
|
Zeile 7608 | Zeile 7923 |
---|
function get_execution_time() { static $time_start;
|
function get_execution_time() { static $time_start;
|
|
|
$time = microtime(true);
|
$time = microtime(true);
|
|
|
// Just starting timer, init and return if(!$time_start) { $time_start = $time; return;
|
// Just starting timer, init and return if(!$time_start) { $time_start = $time; return;
|
}
| }
|
// Timer has run, return execution time else {
| // Timer has run, return execution time else {
|
Zeile 7625 | Zeile 7939 |
---|
if($total < 0) $total = 0; $time_start = 0; return $total;
|
if($total < 0) $total = 0; $time_start = 0; return $total;
|
} }
/**
| } }
/**
|
* Processes a checksum list on MyBB files and returns a result set * * @param string $path The base path
| * Processes a checksum list on MyBB files and returns a result set * * @param string $path The base path
|
Zeile 7638 | Zeile 7952 |
---|
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", "htaccess-nginx.txt", "logo.gif", "logo.png"); $ignore_ext = array("attach");
if(substr($path, -1, 1) == "/")
|
// 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", "htaccess-nginx.txt", "logo.gif", "logo.png"); $ignore_ext = array("attach");
if(substr($path, -1, 1) == "/")
|
{
| {
|
$path = substr($path, 0, -1); }
| $path = substr($path, 0, -1); }
|
Zeile 7674 | Zeile 7988 |
---|
}
// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)
|
}
// 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;
| $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)) { $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
// Does this file even exist in our official list? Perhaps it's a plugin if(array_key_exists($file_path, $checksums)) { $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
$contents = '';
| $hashingContext = hash_init('sha512');
|
while(!feof($handle)) {
|
while(!feof($handle)) {
|
$contents .= fread($handle, 8192);
| hash_update($hashingContext, fread($handle, 8192));
|
} fclose($handle);
|
} fclose($handle);
|
$md5 = md5($contents);
| $checksum = hash_final($hashingContext);
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
|
// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
|
if(!in_array($md5, $checksums[$file_path]))
| if(!in_array($checksum, $checksums[$file_path]))
|
{ $bad_verify_files[] = array("status" => "changed", "path" => $file_path); }
| { $bad_verify_files[] = array("status" => "changed", "path" => $file_path); }
|
Zeile 7741 | Zeile 8055 |
---|
return "+$int"; } }
|
return "+$int"; } }
|
|
|
/** * Returns a securely generated seed *
| /** * Returns a securely generated seed *
|
Zeile 7756 | Zeile 8070 |
---|
try { $output = random_bytes($bytes);
|
try { $output = random_bytes($bytes);
|
} catch (Exception $e) {
| } catch (Exception $e) {
|
} }
| } }
|
Zeile 8002 | Zeile 8316 |
---|
{ // Check to see if we have matched a first character in our utf-8 array $offset = match_sequence($string, $hex_chrs);
|
{ // Check to see if we have matched a first character in our utf-8 array $offset = match_sequence($string, $hex_chrs);
|
if(!$offset) { // If not, then we must have a "good" character and we don't need to do anymore processing break;
| if(!$offset) { // If not, then we must have a "good" character and we don't need to do anymore processing break;
|
} $string = substr($string, $offset); }
| } $string = substr($string, $offset); }
|
Zeile 8254 | Zeile 8568 |
---|
{ // Load user language $lang->set_language($pm['language']);
|
{ // Load user language $lang->set_language($pm['language']);
|
$lang->load($pm['language_file']);
| $lang->load($pm['language_file']);
|
$revert = true; }
| $revert = true; }
|
Zeile 8340 | Zeile 8654 |
---|
}
$pm['options'] = array(
|
}
$pm['options'] = array(
|
"signature" => 0,
| |
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0 );
$pm['saveasdraft'] = 0;
|
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0 );
$pm['saveasdraft'] = 0;
|
|
|
// Admin override $pmhandler->admin_override = (int)$admin_override;
| // Admin override $pmhandler->admin_override = (int)$admin_override;
|
Zeile 8378 | Zeile 8691 |
---|
if(!is_array($data)) { $data = array($data);
|
if(!is_array($data)) { $data = array($data);
|
}
| }
|
if(!$ip_address) { $ip_address = get_ip();
| if(!$ip_address) { $ip_address = get_ip();
|
Zeile 8411 | Zeile 8724 |
---|
{ global $mybb, $plugins;
|
{ global $mybb, $plugins;
|
$success = false;
$file_path = (string)$file_path;
| $success = false;
|
|
|
$real_file_path = realpath($file_path);
| $file_path = (string)$file_path;
$real_file_path = realpath($file_path);
|
$file_dir_path = dirname($real_file_path); $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path); $file_dir_path = ltrim($file_dir_path, './\\');
|
$file_dir_path = dirname($real_file_path); $file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path); $file_dir_path = ltrim($file_dir_path, './\\');
|
|
|
$file_name = basename($real_file_path);
if(file_exists($file_path)) { if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))
|
$file_name = basename($real_file_path);
if(file_exists($file_path)) { if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))
|
{
| {
|
$cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)
| $cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)
|
Zeile 8470 | Zeile 8783 |
---|
}
return $success;
|
}
return $success;
|
}
/**
| }
/**
|
* Validate an url
|
* Validate an url
|
*
| *
|
* @param string $url The url to validate. * @param bool $relative_path Whether or not the url could be a relative path.
|
* @param string $url The url to validate. * @param bool $relative_path Whether or not the url could be a relative path.
|
| * @param bool $allow_local Whether or not the url could be pointing to local networks.
|
* * @return bool Whether this is a valid url. */
|
* * @return bool Whether this is a valid url. */
|
function my_validate_url($url, $relative_path=false)
| function my_validate_url($url, $relative_path=false, $allow_local=false)
|
{
|
{
|
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))
| if($allow_local) { $regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS'; } else { $regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS'; }
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))
|
{ return true; }
|
{ return true; }
|
| |
return false;
|
return false;
|
}
/**
| }
/**
|
* Strip html tags from string, also removes <script> and <style> contents.
|
* Strip html tags from string, also removes <script> and <style> contents.
|
*
| * * @deprecated
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags
|
* @param string $string String to stripe * @param string $allowable_tags Allowed html tags
|
*
| *
|
* @return string Striped string */ function my_strip_tags($string, $allowable_tags = '')
| * @return string Striped string */ function my_strip_tags($string, $allowable_tags = '')
|
Zeile 8508 | Zeile 8831 |
---|
); $string = preg_replace($pattern, '', $string); return strip_tags($string, $allowable_tags);
|
); $string = preg_replace($pattern, '', $string); return strip_tags($string, $allowable_tags);
|
| }
/** * Escapes a RFC 4180-compliant CSV string. * Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867 * * @param string $string The string to be escaped * @param boolean $escape_active_content Whether or not to escape active content trigger characters * @return string The escaped string */ function my_escape_csv($string, $escape_active_content=true) { if($escape_active_content) { $active_content_triggers = array('=', '+', '-', '@'); $delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");
$first_character = mb_substr($string, 0, 1);
if( in_array($first_character, $active_content_triggers, true) || in_array($first_character, $delimiters, true) ) { $string = "'".$string; }
foreach($delimiters as $delimiter) { foreach($active_content_triggers as $trigger) { $string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string); } } }
$string = str_replace('"', '""', $string);
return $string; }
// Fallback function for 'array_column', PHP < 5.5.0 compatibility if(!function_exists('array_column')) { function array_column($input, $column_key) { $values = array(); if(!is_array($input)) { $input = array($input); } foreach($input as $val) { if(is_array($val) && isset($val[$column_key])) { $values[] = $val[$column_key]; } elseif(is_object($val) && isset($val->$column_key)) { $values[] = $val->$column_key; } } return $values; } }
/** * Performs a timing attack safe string comparison. * * @param string $known_string The first string to be compared. * @param string $user_string The second, user-supplied string to be compared. * @return bool Result of the comparison. */ function my_hash_equals($known_string, $user_string) { if(version_compare(PHP_VERSION, '5.6.0', '>=')) { return hash_equals($known_string, $user_string); } else { $known_string_length = my_strlen($known_string); $user_string_length = my_strlen($user_string);
if($user_string_length != $known_string_length) { return false; }
$result = 0;
for($i = 0; $i < $known_string_length; $i++) { $result |= ord($known_string[$i]) ^ ord($user_string[$i]); }
return $result === 0; }
|
}
| }
|