Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.com * License: http://www.mybboard.com/eula.html *
|
* Website: http://www.mybboard.com * License: http://www.mybboard.com/eula.html *
|
* $Id$
| * $Id: functions.php 966 2005-12-12 23:33:28Z chris $
|
*/
/* Do not change the following line if you wish to receive technical support */
|
*/
/* Do not change the following line if you wish to receive technical support */
|
$mybboard['internalver'] = "1.00"; $mybboard['vercode'] = "100.07";
| $mybboard['internalver'] = "1.04"; $mybboard['vercode'] = "100.11";
|
// // Outputs the contents of a page rendering variables
| // // Outputs the contents of a page rendering variables
|
Zeile 315 | Zeile 315 |
---|
$title = $mybb->settings['bbname']; } if($mybb->settings['redirects'] == "on")
|
$title = $mybb->settings['bbname']; } if($mybb->settings['redirects'] == "on")
|
{
| {
|
eval("\$redirectpage = \"".$templates->get("redirect")."\";"); outputpage($redirectpage);
|
eval("\$redirectpage = \"".$templates->get("redirect")."\";"); outputpage($redirectpage);
|
}
| }
|
else { $url = str_replace("#", "&#", $url);
| else { $url = str_replace("#", "&#", $url);
|
Zeile 338 | Zeile 338 |
---|
{ $pages = $count / $perpage; $pages = ceil($pages);
|
{ $pages = $count / $perpage; $pages = ceil($pages);
|
|
|
if($page > 1) { $prev = $page - 1;
| if($page > 1) { $prev = $page - 1;
|
Zeile 353 | Zeile 353 |
---|
if($page == $pages) { $to = $pages;
|
if($page == $pages) { $to = $pages;
|
}
| }
|
elseif($page == $pages-1) { $to = $page+1;
| elseif($page == $pages-1) { $to = $page+1;
|
Zeile 361 | Zeile 361 |
---|
elseif($page == $pages-2) { $to = $page+2;
|
elseif($page == $pages-2) { $to = $page+2;
|
}
| }
|
elseif($page == $pages-3)
|
elseif($page == $pages-3)
|
{
| {
|
$to = $page+3;
|
$to = $page+3;
|
}
| }
|
else { $to = $page+4;
| else { $to = $page+4;
|
Zeile 380 | Zeile 380 |
---|
eval("\$end = \"".$templates->get("multipage_end")."\";"); eval("\$multipage = \"".$templates->get("multipage")."\";"); return $multipage;
|
eval("\$end = \"".$templates->get("multipage_end")."\";"); eval("\$multipage = \"".$templates->get("multipage")."\";"); return $multipage;
|
} }
//
| } }
//
|
// Check if a certain forum by id exists // function validateforum($fid)
| // Check if a certain forum by id exists // function validateforum($fid)
|
Zeile 392 | Zeile 392 |
---|
$query = $db->query("SELECT fid FROM ".TABLE_PREFIX."forums WHERE fid='$fid'"); $validforum = $db->fetch_array($query); return (($fid=$validforum['fid'])? true:false);
|
$query = $db->query("SELECT fid FROM ".TABLE_PREFIX."forums WHERE fid='$fid'"); $validforum = $db->fetch_array($query); return (($fid=$validforum['fid'])? true:false);
|
| }
// Build the usergroup permissions for a specific user // function user_permissions($uid=0) { global $mybb, $cache, $groupscache, $usercache;
if($uid == 0) { $uid = $mybb->user['uid']; }
if($uid != $mybb->user['uid']) { if($usercache[$uid]) { $query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid'"); $usercache[$uid] = $db->fetch_array($query); } $gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups']; $groupperms = usergroup_permissions($gid); } else { $groupperms = $mybb->usergroup; } return $groupperms;
|
}
//
| }
//
|
Zeile 405 | Zeile 433 |
---|
$groupscache = $cache->read("usergroups"); } $groups = explode(",", $gid);
|
$groupscache = $cache->read("usergroups"); } $groups = explode(",", $gid);
|
if(count($groups) == 1) {
| if(count($groups) == 1) {
|
return $groupscache[$gid]; } foreach($groups as $gid)
| return $groupscache[$gid]; } foreach($groups as $gid)
|
Zeile 432 | Zeile 460 |
---|
if($access == 0) { $usergroup[$perm] = 0;
|
if($access == 0) { $usergroup[$perm] = 0;
|
| $zerogreater = 1;
|
} }
|
} }
|
elseif($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit)
| if(($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) && $zerogreater != 1)
|
{ $usergroup[$perm] = $access; }
|
{ $usergroup[$perm] = $access; }
|
| $zerogreater = 0;
|
} } } return $usergroup; }
|
} } } return $usergroup; }
|
//
| //
|
// Build the display group details for the given group // function usergroup_displaygroup($gid) { global $cache, $groupscache, $displaygroupfields; if(!is_array($groupscache))
|
// Build the display group details for the given group // function usergroup_displaygroup($gid) { global $cache, $groupscache, $displaygroupfields; if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups"); } $displaygroup = array(); $group = $groupscache[$gid]; foreach($displaygroupfields as $field)
|
$groupscache = $cache->read("usergroups"); } $displaygroup = array(); $group = $groupscache[$gid]; foreach($displaygroupfields as $field)
|
{
| {
|
$displaygroup[$field] = $group[$field]; } return $displaygroup; }
|
$displaygroup[$field] = $group[$field]; } return $displaygroup; }
|
//
| //
|
// Build forum permissions for the specific forum, user or group // function forum_permissions($fid=0, $uid=0, $gid=0)
| // Build forum permissions for the specific forum, user or group // function forum_permissions($fid=0, $uid=0, $gid=0)
|
Zeile 475 | Zeile 504 |
---|
$uid = $mybb->user['uid']; } if(!$gid || $gid == 0) // If no group, we need to fetch it
|
$uid = $mybb->user['uid']; } if(!$gid || $gid == 0) // If no group, we need to fetch it
|
{
| {
|
if($uid != $mybb->user['uid']) { if($usercache[$uid])
| if($uid != $mybb->user['uid']) { if($usercache[$uid])
|
Zeile 488 | Zeile 517 |
---|
} else {
|
} else {
|
$gid = $mybb->user['usergroup'].",".$mybbuser['additionalgroups'];
| $gid = $mybb->user['usergroup'].",".$mybb->user['additionalgroups'];
|
$groupperms = $mybbgroup; }
|
$groupperms = $mybbgroup; }
|
} if(!is_array($forumcache)) {
| } if(!is_array($forumcache)) {
|
cacheforums(); } if(!is_array($forumcache)) { return false;
|
cacheforums(); } if(!is_array($forumcache)) { return false;
|
}
| }
|
if(!is_array($fpermcache)) { $fpermcache = $cache->read("forumpermissions");
| if(!is_array($fpermcache)) { $fpermcache = $cache->read("forumpermissions");
|
Zeile 523 | Zeile 552 |
---|
// function fetch_forum_permissions($fid, $gid, $groupperms) {
|
// function fetch_forum_permissions($fid, $gid, $groupperms) {
|
global $groupscache, $forumcache, $fpermcache;
| global $groupscache, $forumcache, $fpermcache, $mybb;
|
$groups = explode(",", $gid); if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions {
| $groups = explode(",", $gid); if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions {
|
Zeile 538 | Zeile 567 |
---|
if(!is_array($fpermcache[$fid][$gid])) { continue;
|
if(!is_array($fpermcache[$fid][$gid])) { continue;
|
}
| }
|
foreach($fpermcache[$fid][$gid] as $perm => $access) { if($perm != "fid" && $perm != "gid" && $perm != "pid")
| foreach($fpermcache[$fid][$gid] as $perm => $access) { if($perm != "fid" && $perm != "gid" && $perm != "pid")
|
Zeile 548 | Zeile 577 |
---|
{ $forumpermissions[$perm] = $access; }
|
{ $forumpermissions[$perm] = $access; }
|
} } }
| } } }
|
} } if(!isset($forumpermissions))
|
} } if(!isset($forumpermissions))
|
{
| {
|
$forumpermissions = $groupperms; } return $forumpermissions;
|
$forumpermissions = $groupperms; } return $forumpermissions;
|
}
// // REDUNDANT CODE - TO BE REMOVED // function getpermissions($fid=0, $uid=0, $gid="", $parentslist="") { die("USING OLD CODE - getpmerissions"); global $db, $mybb, $mybbuser, $usercache, $permscache, $usergroups, $mybbgroup, $groupscache, $cache; if(!$groupscache) { $groupscache = $cache->read("usergroups"); } $uid = (!$uid) ? $mybb->user['uid'] : $uid; if(!$gid) { if($uid == 0) { $gid = 1; } else { $usercache[$uid]=($uid==$mybb->user['uid'])?$mybbuser:$uid; $usercache[$uid]=($uid==$mybb->user['uid'])?$mybb:$uid; if(!$usercache[$uid]) { $query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid'"); $user = $db->fetch_array($query); $usercache[$user['uid']] = $user; $gid = $user['usergroup']; } $gid = ($usercache[$uid]) ? $usercache[$uid]['usergroup'] : $gid; } } if(!$permissioncache[$gid][$fid]) { if(!$fid) { if(!$usergroups[$gid]) { if($mybb->user['uid'] && $gid == $mybbuser['usergroup']) { $usergroups[$gid] = $mybbgroup; } else { $usergroups[$gid] = $groupscache[$gid]; } } return $usergroups[$gid]; } else { $parentslist=(!$parentslist)?getparentlist($fid):$parentslist; $sql = buildparentlist($fid, "fid", "OR", $parentslist); $query = $db->query("SELECT *, INSTR(',$parentslist,', CONCAT(',', fid, ',') ) AS useperm FROM ".TABLE_PREFIX."forumpermissions WHERE gid='$gid' AND $sql ORDER BY useperm LIMIT 1"); $perms = $db->fetch_array($query); if(!$perms['pid']) { if(!$usergroups[$gid]) { if($gid == $mybbuser['usergroup']) { $usergroups[$gid] = $mybbgroup; } else { //$perms=$db->fetch_array($db->query("SELECT * FROM usergroups WHERE gid='$gid'")); $usergroups[$gid] = $groupscache[$gid]; } $perms = $usergroups[$gid];
} else { $perms = $usergroups[$gid]; } } } $permscache[$gid][$fid] = $perms; } else { return $permscache[$gid][$fid]; } return $perms;
| |
}
//
| }
//
|
Zeile 661 | Zeile 604 |
---|
if($uid) { if($usercache[$uid])
|
if($uid) { if($usercache[$uid])
|
{
| {
|
$gid = $usercache[$uid]['usergroup']; } else
| $gid = $usercache[$uid]['usergroup']; } else
|
Zeile 703 | Zeile 646 |
---|
if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid])) { $showform = 1;
|
if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid])) { $showform = 1;
|
} else { $showform = 0; } } } else
| } else { $showform = 0; } } } else
|
{ $showform = 0; }
| { $showform = 0; }
|
Zeile 784 | Zeile 727 |
---|
else { if($modperms[$action] == "yes")
|
else { if($modperms[$action] == "yes")
|
{
| {
|
return "yes";
|
return "yes";
|
} else
| } else
|
{ return "no"; }
| { return "no"; }
|
Zeile 807 | Zeile 750 |
---|
while($dbicon = $db->fetch_array($query)) { if($icon == $dbicon['iid'])
|
while($dbicon = $db->fetch_array($query)) { if($icon == $dbicon['iid'])
|
{
| {
|
$iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\">"; } else { $iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\"> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\">";
|
$iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\">"; } else { $iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\"> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\">";
|
}
| }
|
$listed++; if($listed == 9) {
| $listed++; if($listed == 9) {
|
Zeile 829 | Zeile 772 |
---|
// MyBB setcookie() wrapper // function mysetcookie($name, $value="", $expires="")
|
// MyBB setcookie() wrapper // function mysetcookie($name, $value="", $expires="")
|
{
| {
|
global $mybb; if(!$mybb->settings['cookiepath'])
|
global $mybb; if(!$mybb->settings['cookiepath'])
|
{
| {
|
$mybb->settings['cookiepath'] = "/";
|
$mybb->settings['cookiepath'] = "/";
|
}
| }
|
if($expires == -1)
|
if($expires == -1)
|
{
| {
|
$expires = 0;
|
$expires = 0;
|
}
| }
|
else
|
else
|
{
| {
|
if($mybb->user['rememberme'] == "no")
|
if($mybb->user['rememberme'] == "no")
|
{
| {
|
$expires = "";
|
$expires = "";
|
} else { $expires = time() + (60*60*24*365); // Make the cookie expire in a years time } } if($mybb->settings['cookiedomain']) { setcookie($name, $value, $expires, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
| } else { $expires = time() + (60*60*24*365); // Make the cookie expire in a years time } } if($mybb->settings['cookiedomain']) { setcookie($name, $value, $expires, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
|
} else
|
} else
|
{
| {
|
setcookie($name, $value, $expires, $mybb->settings['cookiepath']); } }
| setcookie($name, $value, $expires, $mybb->settings['cookiepath']); } }
|
Zeile 872 | Zeile 815 |
---|
if($mybb->settings['cookiedomain']) { @setcookie($name, "", $expires, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
|
if($mybb->settings['cookiedomain']) { @setcookie($name, "", $expires, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
|
} else {
| } else {
|
@setcookie($name, "", $expires, $mybb->settings['cookiepath']); } }
| @setcookie($name, "", $expires, $mybb->settings['cookiepath']); } }
|
Zeile 919 | Zeile 862 |
---|
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); if(!$serverload)
|
$serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); if(!$serverload)
|
{
| {
|
$load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
| $load = @exec("uptime"); $load = split("load averages?: ", $load); $serverload = explode(",", $load[1]);
|
Zeile 965 | Zeile 908 |
---|
$lp['lastposter'] = addslashes($lp['lastposter']); $lpadd = ",lastpost='".$lp['lastpost']."', lastposter='".$lp['lastposter']."', lastposttid='".$lp['tid']."'"; }
|
$lp['lastposter'] = addslashes($lp['lastposter']); $lpadd = ",lastpost='".$lp['lastpost']."', lastposter='".$lp['lastposter']."', lastposttid='".$lp['tid']."'"; }
|
|
|
// Get the post counters for this forum and its children $query = $db->query("SELECT COUNT(*) AS totthreads, SUM(replies) AS totreplies FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'"); $posts2 = $db->fetch_array($query);
| // Get the post counters for this forum and its children $query = $db->query("SELECT COUNT(*) AS totthreads, SUM(replies) AS totreplies FROM ".TABLE_PREFIX."threads WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'"); $posts2 = $db->fetch_array($query);
|
Zeile 1179 | Zeile 1122 |
---|
if($displaygroup != 0) { $usergroup = $displaygroup;
|
if($displaygroup != 0) { $usergroup = $displaygroup;
|
}
| }
|
$ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
| $ugroup = $groupscache[$usergroup]; $format = $ugroup['namestyle']; $userin = substr_count($format, "{username}");
|
Zeile 1276 | Zeile 1219 |
---|
if(function_exists("gzcompress") && function_exists("crc32") && !headers_sent()) { if(strpos(" ".$_SERVER['HTTP_ACCEPT_ENCODING'], "x-gzip"))
|
if(function_exists("gzcompress") && function_exists("crc32") && !headers_sent()) { if(strpos(" ".$_SERVER['HTTP_ACCEPT_ENCODING'], "x-gzip"))
|
{
| {
|
$encoding = "x-gzip";
|
$encoding = "x-gzip";
|
}
| }
|
if(strpos(" ".$_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { $encoding = "gzip";
| if(strpos(" ".$_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) { $encoding = "gzip";
|
Zeile 1287 | Zeile 1230 |
---|
{ header("Content-Encoding: $encoding"); if(function_exists("gzencode"))
|
{ header("Content-Encoding: $encoding"); if(function_exists("gzencode"))
|
{
| {
|
$contents = gzencode($contents, $level); } else
| $contents = gzencode($contents, $level); } else
|
Zeile 1299 | Zeile 1242 |
---|
$gzdata .= pack("V", $crc); $gzdata .= pack("V", $size); $contents = $gzdata;
|
$gzdata .= pack("V", $crc); $gzdata .= pack("V", $size); $contents = $gzdata;
|
} } }
| } } }
|
return $contents;
|
return $contents;
|
}
| }
|
function logmod($data, $action="") { global $mybb, $mybbuser, $db, $session;
|
function logmod($data, $action="") { global $mybb, $mybbuser, $db, $session;
|
|
|
$time = time(); $db->query("INSERT INTO ".TABLE_PREFIX."moderatorlog (uid,dateline,fid,tid,action,ipaddress) VALUES ('".$mybb->user['uid']."','$time','".$data['fid']."','".$data['tid']."','$action','".$session->ipaddress."')"); }
| $time = time(); $db->query("INSERT INTO ".TABLE_PREFIX."moderatorlog (uid,dateline,fid,tid,action,ipaddress) VALUES ('".$mybb->user['uid']."','$time','".$data['fid']."','".$data['tid']."','$action','".$session->ipaddress."')"); }
|
Zeile 1320 | Zeile 1263 |
---|
{ // negative $img = "repbit_neg.gif"; $reputation = str_replace("-", "", $reputation);
|
{ // negative $img = "repbit_neg.gif"; $reputation = str_replace("-", "", $reputation);
|
}
| }
|
elseif($reputation == 0) { // balanced $img = "repbit_bal.gif"; } else
|
elseif($reputation == 0) { // balanced $img = "repbit_bal.gif"; } else
|
{
| {
|
$img = "repbit_pos.gif"; // positive } $numimages = intval($reputation/10); // 10 points = 1 image
| $img = "repbit_pos.gif"; // positive } $numimages = intval($reputation/10); // 10 points = 1 image
|
Zeile 1376 | Zeile 1319 |
---|
}
function getfriendlysize($size)
|
}
function getfriendlysize($size)
|
{ global $lang;
| { global $lang;
|
if($size >= 1073741824) { $size = round(($size / 1073741824), 2) . " " . $lang->size_gb;
| if($size >= 1073741824) { $size = round(($size / 1073741824), 2) . " " . $lang->size_gb;
|
Zeile 1970 | Zeile 1913 |
---|
$location = "?".$_ENV['QUERY_STRING']; } }
|
$location = "?".$_ENV['QUERY_STRING']; } }
|
|
|
if($_SERVER['REQUEST_METHOD'] == "POST" || $_ENV['REQUEST_METHOD'] == "POST") { if($_POST['action'])
| if($_SERVER['REQUEST_METHOD'] == "POST" || $_ENV['REQUEST_METHOD'] == "POST") { if($_POST['action'])
|