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 4058 2008-08-03 00:37:09Z Tikitiki $
| * $Id: functions.php 4116 2008-08-15 15:37:11Z ybwzrd $
|
*/
/**
| */
/**
|
Zeile 162 | Zeile 162 |
---|
if(isset($config)) { require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
|
if(isset($config)) { require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
|
$db = new databaseEngine;
| switch($config['database']['type']) { case "sqlite3": $db = new DB_SQLite3; break; case "sqlite2": $db = new DB_SQLite2; break; case "pgsql": $db = new DB_PgSQL; break; case "mysqli": $db = new DB_MySQLi; break; default: $db = new DB_MySQL; }
|
$db->connect($config['database']); define("TABLE_PREFIX", $config['database']['table_prefix']); $db->set_table_prefix(TABLE_PREFIX);
| $db->connect($config['database']); define("TABLE_PREFIX", $config['database']['table_prefix']); $db->set_table_prefix(TABLE_PREFIX);
|
Zeile 452 | Zeile 470 |
---|
// Guests get a special string else {
|
// Guests get a special string else {
|
return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].$mybb->config['database']['password']);
| return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].md5($mybb->config['database']['password']));
|
} }
| } }
|
Zeile 1071 | Zeile 1089 |
---|
if(!$gid || $gid == 0) // If no group, we need to fetch it {
|
if(!$gid || $gid == 0) // If no group, we need to fetch it {
|
if($uid != $mybb->user['uid'])
| if($uid != 0 && $uid != $mybb->user['uid'])
|
{ if($usercache[$uid]) {
| { if($usercache[$uid]) {
|
Zeile 1853 | Zeile 1871 |
---|
$update_query = array();
|
$update_query = array();
|
$counters = array('replies','unapprovedposts','attachmentcount');
| $counters = array('replies','unapprovedposts','attachmentcount', 'attachmentcount');
|
// Fetch above counters for this thread $query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
| // Fetch above counters for this thread $query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
|
Zeile 2066 | Zeile 2084 |
---|
{ $newdepth = $depth."--"; $forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);
|
{ $newdepth = $depth."--"; $forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);
|
} } } } }
| } } } } }
|
if($addselect) { if(!$selecteddone)
| if($addselect) { if(!$selecteddone)
|
Zeile 2101 | Zeile 2119 |
---|
/** * Returns the extension of a file.
|
/** * Returns the extension of a file.
|
*
| *
|
* @param string The filename. * @return string The extension of the file. */
| * @param string The filename. * @return string The extension of the file. */
|
Zeile 2141 | Zeile 2159 |
---|
function format_name($username, $usergroup, $displaygroup="") { global $groupscache, $cache;
|
function format_name($username, $usergroup, $displaygroup="") { global $groupscache, $cache;
|
|
|
if(!is_array($groupscache))
|
if(!is_array($groupscache))
|
{
| {
|
$groupscache = $cache->read("usergroups");
|
$groupscache = $cache->read("usergroups");
|
}
| }
|
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 2228 | Zeile 2246 |
---|
}
$editor_language .= "\n";
|
}
$editor_language .= "\n";
|
}
$editor_language .= "};";
| }
$editor_language .= "};";
|
if(defined("IN_ADMINCP")) {
| if(defined("IN_ADMINCP")) {
|
Zeile 2386 | Zeile 2404 |
---|
$gzdata .= pack("V", $crc); $gzdata .= pack("V", $size); $contents = $gzdata;
|
$gzdata .= pack("V", $crc); $gzdata .= pack("V", $size); $contents = $gzdata;
|
} } }
| } } }
|
return $contents; }
| return $contents; }
|
Zeile 2546 | Zeile 2564 |
---|
else { $ip = '';
|
else { $ip = '';
|
} }
| } }
|
$ip = preg_replace("#([^.0-9 ]*)#", "", $ip); return $ip; }
| $ip = preg_replace("#([^.0-9 ]*)#", "", $ip); return $ip; }
|
Zeile 2558 | Zeile 2576 |
---|
* * @param int The size in bytes * @return string The friendly file size
|
* * @param int The size in bytes * @return string The friendly file size
|
*/
| */
|
function get_friendly_size($size) { global $lang;
| function get_friendly_size($size) { global $lang;
|
Zeile 2627 | Zeile 2645 |
---|
* @return string The attachment icon */ function get_attachment_icon($ext)
|
* @return string The attachment icon */ function get_attachment_icon($ext)
|
{
| {
|
global $cache, $attachtypes, $theme;
if(!$attachtypes)
| global $cache, $attachtypes, $theme;
if(!$attachtypes)
|
Zeile 2657 | Zeile 2675 |
---|
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); } return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
|
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']); } return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
|
}
| }
|
else { if(defined("IN_ADMINCP"))
| else { if(defined("IN_ADMINCP"))
|
Zeile 2687 | Zeile 2705 |
---|
$pid = intval($pid);
if(!$permissions)
|
$pid = intval($pid);
if(!$permissions)
|
{
| {
|
$permissions = $mybb->usergroup;
|
$permissions = $mybb->usergroup;
|
}
| }
|
if(!is_array($forum_cache)) { cache_forums(); }
if(!is_array($permissioncache))
|
if(!is_array($forum_cache)) { cache_forums(); }
if(!is_array($permissioncache))
|
{
| {
|
$permissioncache = forum_permissions(); }
| $permissioncache = forum_permissions(); }
|
Zeile 2706 | Zeile 2724 |
---|
if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
if($permissioncache[$forum['fid']]) { $perms = $permissioncache[$forum['fid']];
|
}
| }
|
else { $perms = $mybb->usergroup;
| else { $perms = $mybb->usergroup;
|
Zeile 2725 | Zeile 2743 |
---|
if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0)) { if($unviewableforums)
|
if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0)) { if($unviewableforums)
|
{
| {
|
$unviewableforums .= ","; }
|
$unviewableforums .= ","; }
|
|
|
$unviewableforums .= "'".$forum['fid']."'"; } }
return $unviewableforums;
|
$unviewableforums .= "'".$forum['fid']."'"; } }
return $unviewableforums;
|
}
| }
|
/** * Fixes mktime for dates earlier than 1970
| /** * Fixes mktime for dates earlier than 1970
|
Zeile 2781 | Zeile 2799 |
---|
}
eval("\$nav .= \"".$templates->get("nav_bit")."\";");
|
}
eval("\$nav .= \"".$templates->get("nav_bit")."\";");
|
} } }
$navsize = count($navbits);
| } } }
$navsize = count($navbits);
|
$navbit = $navbits[$navsize-1];
if($nav)
| $navbit = $navbits[$navsize-1];
if($nav)
|
Zeile 2943 | Zeile 2961 |
---|
$phpversion = phpversion();
$serverload = get_server_load();
|
$phpversion = phpversion();
$serverload = get_server_load();
|
|
|
if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled";
| if($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled";
|
Zeile 3101 | Zeile 3119 |
---|
break; case "thread": $db->update_query("reportedposts", array('reportstatus' => 1), "tid='$id' AND reportstatus='0'");
|
break; case "thread": $db->update_query("reportedposts", array('reportstatus' => 1), "tid='$id' AND reportstatus='0'");
|
break;
| break;
|
case "forum": $db->update_query("reportedposts", array('reportstatus' => 1), "fid='$id' AND reportstatus='0'"); break;
| case "forum": $db->update_query("reportedposts", array('reportstatus' => 1), "fid='$id' AND reportstatus='0'"); break;
|
Zeile 3257 | Zeile 3275 |
---|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
if(is_array($nicetime)) { return implode(", ", $nicetime);
|
} }
| } }
|
/** * Select an alternating row colour based on the previous call to this function *
| /** * Select an alternating row colour based on the previous call to this function *
|
Zeile 3269 | Zeile 3287 |
---|
function alt_trow($reset=0) { global $alttrow;
|
function alt_trow($reset=0) { global $alttrow;
|
|
|
if($alttrow == "trow1" && !$reset) { $trow = "trow2";
| if($alttrow == "trow1" && !$reset) { $trow = "trow2";
|
Zeile 3289 | Zeile 3307 |
---|
* * @param int The user ID * @param int The user group ID to join
|
* * @param int The user ID * @param int The user group ID to join
|
*/
| */
|
function join_usergroup($uid, $joingroup) { global $db;
|
function join_usergroup($uid, $joingroup) { global $db;
|
if($uid == $mybb->user['uid']) { $user = $mybb->user; } else {
| if($uid == $mybb->user['uid']) { $user = $mybb->user; } else {
|
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='{$uid}'"); $user = $db->fetch_array($query); }
| $query = $db->simple_select("users", "additionalgroups, usergroup", "uid='{$uid}'"); $user = $db->fetch_array($query); }
|
Zeile 3309 | Zeile 3327 |
---|
$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(is_array($groups)) { foreach($groups as $gid)
|
Zeile 3339 | Zeile 3357 |
---|
if($uid == $mybb->user['uid']) { $user = $mybb->user;
|
if($uid == $mybb->user['uid']) { $user = $mybb->user;
|
} else {
| } else {
|
$query = $db->simple_select("users", "*", "uid='{$uid}'"); $user = $db->fetch_array($query); }
| $query = $db->simple_select("users", "*", "uid='{$uid}'"); $user = $db->fetch_array($query); }
|
Zeile 3459 | Zeile 3477 |
---|
} }
|
} }
|
if(isset($addlock) && is_array($addloc))
| if(isset($addloc) && is_array($addloc))
|
{ $location .= "?".implode("&", $addloc); }
| { $location .= "?".implode("&", $addloc); }
|
Zeile 3499 | Zeile 3517 |
---|
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(is_array($tcache[$tid])) { // Figure out what groups this user is in
|
Zeile 3798 | Zeile 3816 |
---|
{ global $db;
|
{ global $db;
|
$query = $db->simple_select("posts", "pid", "tid='{$tid}'", array('order_by' => 'dateline', 'limit' => 1));
| $query = $db->simple_select("posts", "pid,replyto", "tid='{$tid}'", array('order_by' => 'dateline', 'limit' => 1));
|
$post = $db->fetch_array($query);
if($post['replyto'] != 0)
| $post = $db->fetch_array($query);
if($post['replyto'] != 0)
|
Zeile 3806 | Zeile 3824 |
---|
$replyto_update = array( "replyto" => 0 );
|
$replyto_update = array( "replyto" => 0 );
|
$db->update_query("threads", $replyto_update, "pid='{$post['pid']}'");
| $db->update_query("posts", $replyto_update, "pid='{$post['pid']}'");
|
}
$firstpostup = array(
| }
$firstpostup = array(
|
Zeile 3825 | Zeile 3843 |
---|
{ global $lang;
|
{ global $lang;
|
$string = preg_replace("#&\#(0-9]+);#", "-", $string);
| $string = preg_replace("#&\#([0-9]+);#", "-", $string);
|
if(strtolower($lang->settings['charset']) == "utf-8") {
| if(strtolower($lang->settings['charset']) == "utf-8") {
|
Zeile 3835 | Zeile 3853 |
---|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
// Remove dodgy whitespaces $string = str_replace(chr(0xCA), "", $string);
|
$string = str_replace(" ", " ", $string);
| |
} $string = trim($string);
| } $string = trim($string);
|
Zeile 3980 | Zeile 3997 |
---|
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
|
}
| }
|
/** * Get the event poster. *
| /** * Get the event poster. *
|
Zeile 5244 | Zeile 5261 |
---|
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks * * @param string The file to chmod
|
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks * * @param string The file to chmod
|
* @param octal The mode to chmod(i.e. 0666)
| * @param string The mode to chmod(i.e. 0666)
|
*/ function my_chmod($file, $mode) {
|
*/ function my_chmod($file, $mode) {
|
| // Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string
|
if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4) { return false; } $old_umask = umask(0);
|
if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4) { return false; } $old_umask = umask(0);
|
$result = chmod($file, $mode);
| // We convert the octal string to a decimal number because passing a octal string doesn't work with chmod // and type casting subsequently removes the prepended 0 which is needed for octal numbers $result = chmod($file, octdec($mode));
|
umask($old_umask); return $result; }
| umask($old_umask); return $result; }
|