Zeile 3 | Zeile 3 |
---|
* MyBB 1.2 * Copyright � 2006 MyBB Group, All Rights Reserved *
|
* MyBB 1.2 * Copyright � 2006 MyBB Group, All Rights Reserved *
|
* Website: http://www.mybboard.com * License: http://www.mybboard.com/eula.html
| * Website: http://www.mybboard.net * License: http://www.mybboard.net/eula.html
|
*
|
*
|
* $Id: functions.php 2459 2006-11-29 09:09:55Z chris $
| * $Id: functions.php 3070 2007-05-18 07:44:28Z chris $
|
*/
/**
| */
/**
|
Zeile 79 | Zeile 79 |
---|
$plugins->run_hooks("post_output_page");
// If the use shutdown functionality is turned off, run any shutdown related items now.
|
$plugins->run_hooks("post_output_page");
// If the use shutdown functionality is turned off, run any shutdown related items now.
|
if(($mybb->settings['useshutdownfunc'] == "no" || phpversion() >= '5.0.5') && $mybb->use_shutdown != true)
| if(($mybb->settings['useshutdownfunc'] == "no"|| phpversion() >= '5.0.5') && $mybb->use_shutdown != true)
|
{ run_shutdown(); }
| { run_shutdown(); }
|
Zeile 353 | Zeile 353 |
---|
$headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: MyBB\n";
|
$headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: MyBB\n";
|
| $headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}\n";
|
// For some reason sendmail/qmail doesn't like \r\n $sendmail = @ini_get('sendmail_path');
| // For some reason sendmail/qmail doesn't like \r\n $sendmail = @ini_get('sendmail_path');
|
Zeile 425 | Zeile 426 |
---|
/** * Load the forum cache in to memory
|
/** * Load the forum cache in to memory
|
| * * @param boolean True to force a reload of the cache
|
*/
|
*/
|
function cache_forums()
| function cache_forums($force=false)
|
{ global $forum_cache, $db, $cache;
|
{ global $forum_cache, $db, $cache;
|
| if($force == true) { $forum_cache = $cache->read("forums", 1); return $forum_cache; }
|
if(!$forum_cache)
|
if(!$forum_cache)
|
{
| {
|
$forum_cache = $cache->read("forums"); if(!$forum_cache) {
| $forum_cache = $cache->read("forums"); if(!$forum_cache) {
|
Zeile 440 | Zeile 449 |
---|
} } return $forum_cache;
|
} } return $forum_cache;
|
}
/**
| }
/**
|
* Produce a friendly error message page * * @param string The error message to be shown
| * Produce a friendly error message page * * @param string The error message to be shown
|
Zeile 470 | Zeile 479 |
---|
/** * Produce an error message for displaying inline on a page
|
/** * Produce an error message for displaying inline on a page
|
*
| *
|
* @param array Array of errors to be shown * @param string The title of the error message * @return string The inline error HTML
| * @param array Array of errors to be shown * @param string The title of the error message * @return string The inline error HTML
|
Zeile 509 | Zeile 518 |
---|
"location2" => 0 ); $db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'");
|
"location2" => 0 ); $db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'");
|
$url = $_SERVER['REQUEST_URI']; $url = str_replace("&", "&", $url);
| $url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
|
if($mybb->user['uid']) { $lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']); eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
|
if($mybb->user['uid']) { $lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']); eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
|
} else
| } else
|
{ eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); } error($errorpage); }
|
{ eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); } error($errorpage); }
|
|
|
/** * Redirect the user to a given URL with a given message *
| /** * Redirect the user to a given URL with a given message *
|
Zeile 559 | Zeile 567 |
---|
header("Location: $url"); } exit;
|
header("Location: $url"); } exit;
|
}
| }
|
/** * Generate a listing of page - pagination *
| /** * Generate a listing of page - pagination *
|
Zeile 736 | Zeile 744 |
---|
global $cache, $groupscache, $displaygroupfields;
if(!is_array($groupscache))
|
global $cache, $groupscache, $displaygroupfields;
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups"); } $displaygroup = array(); $group = $groupscache[$gid]; foreach($displaygroupfields as $field)
|
$groupscache = $cache->read("usergroups"); } $displaygroup = array(); $group = $groupscache[$gid]; foreach($displaygroupfields as $field)
|
{
| {
|
$displaygroup[$field] = $group[$field]; } return $displaygroup; }
|
$displaygroup[$field] = $group[$field]; } return $displaygroup; }
|
|
|
/** * Build the forum permissions for a specific forum, user or group *
| /** * Build the forum permissions for a specific forum, user or group *
|
Zeile 780 | Zeile 788 |
---|
{ $gid = $mybb->user['usergroup']; if(isset($mybb->user['additionalgroups']))
|
{ $gid = $mybb->user['usergroup']; if(isset($mybb->user['additionalgroups']))
|
{
| {
|
$gid .= ",".$mybb->user['additionalgroups']; } $groupperms = $mybb->usergroup;
| $gid .= ",".$mybb->user['additionalgroups']; } $groupperms = $mybb->usergroup;
|
Zeile 801 | Zeile 809 |
---|
if($fid) // Fetch the permissions for a single forum { $permissions = fetch_forum_permissions($fid, $gid, $groupperms);
|
if($fid) // Fetch the permissions for a single forum { $permissions = fetch_forum_permissions($fid, $gid, $groupperms);
|
}
| }
|
else { foreach($forum_cache as $forum)
| else { foreach($forum_cache as $forum)
|
Zeile 822 | Zeile 830 |
---|
* @return array Permissions for this forum */ function fetch_forum_permissions($fid, $gid, $groupperms)
|
* @return array Permissions for this forum */ function fetch_forum_permissions($fid, $gid, $groupperms)
|
{
| {
|
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
|
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
|
|
|
$groups = explode(",", $gid);
|
$groups = explode(",", $gid);
|
|
|
if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
|
if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
|
{
| {
|
return $groupperms; }
|
return $groupperms; }
|
// The fix here for better working inheritance was provided by tinywizard - http://windizupdate.com/ // Many thanks. foreach($fpermfields as $perm) { $forumpermissions[$perm] = "no"; }
| $current_permissions = array();
|
foreach($groups as $gid) {
|
foreach($groups as $gid) {
|
if($gid && $groupscache[$gid])
| if($groupscache[$gid])
|
{
|
{
|
if(is_array($fpermcache[$fid][$gid]))
| // If this forum has permissions set if($fpermcache[$fid][$gid])
|
{
|
{
|
$p = $fpermcache[$fid][$gid]; } else { $p = $groupperms; } if($p == NULL) { foreach($forumpermissions as $k => $v) { $forumpermissions[$k] = 'yes'; // no inherited group, assume one has access } } else { foreach($p as $perm => $access)
| $level_permissions = $fpermcache[$fid][$gid]; foreach($level_permissions as $permission => $access)
|
{
|
{
|
if(isset($forumpermissions[$perm]) && $access == 'yes')
| if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
|
{
|
{
|
$forumpermissions[$perm] = $access;
| $current_permissions[$permission] = $access;
|
} } } } }
|
} } } } }
|
return $forumpermissions;
| if(count($current_permissions) == 0) { $current_permissions = $groupperms; } return $current_permissions;
|
}
/**
| }
/**
|
Zeile 887 | Zeile 884 |
---|
if($mybb->input['pwverify']) { if($password == $mybb->input['pwverify'])
|
if($mybb->input['pwverify']) { if($password == $mybb->input['pwverify'])
|
{
| {
|
my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
|
my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
|
$showform = 0; } else {
| $showform = 0; } else {
|
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";"); $showform = 1; }
| eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";"); $showform = 1; }
|
Zeile 908 | Zeile 905 |
---|
$showform = 0; } }
|
$showform = 0; } }
|
}
| }
|
else { $showform = 0; } if($showform) {
|
else { $showform = 0; } if($showform) {
|
| $_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
|
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform); exit;
| eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";"); output_page($pwform); exit;
|
Zeile 930 | Zeile 928 |
---|
* @return array Array of moderator permissions for the specific forum */ function get_moderator_permissions($fid, $uid="0", $parentslist="")
|
* @return array Array of moderator permissions for the specific forum */ function get_moderator_permissions($fid, $uid="0", $parentslist="")
|
{
| {
|
global $mybb, $db; static $modpermscache;
if($uid < 1) { $uid = $mybb->user['uid'];
|
global $mybb, $db; static $modpermscache;
if($uid < 1) { $uid = $mybb->user['uid'];
|
} if(!isset($modpermscache[$uid][$fid]))
| } if(!isset($modpermscache[$fid][$uid]))
|
{ if(!$parentslist) { $parentslist = get_parent_list($fid); }
|
{ if(!$parentslist) { $parentslist = get_parent_list($fid); }
|
|
|
$sql = build_parent_list($fid, "fid", "OR", $parentslist);
|
$sql = build_parent_list($fid, "fid", "OR", $parentslist);
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."moderators WHERE uid='$uid' AND $sql ");
| $query = $db->simple_select(TABLE_PREFIX."moderators", "*", "uid='{$uid}' AND {$sql}");
|
$perms = $db->fetch_array($query);
|
$perms = $db->fetch_array($query);
|
$modpermscache[$uid][$fid] = $perms;
| $modpermscache[$fid][$uid] = $perms;
|
} else {
|
} else {
|
$perms = $modpermscache[$uid][$fid];
| $perms = $modpermscache[$fid][$uid];
|
}
|
}
|
|
|
return $perms; }
| return $perms; }
|
Zeile 978 | Zeile 974 |
---|
$uid = $mybb->user['uid']; }
|
$uid = $mybb->user['uid']; }
|
if($mybb->usergroup['issupermod'] == "yes")
| $user_perms = user_permissions($uid); if($user_perms['issupermod'] == "yes")
|
{ return "yes"; }
| { return "yes"; }
|
Zeile 986 | Zeile 983 |
---|
{ if(!$fid) {
|
{ if(!$fid) {
|
$query = $db->simple_select(TABLE_PREFIX.'moderators', 'mid', "uid={$uid}", array('limit' => 1));
| $query = $db->simple_select(TABLE_PREFIX.'moderators', 'COUNT(*) as count', "uid={$uid}", array('limit' => 1));
|
$modcheck = $db->fetch_array($query);
|
$modcheck = $db->fetch_array($query);
|
if($modcheck['mid'])
| if($modcheck['count'] > 0)
|
{ return "yes"; }
| { return "yes"; }
|
Zeile 1025 | Zeile 1022 |
---|
* @return string The template of posticons. */ function get_post_icons()
|
* @return string The template of posticons. */ function get_post_icons()
|
{
| {
|
global $mybb, $db, $icon, $theme, $templates, $lang;
$listed = 0; if($mybb->input['icon'])
|
global $mybb, $db, $icon, $theme, $templates, $lang;
$listed = 0; if($mybb->input['icon'])
|
{
| {
|
$icon = $mybb->input['icon']; } $no_icons_checked = " checked=\"checked\"";
| $icon = $mybb->input['icon']; } $no_icons_checked = " checked=\"checked\"";
|
Zeile 1068 | Zeile 1065 |
---|
* @param string The cookie value. * @param int The timestamp of the expiry date. * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
|
* @param string The cookie value. * @param int The timestamp of the expiry date. * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
|
*/
| */
|
function my_setcookie($name, $value="", $expires="", $httponly=false) { global $mybb;
| function my_setcookie($name, $value="", $expires="", $httponly=false) { global $mybb;
|
Zeile 1078 | Zeile 1075 |
---|
$mybb->settings['cookiepath'] = "/"; } if($expires == -1)
|
$mybb->settings['cookiepath'] = "/"; } if($expires == -1)
|
{
| {
|
$expires = 0; } else if($expires == "" || $expires == null) { if($mybb->user['remember'] == "no")
|
$expires = 0; } else if($expires == "" || $expires == null) { if($mybb->user['remember'] == "no")
|
{
| {
|
$expires = 0; } else
| $expires = 0; } else
|
Zeile 1105 | Zeile 1102 |
---|
if($expires > 0) { $cookie .= "; expires=".gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
|
if($expires > 0) { $cookie .= "; expires=".gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
|
}
| }
|
if(!empty($mybb->settings['cookiepath']))
|
if(!empty($mybb->settings['cookiepath']))
|
{
| {
|
$cookie .= "; path={$mybb->settings['cookiepath']}"; } if(!empty($mybb->settings['cookiedomain']))
|
$cookie .= "; path={$mybb->settings['cookiepath']}"; } if(!empty($mybb->settings['cookiedomain']))
|
{
| {
|
$cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
$cookie .= "; domain={$mybb->settings['cookiedomain']}";
|
}
| }
|
if($httponly == true) { $cookie .= "; HttpOnly";
|
if($httponly == true) { $cookie .= "; HttpOnly";
|
}
| }
|
header($cookie, false); }
| header($cookie, false); }
|
Zeile 1127 | Zeile 1124 |
---|
* @param string The cookie identifier. */ function my_unsetcookie($name)
|
* @param string The cookie identifier. */ function my_unsetcookie($name)
|
{
| {
|
global $mybb; $expires = -3600; my_setcookie($name, "", $expires);
|
global $mybb; $expires = -3600; my_setcookie($name, "", $expires);
|
}
| }
|
/** * Get the contents from a serialised cookie array. *
| /** * Get the contents from a serialised cookie array. *
|
Zeile 1143 | Zeile 1140 |
---|
function my_get_array_cookie($name, $id) { if(!isset($_COOKIE['mybb'][$name]))
|
function my_get_array_cookie($name, $id) { if(!isset($_COOKIE['mybb'][$name]))
|
{
| {
|
return false; } $cookie = unserialize($_COOKIE['mybb'][$name]); if(isset($cookie[$id]))
|
return false; } $cookie = unserialize($_COOKIE['mybb'][$name]); if(isset($cookie[$id]))
|
{
| {
|
return $cookie[$id];
|
return $cookie[$id];
|
}
| }
|
else { return 0;
|
else { return 0;
|
} }
| } }
|
/** * Set a serialised cookie array. *
| /** * Set a serialised cookie array. *
|
Zeile 1185 | Zeile 1182 |
---|
{ return $lang->unknown; }
|
{ return $lang->unknown; }
|
elseif(@file_exists("/proc/loadavg"))
| elseif(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
|
{
|
{
|
$load = @file_get_contents("/proc/loadavg");
| |
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); if(!$serverload)
| $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); if(!$serverload)
|
Zeile 1195 | Zeile 1191 |
---|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
|
} } else {
| } } else {
|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
| $load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
|
Zeile 1212 | Zeile 1208 |
---|
}
/**
|
}
/**
|
* Update the forum counters for a specific forum
| * Updates the forum statistics with specific values (or addition/subtraction of the previous value) * * @param array Array of items being updated (numthreads,numposts,numusers) */ function update_stats($changes=array()) { global $cache, $db;
$stats = $cache->read("stats");
$counters = array('numthreads','numposts','numusers'); $update = array(); foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $new_stats[$counter] = $stats[$counter] + $changes[$counter]; } else { $new_stats[$counter] = $changes[$counter]; } // Less than 0? That's bad if($new_stats[$counter] < 0) { $new_stats[$counter] = 0; } } }
// Fetch latest user if the user count is changing if(array_key_exists('numusers', $changes)) { $query = $db->simple_select(TABLE_PREFIX."users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1)); $lastmember = $db->fetch_array($query); $new_stats['lastuid'] = $lastmember['uid']; $new_stats['lastusername'] = $lastmember['username']; } if(is_array($stats)) { $stats = array_merge($stats, $new_stats); } else { $stats = $new_stats; } $cache->update("stats", $stats); }
/** * Updates the forum counters with a specific value (or addition/subtraction of the previous value)
|
* * @param int The forum ID
|
* * @param int The forum ID
|
| * @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)
|
*/
|
*/
|
function update_forum_count($fid)
| function update_forum_counters($fid, $changes=array())
|
{ global $db, $cache;
|
{ global $db, $cache;
|
| $update_query = array();
$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts');
// Fetch above counters for this forum $query = $db->simple_select(TABLE_PREFIX."forums", implode(",", $counters), "fid='{$fid}'"); $forum = $db->fetch_array($query);
foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $update_query[$counter] = $forum[$counter] + $changes[$counter]; } else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if($update_query[$counter] < 0) { $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query(TABLE_PREFIX."forums", $update_query, "fid='".intval($fid)."'"); }
// Guess we should update the statistics too? if($update_query['threads'] || $update_query['posts']) { $new_stats = array(); if(array_key_exists('threads', $update_query)) { $threads_diff = $update_query['threads'] - $forum['threads']; if($threads_diff > -1) { $new_stats['numthreads'] = "+{$threads_diff}"; } else { $new_stats['numthreads'] = "{$threads_diff}"; } } if(array_key_exists('posts', $update_query)) { $posts_diff = $update_query['posts'] - $forum['posts']; if($posts_diff > -1) { $new_stats['numposts'] = "+{$posts_diff}"; } else { $new_stats['numposts'] = "{$posts_diff}"; } } update_stats($new_stats); }
// Update last post info update_forum_lastpost($fid); }
/** * Update the last post information for a specific forum * * @param int The forum ID */ function update_forum_lastpost($fid) { global $db;
|
// Fetch the last post for this forum $query = $db->query(" SELECT tid, lastpost, lastposter, lastposteruid, subject
| // Fetch the last post for this forum $query = $db->query(" SELECT tid, lastpost, lastposter, lastposteruid, subject
|
Zeile 1228 | Zeile 1357 |
---|
ORDER BY lastpost DESC LIMIT 0, 1 ");
|
ORDER BY lastpost DESC LIMIT 0, 1 ");
|
$lastpost = $db->fetch_array($query);
// Fetch the number of threads and replies in this forum (Approved only) $query = $db->query(" SELECT COUNT(*) AS threads, SUM(replies) AS replies FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%' "); $count = $db->fetch_array($query); $count['posts'] = $count['threads'] + $count['replies'];
// Fetch the number of threads and replies in this forum (Unapproved only) $query = $db->query(" SELECT COUNT(*) AS threads FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%' "); $unapproved_count['threads'] = $db->fetch_field($query, "threads"); $query = $db->query(" SELECT SUM(unapprovedposts) AS posts FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND closed NOT LIKE 'moved|%' "); $unapproved_count['posts'] = $db->fetch_field($query, "posts");
| $lastpost = $db->fetch_array($query);
|
|
|
$update_count = array( "posts" => intval($count['posts']), "threads" => intval($count['threads']), "unapprovedposts" => intval($unapproved_count['posts']), "unapprovedthreads" => intval($unapproved_count['threads']),
| $updated_forum = array(
|
"lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']), "lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']) );
|
"lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']), "lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']) );
|
$db->update_query(TABLE_PREFIX."forums", $update_count, "fid='{$fid}'");
| $db->update_query(TABLE_PREFIX."forums", $updated_forum, "fid='{$fid}'"); }
/** * Updates the thread counters with a specific value (or addition/subtraction of the previous value) * * @param int The thread ID * @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1) */ function update_thread_counters($tid, $changes=array()) { global $db;
$update_query = array(); $counters = array('replies', 'unapprovedposts', 'attachmentcount');
// Fetch above counters for this thread $query = $db->simple_select(TABLE_PREFIX."threads", implode(",", $counters), "tid='{$tid}'"); $thread = $db->fetch_array($query); foreach($counters as $counter) { if(array_key_exists($counter, $changes)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $update_query[$counter] = $thread[$counter] + $changes[$counter]; } else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if($update_query[$counter] < 0) { $update_query[$counter] = 0; } } }
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query(TABLE_PREFIX."threads", $update_query, "tid='".intval($tid)."'"); }
update_thread_data($tid);
|
}
/**
|
}
/**
|
* Update the thread counters for a specific thread
| * Update the first post and lastpost data for a specific thread
|
* * @param int The thread ID */
|
* * @param int The thread ID */
|
function update_thread_count($tid) { global $db, $cache; $query = $db->query(" SELECT COUNT(*) AS replies FROM ".TABLE_PREFIX."posts WHERE tid='$tid' AND visible='1' "); $replies = $db->fetch_array($query); $treplies = $replies['replies'] - 1; if($treplies < 0) { $treplies = 0; } $query = $db->query("
| function update_thread_data($tid) { global $db; $query = $db->query("
|
SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
| FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
|
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"
|
Zeile 1299 | Zeile 1438 |
---|
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
| FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
|
WHERE p.tid='$tid' ORDER BY p.dateline ASC
|
WHERE p.tid='$tid' ORDER BY p.dateline ASC
|
LIMIT 0,1
| LIMIT 1
|
"); $firstpost = $db->fetch_array($query);
|
"); $firstpost = $db->fetch_array($query);
|
|
|
if(!$firstpost['username']) { $firstpost['username'] = $firstpost['postusername']; }
|
if(!$firstpost['username']) { $firstpost['username'] = $firstpost['postusername']; }
|
|
|
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername']; }
|
if(!$lastpost['username']) { $lastpost['username'] = $lastpost['postusername']; }
|
|
|
if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username']; $lastpost['uid'] = $firstpost['uid']; $lastpost['dateline'] = $firstpost['dateline'];
|
if(!$lastpost['dateline']) { $lastpost['username'] = $firstpost['username']; $lastpost['uid'] = $firstpost['uid']; $lastpost['dateline'] = $firstpost['dateline'];
|
}
| }
|
$lastpost['username'] = $db->escape_string($lastpost['username']); $firstpost['username'] = $db->escape_string($firstpost['username']);
|
$lastpost['username'] = $db->escape_string($lastpost['username']); $firstpost['username'] = $db->escape_string($firstpost['username']);
|
// Unapproved posts $query = $db->query(" SELECT COUNT(*) AS totunposts FROM ".TABLE_PREFIX."posts WHERE tid='$tid' AND visible='0' "); $nounposts = $db->fetch_field($query, "totunposts");
| |
|
|
// Update the attachment count for this thread update_thread_attachment_count($tid); $db->query(" UPDATE ".TABLE_PREFIX."threads SET username='".$firstpost['username']."', uid='".intval($firstpost['uid'])."', lastpost='".intval($lastpost['dateline'])."', lastposter='".$lastpost['username']."', lastposteruid='".intval($lastpost['uid'])."', replies='$treplies', unapprovedposts='$nounposts' WHERE tid='$tid' ");
| $update_array = array( 'username' => $firstpost['username'], 'uid' => intval($firstpost['uid']), 'lastpost' => intval($lastpost['dateline']), 'lastposter' => $lastpost['username'], 'lastposteruid' => intval($lastpost['uid']), ); $db->update_query(TABLE_PREFIX."threads", $update_array, "tid='{$tid}'");
|
}
|
}
|
/** * Updates the number of attachments for a specific thread * * @param int The thread ID */
| function update_forum_count($fid) { die("Depreciated function call: update_forum_count"); } function update_thread_count($tid) { die("Depreciated function call: update_thread_count"); }
|
function update_thread_attachment_count($tid) {
|
function update_thread_attachment_count($tid) {
|
global $db; $query = $db->query(" SELECT COUNT(*) AS attachment_count FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid) WHERE p.tid='$tid' "); $attachment_count = $db->fetch_field($query, "attachment_count"); $db->query(" UPDATE ".TABLE_PREFIX."threads SET attachmentcount='{$attachment_count}' WHERE tid='$tid' ");
| die("Depreciated function call: update_thread_attachment_count");
|
}
/**
| }
/**
|
Zeile 1626 | Zeile 1754 |
---|
*/ function build_clickable_smilies() {
|
*/ function build_clickable_smilies() {
|
global $db, $smiliecache, $theme, $templates, $lang, $mybb;
| global $db, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;
|
if($mybb->settings['smilieinserter'] != "off" && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) {
|
if($mybb->settings['smilieinserter'] != "off" && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot']) {
|
$smiliecount = 0;
| if(!$smiliecount) { $query = $db->simple_select(TABLE_PREFIX."smilies", "COUNT(*) as smilies"); $smiliecount = $db->fetch_field($query, "smilies"); }
|
if(!$smiliecache) {
|
if(!$smiliecache) {
|
$query = $db->query(" SELECT * FROM ".TABLE_PREFIX."smilies WHERE showclickable != 'no' ORDER BY disporder ");
| $query = $db->simple_select(TABLE_PREFIX."smilies", "*", "showclickable != 'no'", array('order_by' => 'disporder'));
|
while($smilie = $db->fetch_array($query)) { $smiliecache[$smilie['find']] = $smilie['image'];
|
while($smilie = $db->fetch_array($query)) { $smiliecache[$smilie['find']] = $smilie['image'];
|
$smiliecount++; }
| }
|
} unset($smilie); if(is_array($smiliecache)) { reset($smiliecache); if($mybb->settings['smilieinsertertot'] >= $smiliecount)
|
} unset($smilie); if(is_array($smiliecache)) { reset($smiliecache); if($mybb->settings['smilieinsertertot'] >= $smiliecount)
|
{
| {
|
$mybb->settings['smilieinsertertot'] = $smiliecount; } elseif ($mybb->settings['smilieinsertertot'] < $smiliecount)
|
$mybb->settings['smilieinsertertot'] = $smiliecount; } elseif ($mybb->settings['smilieinsertertot'] < $smiliecount)
|
{
| {
|
$smiliecount = $mybb->settings['smilieinsertertot']; eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";"); }
| $smiliecount = $mybb->settings['smilieinsertertot']; eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";"); }
|
Zeile 1665 | Zeile 1792 |
---|
foreach($smiliecache as $find => $image) { if($i < $mybb->settings['smilieinsertertot'])
|
foreach($smiliecache as $find => $image) { if($i < $mybb->settings['smilieinsertertot'])
|
{
| {
|
if($counter == 0) { $smilies .= "<tr>\n"; }
|
if($counter == 0) { $smilies .= "<tr>\n"; }
|
$find = $db->escape_string(htmlspecialchars($find));
| $find = htmlspecialchars_uni($find);
|
$smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n"; $i++; $counter++;
| $smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n"; $i++; $counter++;
|
Zeile 1687 | Zeile 1814 |
---|
$smilies .= "<td colspan=\"{$colspan}\"> </td>\n</tr>\n"; } eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
|
$smilies .= "<td colspan=\"{$colspan}\"> </td>\n</tr>\n"; } eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
|
}
| }
|
else { $clickablesmilies = "";
|
else { $clickablesmilies = "";
|
} } else {
| } } else {
|
$clickablesmilies = ""; } return $clickablesmilies;
| $clickablesmilies = ""; } return $clickablesmilies;
|
Zeile 1778 | Zeile 1905 |
---|
// Any remaining extra data - we serialize and insert in to its own column if(is_array($data))
|
// Any remaining extra data - we serialize and insert in to its own column if(is_array($data))
|
{
| {
|
$data = serialize($data); }
| $data = serialize($data); }
|
Zeile 1791 | Zeile 1918 |
---|
"tid" => $tid, "action" => $db->escape_string($action), "data" => $db->escape_string($data),
|
"tid" => $tid, "action" => $db->escape_string($action), "data" => $db->escape_string($data),
|
"ipaddress" => $session->ipaddress
| "ipaddress" => $db->escape_string($session->ipaddress)
|
); $db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array); }
| ); $db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array); }
|
Zeile 1807 | Zeile 1934 |
---|
{ global $theme;
|
{ global $theme;
|
if($uid != 0)
| if($uid != 0)
|
{ $display_reputation = "<a href=\"reputation.php?uid={$uid}\">"; }
| { $display_reputation = "<a href=\"reputation.php?uid={$uid}\">"; }
|
Zeile 1864 | Zeile 1991 |
---|
$ip = $_SERVER['REMOTE_ADDR']; } }
|
$ip = $_SERVER['REMOTE_ADDR']; } }
|
| $ip = preg_replace("#([^.0-9 ]*)#", "", $ip);
|
return $ip; }
| return $ip; }
|
Zeile 2188 | Zeile 2318 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n"; echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n"; echo "</tr>\n"; echo "<tr>\n";
|
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Proccessing Time:</font></b></td>\n";
| echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">MySQL Processing Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";
| echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">MySQL Processing Time:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";
|
Zeile 2231 | Zeile 2361 |
---|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";
| echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";
|
echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
| echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
|
Zeile 2244 | Zeile 2374 |
---|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
{ echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
| echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
|
echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", $templates->uncached_templates)."</td>\n";
| echo "</tr>\n"; echo "<tr>\n"; echo "<td style=\"background: #fff;\">".implode(", ", $templates->uncached_templates)."</td>\n";
|
Zeile 2270 | Zeile 2400 |
---|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
|
} }
/**
| } }
/**
|
* Mark specific reported posts of a certain type as dealt with * * @param mixed An array or int of the ID numbers you're marking as dealt with
| * Mark specific reported posts of a certain type as dealt with * * @param mixed An array or int of the ID numbers you're marking as dealt with
|
Zeile 2294 | Zeile 2424 |
---|
} break; case "post":
|
} break; case "post":
|
$db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
| $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
|
case "threads": if(is_array($id)) {
| case "threads": if(is_array($id)) {
|
Zeile 2306 | Zeile 2436 |
---|
break; case "thread": $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "tid='$id' AND reportstatus='0'");
|
break; case "thread": $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "tid='$id' AND reportstatus='0'");
|
break;
| break;
|
case "forum": $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "fid='$id' AND reportstatus='0'"); break;
| case "forum": $db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "fid='$id' AND reportstatus='0'"); break;
|
Zeile 2316 | Zeile 2446 |
---|
} $plugins->run_hooks("mark_reports"); $cache->updatereportedposts();
|
} $plugins->run_hooks("mark_reports"); $cache->updatereportedposts();
|
}
| }
|
/** * Fetch a friendly x days, y months etc date stamp from a timestamp *
| /** * Fetch a friendly x days, y months etc date stamp from a timestamp *
|
Zeile 2334 | Zeile 2464 |
---|
$dsecs = 24*60*60; $hsecs = 60*60; $msecs = 60;
|
$dsecs = 24*60*60; $hsecs = 60*60; $msecs = 60;
|
|
|
$years = floor($stamp/$ysecs); $stamp %= $ysecs; $months = floor($stamp/$mosecs);
| $years = floor($stamp/$ysecs); $stamp %= $ysecs; $months = floor($stamp/$mosecs);
|
Zeile 2350 | Zeile 2480 |
---|
$seconds = $stamp;
if($years == 1)
|
$seconds = $stamp;
if($years == 1)
|
{
| {
|
$nicetime['years'] = "1 ".$lang->year; } elseif($years > 1)
| $nicetime['years'] = "1 ".$lang->year; } elseif($years > 1)
|
Zeile 2361 | Zeile 2491 |
---|
if($months == 1) { $nicetime['months'] = "1 ".$lang->month;
|
if($months == 1) { $nicetime['months'] = "1 ".$lang->month;
|
}
| }
|
elseif($months > 1) { $nicetime['months'] = $months." ".$lang->months;
|
elseif($months > 1) { $nicetime['months'] = $months." ".$lang->months;
|
}
| }
|
if($weeks == 1) { $nicetime['weeks'] = "1 ".$lang->week;
| if($weeks == 1) { $nicetime['weeks'] = "1 ".$lang->week;
|
Zeile 2377 | Zeile 2507 |
---|
}
if($days == 1)
|
}
if($days == 1)
|
{
| {
|
$nicetime['days'] = "1 ".$lang->day; } elseif($days > 1)
| $nicetime['days'] = "1 ".$lang->day; } elseif($days > 1)
|
Zeile 2392 | Zeile 2522 |
---|
elseif($hours > 1) { $nicetime['hours'] = $hours." ".$lang->hours;
|
elseif($hours > 1) { $nicetime['hours'] = $hours." ".$lang->hours;
|
}
| }
|
if($minutes == 1) { $nicetime['minutes'] = "1 ".$lang->minute;
| if($minutes == 1) { $nicetime['minutes'] = "1 ".$lang->minute;
|
Zeile 2404 | Zeile 2534 |
---|
}
if($seconds == 1)
|
}
if($seconds == 1)
|
{ $nicetime['seconds'] = "1 ".$lang->seconds; }
| { $nicetime['seconds'] = "1 ".$lang->second; }
|
elseif($seconds > 1) { $nicetime['seconds'] = $seconds." ".$lang->seconds;
|
elseif($seconds > 1) { $nicetime['seconds'] = $seconds." ".$lang->seconds;
|
}
| }
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
} }
| } }
|
/** * Select an alternating row colour based on the previous call to this function
| /** * Select an alternating row colour based on the previous call to this function
|
Zeile 2431 | Zeile 2561 |
---|
$trow = "trow2"; } else
|
$trow = "trow2"; } else
|
{
| {
|
$trow = "trow1"; } $alttrow = $trow;
| $trow = "trow1"; } $alttrow = $trow;
|
Zeile 2447 | Zeile 2577 |
---|
function join_usergroup($uid, $joingroup) { global $db;
|
function join_usergroup($uid, $joingroup) { global $db;
|
if($uid == $mybb->user['uid']) { $user = $mybb->user; }
| if($uid == $mybb->user['uid']) { $user = $mybb->user; }
|
else { $query = $db->query("
| else { $query = $db->query("
|
Zeile 2492 | Zeile 2622 |
---|
* @param int The user group ID */ function leave_usergroup($uid, $leavegroup)
|
* @param int The user group ID */ function leave_usergroup($uid, $leavegroup)
|
{ global $db, $mybb;
| { global $db, $mybb;
|
if($uid == $mybb->user['uid']) { $user = $mybb->user;
| if($uid == $mybb->user['uid']) { $user = $mybb->user;
|
Zeile 2612 | Zeile 2742 |
---|
*/ function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0) {
|
*/ function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0) {
|
global $db, $themeselect, $tcache, $lang, $mybb;
| global $db, $themeselect, $tcache, $lang, $mybb, $limit;
|
if($tid == 0)
|
if($tid == 0)
|
{
| {
|
$themeselect = "<select name=\"$name\">"; $themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n"; $themeselect .= "<option value=\"0\">-----------</option>\n";
|
$themeselect = "<select name=\"$name\">"; $themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n"; $themeselect .= "<option value=\"0\">-----------</option>\n";
|
}
| $tid = 1; }
|
if(!is_array($tcache)) {
|
if(!is_array($tcache)) {
|
$query = $db->query(" SELECT name, pid, tid, allowedgroups FROM ".TABLE_PREFIX."themes WHERE pid != 0 ORDER BY pid, name ");
| $query = $db->simple_select(TABLE_PREFIX."themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));
|
while($theme = $db->fetch_array($query)) {
|
while($theme = $db->fetch_array($query)) {
|
$tcache[$theme['pid']][] = $theme;
| $tcache[$theme['pid']][$theme['tid']] = $theme;
|
} }
|
} }
|
if(is_array($tcache))
| if(is_array($tcache[$tid]))
|
{ // Figure out what groups this user is in if($mybb->user['additionalgroups'])
| { // Figure out what groups this user is in if($mybb->user['additionalgroups'])
|
Zeile 2641 | Zeile 2771 |
---|
} $in_groups[] = $mybb->user['usergroup'];
|
} $in_groups[] = $mybb->user['usergroup'];
|
foreach($tcache as $misc)
| foreach($tcache[$tid] as $theme)
|
{
|
{
|
foreach($misc as $theme)
| $sel = ""; // Make theme allowed groups into array $is_allowed = false; if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")
|
{
|
{
|
$sel = ""; // Make theme allowed groups into array $is_allowed = false; if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")
| $allowed_groups = explode(",", $theme['allowedgroups']); // See if groups user is in is allowed foreach($allowed_groups as $agid)
|
{
|
{
|
$allowed_groups = explode(",", $theme['allowedgroups']); // See if groups user is in is allowed foreach($allowed_groups as $agid)
| if(in_array($agid, $in_groups))
|
{
|
{
|
if(in_array($agid, $in_groups)) { $is_allowed = true; break; }
| $is_allowed = true; break;
|
} }
|
} }
|
// Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == 1)
| } // Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1) { if($theme['tid'] == $selected) { $sel = " selected=\"selected\""; } if($theme['pid'] != 0) { $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--"; } if(array_key_exists($theme['tid'], $tcache))
|
{
|
{
|
if($theme['tid'] == $selected) { $sel = " selected=\"selected\""; } if($theme['pid'] != 0) { $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--"; } if(array_key_exists($theme['tid'], $tcache)) { build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override); }
| build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
|
} } } }
|
} } } }
|
if(!$tid)
| if($tid)
|
{ $themeselect .= "</select>"; }
|
{ $themeselect .= "</select>"; }
|
|
|
return $themeselect; }
| return $themeselect; }
|
Zeile 2700 | Zeile 2832 |
---|
$message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("\"",""",$message);
|
$message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("\"",""",$message);
|
$message = str_replace(" ", " ", $message); return $message; }
| return $message; }
|
/** * Custom function for formatting numbers.
| /** * Custom function for formatting numbers.
|
Zeile 2714 | Zeile 2845 |
---|
{ global $mybb; if($number == "-")
|
{ global $mybb; if($number == "-")
|
{
| {
|
return $number; } if(is_int($number))
|
return $number; } if(is_int($number))
|
{
| {
|
return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); } else
| return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']); } else
|
Zeile 2733 | Zeile 2864 |
---|
$decimals = 0; } return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
$decimals = 0; } return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
}
| }
|
}
/**
| }
/**
|
Zeile 2825 | Zeile 2956 |
---|
* @return float The age of a user with that birthday. */ function get_age($birthday)
|
* @return float The age of a user with that birthday. */ function get_age($birthday)
|
{ $bday = explode("-", $birthday); if($bday[2] < 1970) { $years = 1970-$bday[2]; $year = $bday[2]+($years*2); $stamp = mktime(0, 0, 0, $bday[1], $bday[0], $year)-($years*31556926*2); } else { $stamp = mktime(0, 0, 0, $bday[1], $bday[0], $bday[2]); } $age = floor((time()-$stamp)/31556926); return $age;
| { $bday = explode("-", $birthday); if(!$bday[2]) { return; }
list($day, $month, $year) = explode("-", my_date("j-n-Y", time(), 0, 0));
$age = $year-$bday[2];
if(($month == $bday[1] && $day < $bday[1]) || $month < $bday[1]) { --$age; } return $age;
|
}
/**
| }
/**
|
Zeile 2869 | Zeile 3002 |
---|
/** * Checks for the length of a string, mb strings accounted for
|
/** * Checks for the length of a string, mb strings accounted for
|
*
| *
|
* @param string The string to check the length of. * @return int The length of the string.
|
* @param string The string to check the length of. * @return int The length of the string.
|
*/
| */
|
function my_strlen($string)
|
function my_strlen($string)
|
{ $string = preg_replace("#&\#(0-9]+);#", "-", $string); if(function_exists("mb_strlen")) { $string_length = mb_strlen($string); } else { $string_length = strlen($string); }
| { global $lang;
$string = preg_replace("#&\#(0-9]+);#", "-", $string);
if(strtolower($lang->settings['charset']) == "utf-8") { // Get rid of any excess RTL and LTR override for they are the workings of the devil $string = str_replace(dec_to_utf8(8238), "", $string); $string = str_replace(dec_to_utf8(8237), "", $string);
// Remove dodgy whitspaces $string = str_replace(chr(0xCA), "", $string); } $string = trim($string);
if(function_exists("mb_strlen")) { $string_length = mb_strlen($string); } else { $string_length = strlen($string); }
|
|
|
return $string_length;
| return $string_length;
|
}
/**
| }
/**
|
Zeile 2904 | Zeile 3051 |
---|
{ $cut_string = mb_substr($string, $start, $length); }
|
{ $cut_string = mb_substr($string, $start, $length); }
|
else { $cut_string = mb_substr($string, $start); } } else
| else { $cut_string = mb_substr($string, $start); } } else
|
{ if($length != "") {
| { if($length != "") {
|
Zeile 2919 | Zeile 3066 |
---|
{ $cut_string = substr($string, $start); }
|
{ $cut_string = substr($string, $start); }
|
}
| }
|
return $cut_string;
|
return $cut_string;
|
| }
/** * lowers the case of a string, mb strings accounted for * * @param string The string to lower. * @return int The lowered string. */ function my_strtolower($string) { if(function_exists("mb_strtolower")) { $string = mb_strtolower($string); } else { $string = strtolower($string); }
return $string; }
/** * Finds a needle in a haystack and returns it position, mb strings accounted for * * @param string String to look in (haystack) * @param string What to look for (needle) * @param int (optional) How much to offset * @return int false on needle not found, integer position if found */ function my_strpos($haystack, $needle, $offset=0) { if($needle == '') { return false; }
if(function_exists("mb_strpos")) { $position = mb_strpos($haystack, $needle, $offset); } else { $position = strpos($haystack, $needle, $offset); }
return $position; }
/** * ups the case of a string, mb strings accounted for * * @param string The string to up. * @return int The uped string. */ function my_strtoupper($string) { if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string); } else { $string = strtoupper($string); }
return $string;
|
}
/**
| }
/**
|
Zeile 2932 | Zeile 3146 |
---|
*/ function unhtmlentities($string) {
|
*/ function unhtmlentities($string) {
|
// replace numeric entities
| // Replace numeric entities
|
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
// replace literal entities
| // Replace literal entities
|
$trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
|
$trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
|
|
|
return strtr($string, $trans_tbl); }
| return strtr($string, $trans_tbl); }
|
Zeile 3302 | Zeile 3518 |
---|
*/ function validate_email_format($email) {
|
*/ function validate_email_format($email) {
|
if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email))
| if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email) || strpos($email, ' ') !== false)
|
{ return false; }
| { return false; }
|
Zeile 3336 | Zeile 3552 |
---|
while($setting = $db->fetch_array($query)) {
|
while($setting = $db->fetch_array($query)) {
|
$setting['value'] = str_replace("\"", "\\\"", $setting['value']); $settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
| |
$mybb->settings[$setting['name']] = $setting['value'];
|
$mybb->settings[$setting['name']] = $setting['value'];
|
| $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
} $settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">"; $file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
| } $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);
|
Zeile 3388 | Zeile 3604 |
---|
return false; } return $dest;
|
return false; } return $dest;
|
| }
/** * Return a list of banned usernames. * * @return array The array of banned usernames. */ function get_banned_usernames() { global $mybb; $banned_usernames = explode(",", $mybb->settings['bannedusernames']); $banned_usernames = array_map("trim", $banned_usernames); $banned_usernames = array_map("strtolower", $banned_usernames); return $banned_usernames; }
/** * Checks if a username has been disallowed for registration/use. * * @param string The username * @return boolean True if banned, false if not banned */ function is_banned_username($username) { $banned_usernames = get_banned_usernames(); if(in_array(strtolower($username), $banned_usernames)) { return true; } else { return false; } }
/** * Return a list of banned email addresses. * * @return array The array of banned email addresses. */ function get_banned_emails() { global $mybb; $banned_emails = explode(",", $mybb->settings['bannedemails']); $banned_emails = array_map("trim", $banned_emails); $banned_emails = array_map("strtolower", $banned_emails); return $banned_emails; }
/** * Check if a specific email address has been banned. * * @param string The email address. * @return boolean True if banned, false if not banned */ function is_banned_email($email) { $banned_emails = get_banned_emails(); $email = strtolower($email); foreach($banned_emails as $banned_email) { if($banned_email != "" && strpos($email, $banned_email) !== false) { return true; } } return false; }
/** * Return a list of banned IP addresses. * * @return array The array of banned IP addresses. */ function get_banned_ips() { global $mybb; $banned_ips = explode(",", $mybb->settings['bannedips']); $banned_ips = array_map("trim", $banned_ips); return $banned_ips; }
/** * Checks if a specific IP address has been banned. * * @param string The IP address. * @return boolean True if banned, false if not banned. */ function is_banned_ip($ip_address) { $banned_ips = get_banned_ips(); foreach($banned_ips as $banned_ip) { if($banned_ip != "" && strpos($ip_address, $banned_ip) !== false) { return true; } } return false;
|
}
/**
| }
/**
|