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'] = '';
| if($diff < 0) { $diff = abs($diff); $relative['suffix'] = '';
|
$relative['prefix'] = $lang->rel_in; }
| $relative['prefix'] = $lang->rel_in; }
|
Zeile 423 | Zeile 438 |
---|
if($diff <= 60) { // Less than a minute
|
if($diff <= 60) { // Less than a minute
|
$relative['prefix'] = $lang->rel_less_than; }
$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);
| $relative['prefix'] = $lang->rel_less_than; }
$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 448 | Zeile 463 |
---|
$relative['plural'] = $lang->rel_hours_single; }
|
$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)
|
} else { if($ty)
|
{
| {
|
if($todaysdate == $date) {
|
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);
|
} }
| } }
|
Zeile 473 | Zeile 488 |
---|
{ $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 783 | Zeile 823 |
---|
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 *
| /** * Produce an error message for displaying inline on a page *
|
Zeile 799 | Zeile 839 |
---|
global $theme, $mybb, $db, $lang, $templates;
if(!$title)
|
global $theme, $mybb, $db, $lang, $templates;
if(!$title)
|
{
| {
|
$title = $lang->please_correct_errors;
|
$title = $lang->please_correct_errors;
|
}
| }
|
if(!is_array($errors)) { $errors = array($errors); }
|
if(!is_array($errors)) { $errors = array($errors); }
|
|
|
// AJAX error message? if($mybb->get_input('ajax', MyBB::INPUT_INT)) {
| // AJAX error message? if($mybb->get_input('ajax', MyBB::INPUT_INT)) {
|
Zeile 815 | Zeile 855 |
---|
@header("Content-type: application/json; charset={$lang->settings['charset']}");
if(empty($json_data))
|
@header("Content-type: application/json; charset={$lang->settings['charset']}");
if(empty($json_data))
|
{
| {
|
echo json_encode(array("errors" => $errors)); } else
| echo json_encode(array("errors" => $errors)); } else
|
Zeile 823 | Zeile 863 |
---|
echo json_encode(array_merge(array("errors" => $errors), $json_data)); } exit;
|
echo json_encode(array_merge(array("errors" => $errors), $json_data)); } exit;
|
}
| }
|
$errorlist = '';
foreach($errors as $error)
|
$errorlist = '';
foreach($errors as $error)
|
{ $errorlist .= "<li>".$error."</li>\n"; }
eval("\$errors = \"".$templates->get("error_inline")."\";");
| { eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";"); }
eval("\$errors = \"".$templates->get("error_inline")."\";");
|
return $errors; }
| return $errors; }
|
Zeile 864 | Zeile 904 |
---|
}
if($mybb->user['uid'])
|
}
if($mybb->user['uid'])
|
{
| {
|
$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username'])); eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";"); }
| $lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username'])); eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";"); }
|
Zeile 896 | Zeile 936 |
---|
} eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
|
} eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
|
|
|
error($errorpage); }
| error($errorpage); }
|
Zeile 911 | Zeile 951 |
---|
function redirect($url, $message="", $title="", $force_redirect=false) { global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
|
function redirect($url, $message="", $title="", $force_redirect=false) { global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
|
|
|
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
$plugins->run_hooks("redirect", $redirect_args);
| $redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
$plugins->run_hooks("redirect", $redirect_args);
|
Zeile 926 | Zeile 966 |
---|
$data .= 'alert("'.addslashes($message).'");'; } $url = str_replace("#", "&#", $url);
|
$data .= 'alert("'.addslashes($message).'");'; } $url = str_replace("#", "&#", $url);
|
$url = htmlspecialchars_decode($url); $url = str_replace(array("\n","\r",";"), "", $url);
| $url = htmlspecialchars_decode($url); $url = str_replace(array("\n","\r",";"), "", $url);
|
$data .= 'window.location = "'.addslashes($url).'";'."\n"; $data .= "</script>\n"; //exit;
| $data .= 'window.location = "'.addslashes($url).'";'."\n"; $data .= "</script>\n"; //exit;
|
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 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 1024 | Zeile 1066 |
---|
{ $from = 1; $to = $from+$mybb->settings['maxmultipagelinks']-1;
|
{ $from = 1; $to = $from+$mybb->settings['maxmultipagelinks']-1;
|
}
| }
|
if($to > $pages)
|
if($to > $pages)
|
{ $to = $pages;
| { $to = $pages;
|
$from = $pages-$mybb->settings['maxmultipagelinks']+1; if($from <= 0) {
| $from = $pages-$mybb->settings['maxmultipagelinks']+1; if($from <= 0) {
|
Zeile 1039 | Zeile 1081 |
---|
if($to == 0) { $to = $pages;
|
if($to == 0) { $to = $pages;
|
}
| }
|
$start = ''; if($from > 1)
| $start = ''; if($from > 1)
|
Zeile 1055 | Zeile 1097 |
---|
$mppage = ''; for($i = $from; $i <= $to; ++$i)
|
$mppage = ''; for($i = $from; $i <= $to; ++$i)
|
{
| {
|
$page_url = fetch_page_url($url, $i); if($page == $i) {
| $page_url = fetch_page_url($url, $i); if($page == $i) {
|
Zeile 1084 | Zeile 1126 |
---|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";");
|
$page_url = fetch_page_url($url, $pages); eval("\$end = \"".$templates->get("multipage_end")."\";");
|
}
| }
|
$nextpage = ''; if($page < $pages) {
| $nextpage = ''; if($page < $pages) {
|
Zeile 1100 | Zeile 1142 |
---|
// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary $jump_url = fetch_page_url($url, 1); eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
|
// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary $jump_url = fetch_page_url($url, 1); 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 1132 | Zeile 1174 |
---|
"&page={page}", "{page}" );
|
"&page={page}", "{page}" );
|
|
|
// Remove "Page 1" to the defacto URL $url = str_replace($find, array("", "", $page), $url); return $url;
| // Remove "Page 1" to the defacto URL $url = str_replace($find, array("", "", $page), $url); return $url;
|
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 1422 | Zeile 1470 |
---|
if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
if(empty($level_permissions)) { $level_permissions = $groupscache[$gid];
|
}
| }
|
foreach($level_permissions as $permission => $access) {
| foreach($level_permissions as $permission => $access) {
|
Zeile 1435 | Zeile 1483 |
---|
if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"])) { $only_view_own_threads = 0;
|
if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"])) { $only_view_own_threads = 0;
|
}
| }
|
if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"])) { $only_reply_own_threads = 0; } }
|
if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"])) { $only_reply_own_threads = 0; } }
|
}
| }
|
// Figure out if we can view more than our own threads if($only_view_own_threads == 0) {
| // Figure out if we can view more than our own threads if($only_view_own_threads == 0) {
|
Zeile 1478 | Zeile 1526 |
---|
$showform = true;
if(!is_array($forum_cache))
|
$showform = true;
if(!is_array($forum_cache))
|
{
| {
|
$forum_cache = cache_forums(); if(!$forum_cache) { return false;
|
$forum_cache = cache_forums(); if(!$forum_cache) { return false;
|
} }
| } }
|
// Loop through each of parent forums to ensure we have a password for them too if(isset($forum_cache[$fid]['parentlist'])) {
| // Loop through each of parent forums to ensure we have a password for them too if(isset($forum_cache[$fid]['parentlist'])) {
|
Zeile 1499 | Zeile 1547 |
---|
if($parent_id == $fid || $parent_id == $pid) { continue;
|
if($parent_id == $fid || $parent_id == $pid) { continue;
|
}
| }
|
if($forum_cache[$parent_id]['password'] != "") {
| if($forum_cache[$parent_id]['password'] != "") {
|
Zeile 1527 | Zeile 1575 |
---|
else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))
|
else { if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))
|
{
| {
|
$showform = true; } else { $showform = false;
|
$showform = true; } else { $showform = false;
|
}
| }
|
}
|
}
|
}
| }
|
else { $showform = false;
|
else { $showform = false;
|
}
| }
|
if($return) {
| if($return) {
|
Zeile 1559 | Zeile 1607 |
---|
output_page($pwform); } exit;
|
output_page($pwform); } exit;
|
}
| }
|
}
/**
| }
/**
|
Zeile 1578 | Zeile 1626 |
---|
if($uid < 1) { $uid = $mybb->user['uid'];
|
if($uid < 1) { $uid = $mybb->user['uid'];
|
}
| }
|
if($uid == 0)
|
if($uid == 0)
|
{
| {
|
return false; }
|
return false; }
|
if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid]; }
| if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid]; }
|
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
| if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid));
|
Zeile 1610 | Zeile 1658 |
---|
$groups[] = $extra_group; } }
|
$groups[] = $extra_group; } }
|
|
|
$mod_cache = $cache->read("moderators");
foreach($mod_cache as $forumid => $forum)
| $mod_cache = $cache->read("moderators");
foreach($mod_cache as $forumid => $forum)
|
Zeile 1641 | Zeile 1689 |
---|
else { $perms[$action] = max($perm[$action], $perms[$action]);
|
else { $perms[$action] = max($perm[$action], $perms[$action]);
|
} } }
| } } }
|
foreach($groups as $group) { if(!is_array($forum['usergroups'][$group]))
| foreach($groups as $group) { if(!is_array($forum['usergroups'][$group]))
|
Zeile 1753 | Zeile 1801 |
---|
return false; } }
|
return false; } }
|
} } }
| } } }
|
/** * Generate a list of the posticons.
| /** * Generate a list of the posticons.
|
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 3243 | Zeile 3317 |
---|
$emoticon = ""; $emoticons_enabled = "false"; if($smilies)
|
$emoticon = ""; $emoticons_enabled = "false"; if($smilies)
|
{
| {
|
if(!$smiliecache) { if(!isset($smilie_cache) || !is_array($smilie_cache))
| if(!$smiliecache) { if(!isset($smilie_cache) || !is_array($smilie_cache))
|
Zeile 3353 | Zeile 3427 |
---|
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);";
|
Zeile 3368 | Zeile 3442 |
---|
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('dont', '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 3461 | Zeile 3582 |
---|
}
eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
|
}
eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
|
} else
| } else
|
{ $clickablesmilies = ""; }
| { $clickablesmilies = ""; }
|
Zeile 3491 | Zeile 3612 |
---|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid];
|
}
return $prefixes_cache; }
| }
return $prefixes_cache; }
|
$prefix_cache = $cache->read("threadprefixes");
| $prefix_cache = $cache->read("threadprefixes");
|
Zeile 3502 | Zeile 3623 |
---|
{ // No cache $prefix_cache = $cache->read("threadprefixes", true);
|
{ // No cache $prefix_cache = $cache->read("threadprefixes", true);
|
|
|
if(!is_array($prefix_cache)) { return array();
| if(!is_array($prefix_cache)) { return array();
|
Zeile 3510 | Zeile 3631 |
---|
}
$prefixes_cache = array();
|
}
$prefixes_cache = array();
|
foreach($prefix_cache as $prefix)
| foreach($prefix_cache as $prefix)
|
{ $prefixes_cache[$prefix['pid']] = $prefix;
|
{ $prefixes_cache[$prefix['pid']] = $prefix;
|
}
| }
|
if($pid != 0 && is_array($prefixes_cache[$pid]))
|
if($pid != 0 && is_array($prefixes_cache[$pid]))
|
{
| {
|
return $prefixes_cache[$pid];
|
return $prefixes_cache[$pid];
|
}
| }
|
else if(!empty($prefixes_cache)) { return $prefixes_cache;
| else if(!empty($prefixes_cache)) { return $prefixes_cache;
|
Zeile 3526 | Zeile 3647 |
---|
return false; }
|
return false; }
|
|
|
/** * Build the thread prefix selection menu for the current user *
| /** * Build the thread prefix selection menu for the current user *
|
Zeile 3573 | Zeile 3694 |
---|
// The current user can use this prefix $prefixes[$prefix['pid']] = $prefix; }
|
// The current user can use this prefix $prefixes[$prefix['pid']] = $prefix; }
|
}
| }
|
if(empty($prefixes))
|
if(empty($prefixes))
|
{
| {
|
return ''; }
| return ''; }
|
Zeile 3588 | Zeile 3709 |
---|
if($selected_pid == 'any') { $any_selected = " selected=\"selected\"";
|
if($selected_pid == 'any') { $any_selected = " selected=\"selected\"";
|
} }
| } }
|
$default_selected = ""; if(((int)$selected_pid == 0) && $selected_pid != 'any')
| $default_selected = ""; if(((int)$selected_pid == 0) && $selected_pid != 'any')
|
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
| }
// Any remaining extra data - we my_serialize and insert in to its own column
|
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 3821 | Zeile 3965 |
---|
elseif($reputation > 0) { $reputation_class = "reputation_positive";
|
elseif($reputation > 0) { $reputation_class = "reputation_positive";
|
}
| }
|
else { $reputation_class = "reputation_neutral";
|
else { $reputation_class = "reputation_neutral";
|
}
$reputation = my_number_format($reputation);
| }
$reputation = my_number_format($reputation);
|
if($uid != 0) { eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");
| if($uid != 0) { eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");
|
Zeile 3843 | Zeile 3987 |
---|
/** * Fetch a color coded version of a warning level (based on it's percentage)
|
/** * Fetch a color coded version of a warning level (based on it's percentage)
|
*
| *
|
* @param int $level The warning level (percentage of 100) * @return string Formatted warning level */
| * @param int $level The warning level (percentage of 100) * @return string Formatted warning level */
|
Zeile 4222 | Zeile 4366 |
---|
if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1) { $mybb->settings['threadsperpage'] = 20;
|
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 4236 | Zeile 4380 |
---|
// Replace page 1 URLs $navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']); $navbit['url'] = preg_replace("/&page=1$/", "", $navbit['url']);
|
// Replace page 1 URLs $navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']); $navbit['url'] = preg_replace("/&page=1$/", "", $navbit['url']);
|
|
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
eval("\$nav .= \"".$templates->get("nav_bit")."\";"); } }
|
| $navsize = count($navbits); $navbit = $navbits[$navsize-1];
|
}
|
}
|
$activesep = ''; $navsize = count($navbits); $navbit = $navbits[$navsize-1];
| |
if($nav) {
| if($nav) {
|
Zeile 4475 | Zeile 4617 |
---|
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$gzipen</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. Templates Used:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">".count($templates->cache)." (".(int)count(explode(",", $templatelist))." Cached / ".(int)count($templates->uncached_templates)." Manually Loaded)</span></td>\n";
|
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$gzipen</span></td>\n"; echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. Templates Used:</span></b></td>\n"; echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">".count($templates->cache)." (".(int)count(explode(",", $templatelist))." Cached / ".(int)count($templates->uncached_templates)." Manually Loaded)</span></td>\n";
|
echo "</tr>\n";
| echo "</tr>\n";
|
$memory_usage = get_memory_usage(); if(!$memory_usage) {
| $memory_usage = get_memory_usage(); if(!$memory_usage) {
|
Zeile 4503 | Zeile 4645 |
---|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
echo "</tr>\n"; echo "</table>\n"; echo "<br />\n";
|
|
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain;
|
echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n"; echo $db->explain;
|
|
|
if($cache->call_count > 0) { echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n"; echo $cache->cache_debug; }
|
if($cache->call_count > 0) { echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n"; echo $cache->cache_debug; }
|
|
|
echo "<h2>Template Statistics</h2>\n";
if(count($templates->cache) > 0)
|
echo "<h2>Template Statistics</h2>\n";
if(count($templates->cache) > 0)
|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
| { echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
|
echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n"; echo "</tr>\n";
| echo "<tr>\n"; echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n"; echo "</tr>\n";
|
Zeile 4543 | Zeile 4685 |
---|
echo "</body>"; echo "</html>"; exit;
|
echo "</body>"; echo "</html>"; exit;
|
}
| }
|
/** * Outputs the correct page headers.
| /** * Outputs the correct page headers.
|
Zeile 4582 | Zeile 4724 |
---|
} break; case "post":
|
} break; case "post":
|
$db->update_query("reportedcontent", array('reportstatus' => 1), "id='$id' AND reportstatus='0' AND (type = 'post' OR type = '')"); break;
| $db->update_query("reportedcontent", array('reportstatus' => 1), "id='$id' AND reportstatus='0' AND (type = 'post' OR type = '')"); break;
|
case "threads": if(is_array($id)) {
| case "threads": if(is_array($id)) {
|
Zeile 4627 | Zeile 4769 |
---|
$msecs = 60;
if(isset($options['short']))
|
$msecs = 60;
if(isset($options['short']))
|
{
| {
|
$lang_year = $lang->year_short; $lang_years = $lang->years_short; $lang_month = $lang->month_short;
| $lang_year = $lang->year_short; $lang_years = $lang->years_short; $lang_month = $lang->month_short;
|
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; } else if($months > 1) { $nicetime['months'] = $months.$lang_months; }
if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; }
if($days == 1) { $nicetime['days'] = "1".$lang_day;
| // 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; } }
if(!isset($options['months']) || $options['months'] !== false) { if($months == 1) { $nicetime['months'] = "1".$lang_month; } else if($months > 1) { $nicetime['months'] = $months.$lang_months; } }
if(!isset($options['weeks']) || $options['weeks'] !== false) { if($weeks == 1) { $nicetime['weeks'] = "1".$lang_week; } else if($weeks > 1) { $nicetime['weeks'] = $weeks.$lang_weeks; }
|
}
|
}
|
else if($days > 1)
| if(!isset($options['days']) || $options['days'] !== false)
|
{
|
{
|
$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 4732 | Zeile 4918 |
---|
else if($minutes > 1) { $nicetime['minutes'] = $minutes.$lang_minutes;
|
else if($minutes > 1) { $nicetime['minutes'] = $minutes.$lang_minutes;
|
} }
| } }
|
if(!isset($options['seconds']) || $options['seconds'] !== false) { if($seconds == 1)
|
if(!isset($options['seconds']) || $options['seconds'] !== false) { if($seconds == 1)
|
{
| {
|
$nicetime['seconds'] = "1".$lang_second;
|
$nicetime['seconds'] = "1".$lang_second;
|
}
| }
|
else if($seconds > 1) { $nicetime['seconds'] = $seconds.$lang_seconds; }
|
else if($seconds > 1) { $nicetime['seconds'] = $seconds.$lang_seconds; }
|
}
| }
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
| if(is_array($nicetime)) { return implode(", ", $nicetime);
|
Zeile 4770 | Zeile 4956 |
---|
else { $trow = "trow1";
|
else { $trow = "trow1";
|
}
$alttrow = $trow;
| }
$alttrow = $trow;
|
return $trow; }
| return $trow; }
|
Zeile 4810 | Zeile 4996 |
---|
foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
|
foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
|
{ $groupslist .= $comma.$gid; $comma = ",";
| { $groupslist .= $comma.$gid; $comma = ",";
|
$donegroup[$gid] = 1; } }
| $donegroup[$gid] = 1; } }
|
Zeile 4839 | Zeile 5025 |
---|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
|
|
$user = get_user($uid);
$groupslist = $comma = '';
| $user = get_user($uid);
$groupslist = $comma = '';
|
Zeile 4865 | Zeile 5051 |
---|
if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
if($leavegroup == $user['displaygroup']) { $dispupdate = ", displaygroup=usergroup";
|
}
| }
|
$db->write_query(" UPDATE ".TABLE_PREFIX."users
| $db->write_query(" UPDATE ".TABLE_PREFIX."users
|
Zeile 4892 | Zeile 5078 |
---|
}
if(!empty($_SERVER['SCRIPT_NAME']))
|
}
if(!empty($_SERVER['SCRIPT_NAME']))
|
{
| {
|
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']); } elseif(!empty($_SERVER['PHP_SELF']))
| $location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']); } elseif(!empty($_SERVER['PHP_SELF']))
|
Zeile 4918 | Zeile 5104 |
---|
}
if($fields == true)
|
}
if($fields == true)
|
{
| {
|
global $mybb;
if(!is_array($ignore))
| global $mybb;
if(!is_array($ignore))
|
Zeile 5238 | Zeile 5424 |
---|
* @return string */ function my_wordwrap($message)
|
* @return string */ function my_wordwrap($message)
|
{
| {
|
return $message; }
| return $message; }
|
Zeile 5265 | Zeile 5451 |
---|
for($m = $j[$k]; $m >= 1; $m--) { $h--;
|
for($m = $j[$k]; $m >= 1; $m--) { $h--;
|
|
|
if($i == $year && $l == $month && $m == $day)
|
if($i == $year && $l == $month && $m == $day)
|
{
| {
|
return $h;
|
return $h;
|
}
| }
|
if($h == 0) {
| if($h == 0) {
|
Zeile 5278 | Zeile 5464 |
---|
} } }
|
} } }
|
}
| }
|
/** * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
| /** * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
|
Zeile 5291 | Zeile 5477 |
---|
return array( 31, ($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),
|
return array( 31, ($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),
|
31,
| 31,
|
30, 31, 30,
| 30, 31, 30,
|
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 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 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) {
| } elseif($uid == 0) {
|
Zeile 5888 | Zeile 6095 |
---|
else { $link = str_replace("{pid}", $pid, POST_URL);
|
else { $link = str_replace("{pid}", $pid, POST_URL);
|
return htmlspecialchars_uni($link); } }
/**
| return htmlspecialchars_uni($link); } }
/**
|
* Build the event link. * * @param int $eid The event ID of the event
| * Build the event link. * * @param int $eid The event ID of the event
|
Zeile 5901 | Zeile 6108 |
---|
function get_event_link($eid) { $link = str_replace("{eid}", $eid, EVENT_URL);
|
function get_event_link($eid) { $link = str_replace("{eid}", $eid, EVENT_URL);
|
return htmlspecialchars_uni($link); }
/**
| return htmlspecialchars_uni($link); }
/**
|
* Build the link to a specified date on the calendar * * @param int $calendar The ID of the calendar
| * Build the link to a specified date on the calendar * * @param int $calendar The ID of the calendar
|
Zeile 5981 | Zeile 6188 |
---|
return $user_cache[$uid]; } elseif($uid > 0)
|
return $user_cache[$uid]; } elseif($uid > 0)
|
{
| {
|
$query = $db->simple_select("users", "*", "uid = '{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
| $query = $db->simple_select("users", "*", "uid = '{$uid}'"); $user_cache[$uid] = $db->fetch_array($query);
|
Zeile 6002 | Zeile 6209 |
---|
global $mybb, $db;
$username = $db->escape_string(my_strtolower($username));
|
global $mybb, $db;
$username = $db->escape_string(my_strtolower($username));
|
|
|
if(!isset($options['username_method'])) { $options['username_method'] = 0;
| if(!isset($options['username_method'])) { $options['username_method'] = 0;
|
Zeile 6045 | Zeile 6252 |
---|
if(isset($options['exists'])) { return (bool)$db->num_rows($query);
|
if(isset($options['exists'])) { return (bool)$db->num_rows($query);
|
}
| }
|
return $db->fetch_array($query); }
| return $db->fetch_array($query); }
|
Zeile 6068 | Zeile 6275 |
---|
}
if(empty($forum_cache[$fid]))
|
}
if(empty($forum_cache[$fid]))
|
{ return false; }
| { return false; }
|
if($active_override != 1) {
| if($active_override != 1) {
|
Zeile 6088 | Zeile 6295 |
---|
}
return $forum_cache[$fid];
|
}
return $forum_cache[$fid];
|
}
| }
|
/** * Get the thread of a thread id. *
| /** * Get the thread of a thread id. *
|
Zeile 6121 | Zeile 6328 |
---|
else { $thread_cache[$tid] = false;
|
else { $thread_cache[$tid] = false;
|
return false; }
| return false; }
|
} }
| } }
|
Zeile 6156 | Zeile 6363 |
---|
else { $post_cache[$pid] = false;
|
else { $post_cache[$pid] = false;
|
return false; } } }
| return false; } } }
|
/** * Get inactivate forums. *
| /** * Get inactivate forums. *
|
Zeile 6183 | Zeile 6390 |
---|
{ $inactive[] = $fid; foreach($forum_cache as $fid1 => $forum1)
|
{ $inactive[] = $fid; foreach($forum_cache as $fid1 => $forum1)
|
{
| {
|
if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive)) { $inactive[] = $fid1;
| if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive)) { $inactive[] = $fid1;
|
Zeile 6203 | Zeile 6410 |
---|
* @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;
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;
| global $mybb, $lang, $db;
|
|
|
if(!empty($mybb->cookies['loginattempts'])) { $loginattempts = $mybb->cookies['loginattempts'];
| $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($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);
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false;
|
}
|
}
|
if(!empty($mybb->cookies['failedlogin']))
| if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
|
{
|
{
|
$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']))
| // Set the expiry dateline if not set yet if($attempts['loginlockoutexpiry'] == 0)
|
{
|
{
|
$failedtime = $now;
| $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 {
|
} else {
|
$failedtime = $mybb->cookies['failedlogin'];
| $failedtime = $mybb->cookies['lockoutexpiry'];
|
}
|
}
|
$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);
| // 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)); }
return false; }
|
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false; }
|
| // Unlock if enough time has passed else {
|
|
|
// 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)
| if($uid > 0)
|
{
|
{
|
$update_array = array( 'loginattempts' => 1 ); $db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
| $db->update_query("users", array( "loginattempts" => 0, "loginlockoutexpiry" => 0 ), "uid='{$uid}'");
|
}
|
}
|
return 1; } // Not waited long enough else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60)) { if($fatal) { error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft)); }
return false;
| // 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']; }
|
/** * Validates the format of an email address. *
| /** * Validates the format of an email address. *
|
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 6315 | Zeile 6526 |
---|
* @return boolean True when in use, false when not. */ function email_already_in_use($email, $uid=0)
|
* @return boolean True when in use, false when not. */ function email_already_in_use($email, $uid=0)
|
{
| {
|
global $db;
$uid_string = ""; if($uid) { $uid_string = " AND uid != '".(int)$uid."'";
|
global $db;
$uid_string = ""; if($uid) { $uid_string = " AND uid != '".(int)$uid."'";
|
}
| }
|
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
|
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");
|
|
|
if($db->fetch_field($query, "emails") > 0) { return true;
|
if($db->fetch_field($query, "emails") > 0) { return true;
|
}
| }
|
return false; }
| return false; }
|
Zeile 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 7432 | 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 7713 | Zeile 7925 |
---|
static $time_start;
$time = microtime(true);
|
static $time_start;
$time = microtime(true);
|
| |
// Just starting timer, init and return if(!$time_start)
| // Just starting timer, init and return if(!$time_start)
|
Zeile 7784 | Zeile 7995 |
---|
{ $filename = $path."/".$file; $handle = fopen($filename, "rb");
|
{ $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 8383 | Zeile 8594 |
---|
}
if(isset($revert))
|
}
if(isset($revert))
|
{
| {
|
// Revert language $lang->set_language($mybb->user['language']); $lang->load($pm['language_file']);
| // Revert language $lang->set_language($mybb->user['language']); $lang->load($pm['language_file']);
|
Zeile 8443 | Zeile 8654 |
---|
}
$pm['options'] = array(
|
}
$pm['options'] = array(
|
"signature" => 0,
| |
"disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
| "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0
|
Zeile 8580 | Zeile 8790 |
---|
* * @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)
|
{
|
{
|
return true;
| $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 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 = '')
|
{
| {
|
$pattern = array( '@(<)style[^(>)]*?(>).*?(<)/style(>)@siu', '@(<)script[^(>)]*?.*?(<)/script(>)@siu',
| $pattern = array( '@(<)style[^(>)]*?(>).*?(<)/style(>)@siu', '@(<)script[^(>)]*?.*?(<)/script(>)@siu',
|
Zeile 8611 | 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; }
|
}
| }
|