Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: functions.php 5172 2010-08-02 23:13:03Z RyanGordon $
| * $Id: functions.php 5765 2012-03-27 09:52:45Z Tomm $
|
*/
/**
| */
/**
|
Zeile 92 | Zeile 92 |
---|
echo $contents;
$plugins->run_hooks("post_output_page");
|
echo $contents;
$plugins->run_hooks("post_output_page");
|
// If the use shutdown functionality is turned off, run any shutdown related items now. if($mybb->settings['useshutdownfunc'] == 0 && $mybb->use_shutdown != true) { run_shutdown(); }
| |
}
/**
| }
/**
|
Zeile 197 | Zeile 191 |
---|
}
// And finally.. plugins
|
}
// And finally.. plugins
|
if(!is_object($plugins) && !defined("NO_PLUGINS"))
| if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))
|
{ require_once MYBB_ROOT."inc/class_plugins.php"; $plugins = new pluginSystem;
| { require_once MYBB_ROOT."inc/class_plugins.php"; $plugins = new pluginSystem;
|
Zeile 246 | Zeile 240 |
---|
// Fetch emails for this page view - and send them $query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));
|
// Fetch emails for this page view - and send them $query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));
|
$plugins->run_hooks_by_ref("send_mail_queue_mail", $query);
| |
while($email = $db->fetch_array($query)) { // Delete the message from the queue $db->delete_query("mailqueue", "mid='{$email['mid']}'");
|
while($email = $db->fetch_array($query)) { // Delete the message from the queue $db->delete_query("mailqueue", "mid='{$email['mid']}'");
|
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
| if($db->affected_rows() == 1) { my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']); }
|
} // Update the mailqueue cache and remove the lock $cache->update_mailqueue(TIME_NOW, 0);
|
} // Update the mailqueue cache and remove the lock $cache->update_mailqueue(TIME_NOW, 0);
|
}
| }
|
$plugins->run_hooks("send_mail_queue_end"); }
| $plugins->run_hooks("send_mail_queue_end"); }
|
Zeile 395 | Zeile 390 |
---|
if(is_object($plugins)) {
|
if(is_object($plugins)) {
|
$plugins->run_hooks_by_ref("my_date", $date);
| $date = $plugins->run_hooks("my_date", $date);
|
}
return $date;
| }
return $date;
|
Zeile 502 | Zeile 497 |
---|
else { error($lang->invalid_post_code);
|
else { error($lang->invalid_post_code);
|
} }
| } }
|
} else {
| } else {
|
Zeile 534 | Zeile 529 |
---|
{ cache_forums(); return $forum_cache[$fid]['parentlist'];
|
{ cache_forums(); return $forum_cache[$fid]['parentlist'];
|
}
| }
|
}
/**
| }
/**
|
Zeile 561 | Zeile 556 |
---|
{ $builtlist .= "$sep$column='$val'"; $sep = " $joiner ";
|
{ $builtlist .= "$sep$column='$val'"; $sep = " $joiner ";
|
}
$builtlist .= ")";
| }
$builtlist .= ")";
|
return $builtlist; }
| return $builtlist; }
|
Zeile 584 | Zeile 579 |
---|
}
if(!$forum_cache)
|
}
if(!$forum_cache)
|
{
| {
|
$forum_cache = $cache->read("forums"); if(!$forum_cache) {
| $forum_cache = $cache->read("forums"); if(!$forum_cache) {
|
Zeile 593 | Zeile 588 |
---|
} } return $forum_cache;
|
} } return $forum_cache;
|
}
/**
| }
/**
|
* Generate an array of all child and descendant forums for a specific forum. * * @param int The forum ID
| * Generate an array of all child and descendant forums for a specific forum. * * @param int The forum ID
|
Zeile 615 | Zeile 610 |
---|
{ $forums_by_parent[$forum['pid']][$forum['fid']] = $forum; }
|
{ $forums_by_parent[$forum['pid']][$forum['fid']] = $forum; }
|
}
| }
|
} if(!is_array($forums_by_parent[$fid])) {
| } if(!is_array($forums_by_parent[$fid])) {
|
Zeile 644 | Zeile 639 |
---|
{ global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;
|
{ global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;
|
$plugins->run_hooks_by_ref("error", $error);
| $error = $plugins->run_hooks("error", $error);
|
if(!$error)
|
if(!$error)
|
{
| {
|
$error = $lang->unknown_error; }
| $error = $lang->unknown_error; }
|
Zeile 666 | Zeile 661 |
---|
$timenow = my_date($mybb->settings['dateformat'], TIME_NOW) . " " . my_date($mybb->settings['timeformat'], TIME_NOW); reset_breadcrumb();
|
$timenow = my_date($mybb->settings['dateformat'], TIME_NOW) . " " . my_date($mybb->settings['timeformat'], TIME_NOW); reset_breadcrumb();
|
add_breadcrumb($lang->error);
| add_breadcrumb($lang->error);
|
eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
| eval("\$errorpage = \"".$templates->get("error")."\";"); output_page($errorpage);
|
Zeile 696 | Zeile 691 |
---|
}
// AJAX error message?
|
}
// AJAX error message?
|
if($mybb->input['ajax']) {
| if($mybb->input['ajax']) {
|
$error = implode("\n\n", $errors); // Send our headers. @header("Content-type: text/html; charset={$lang->settings['charset']}");
| $error = implode("\n\n", $errors); // Send our headers. @header("Content-type: text/html; charset={$lang->settings['charset']}");
|
Zeile 732 | Zeile 727 |
---|
);
$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
|
);
$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
|
$url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
| |
if($mybb->input['ajax']) {
| if($mybb->input['ajax']) {
|
Zeile 749 | Zeile 743 |
---|
} else {
|
} else {
|
| // Redirect to where the user came from $redirect_url = $_SERVER['PHP_SELF']; if($_SERVER['QUERY_STRING']) { $redirect_url .= '?'.$_SERVER['QUERY_STRING']; }
$redirect_url = htmlspecialchars_uni($redirect_url); switch($mybb->settings['username_method']) { case 0: $lang_username = $lang->username; break; case 1: $lang_username = $lang->username1; break; case 2: $lang_username = $lang->username2; break; default: $lang_username = $lang->username; break; }
|
eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
| eval("\$errorpage = \"".$templates->get("error_nopermission")."\";"); }
|
Zeile 767 | Zeile 785 |
---|
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
|
$plugins->run_hooks_by_ref("redirect", $redirect_args);
| $plugins->run_hooks("redirect", $redirect_args);
|
if($mybb->input['ajax']) {
| if($mybb->input['ajax']) {
|
Zeile 815 | Zeile 833 |
---|
run_shutdown();
|
run_shutdown();
|
if(my_substr($url, 0, 7) !== 'http://')
| if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://')
|
{ header("Location: {$mybb->settings['bburl']}/{$url}"); }
| { header("Location: {$mybb->settings['bburl']}/{$url}"); }
|
Zeile 958 | Zeile 976 |
---|
*/ function fetch_page_url($url, $page) {
|
*/ function fetch_page_url($url, $page) {
|
// If no page identifier is specified we tack it on to the end of the URL if(strpos($url, "{page}") === false)
| if($page <= 1) { $find = array( "-page-{page}", "&page={page}", "{page}" );
// Remove "Page 1" to the defacto URL $url = str_replace($find, array("", "", $page), $url); return $url; } else if(strpos($url, "{page}") === false)
|
{
|
{
|
| // If no page identifier is specified we tack it on to the end of the URL
|
if(strpos($url, "?") === false)
|
if(strpos($url, "?") === false)
|
{
| {
|
$url .= "?"; } else { $url .= "&";
|
$url .= "?"; } else { $url .= "&";
|
}
| }
|
$url .= "page=$page";
|
$url .= "page=$page";
|
}
| }
|
else { $url = str_replace("{page}", $page, $url); }
|
else { $url = str_replace("{page}", $page, $url); }
|
|
|
return $url;
|
return $url;
|
}
| }
|
/** * Fetch the permissions for a specific user
| /** * Fetch the permissions for a specific user
|
Zeile 992 | Zeile 1024 |
---|
if($uid == 0) { $uid = $mybb->user['uid'];
|
if($uid == 0) { $uid = $mybb->user['uid'];
|
}
| }
|
// User id does not match current user, fetch permissions if($uid != $mybb->user['uid']) {
| // User id does not match current user, fetch permissions if($uid != $mybb->user['uid']) {
|
Zeile 1001 | Zeile 1033 |
---|
if($user_cache[$uid]['permissions']) { return $user_cache[$uid]['permissions'];
|
if($user_cache[$uid]['permissions']) { return $user_cache[$uid]['permissions'];
|
}
| }
|
// This user was not already cached, fetch their user information. if(!$user_cache[$uid])
| // This user was not already cached, fetch their user information. if(!$user_cache[$uid])
|
Zeile 1026 | Zeile 1058 |
---|
/** * Fetch the usergroup permissions for a specic group or series of groups combined
|
/** * Fetch the usergroup permissions for a specic group or series of groups combined
|
*
| *
|
* @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma) * @return array Array of permissions generated for the groups */
| * @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma) * @return array Array of permissions generated for the groups */
|
Zeile 1154 | Zeile 1186 |
---|
} }
|
} }
|
if(!is_array($forum_cache)) { $forum_cache = cache_forums();
if(!$forum_cache) { return false; } }
| if(!is_array($forum_cache)) { $forum_cache = cache_forums();
if(!$forum_cache) { return false; } }
|
if(!is_array($fpermcache)) { $fpermcache = $cache->read("forumpermissions");
| if(!is_array($fpermcache)) { $fpermcache = $cache->read("forumpermissions");
|
Zeile 1211 | Zeile 1243 |
---|
} $current_permissions = array();
|
} $current_permissions = array();
|
| $only_view_own_threads = 1;
|
foreach($groups as $gid) {
| foreach($groups as $gid) {
|
Zeile 1248 | Zeile 1281 |
---|
{ $current_permissions[$permission] = $access; }
|
{ $current_permissions[$permission] = $access; }
|
| }
if(!$level_permissions["canonlyviewownthreads"]) { $only_view_own_threads = 0;
|
} }
|
} }
|
| }
// Figure out if we can view more than our own threads if($only_view_own_threads == 0) { $current_permissions["canonlyviewownthreads"] = 0;
|
}
if(count($current_permissions) == 0)
| }
if(count($current_permissions) == 0)
|
Zeile 1358 | Zeile 1402 |
---|
*/ function get_moderator_permissions($fid, $uid="0", $parentslist="") {
|
*/ function get_moderator_permissions($fid, $uid="0", $parentslist="") {
|
global $mybb, $db;
| global $mybb, $cache, $db;
|
static $modpermscache;
if($uid < 1)
| static $modpermscache;
if($uid < 1)
|
Zeile 1370 | Zeile 1414 |
---|
{ return false; }
|
{ return false; }
|
if(!isset($modpermscache[$fid][$uid]))
| if(isset($modpermscache[$fid][$uid])) { return $modpermscache[$fid][$uid]; }
if(!$parentslist) { $parentslist = explode(',', get_parent_list($fid)); }
// Get user groups $perms = array(); $user = get_user($uid);
$groups = array($user['usergroup']);
if(!empty($user['additionalgroups'])) { $extra_groups = explode(",", $user['additionalgroups']);
foreach($extra_groups as $extra_group) { $groups[] = $extra_group; } }
$mod_cache = $cache->read("moderators");
foreach($mod_cache as $fid => $forum)
|
{
|
{
|
if(!$parentslist)
| if(!is_array($forum) || !in_array($fid, $parentslist))
|
{
|
{
|
$parentslist = get_parent_list($fid);
| // No perms or we're not after this forum continue; }
// User settings override usergroup settings if(is_array($forum['users'][$uid])) { $perm = $forum['users'][$uid]; foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
// Figure out the user permissions if($value == 0) { // The user doesn't have permission to set this action $perms[$action] = 0; } else { $perms[$action] = max($perm[$action], $perms[$action]); } } }
foreach($groups as $group) { if(!is_array($forum['usergroups'][$group])) { // There are no permissions set for this group continue; }
$perm = $forum['usergroups'][$group]; foreach($perm as $action => $value) { if(strpos($action, "can") === false) { continue; }
$perms[$action] = max($perm[$action], $perms[$action]); }
|
}
|
}
|
// Get user groups $query = $db->simple_select("users", "usergroup,additionalgroups", "uid='{$uid}'"); $usergroups = $db->fetch_array($query); $groups = "'{$usergroups['usergroup']}'"; if(!empty($usergroups['additionalgroups'])) { $groups .= ",'{$usergroups['additionalgroups']}'"; } $query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND fid='$fid'"); while($results = $db->fetch_array($query)) { $perms['caneditposts'] = max($perms['caneditposts'], $results['caneditposts']); $perms['candeleteposts'] = max($perms['candeleteposts'], $results['candeleteposts']); $perms['canviewips'] = max($perms['canviewips'], $results['canviewips']); $perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $results['canopenclosethreads']); $perms['canmanagethreads'] = max($perms['canmanagethreads'], $results['canmanagethreads']); $perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $results['canmovetononmodforum']); } $sql = build_parent_list($fid, "fid", "OR", $parentslist); $query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND {$sql}"); $uperms = $db->fetch_array($query); if(!$uperms && !$perms) { return false; } //Join the group permissions with the user permissions $perms['caneditposts'] = max($perms['caneditposts'], $uperms['caneditposts']); $perms['candeleteposts'] = max($perms['candeleteposts'], $uperms['candeleteposts']); $perms['canviewips'] = max($perms['canviewips'], $uperms['canviewips']); $perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $uperms['canopenclosethreads']); $perms['canmanagethreads'] = max($perms['canmanagethreads'], $uperms['canmanagethreads']); $perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $uperms['canmovetononmodforum']); $modpermscache[$fid][$uid] = $perms; } else { $perms = $modpermscache[$fid][$uid];
| |
}
|
}
|
| $modpermscache[$fid][$uid] = $perms;
|
return $perms; }
| return $perms; }
|
Zeile 1436 | Zeile 1512 |
---|
function is_moderator($fid="0", $action="", $uid="0") { global $mybb, $cache;
|
function is_moderator($fid="0", $action="", $uid="0") { global $mybb, $cache;
|
|
|
if($uid == 0) { $uid = $mybb->user['uid'];
| if($uid == 0) { $uid = $mybb->user['uid'];
|
Zeile 1458 | Zeile 1534 |
---|
{ $modcache = $cache->read('moderators'); if(!empty($modcache))
|
{ $modcache = $cache->read('moderators'); if(!empty($modcache))
|
{
| {
|
foreach($modcache as $modusers) { if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid']) {
|
foreach($modcache as $modusers) { if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid']) {
|
| return true; } elseif(isset($modusers['usergroups'][$user_perms['gid']])) { // Moderating usergroup
|
return true; } }
| return true; } }
|
Zeile 1491 | Zeile 1572 |
---|
} } }
|
} } }
|
|
|
/** * Generate a list of the posticons. *
| /** * Generate a list of the posticons. *
|
Zeile 1500 | Zeile 1581 |
---|
function get_post_icons() { global $mybb, $cache, $icon, $theme, $templates, $lang;
|
function get_post_icons() { global $mybb, $cache, $icon, $theme, $templates, $lang;
|
|
|
$listed = 0; if($mybb->input['icon']) {
| $listed = 0; if($mybb->input['icon']) {
|
Zeile 1519 | Zeile 1600 |
---|
foreach($posticons as $dbicon) {
|
foreach($posticons as $dbicon) {
|
| $dbicon['path'] = htmlspecialchars_uni($dbicon['path']); $dbicon['name'] = htmlspecialchars_uni($dbicon['name']);
|
if($icon == $dbicon['iid']) { $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>"; $no_icons_checked = "";
|
if($icon == $dbicon['iid']) { $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>"; $no_icons_checked = "";
|
} else
| } else
|
{ $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>"; }
| { $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>"; }
|
Zeile 1635 | Zeile 1719 |
---|
return false; }
|
return false; }
|
$cookie = unserialize($mybb->cookies['mybb'][$name]);
| $cookie = my_unserialize($mybb->cookies['mybb'][$name]);
|
|
|
if(isset($cookie[$id]))
| if(is_array($cookie) && isset($cookie[$id]))
|
{ return $cookie[$id]; } else { return 0;
|
{ return $cookie[$id]; } else { return 0;
|
} }
| } }
|
/** * Set a serialised cookie array.
|
/** * Set a serialised cookie array.
|
*
| *
|
* @param string The cookie identifier. * @param int The cookie content id. * @param string The value to set the cookie to.
|
* @param string The cookie identifier. * @param int The cookie content id. * @param string The value to set the cookie to.
|
*/ function my_set_array_cookie($name, $id, $value)
| */ function my_set_array_cookie($name, $id, $value, $expires="")
|
{ global $mybb; $cookie = $mybb->cookies['mybb'];
|
{ global $mybb; $cookie = $mybb->cookies['mybb'];
|
$newcookie = unserialize($cookie[$name]);
| $newcookie = my_unserialize($cookie[$name]);
|
$newcookie[$id] = $value; $newcookie = serialize($newcookie);
|
$newcookie[$id] = $value; $newcookie = serialize($newcookie);
|
my_setcookie("mybb[$name]", addslashes($newcookie));
| my_setcookie("mybb[$name]", addslashes($newcookie), $expires);
|
// Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie; }
|
// Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie; }
|
| /** * Verifies that data passed is an array * * @param array Data to unserialize * @return array Unserialized data array */ function my_unserialize($data) { $array = unserialize($data);
if(!is_array($array)) { $array = array(); }
return $array; }
|
/** * Returns the serverload of the system.
| /** * Returns the serverload of the system.
|
Zeile 1769 | Zeile 1872 |
---|
if($new_stats[$counter] < 0) { $new_stats[$counter] = 0;
|
if($new_stats[$counter] < 0) { $new_stats[$counter] = 0;
|
}
| }
|
} }
// Fetch latest user if the user count is changing if(array_key_exists('numusers', $changes))
|
} }
// Fetch latest user if the user count is changing if(array_key_exists('numusers', $changes))
|
{
| {
|
$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1)); $lastmember = $db->fetch_array($query); $new_stats['lastuid'] = $lastmember['uid'];
| $query = $db->simple_select("users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1)); $lastmember = $db->fetch_array($query); $new_stats['lastuid'] = $lastmember['uid'];
|
Zeile 1817 | Zeile 1920 |
---|
function update_forum_counters($fid, $changes=array()) { global $db, $cache;
|
function update_forum_counters($fid, $changes=array()) { global $db, $cache;
|
|
|
$update_query = array();
|
$update_query = array();
|
|
|
$counters = array('threads','unapprovedthreads','posts','unapprovedposts');
|
$counters = array('threads','unapprovedthreads','posts','unapprovedposts');
|
|
|
// Fetch above counters for this forum $query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'"); $forum = $db->fetch_array($query);
|
// Fetch above counters for this forum $query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'"); $forum = $db->fetch_array($query);
|
foreach($counters as $counter) { if(array_key_exists($counter, $changes)) {
| 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) == "-")
|
// Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
|
{
| {
|
$update_query[$counter] = $forum[$counter] + $changes[$counter];
|
$update_query[$counter] = $forum[$counter] + $changes[$counter];
|
}
| }
|
else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad
|
else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad
|
if($update_query[$counter] < 0)
| if(!$update_query[$counter])
|
{ $update_query[$counter] = 0; }
| { $update_query[$counter] = 0; }
|
Zeile 2009 | Zeile 2112 |
---|
function update_thread_data($tid) { global $db;
|
function update_thread_data($tid) { global $db;
|
| $thread = get_thread($tid);
// If this is a moved thread marker, don't update it - we need it to stay as it is if(strpos($thread['closed'], 'moved|') !== false) { return false; }
|
$query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p
| $query = $db->query(" SELECT u.uid, u.username, p.username AS postusername, p.dateline FROM ".TABLE_PREFIX."posts p
|
Zeile 2322 | Zeile 2434 |
---|
"editor_enter_image", "editor_enter_video_url", "editor_video_dailymotion",
|
"editor_enter_image", "editor_enter_video_url", "editor_video_dailymotion",
|
"editor_video_googlevideo",
| |
"editor_video_metacafe", "editor_video_myspacetv", "editor_video_vimeo",
| "editor_video_metacafe", "editor_video_myspacetv", "editor_video_vimeo",
|
Zeile 2341 | Zeile 2452 |
---|
); $editor_language = "var editor_language = {\n";
|
); $editor_language = "var editor_language = {\n";
|
$plugins->run_hooks_by_ref("mycode_add_codebuttons", $editor_lang_strings);
| $editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);
|
foreach($editor_lang_strings as $key => $lang_string) {
| foreach($editor_lang_strings as $key => $lang_string) {
|
Zeile 2467 | Zeile 2578 |
---|
}
return $clickablesmilies;
|
}
return $clickablesmilies;
|
| }
/** * Builds thread prefixes and returns a selected prefix (or all) * * @param int The prefix ID (0 to return all) * @return array The thread prefix's values (or all thread prefixes) */ function build_prefixes($pid=0) { global $cache; static $prefixes_cache;
if(is_array($prefixes_cache)) { if($pid > 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid]; }
return $prefixes_cache; }
$prefix_cache = $cache->read("threadprefixes");
if(!is_array($prefix_cache)) { // No cache $prefix_cache = $cache->read("threadprefixes", true);
if(!is_array($prefix_cache)) { return array(); } }
$prefixes_cache = array(); foreach($prefix_cache as $prefix) { $prefixes_cache[$prefix['pid']] = $prefix; }
if($pid != 0 && is_array($prefixes_cache[$pid])) { return $prefixes_cache[$pid]; } else if(!empty($prefixes_cache)) { return $prefixes_cache; }
return false;
|
}
/**
| }
/**
|
Zeile 2478 | Zeile 2641 |
---|
*/ function build_prefix_select($fid, $selected_pid=0, $multiple=0) {
|
*/ function build_prefix_select($fid, $selected_pid=0, $multiple=0) {
|
global $db, $lang, $mybb;
| global $cache, $db, $lang, $mybb;
|
if($fid != 'all') { $fid = intval($fid);
|
if($fid != 'all') { $fid = intval($fid);
|
}
// Does this user have additional groups?
| }
$prefix_cache = build_prefixes(0); if(!$prefix_cache) { return false; // We've got no prefixes to show }
$groups = array($mybb->user['usergroup']);
|
if($mybb->user['additionalgroups']) { $exp = explode(",", $mybb->user['additionalgroups']);
|
if($mybb->user['additionalgroups']) { $exp = explode(",", $mybb->user['additionalgroups']);
|
// Because we like apostrophes... $imps = array();
| |
foreach($exp as $group)
|
foreach($exp as $group)
|
{ $imps[] = "'{$group}'"; }
$additional_groups = implode(",", $imps); $extra_sql = "groups IN ({$additional_groups}) OR "; } else { $extra_sql = '';
| { $groups[] = $group; }
|
}
|
}
|
switch($db->type)
| // Go through each of our prefixes and decide which ones we can use $prefixes = array(); foreach($prefix_cache as $prefix)
|
{
|
{
|
case "pgsql": case "sqlite": $whereforum = ""; if($fid != 'all') { $whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')"; } $query = $db->query(" SELECT pid, prefix FROM ".TABLE_PREFIX."threadprefixes WHERE ({$extra_sql}','||groups||',' LIKE '%,{$mybb->user['usergroup']},%' OR ','||groups||',' LIKE '%,-1,%' OR groups='') {$whereforum} "); break; default: $whereforum = ""; if($fid != 'all') { $whereforum = " AND (CONCAT(',',forums,',') LIKE '%,{$fid},%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='')"; } $query = $db->query(" SELECT pid, prefix FROM ".TABLE_PREFIX."threadprefixes WHERE ({$extra_sql}CONCAT(',',groups,',') LIKE '%,{$mybb->user['usergroup']},%' OR CONCAT(',',groups,',') LIKE '%,-1,%' OR groups='') {$whereforum} "); } $prefixselect = ""; if($db->num_rows($query) > 0) { $multipleselect = ""; if($multiple != 0) { $multipleselect = " multiple=\"multiple\" size=\"5\"";
| if($fid != "all" && $prefix['forums'] != "-1") { // Decide whether this prefix can be used in our forum $forums = explode(",", $prefix['forums']);
if(!in_array($fid, $forums)) { // This prefix is not in our forum list continue; }
|
}
|
}
|
$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n"; if($multiple == 1)
| if($prefix['groups'] != "-1")
|
{
|
{
|
$any_selected = ""; if($selected_pid == 'any')
| $prefix_groups = explode(",", $prefix['groups']);
foreach($groups as $group)
|
{
|
{
|
$any_selected = " selected=\"selected\""; } $prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n"; } $default_selected = ""; if((intval($selected_pid) == 0) && $selected_pid != 'any')
| if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']])) { // Our group can use this prefix! $prefixes[$prefix['pid']] = $prefix; } } } else
|
{
|
{
|
$default_selected = " selected=\"selected\"";
| // This prefix is for anybody to use... $prefixes[$prefix['pid']] = $prefix;
|
}
|
}
|
$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n"; while($prefix = $db->fetch_array($query))
| }
if(empty($prefixes)) { return false; }
$prefixselect = ""; $multipleselect = ""; if($multiple != 0) { $multipleselect = " multiple=\"multiple\" size=\"5\""; }
$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";
if($multiple == 1) { $any_selected = ""; if($selected_pid == 'any') { $any_selected = " selected=\"selected\""; }
$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n"; }
$default_selected = ""; if((intval($selected_pid) == 0) && $selected_pid != 'any') { $default_selected = " selected=\"selected\""; }
$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";
foreach($prefixes as $prefix) { $selected = ""; if($prefix['pid'] == $selected_pid)
|
{
|
{
|
$selected = ""; if($prefix['pid'] == $selected_pid) { $selected = " selected=\"selected\""; } $prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
| $selected = " selected=\"selected\"";
|
}
|
}
|
$prefixselect .= "</select>\n ";
| $prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
|
}
|
}
|
| $prefixselect .= "</select>\n ";
|
return $prefixselect; }
| return $prefixselect; }
|
Zeile 2762 | Zeile 2927 |
---|
*/ function get_ip() {
|
*/ function get_ip() {
|
if(isset($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses))
| global $mybb, $plugins;
$ip = 0;
if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; }
if($mybb->settings['ip_forwarded_check']) { if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses); } elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses); }
if(is_array($addresses[0]))
|
{ foreach($addresses[0] as $key => $val) {
| { foreach($addresses[0] as $key => $val) {
|
Zeile 2779 | Zeile 2958 |
---|
} } }
|
} } }
|
}
| }
if(!$ip) { if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } }
|
|
|
if(!isset($ip)) { if(isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = ''; } }
| if($plugins) { $ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function. $plugins->run_hooks("get_ip", $ip_array); }
|
|
|
$ip = preg_replace("#([^.0-9 ]*)#", "", $ip); return $ip;
| return $ip;
|
}
/**
| }
/**
|
Zeile 2945 | Zeile 3125 |
---|
$permissioncache = forum_permissions(); }
|
$permissioncache = forum_permissions(); }
|
| $password_forums = array();
|
foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
| foreach($forum_cache as $fid => $forum) { if($permissioncache[$forum['fid']])
|
Zeile 2963 | Zeile 3144 |
---|
if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password'])) { $pwverified = 0;
|
| } $password_forums[$forum['fid']] = $forum['password']; } else { // Check parents for passwords $parents = explode(",", $forum['parentlist']); foreach($parents as $parent) { if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent])) { $pwverified = 0; }
|
} }
| } }
|
Zeile 3038 | Zeile 3233 |
---|
$sep = $multipage_dropdown.$sep; } }
|
$sep = $multipage_dropdown.$sep; } }
|
| // 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")."\";"); } }
|
Zeile 3056 | Zeile 3255 |
---|
eval("\$donenav = \"".$templates->get("nav")."\";");
return $donenav;
|
eval("\$donenav = \"".$templates->get("nav")."\";");
return $donenav;
|
}
| }
|
/** * Add a breadcrumb menu item to the list. *
| /** * Add a breadcrumb menu item to the list. *
|
Zeile 3067 | Zeile 3266 |
---|
function add_breadcrumb($name, $url="") { global $navbits;
|
function add_breadcrumb($name, $url="") { global $navbits;
|
|
|
$navsize = count($navbits); $navbits[$navsize]['name'] = $name; $navbits[$navsize]['url'] = $url;
| $navsize = count($navbits); $navbits[$navsize]['name'] = $name; $navbits[$navsize]['url'] = $url;
|
Zeile 3117 | Zeile 3316 |
---|
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c') { $navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
|
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c') { $navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
|
}
| }
|
else { $navbits[$navsize]['url'] = $archiveurl."/index.php";
| else { $navbits[$navsize]['url'] = $archiveurl."/index.php";
|
Zeile 3128 | Zeile 3327 |
---|
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']); $navbits[$navsize]['multipage'] = $multipage;
|
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']); $navbits[$navsize]['multipage'] = $multipage;
|
$navbits[$navsize]['multipage']['url'] = get_forum_link($forumnav['fid']);
| $navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED);
|
} else {
| } else {
|
Zeile 3274 | Zeile 3473 |
---|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".get_friendly_size($memory_usage)." ({$memory_usage} bytes)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n";
|
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".get_friendly_size($memory_usage)." ({$memory_usage} bytes)</font></td>\n"; echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n"; echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n";
|
echo "</tr>\n"; }
echo "</table>\n";
| echo "</tr>\n"; }
echo "</table>\n";
|
echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
| echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n"; echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n"; echo "<tr>\n";
|
Zeile 3297 | Zeile 3496 |
---|
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";
|
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"; echo "</tr>\n";
|
echo "</table>\n"; echo "<br />\n"; }
| echo "</table>\n"; echo "<br />\n"; }
|
Zeile 3327 | Zeile 3526 |
---|
function send_page_headers() { global $mybb;
|
function send_page_headers() { global $mybb;
|
if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1) {
| if($mybb->settings['nocacheheaders'] == 1) {
|
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate");
| header("Expires: Sat, 1 Jan 2000 01:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate");
|
Zeile 3358 | Zeile 3557 |
---|
} break; case "post":
|
} break; case "post":
|
$db->update_query("reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
| $db->update_query("reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'"); break;
|
case "threads": if(is_array($id)) {
| case "threads": if(is_array($id)) {
|
Zeile 3597 | Zeile 3796 |
---|
{ $db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'"); return true;
|
{ $db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'"); return true;
|
} else {
| } else {
|
return false; } }
| return false; } }
|
Zeile 3609 | Zeile 3808 |
---|
* * @param int The user ID * @param int The user group ID
|
* * @param int The user ID * @param int The user group ID
|
*/
| */
|
function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
| function leave_usergroup($uid, $leavegroup) { global $db, $mybb, $cache;
|
Zeile 3619 | Zeile 3818 |
---|
$user = $mybb->user; } else
|
$user = $mybb->user; } else
|
{
| {
|
$query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query); }
|
$query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query); }
|
|
|
$groupslist = ""; $usergroups = ""; $usergroups = $user['additionalgroups'].",";
$groups = explode(",", $user['additionalgroups']);
|
$groupslist = ""; $usergroups = ""; $usergroups = $user['additionalgroups'].",";
$groups = explode(",", $user['additionalgroups']);
|
|
|
if(is_array($groups)) { foreach($groups as $gid)
| if(is_array($groups)) { foreach($groups as $gid)
|
Zeile 3679 | Zeile 3878 |
---|
elseif(!empty($_ENV['PATH_INFO'])) { $location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
elseif(!empty($_ENV['PATH_INFO'])) { $location = htmlspecialchars_uni($_ENV['PATH_INFO']);
|
}
| }
|
elseif(!empty($_ENV['PHP_SELF'])) { $location = htmlspecialchars_uni($_ENV['PHP_SELF']);
| elseif(!empty($_ENV['PHP_SELF'])) { $location = htmlspecialchars_uni($_ENV['PHP_SELF']);
|
Zeile 3700 | Zeile 3899 |
---|
$form_html = ""; $field_parts = explode('&', $field_parts);
|
$form_html = ""; $field_parts = explode('&', $field_parts);
|
|
|
if(!empty($mybb->input)) { foreach($mybb->input as $name => $value)
| if(!empty($mybb->input)) { foreach($mybb->input as $name => $value)
|
Zeile 3721 | Zeile 3920 |
---|
if(isset($_SERVER['QUERY_STRING'])) { $location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
if(isset($_SERVER['QUERY_STRING'])) { $location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
|
}
| }
|
else if(isset($_ENV['QUERY_STRING'])) { $location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
| else if(isset($_ENV['QUERY_STRING'])) { $location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
|
Zeile 3734 | Zeile 3933 |
---|
foreach($post_array as $var) { if(isset($_POST[$var]))
|
foreach($post_array as $var) { if(isset($_POST[$var]))
|
{
| {
|
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]); } }
| $addloc[] = urlencode($var).'='.urlencode($_POST[$var]); } }
|
Zeile 3752 | Zeile 3951 |
---|
$location .= implode("&", $addloc); } }
|
$location .= implode("&", $addloc); } }
|
| if(strlen($location) > 150) { $location = substr($location, 0, 150); }
|
return $location; } }
| return $location; } }
|
Zeile 3786 | Zeile 3990 |
---|
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
|
while($theme = $db->fetch_array($query)) { $tcache[$theme['pid']][$theme['tid']] = $theme;
|
} }
| } }
|
if(is_array($tcache[$tid])) { // Figure out what groups this user is in if($mybb->user['additionalgroups']) { $in_groups = explode(",", $mybb->user['additionalgroups']);
|
if(is_array($tcache[$tid])) { // Figure out what groups this user is in if($mybb->user['additionalgroups']) { $in_groups = explode(",", $mybb->user['additionalgroups']);
|
}
| }
|
$in_groups[] = $mybb->user['usergroup'];
foreach($tcache[$tid] as $theme)
| $in_groups[] = $mybb->user['usergroup'];
foreach($tcache[$tid] as $theme)
|
Zeile 3814 | Zeile 4018 |
---|
$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 == true)
| // Show theme if allowed, or if override is on if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == true)
|
Zeile 3829 | Zeile 4033 |
---|
{ $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--";
|
{ $themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>"; $depthit = $depth."--";
|
}
| }
|
if(array_key_exists($theme['tid'], $tcache)) {
| if(array_key_exists($theme['tid'], $tcache)) {
|
Zeile 3840 | Zeile 4044 |
---|
}
if($tid == 1)
|
}
if($tid == 1)
|
{ $themeselect .= "</select>"; }
| { $themeselect .= "</select>"; }
|
return $themeselect; }
/** * Custom function for htmlspecialchars which takes in to account unicode
|
return $themeselect; }
/** * Custom function for htmlspecialchars which takes in to account unicode
|
*
| *
|
* @param string The string to format * @return string The string with htmlspecialchars applied */
| * @param string The string to format * @return string The string with htmlspecialchars applied */
|
Zeile 3875 | Zeile 4079 |
---|
if($number == "-") { return $number;
|
if($number == "-") { return $number;
|
}
| }
|
if(is_int($number)) { return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
| if(is_int($number)) { return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
Zeile 3895 | Zeile 4099 |
---|
}
return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
}
return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
} }
| } }
|
function convert_through_utf8($str, $to=true) {
| function convert_through_utf8($str, $to=true) {
|
Zeile 3931 | Zeile 4135 |
---|
{ $from_charset = $lang->settings['charset']; $to_charset = "UTF-8";
|
{ $from_charset = $lang->settings['charset']; $to_charset = "UTF-8";
|
}
| }
|
else { $from_charset = "UTF-8"; $to_charset = $lang->settings['charset']; } if($use_iconv)
|
else { $from_charset = "UTF-8"; $to_charset = $lang->settings['charset']; } if($use_iconv)
|
{
| {
|
return iconv($from_charset, $to_charset."//IGNORE", $str); } else
| return iconv($from_charset, $to_charset."//IGNORE", $str); } else
|
Zeile 3951 | Zeile 4155 |
---|
if($to) { return utf8_encode($str);
|
if($to) { return utf8_encode($str);
|
}
| }
|
else { return utf8_decode($str);
| else { return utf8_decode($str);
|
Zeile 3977 | Zeile 4181 |
---|
{ $message = convert_through_utf8($message);
|
{ $message = convert_through_utf8($message);
|
if(!($new_message = @preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0​", $message)))
| if(!($new_message = @preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#u", "$0​", $message)))
|
{
|
{
|
$new_message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0​", $message);
| $new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0​", $message);
|
} $new_message = convert_through_utf8($new_message, false);
| } $new_message = convert_through_utf8($new_message, false);
|
Zeile 4101 | Zeile 4305 |
---|
'Y', 'j', 'S',
|
'Y', 'j', 'S',
|
'l',
| |
'F',
|
'F',
|
| 'l',
|
'M', );
|
'M', );
|
| $html = array( 'm', 'c', 'D', 'y', 'Y', 'j', 'S', 'F', 'l', 'M', );
$bdays = str_replace($find, $html, $bdays); $bmonth = str_replace($find, $html, $bmonth);
|
$replace = array( sprintf('%02s', $bm), sprintf('%02s', $bd),
| $replace = array( sprintf('%02s', $bm), sprintf('%02s', $bd),
|
Zeile 4114 | Zeile 4334 |
---|
$by, ($bd[0] == 0 ? my_substr($bd, 1) : $bd), ($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
|
$by, ($bd[0] == 0 ? my_substr($bd, 1) : $bd), ($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
|
$wd,
| |
$bmonth[$bm-1],
|
$bmonth[$bm-1],
|
| $wd,
|
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)), );
| ($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)), );
|
Zeile 4401 | Zeile 4621 |
---|
*/ function get_event_date($event) {
|
*/ function get_event_date($event) {
|
| global $mybb;
|
$event_date = explode("-", $event['date']); $event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
| $event_date = explode("-", $event['date']); $event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]); $event_date = my_date($mybb->settings['dateformat'], $event_date);
|
Zeile 4565 | Zeile 4787 |
---|
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
| /** * Build the link to a specified date on the calendar
|
Zeile 4655 | Zeile 4877 |
---|
return $user_cache[$uid]; } }
|
return $user_cache[$uid]; } }
|
| |
/** * Get the forum of a specific forum id.
| /** * Get the forum of a specific forum id.
|
Zeile 4665 | Zeile 4886 |
---|
* @return array The database row of a forum. */ function get_forum($fid, $active_override=0)
|
* @return array The database row of a forum. */ function get_forum($fid, $active_override=0)
|
{
| {
|
global $cache; static $forum_cache;
| global $cache; static $forum_cache;
|
Zeile 4691 | Zeile 4912 |
---|
return false; } }
|
return false; } }
|
}
| }
|
}
return $forum_cache[$fid];
| }
return $forum_cache[$fid];
|
Zeile 4708 | Zeile 4929 |
---|
{ global $db; static $thread_cache;
|
{ global $db; static $thread_cache;
|
|
|
if(isset($thread_cache[$tid]) && !$recache)
|
if(isset($thread_cache[$tid]) && !$recache)
|
{
| {
|
return $thread_cache[$tid]; } else { $query = $db->simple_select("threads", "*", "tid='".intval($tid)."'"); $thread = $db->fetch_array($query);
|
return $thread_cache[$tid]; } else { $query = $db->simple_select("threads", "*", "tid='".intval($tid)."'"); $thread = $db->fetch_array($query);
|
|
|
if($thread)
|
if($thread)
|
{
| {
|
$thread_cache[$tid] = $thread; return $thread;
|
$thread_cache[$tid] = $thread; return $thread;
|
}
| }
|
else { $thread_cache[$tid] = false;
|
else { $thread_cache[$tid] = false;
|
return false; } } }
/**
| return false; } } }
/**
|
* Get the post of a post id. * * @param int The post id of the post.
| * Get the post of a post id. * * @param int The post id of the post.
|
Zeile 4896 | Zeile 5117 |
---|
}
return false;
|
}
return false;
|
} }
| } }
|
// User can attempt another login return $loginattempts;
| // User can attempt another login return $loginattempts;
|
Zeile 4908 | Zeile 5129 |
---|
* * @param string The string to check. * @return boolean True when valid, false when invalid.
|
* * @param string The string to check. * @return boolean True when valid, false when invalid.
|
*/
| */
|
function validate_email_format($email) { if(strpos($email, ' ') !== false)
| function validate_email_format($email) { if(strpos($email, ' ') !== false)
|
Zeile 4917 | Zeile 5138 |
---|
} // 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);
|
} // 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);
|
}
| }
|
/** * Checks to see if the email is already in use by another *
| /** * Checks to see if the email is already in use by another *
|
Zeile 4929 | Zeile 5150 |
---|
function email_already_in_use($email, $uid="") { global $db;
|
function email_already_in_use($email, $uid="") { global $db;
|
|
|
$uid_string = ""; if($uid)
|
$uid_string = ""; if($uid)
|
{
| {
|
$uid_string = " AND uid != '".intval($uid)."'"; }
|
$uid_string = " AND uid != '".intval($uid)."'"; }
|
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string(my_strtolower($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 4981 | Zeile 5202 |
---|
$mybb->settings[$setting['name']] = $setting['value']; $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
$mybb->settings[$setting['name']] = $setting['value']; $setting['value'] = addcslashes($setting['value'], '\\"$'); $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
|
}
| }
|
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">"; $file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
| $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 5002 | Zeile 5223 |
---|
global $mybb;
if($mybb->settings['minsearchword'] < 1)
|
global $mybb;
if($mybb->settings['minsearchword'] < 1)
|
{
| {
|
$mybb->settings['minsearchword'] = 3; }
|
$mybb->settings['minsearchword'] = 3; }
|
| if(is_array($terms)) { $terms = implode(' ', $terms); }
|
// Strip out any characters that shouldn't be included $bad_characters = array(
| // Strip out any characters that shouldn't be included $bad_characters = array(
|
Zeile 5022 | Zeile 5248 |
---|
$inquote = false; $terms = explode("\"", $terms); foreach($terms as $phrase)
|
$inquote = false; $terms = explode("\"", $terms); foreach($terms as $phrase)
|
{
| {
|
$phrase = htmlspecialchars_uni($phrase); if($phrase != "") {
| $phrase = htmlspecialchars_uni($phrase); if($phrase != "") {
|
Zeile 5055 | Zeile 5281 |
---|
{ $terms = htmlspecialchars_uni($terms); $split_words = preg_split("#\s{1,}#", $terms, -1);
|
{ $terms = htmlspecialchars_uni($terms); $split_words = preg_split("#\s{1,}#", $terms, -1);
|
if(!is_array($split_words))
| if(is_array($split_words))
|
{
|
{
|
continue; } foreach($split_words as $word) { if(!$word || strlen($word) < $mybb->settings['minsearchword'])
| foreach($split_words as $word)
|
{
|
{
|
continue;
| if(!$word || strlen($word) < $mybb->settings['minsearchword']) { continue; } $words[] = trim($word);
|
}
|
}
|
$words[] = trim($word);
| |
}
|
}
|
| |
}
if(!is_array($words))
| }
if(!is_array($words))
|
Zeile 5093 | Zeile 5317 |
---|
}
// Now make PREG compatible
|
}
// Now make PREG compatible
|
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";
| $find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
|
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>"; $highlight_cache[$find] = $replacement; }
| $replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>"; $highlight_cache[$find] = $replacement; }
|
Zeile 5102 | Zeile 5326 |
---|
}
/**
|
}
/**
|
* Converts a decimal reference of a character to its UTF-8 equivilant
| * Converts a decimal reference of a character to its UTF-8 equivalent
|
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references) * * @param string Decimal value of a character reference
| * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references) * * @param string Decimal value of a character reference
|
Zeile 5184 | Zeile 5408 |
---|
*/ function is_banned_email($email, $update_lastuse=false) {
|
*/ function is_banned_email($email, $update_lastuse=false) {
|
global $db; $query = $db->simple_select("banfilters", "*", "type='3'"); while($banned_email = $db->fetch_array($query)) { // Make regular expression * match $banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#')); if(preg_match("#{$banned_email['filter']}#i", $email)) { // Updating last use if($update_lastuse == true) { $db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
| global $cache, $db;
$banned_cache = $cache->read("bannedemails"); if($banned_cache === false) { // Failed to read cache, see if we can rebuild it $cache->update_bannedemails(); $banned_cache = $cache->read("bannedemails"); }
if(is_array($banned_cache) && !empty($banned_cache)) { foreach($banned_cache as $banned_email) { // Make regular expression * match $banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email)) { // Updating last use if($update_lastuse == true) { $db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'"); } return true;
|
}
|
}
|
return true;
| |
} }
|
} }
|
|
|
// Still here - good email return false; }
| // Still here - good email return false; }
|
Zeile 5226 | Zeile 5464 |
---|
if(!$banned_ip['filter']) { continue;
|
if(!$banned_ip['filter']) { continue;
|
}
| }
|
// Make regular expression * match $banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));
|
// Make regular expression * match $banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));
|
if(preg_match("#{$banned_ip['filter']}#i", $ip_address))
| if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))
|
{ // Updating last use if($update_lastuse == true)
| { // Updating last use if($update_lastuse == true)
|
Zeile 5240 | Zeile 5478 |
---|
return true; } }
|
return true; } }
|
|
|
// Still here - good ip return false; }
| // Still here - good ip return false; }
|
Zeile 5400 | Zeile 5639 |
---|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close";
|
$headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close";
|
$headers[] = "\r\n";
| $headers[] = '';
|
if(!empty($post_body)) { $headers[] = $post_body;
|
if(!empty($post_body)) { $headers[] = $post_body;
|
| } else { // If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts $headers[] = '';
|
} $headers = implode("\r\n", $headers);
| } $headers = implode("\r\n", $headers);
|
Zeile 5423 | Zeile 5667 |
---|
else if(empty($post_data)) { return @implode("", @file($url));
|
else if(empty($post_data)) { return @implode("", @file($url));
|
} else { return false; } }
/**
| } else { return false; } }
/**
|
* Checks if a particular user is a super administrator. * * @param int The user ID to check against the list of super admins
| * Checks if a particular user is a super administrator. * * @param int The user ID to check against the list of super admins
|
Zeile 5472 | Zeile 5716 |
---|
function escaped_explode_escape($string) { return preg_quote($string, "#");
|
function escaped_explode_escape($string) { return preg_quote($string, "#");
|
}
| }
|
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")"; } else
| $escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")"; } else
|
Zeile 5516 | Zeile 5760 |
---|
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses. * * @param string The IP address to convert to a range based LONG
|
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses. * * @param string The IP address to convert to a range based LONG
|
* @rturn mixed If a full IP address is provided, the ip2long equivilent, otherwise an array of the upper & lower extremities of the IP
| * @rturn mixed If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP
|
*/ function fetch_longipv4_range($ip) {
| */ function fetch_longipv4_range($ip) {
|
Zeile 5592 | Zeile 5836 |
---|
"0-0-2" => "2 {$lang->years}" );
|
"0-0-2" => "2 {$lang->years}" );
|
$plugins->run_hooks_by_ref("functions_fetch_ban_times", $ban_times);
| $ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);
|
$ban_times['---'] = $lang->permanent; return $ban_times;
| $ban_times['---'] = $lang->permanent; return $ban_times;
|
Zeile 5618 | Zeile 5862 |
---|
$n[2] += $d[1]; $n[3] += $d[2]; return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);
|
$n[2] += $d[1]; $n[3] += $d[2]; return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);
|
}
/**
| }
/**
|
* Expire old warnings in the database. * */
| * Expire old warnings in the database. * */
|
Zeile 5637 | Zeile 5881 |
---|
WHERE expires<".TIME_NOW." AND expires!=0 AND expired!=1 "); while($warning = $db->fetch_array($query))
|
WHERE expires<".TIME_NOW." AND expires!=0 AND expired!=1 "); while($warning = $db->fetch_array($query))
|
{
| {
|
$updated_warning = array( "expired" => 1 ); $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
$updated_warning = array( "expired" => 1 ); $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
|
|
if(array_key_exists($warning['uid'], $users))
|
if(array_key_exists($warning['uid'], $users))
|
{
| {
|
$users[$warning['uid']] -= $warning['points']; } else
|
$users[$warning['uid']] -= $warning['points']; } else
|
{
| {
|
$users[$warning['uid']] = $warning['warningpoints']-$warning['points']; } }
| $users[$warning['uid']] = $warning['warningpoints']-$warning['points']; } }
|
Zeile 5665 | Zeile 5909 |
---|
); $db->update_query("users", $updated_user, "uid='".intval($uid)."'"); }
|
); $db->update_query("users", $updated_user, "uid='".intval($uid)."'"); }
|
}
/** * Unicode function for php function chr() * * @param string The character * @return mixed The unicoded chr() */ function unicode_chr($c) { if($c <= 0x7F) { return chr($c); } elseif($c <= 0x7FF) { return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F); } elseif($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); } elseif($c <= 0x10FFFF) { return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); } else { return false; }
| |
}
/**
| }
/**
|
Zeile 5789 | Zeile 6000 |
---|
*/ function my_ip2long($ip) {
|
*/ function my_ip2long($ip) {
|
$ip = ip2long($ip); if($ip >= 2147483648) // Won't occur on 32-bit PHP
| $ip_long = ip2long($ip);
if(!$ip_long) { $ip_long = sprintf("%u", ip2long($ip)); if(!$ip_long) { return 0; } }
if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
|
{
|
{
|
$ip -= 4294967296;
| $ip_long -= 4294967296;
|
}
|
}
|
return $ip;
| return $ip_long;
|
}
/**
| }
/**
|
Zeile 5914 | Zeile 6137 |
---|
* Returns a signed value equal to an integer * * @param int The integer
|
* Returns a signed value equal to an integer * * @param int The integer
|
* @return string The signed equivallent
| * @return string The signed equivalent
|
*/ function signed($int) {
| */ function signed($int) {
|
Zeile 5932 | Zeile 6155 |
---|
* Returns a securely generated seed for PHP's RNG (Random Number Generator) * * @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)
|
* Returns a securely generated seed for PHP's RNG (Random Number Generator) * * @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)
|
* @return int An integer equivilent of a secure hexadecimal seed
| * @return int An integer equivalent of a secure hexadecimal seed
|
*/ function secure_seed_rng($count=8) {
| */ function secure_seed_rng($count=8) {
|
Zeile 5972 | Zeile 6195 |
---|
* @param int Optional lowest value to be returned (default: 0) * @param int Optional highest value to be returned (default: mt_getrandmax()) * @param boolean True forces it to reseed the RNG first
|
* @param int Optional lowest value to be returned (default: 0) * @param int Optional highest value to be returned (default: mt_getrandmax()) * @param boolean True forces it to reseed the RNG first
|
* @return int An integer equivilent of a secure hexadecimal seed
| * @return int An integer equivalent of a secure hexadecimal seed
|
*/ function my_rand($min=null, $max=null, $force_seed=false) {
| */ function my_rand($min=null, $max=null, $force_seed=false) {
|
Zeile 6028 | Zeile 6251 |
---|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
| 0xAD => 1, 0xC2 => array(0xA0 => 1, 0xAD => 1, 0xBF => 1, 0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1,),
|
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160} 0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}
| 0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338} 0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160} 0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}
|
Zeile 6046 | Zeile 6277 |
---|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
0x0A => 1, 0x0D => 1, 0x0B => 1,
|
| 0xA0 => array(0xC2 => 1), 0xAD => array(0xC2 => 1), 0xBF => array(0xC2 => 1), 0x81 => array(0xC2 => 1), 0x8D => array(0xC2 => 1), 0x90 => array(0xC2 => 1), 0x9D => array(0xC2 => 1),
|
0xB8 => array(0xCC => 1), // \x{0338} 0xB7 => array(0xCC => 1), // \x{0337} 0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}
| 0xB8 => array(0xCC => 1), // \x{0338} 0xB7 => array(0xCC => 1), // \x{0337} 0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}
|