Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: functions.php 4182 2008-09-07 18:05:30Z Tikitiki $
| * $Id: functions.php 4350 2009-04-14 23:14:07Z Tikitiki $
|
*/
/**
| */
/**
|
Zeile 409 | Zeile 409 |
---|
* @param string The from address of the email, if blank, the board name will be used. * @param string The chracter set being used to send this email. * @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)
|
* @param string The from address of the email, if blank, the board name will be used. * @param string The chracter set being used to send this email. * @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)
|
| * @param string The format of the email to be sent (text or html). text is default * @param string The text message of the email if being sent in html format, for email clients that don't support html * @param string The email address to return to. Defaults to admin return email address.
|
*/
|
*/
|
function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="")
| function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")
|
{ global $mybb; static $mail;
| { global $mybb; static $mail;
|
Zeile 451 | Zeile 454 |
---|
} // Build and send
|
} // Build and send
|
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text);
| $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
|
return $mail->send(); }
| return $mail->send(); }
|
Zeile 470 | Zeile 473 |
---|
// Guests get a special string else {
|
// Guests get a special string else {
|
return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].md5($mybb->config['database']['password']));
| return md5($mybb->settings['bburl'].$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
|
} }
| } }
|
Zeile 491 | Zeile 494 |
---|
} else {
|
} else {
|
error($lang->invalid_post_code);
| if(defined("IN_ADMINCP")) { return false; } else { error($lang->invalid_post_code); }
|
} } else
| } } else
|
Zeile 706 | Zeile 716 |
---|
/** * Presents the user with a "no permission" page
|
/** * Presents the user with a "no permission" page
|
*/
| */
|
function error_no_permission() { global $mybb, $theme, $templates, $db, $lang, $plugins, $session;
| function error_no_permission() { global $mybb, $theme, $templates, $db, $lang, $plugins, $session;
|
Zeile 765 | Zeile 775 |
---|
echo "<script type=\"text/javascript\">\n"; if($message != "") {
|
echo "<script type=\"text/javascript\">\n"; if($message != "") {
|
echo "alert('{$message}');\n";
| echo 'alert("'.addslashes($message).'");';
|
} $url = str_replace("#", "&#", $url); $url = htmlspecialchars_decode($url); $url = str_replace(array("\n","\r",";"), "", $url);
|
} $url = str_replace("#", "&#", $url); $url = htmlspecialchars_decode($url); $url = str_replace(array("\n","\r",";"), "", $url);
|
echo "window.location = '{$url}';\n";
| echo 'window.location = "'.addslashes($url).'";'."\n";
|
echo "</script>\n"; exit; }
| echo "</script>\n"; exit; }
|
Zeile 799 | Zeile 809 |
---|
} else {
|
} else {
|
$url = str_replace("#", "&#", $url);
| |
$url = htmlspecialchars_decode($url); $url = str_replace(array("\n","\r",";"), "", $url);
| $url = htmlspecialchars_decode($url); $url = str_replace(array("\n","\r",";"), "", $url);
|
Zeile 927 | Zeile 936 |
---|
$url .= "&"; } $url .= "page=$page";
|
$url .= "&"; } $url .= "page=$page";
|
} else
| } else
|
{ $url = str_replace("{page}", $page, $url); }
| { $url = str_replace("{page}", $page, $url); }
|
Zeile 947 | Zeile 956 |
---|
// If no user id is specified, assume it is the current user if($uid == 0)
|
// If no user id is specified, assume it is the current user if($uid == 0)
|
{
| {
|
$uid = $mybb->user['uid']; }
| $uid = $mybb->user['uid']; }
|
Zeile 956 | Zeile 965 |
---|
{ // We've already cached permissions for this user, return them. if($user_cache[$uid]['permissions'])
|
{ // We've already cached permissions for this user, return them. if($user_cache[$uid]['permissions'])
|
{
| {
|
return $user_cache[$uid]['permissions'];
|
return $user_cache[$uid]['permissions'];
|
}
| }
|
// This user was not already cached, fetch their user information. if(!$user_cache[$uid]) { $user_cache[$uid] = get_user($uid); }
|
// This user was not already cached, fetch their user information. if(!$user_cache[$uid]) { $user_cache[$uid] = get_user($uid); }
|
|
|
// Collect group permissions. $gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid);
| // Collect group permissions. $gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid);
|
Zeile 990 | Zeile 999 |
---|
function usergroup_permissions($gid=0) { global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
function usergroup_permissions($gid=0) { global $cache, $groupscache, $grouppermignore, $groupzerogreater;
|
|
|
if(!is_array($groupscache))
|
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups"); }
|
$groupscache = $cache->read("usergroups"); }
|
|
|
$groups = explode(",", $gid);
|
$groups = explode(",", $gid);
|
| |
if(count($groups) == 1) { return $groupscache[$gid];
|
if(count($groups) == 1) { return $groupscache[$gid];
|
}
| }
|
foreach($groups as $gid) { if(trim($gid) == "" || !$groupscache[$gid]) { continue; }
|
foreach($groups as $gid) { if(trim($gid) == "" || !$groupscache[$gid]) { continue; }
|
|
|
foreach($groupscache[$gid] as $perm => $access) { if(!in_array($perm, $grouppermignore))
| foreach($groupscache[$gid] as $perm => $access) { if(!in_array($perm, $grouppermignore))
|
Zeile 1024 | Zeile 1032 |
---|
$permbit = ""; }
|
$permbit = ""; }
|
if(in_array($perm, $groupzerogreater))
| // 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account. if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0))
|
{
|
{
|
if($access == 0) { $usergroup[$perm] = 0; continue; }
| $usergroup[$perm] = 0; continue;
|
}
if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
| }
if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
|
Zeile 1042 | Zeile 1048 |
---|
}
return $usergroup;
|
}
return $usergroup;
|
}
/**
| }
/**
|
* Fetch the display group properties for a specific display group * * @param int The group ID to fetch the display properties for
| * Fetch the display group properties for a specific display group * * @param int The group ID to fetch the display properties for
|
Zeile 1053 | Zeile 1059 |
---|
function usergroup_displaygroup($gid) { global $cache, $groupscache, $displaygroupfields;
|
function usergroup_displaygroup($gid) { global $cache, $groupscache, $displaygroupfields;
|
|
|
if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
| if(!is_array($groupscache)) { $groupscache = $cache->read("usergroups");
|
Zeile 1081 | Zeile 1087 |
---|
function forum_permissions($fid=0, $uid=0, $gid=0) { global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $cached_forum_permissions_permissions, $cached_forum_permissions;
|
function forum_permissions($fid=0, $uid=0, $gid=0) { global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $cached_forum_permissions_permissions, $cached_forum_permissions;
|
if($uid == 0)
| if($uid == 0)
|
{ $uid = $mybb->user['uid']; }
| { $uid = $mybb->user['uid']; }
|
Zeile 1091 | Zeile 1097 |
---|
{ if($uid != 0 && $uid != $mybb->user['uid']) {
|
{ if($uid != 0 && $uid != $mybb->user['uid']) {
|
if($usercache[$uid])
| if(!$usercache[$uid])
|
{ $query = $db->simple_select("users", "*", "uid='$uid'"); $usercache[$uid] = $db->fetch_array($query);
| { $query = $db->simple_select("users", "*", "uid='$uid'"); $usercache[$uid] = $db->fetch_array($query);
|
Zeile 1375 | Zeile 1381 |
---|
if($user_perms['issupermod'] == 1) { return true;
|
if($user_perms['issupermod'] == 1) { return true;
|
} else
| } else
|
{ if(!$fid) {
| { if(!$fid) {
|
Zeile 1392 | Zeile 1398 |
---|
} } return false;
|
} } return false;
|
}
| }
|
else { $modperms = get_moderator_permissions($fid, $uid);
| else { $modperms = get_moderator_permissions($fid, $uid);
|
Zeile 1447 | Zeile 1453 |
---|
{ $iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>"; $no_icons_checked = "";
|
{ $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 1592 | Zeile 1598 |
---|
$cookie = $mybb->cookies['mybb']; $newcookie = unserialize($cookie[$name]); $newcookie[$id] = $value;
|
$cookie = $mybb->cookies['mybb']; $newcookie = unserialize($cookie[$name]); $newcookie[$id] = $value;
|
$newcookie = addslashes(serialize($newcookie)); my_setcookie("mybb[$name]", $newcookie);
| $newcookie = serialize($newcookie); my_setcookie("mybb[$name]", addslashes($newcookie)); // Make sure our current viarables are up-to-date as well $mybb->cookies['mybb'][$name] = $newcookie;
|
}
/**
| }
/**
|
Zeile 1615 | Zeile 1624 |
---|
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); }
|
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); }
|
if(!$serverload)
| if(!is_numeric($serverload[0]))
|
{ if(@ini_get('safe_mode') == 'On') {
| { if(@ini_get('safe_mode') == 'On') {
|
Zeile 1671 | Zeile 1680 |
---|
$counters = array('numthreads','numunapprovedthreads','numposts','numunapprovedposts','numusers'); $update = array();
|
$counters = array('numthreads','numunapprovedthreads','numposts','numunapprovedposts','numusers'); $update = array();
|
foreach($counters as $counter)
| foreach($counters as $counter)
|
{ if(array_key_exists($counter, $changes)) {
| { if(array_key_exists($counter, $changes)) {
|
Zeile 1679 | Zeile 1688 |
---|
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $new_stats[$counter] = $stats[$counter] + $changes[$counter];
|
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") { $new_stats[$counter] = $stats[$counter] + $changes[$counter];
|
}
| }
|
else { $new_stats[$counter] = $changes[$counter];
| else { $new_stats[$counter] = $changes[$counter];
|
Zeile 1704 | Zeile 1713 |
---|
if(is_array($stats)) { $stats = array_merge($stats, $new_stats);
|
if(is_array($stats)) { $stats = array_merge($stats, $new_stats);
|
}
| }
|
else { $stats = $new_stats;
| else { $stats = $new_stats;
|
Zeile 1721 | Zeile 1730 |
---|
$cache->update("stats", $stats, "dateline"); }
|
$cache->update("stats", $stats, "dateline"); }
|
|
|
/** * Updates the forum counters with a specific value (or addition/subtraction of the previous value) *
| /** * Updates the forum counters with a specific value (or addition/subtraction of the previous value) *
|
Zeile 1739 | Zeile 1748 |
---|
// 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)) { // Adding or subtracting from previous value? if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
| 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];
|
{ $update_query[$counter] = $forum[$counter] + $changes[$counter];
|
}
| }
|
else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if($update_query[$counter] < 0)
|
else { $update_query[$counter] = $changes[$counter]; } // Less than 0? That's bad if($update_query[$counter] < 0)
|
{
| {
|
$update_query[$counter] = 0; } }
| $update_query[$counter] = 0; } }
|
Zeile 1781 | Zeile 1790 |
---|
else { $new_stats['numthreads'] = "{$threads_diff}";
|
else { $new_stats['numthreads'] = "{$threads_diff}";
|
} }
| } }
|
if(array_key_exists('unapprovedthreads', $update_query)) {
| if(array_key_exists('unapprovedthreads', $update_query)) {
|
Zeile 1790 | Zeile 1799 |
---|
if($unapprovedthreads_diff > -1) { $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";
|
if($unapprovedthreads_diff > -1) { $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";
|
} else
| } else
|
{ $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}"; }
| { $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}"; }
|
Zeile 1816 | Zeile 1825 |
---|
if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
|
if($unapprovedposts_diff > -1) { $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
|
} else {
| } else {
|
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; } }
| $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}"; } }
|
Zeile 1897 | Zeile 1906 |
---|
} } }
|
} } }
|
| $db->free_result($query);
|
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query("threads", $update_query, "tid='".intval($tid)."'"); }
|
// Only update if we're actually doing something if(count($update_query) > 0) { $db->update_query("threads", $update_query, "tid='".intval($tid)."'"); }
|
| unset($update_query, $thread);
|
update_thread_data($tid); }
| update_thread_data($tid); }
|
Zeile 1922 | Zeile 1935 |
---|
WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline DESC LIMIT 1"
|
WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline DESC LIMIT 1"
|
);
| );
|
$lastpost = $db->fetch_array($query);
|
$lastpost = $db->fetch_array($query);
|
| $db->free_result($query);
|
$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 1934 | Zeile 1949 |
---|
LIMIT 1 "); $firstpost = $db->fetch_array($query);
|
LIMIT 1 "); $firstpost = $db->fetch_array($query);
|
| $db->free_result($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'];
|
Zeile 1963 | Zeile 1980 |
---|
'lastposteruid' => intval($lastpost['uid']), ); $db->update_query("threads", $update_array, "tid='{$tid}'");
|
'lastposteruid' => intval($lastpost['uid']), ); $db->update_query("threads", $update_array, "tid='{$tid}'");
|
}
| unset($firstpost, $lastpost, $update_array); }
|
function update_forum_count($fid) { die("Deprecated function call: update_forum_count");
| function update_forum_count($fid) { die("Deprecated function call: update_forum_count");
|
Zeile 2022 | Zeile 2041 |
---|
* @param int If we need to add select boxes to this cal or not * @param int The current depth of forums we're at * @param int Whether or not to show extra items such as User CP, Forum home
|
* @param int If we need to add select boxes to this cal or not * @param int The current depth of forums we're at * @param int Whether or not to show extra items such as User CP, Forum home
|
| * @param boolean Ignore the showinjump setting and show all forums (for moderation pages)
|
* @param array Array of permissions * @param string The name of the forum jump * @return string Forum jump items */
|
* @param array Array of permissions * @param string The name of the forum jump * @return string Forum jump items */
|
function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid")
| function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")
|
{ global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;
| { global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;
|
Zeile 2066 | Zeile 2086 |
---|
{ $perms = $permissioncache[$forum['fid']];
|
{ $perms = $permissioncache[$forum['fid']];
|
if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && $forum['showinjump'] != 0)
| if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))
|
{ $optionselected = "";
| { $optionselected = "";
|
Zeile 2083 | Zeile 2103 |
---|
if($forum_cache[$forum['fid']]) { $newdepth = $depth."--";
|
if($forum_cache[$forum['fid']]) { $newdepth = $depth."--";
|
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);
| $forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);
|
} } }
| } } }
|
Zeile 2258 | Zeile 2278 |
---|
else { eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
|
else { eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
|
} }
| } }
|
return $codeinsert; }
| return $codeinsert; }
|
Zeile 2938 | Zeile 2958 |
---|
$url = "{$base_url}forum-{$id}.html"; break; default:
|
$url = "{$base_url}forum-{$id}.html"; break; default:
|
$url = $mybb->setings['bburl']."/archive/index.php";
| $url = $mybb->settings['bburl']."/archive/index.php";
|
}
return $url;
| }
return $url;
|
Zeile 3310 | Zeile 3330 |
---|
*/ function join_usergroup($uid, $joingroup) {
|
*/ function join_usergroup($uid, $joingroup) {
|
global $db;
| global $db, $mybb;
|
if($uid == $mybb->user['uid']) {
| if($uid == $mybb->user['uid']) {
|
Zeile 3327 | Zeile 3347 |
---|
$usergroups = $user['additionalgroups'].",".$joingroup; $groupslist = ""; $groups = explode(",", $usergroups);
|
$usergroups = $user['additionalgroups'].",".$joingroup; $groupslist = ""; $groups = explode(",", $usergroups);
|
|
|
if(is_array($groups)) { foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
|
if(is_array($groups)) { foreach($groups as $gid) { if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
|
{ $groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1;
| { $groupslist .= $comma.$gid; $comma = ","; $donegroup[$gid] = 1;
|
} }
|
} }
|
}
| }
|
|
|
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
| // What's the point in updating if they're the same? if($groupslist != $user['additionalgroups']) { $db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'"); return true; } else { return false; }
|
}
/**
| }
/**
|
Zeile 3355 | Zeile 3384 |
---|
global $db, $mybb, $cache;
if($uid == $mybb->user['uid'])
|
global $db, $mybb, $cache;
if($uid == $mybb->user['uid'])
|
{
| {
|
$user = $mybb->user;
|
$user = $mybb->user;
|
}
| }
|
else { $query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query);
|
else { $query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query);
|
}
$usergroups = "";
| }
|
$groupslist = "";
|
$groupslist = "";
|
| $usergroups = "";
|
$usergroups = $user['additionalgroups'].",";
$groups = explode(",", $user['additionalgroups']);
| $usergroups = $user['additionalgroups'].",";
$groups = explode(",", $user['additionalgroups']);
|
Zeile 3382 | Zeile 3411 |
---|
} } }
|
} } }
|
|
|
$dispupdate = ""; if($leavegroup == $user['displaygroup']) {
| $dispupdate = ""; if($leavegroup == $user['displaygroup']) {
|
Zeile 3481 | Zeile 3510 |
---|
if(isset($addloc) && is_array($addloc)) {
|
if(isset($addloc) && is_array($addloc)) {
|
$location .= "?".implode("&", $addloc);
| if(strpos($location, "?") === false) { $location .= "?"; } else { $location .= "&"; } $location .= implode("&", $addloc);
|
} }
| } }
|
Zeile 3616 | Zeile 3653 |
---|
else { $parts = explode('.', $number);
|
else { $parts = explode('.', $number);
|
|
|
if(isset($parts[1])) { $decimals = my_strlen($parts[1]);
|
if(isset($parts[1])) { $decimals = my_strlen($parts[1]);
|
}
| }
|
else { $decimals = 0;
|
else { $decimals = 0;
|
}
| }
|
return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
|
| } }
function convert_through_utf8($str, $to=true) { global $lang; static $charset; static $use_mb; static $use_iconv; if(!isset($charset)) { $charset = my_strtolower($lang->settings['charset']); } if($charset == "utf-8") { return $str; } if(!isset($use_iconv)) { $use_iconv = function_exists("iconv"); } if(!isset($use_mb)) { $use_mb = function_exists("mb_convert_encoding"); } if($use_iconv || $use_mb) { if($to) { $from_charset = $lang->settings['charset']; $to_charset = "UTF-8"; } else { $from_charset = "UTF-8"; $to_charset = $lang->settings['charset']; } if($use_iconv) { return iconv($from_charset, $to_charset."//IGNORE", $str); } else { return @mb_convert_encoding($str, $to_charset, $from_charset); } } elseif($charset == "iso-8859-1" && function_exists("utf8_encode")) { if($to) { return utf8_encode($str); } else { return utf8_decode($str); } } else { return $str;
|
} }
| } }
|
Zeile 3642 | Zeile 3744 |
---|
if($mybb->settings['wordwrap'] > 0) {
|
if($mybb->settings['wordwrap'] > 0) {
|
if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))
| $message = convert_through_utf8($message); if(!($new_message = @preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0​", $message)))
|
{
|
{
|
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0 ", $message); } else { $message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0 ", $message);
| $new_message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0​", $message);
|
}
|
}
|
| $new_message = convert_through_utf8($new_message, false); return $new_message;
|
}
return $message;
| }
return $message;
|
Zeile 3761 | Zeile 3865 |
---|
$find = array( 'm', 'd',
|
$find = array( 'm', 'd',
|
| 'D',
|
'y', 'Y', 'j', 'S', 'l', 'F',
|
'y', 'Y', 'j', 'S', 'l', 'F',
|
| 'M',
|
);
$replace = array( sprintf('%02s', $bm), sprintf('%02s', $bd),
|
);
$replace = array( sprintf('%02s', $bm), sprintf('%02s', $bd),
|
| ($wd == 2 ? my_substr($bdays[$wd], 0, 4) : ($wd == 4 ? my_substr($bdays[$wd], 0, 5) : my_substr($bdays[$wd], 0, 3))),
|
my_substr($by, 2), $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'))),
|
my_substr($by, 2), $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'))),
|
$bdays[$wd],
| $wd,
|
$bmonth[$bm-1],
|
$bmonth[$bm-1],
|
| ($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),
|
);
|
);
|
| // Do we have the full month in our output? // If so there's no need for the short month if(strpos($display, 'F') !== false) { array_pop($find); array_pop($replace); }
|
return str_replace($find, $replace, $display); }
| return str_replace($find, $replace, $display); }
|
Zeile 3889 | Zeile 4005 |
---|
if($length != "") { $cut_string = mb_substr($string, $start, $length);
|
if($length != "") { $cut_string = mb_substr($string, $start, $length);
|
}
| }
|
else { $cut_string = mb_substr($string, $start);
| else { $cut_string = mb_substr($string, $start);
|
Zeile 3898 | Zeile 4014 |
---|
else { if($length != "")
|
else { if($length != "")
|
{
| {
|
$cut_string = substr($string, $start, $length);
|
$cut_string = substr($string, $start, $length);
|
}
| }
|
else { $cut_string = substr($string, $start); }
|
else { $cut_string = substr($string, $start); }
|
}
| }
|
if($handle_entities) { $cut_string = htmlspecialchars_uni($cut_string);
| if($handle_entities) { $cut_string = htmlspecialchars_uni($cut_string);
|
Zeile 3923 | Zeile 4039 |
---|
function my_strtolower($string) { if(function_exists("mb_strtolower"))
|
function my_strtolower($string) { if(function_exists("mb_strtolower"))
|
{
| {
|
$string = mb_strtolower($string); } else
| $string = mb_strtolower($string); } else
|
Zeile 3956 | Zeile 4072 |
---|
else { $position = strpos($haystack, $needle, $offset);
|
else { $position = strpos($haystack, $needle, $offset);
|
}
| }
|
return $position; }
| return $position; }
|
Zeile 3972 | Zeile 4088 |
---|
if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string);
|
if(function_exists("mb_strtoupper")) { $string = mb_strtoupper($string);
|
} else
| } else
|
{ $string = strtoupper($string); }
| { $string = strtoupper($string); }
|
Zeile 3988 | Zeile 4104 |
---|
* @return int The un-htmlentitied' string. */ function unhtmlentities($string)
|
* @return int The un-htmlentitied' string. */ function unhtmlentities($string)
|
{ // Replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
// Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
| { // Replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'unichr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'unichr("\\1")', $string); // Replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl); }
/** * Returns any ascii to it's character (utf-8 safe). * * @param string The ascii to characterize. * @return int The characterized ascii. */ function unichr($c) { if($c <= 0x7F) { return chr($c); } else if($c <= 0x7FF) { return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F); } else if($c <= 0xFFFF) { return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); } else if($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 4005 | Zeile 4154 |
---|
* * @param array The event data array. * @return string The link to the event poster.
|
* * @param array The event data array. * @return string The link to the event poster.
|
*/
| */
|
function get_event_poster($event) { $event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
| function get_event_poster($event) { $event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
|
Zeile 4030 | Zeile 4179 |
---|
/** * Get the profile link.
|
/** * Get the profile link.
|
*
| *
|
* @param int The user id of the profile. * @return string The url to the profile. */ function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL);
|
* @param int The user id of the profile. * @return string The url to the profile. */ function get_profile_link($uid=0) { $link = str_replace("{uid}", $uid, PROFILE_URL);
|
return htmlspecialchars_uni($link); }
/**
| return htmlspecialchars_uni($link); }
/**
|
* Get the announcement link. * * @param int The announement id of the announcement.
| * Get the announcement link. * * @param int The announement id of the announcement.
|
Zeile 4090 | Zeile 4239 |
---|
// If we're in the archive, link back a directory if(IN_ARCHIVE == 1)
|
// If we're in the archive, link back a directory if(IN_ARCHIVE == 1)
|
{ global $mybb; if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1)) { return "<a href=\"../../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>"; } return "<a href=\"../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>"; }
| { return "<a href=\"../../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>"; }
|
elseif(IN_ADMINCP == 1)
|
elseif(IN_ADMINCP == 1)
|
{
| {
|
return "<a href=\"../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
return "<a href=\"../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
}
| }
|
else { return "<a href=\"".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
else { return "<a href=\"".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
|
} } }
| } } }
|
/** * Build the forum link. *
| /** * Build the forum link. *
|
Zeile 4129 | Zeile 4271 |
---|
else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
else { $link = str_replace("{fid}", $fid, FORUM_URL);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
} }
| } }
|
Zeile 4156 | Zeile 4298 |
---|
$link = str_replace("{tid}", $tid, $link); $link = str_replace("{action}", $action, $link); $link = str_replace("{page}", $page, $link);
|
$link = str_replace("{tid}", $tid, $link); $link = str_replace("{action}", $action, $link); $link = str_replace("{page}", $page, $link);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
} else {
| } else {
|
Zeile 4183 | Zeile 4325 |
---|
function get_post_link($pid, $tid=0) { if($tid > 0)
|
function get_post_link($pid, $tid=0) { if($tid > 0)
|
{
| {
|
$link = str_replace("{tid}", $tid, THREAD_URL_POST); $link = str_replace("{pid}", $pid, $link);
|
$link = str_replace("{tid}", $tid, THREAD_URL_POST); $link = str_replace("{pid}", $pid, $link);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
} else { $link = str_replace("{pid}", $pid, POST_URL);
|
} else { $link = str_replace("{pid}", $pid, POST_URL);
|
return htmlspecialchars_uni($link);
| return htmlspecialchars_uni($link);
|
} }
| } }
|
Zeile 4200 | Zeile 4342 |
---|
* * @param int The event ID of the event * @return string The URL of the event
|
* * @param int The event ID of the event * @return string The URL of the event
|
*/
| */
|
function get_event_link($eid) { $link = str_replace("{eid}", $eid, EVENT_URL);
| function get_event_link($eid) { $link = str_replace("{eid}", $eid, EVENT_URL);
|
Zeile 4209 | Zeile 4351 |
---|
/** * Build the link to a specified date on the calendar
|
/** * Build the link to a specified date on the calendar
|
*
| *
|
* @param int The ID of the calendar * @param int The year * @param int The month
| * @param int The ID of the calendar * @param int The year * @param int The month
|
Zeile 4227 | Zeile 4369 |
---|
return htmlspecialchars_uni($link); } else if($month > 0)
|
return htmlspecialchars_uni($link); } else if($month > 0)
|
{
| {
|
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH); $link = str_replace("{year}", $year, $link); $link = str_replace("{calendar}", $calendar, $link);
| $link = str_replace("{month}", $month, CALENDAR_URL_MONTH); $link = str_replace("{year}", $year, $link); $link = str_replace("{calendar}", $calendar, $link);
|
Zeile 4255 | Zeile 4397 |
---|
* @return string The URL of the calendar */ function get_calendar_week_link($calendar, $week)
|
* @return string The URL of the calendar */ function get_calendar_week_link($calendar, $week)
|
{
| { if($week < 0) { $week = str_replace('-', "n", $week); }
|
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
| $link = str_replace("{week}", $week, CALENDAR_URL_WEEK); $link = str_replace("{calendar}", $calendar, $link); return htmlspecialchars_uni($link);
|
Zeile 4263 | Zeile 4409 |
---|
/** * Get the user data of a user id.
|
/** * Get the user data of a user id.
|
*
| *
|
* @param int The user id of the user. * @return array The users data */
| * @param int The user id of the user. * @return array The users data */
|
Zeile 4279 | Zeile 4425 |
---|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
return $mybb->user; } elseif(isset($user_cache[$uid]))
|
{ return $user_cache[$uid];
| { return $user_cache[$uid];
|
} else {
| } else {
|
Zeile 4324 | Zeile 4470 |
---|
if($forum_cache[$parent]['active'] == 0) { return false;
|
if($forum_cache[$parent]['active'] == 0) { return false;
|
} } }
| } } }
|
}
return $forum_cache[$fid];
| }
return $forum_cache[$fid];
|
Zeile 4472 | Zeile 4618 |
---|
else { $failedlogin = $cookietime;
|
else { $failedlogin = $cookietime;
|
}
| }
|
// Work out if the user has had more than the allowed number of login attempts if($loginattempts > $mybb->settings['failedlogincount'])
| // Work out if the user has had more than the allowed number of login attempts if($loginattempts > $mybb->settings['failedlogincount'])
|
Zeile 4484 | Zeile 4630 |
---|
if(empty($mybb->cookies['failedlogin'])) { $failedtime = $now;
|
if(empty($mybb->cookies['failedlogin'])) { $failedtime = $now;
|
}
| }
|
else { $failedtime = $mybb->cookies['failedlogin'];
|
else { $failedtime = $mybb->cookies['failedlogin'];
|
}
| }
|
$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now; $hoursleft = floor($secondsleft / 3600); $minsleft = floor(($secondsleft / 60) % 60);
| $secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now; $hoursleft = floor($secondsleft / 3600); $minsleft = floor(($secondsleft / 60) % 60);
|
Zeile 4506 | Zeile 4652 |
---|
}
return false;
|
}
return false;
|
}
| }
|
// Work out if the user has waited long enough before letting them login again
|
// Work out if the user has waited long enough before letting them login again
|
if($mybb->cookies['failedlogin'] < $now - $mybb->settings['failedlogintime'] * 60)
| if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60) && $mybb->user['uid'] != 0)
|
{ my_setcookie('loginattempts', 1); my_unsetcookie('failedlogin'); $update_array = array( 'loginattempts' => 1 );
|
{ my_setcookie('loginattempts', 1); my_unsetcookie('failedlogin'); $update_array = array( 'loginattempts' => 1 );
|
$db->update_query("sessions", $update_array, "sid = '{$session->sid}'");
| $db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
|
return 1; } // Not waited long enough
|
return 1; } // Not waited long enough
|
else
| else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
|
{ if($fatal) {
| { if($fatal) {
|
Zeile 4621 | Zeile 4767 |
---|
@fclose($file);
$GLOBALS['settings'] = &$mybb->settings;
|
@fclose($file);
$GLOBALS['settings'] = &$mybb->settings;
|
}
| }
|
/** * Build a PREG compatible array of search highlight terms to replace in posts.
| /** * Build a PREG compatible array of search highlight terms to replace in posts.
|
Zeile 4838 | Zeile 4984 |
---|
$banned_ips = $cache->read("bannedips"); if(!is_array($banned_ips))
|
$banned_ips = $cache->read("bannedips"); if(!is_array($banned_ips))
|
{ return false; }
| { return false; }
|
foreach($banned_ips as $banned_ip) { if(!$banned_ip['filter'])
| foreach($banned_ips as $banned_ip) { if(!$banned_ip['filter'])
|
Zeile 4954 | Zeile 5100 |
---|
* @param string The URL of the remote file * @return string The remote file contents. */
|
* @param string The URL of the remote file * @return string The remote file contents. */
|
function fetch_remote_file($url)
| function fetch_remote_file($url, $post_data=array())
|
{
|
{
|
| $post_body = ''; if(!empty($post_data)) { foreach($post_data as $key => $val) { $post_body .= '&'.urlencode($key).'='.urlencode($val); } $post_body = ltrim($post_body, '&'); }
|
if(function_exists("curl_init")) { $ch = curl_init();
| if(function_exists("curl_init")) { $ch = curl_init();
|
Zeile 4963 | Zeile 5119 |
---|
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| if(!empty($post_body)) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); }
|
$data = curl_exec($ch); curl_close($ch); return $data; }
|
$data = curl_exec($ch); curl_close($ch); return $data; }
|
else if(function_exists("fsockopen"))
| else if(function_exists("fsockopen"))
|
{ $url = @parse_url($url); if(!$url['host']) { return false;
|
{ $url = @parse_url($url); if(!$url['host']) { return false;
|
}
| }
|
if(!$url['port']) { $url['port'] = 80;
|
if(!$url['port']) { $url['port'] = 80;
|
}
| }
|
if(!$url['path']) { $url['path'] = "/";
|
if(!$url['path']) { $url['path'] = "/";
|
}
| }
|
if($url['query']) { $url['path'] .= "?{$url['query']}";
| if($url['query']) { $url['path'] .= "?{$url['query']}";
|
Zeile 4989 | Zeile 5150 |
---|
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10); @stream_set_timeout($fp, 10); if(!$fp)
|
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10); @stream_set_timeout($fp, 10); if(!$fp)
|
{ return false; } $headers = "GET {$url['path']} HTTP/1.1\r\n"; $headers .= "Host: {$url['host']}\r\n"; $headers .= "Connection: Close\r\n\r\n";
| { return false; } $headers = array(); if(!empty($post_body)) { $headers[] = "POST {$url['path']} HTTP/1.0"; $headers[] = "Content-Length: ".strlen($post_body); $headers[] = "Content-Type: application/x-www-form-urlencoded"; } else { $headers[] = "GET {$url['path']} HTTP/1.0"; } $headers[] = "Host: {$url['host']}"; $headers[] = "Connection: Close"; $headers[] = "\r\n"; if(!empty($post_body)) { $headers[] = $post_body; } $headers = implode("\r\n", $headers);
|
if(!@fwrite($fp, $headers))
|
if(!@fwrite($fp, $headers))
|
{
| {
|
return false; } while(!feof($fp)) { $data .= fgets($fp, 12800);
|
return false; } while(!feof($fp)) { $data .= fgets($fp, 12800);
|
}
| }
|
fclose($fp); $data = explode("\r\n\r\n", $data, 2); return $data[1];
|
fclose($fp); $data = explode("\r\n\r\n", $data, 2); return $data[1];
|
} else
| } else if(empty($post_data))
|
{ return @implode("", @file($url));
|
{ return @implode("", @file($url));
|
} }
| } else { return false; } }
|
/** * Checks if a particular user is a super administrator.
| /** * Checks if a particular user is a super administrator.
|
Zeile 5020 | Zeile 5204 |
---|
* @return boolean True if a super admin, false if not */ function is_super_admin($uid)
|
* @return boolean True if a super admin, false if not */ function is_super_admin($uid)
|
{
| {
|
global $mybb; $mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']);
| global $mybb; $mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']);
|
Zeile 5029 | Zeile 5213 |
---|
return false; } else
|
return false; } else
|
{
| {
|
return true; } }
| return true; } }
|
Zeile 5063 | Zeile 5247 |
---|
$escape_preg = preg_quote($escape, "#"); } $quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string);
|
$escape_preg = preg_quote($escape, "#"); } $quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string);
|
} else {
| } else {
|
$quoted_strings = array($string); } foreach($quoted_strings as $string)
| $quoted_strings = array($string); } foreach($quoted_strings as $string)
|
Zeile 5075 | Zeile 5259 |
---|
if($in_escape) { $strings[] = trim($string);
|
if($in_escape) { $strings[] = trim($string);
|
}
| }
|
else { $split_strings = explode($delimeter, $string);
| else { $split_strings = explode($delimeter, $string);
|
Zeile 5104 | Zeile 5288 |
---|
function fetch_longipv4_range($ip) { $ip_bits = explode(".", $ip);
|
function fetch_longipv4_range($ip) { $ip_bits = explode(".", $ip);
|
| $ip_string1 = $ip_string2 = "";
|
|
|
if($ip == "*") return array(ip2long(0), ip2long(255));
| if($ip == "*") { return array(ip2long('0.0.0.0'), ip2long('255.255.255.255')); }
|
if(strpos($ip, ".*") === false) {
| if(strpos($ip, ".*") === false) {
|
Zeile 5122 | Zeile 5310 |
---|
// Wildcard based IP provided else {
|
// Wildcard based IP provided else {
|
| $sep = "";
|
foreach($ip_bits as $piece) { if($piece == "*") {
|
foreach($ip_bits as $piece) { if($piece == "*") {
|
return array(ip2long($ip_string."0"), ip2long($ip_string."255"));
| $ip_string1 .= $sep."0"; $ip_string2 .= $sep."255";
|
} else {
|
} else {
|
$ip_string .= $piece.".";
| $ip_string1 .= $sep.$piece; $ip_string2 .= $sep.$piece;
|
}
|
}
|
| $sep = ".";
|
}
|
}
|
| return array(ip2long($ip_string1), ip2long($ip_string2));
|
} }
| } }
|
Zeile 5201 | Zeile 5394 |
---|
function expire_warnings() { global $db;
|
function expire_warnings() { global $db;
|
| $users = array();
|
$query = $db->query(" SELECT w.wid, w.uid, w.points, u.warningpoints FROM ".TABLE_PREFIX."warnings w
| $query = $db->query(" SELECT w.wid, w.uid, w.points, u.warningpoints FROM ".TABLE_PREFIX."warnings w
|
Zeile 5213 | Zeile 5409 |
---|
"expired" => 1 ); $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
"expired" => 1 ); $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
$warning['warningpoints'] -= $warning['points']; if($warning['warningpoints'] < 0)
| if(array_key_exists($warning['uid'], $users)) { $users[$warning['uid']] -= $warning['points']; } else { $users[$warning['uid']] = $warning['warningpoints']-$warning['points']; } } foreach($users as $uid => $warningpoints) { if($warningpoints < 0)
|
{
|
{
|
$warning['warningpoints'] = 0;
| $warningpoints = 0;
|
}
|
}
|
|
|
$updated_user = array(
|
$updated_user = array(
|
"warningpoints" => intval($warning['warningpoints'])
| "warningpoints" => intval($warningpoints)
|
);
|
);
|
$db->update_query("users", $updated_user, "uid='{$warning['uid']}'");
| $db->update_query("users", $updated_user, "uid='".intval($uid)."'");
|
} }
| } }
|