';
if (isset($CONF['cache_life']) && ($CONF['cache_life'] > 0)) {
if ($CONF['is_admin']) {
$bkey = 'siadmincache';
$title = 'Site Info Admin Cache';
} else {
$bkey = 'sicache';
$title = 'Site Info Cache';
}
//echo("func break 1...cachelife: $CONF[cache_life] ");
$cachetime = time() + ($CONF['cache_life']*60);
if (isset($CONF['noentry']) && $CONF['noentry']) {
//echo("func break 2 ");
$sql = "INSERT INTO {$CONF['prefix']}_blocks (bkey, title, content, bposition, active, time) VALUES ('{$bkey}', '{$title}', '{$block_middle}', 'l', '0', '{$cachetime}')";
//echo(" sql: $sql ");
$result = $db->sql_query($sql);
} else {
//echo("func break 3 ");
$sql = "UPDATE {$CONF['prefix']}_blocks SET content = '{$block_middle}', time = '{$cachetime}' WHERE bkey = '{$bkey}'";
$result = $db->sql_query($sql);
}
}
return $block_middle;
} // end function getFreshData()
//******************************** Block Top **************************************
// check whether visitor is logged in as admin, user, or anonymous visitor
// also set username and security code if needed
$CONF['is_admin'] = false;
$CONF['logged_in'] = false;
if (is_admin($_COOKIE['admin'])) {
$CONF['is_admin'] = true;
$cookie = $_COOKIE['admin'];
$cookie = base64_decode($cookie);
$cookie = explode(":", $cookie);
$username = $cookie[0];
}
if (is_user($_COOKIE['user'])) {
$CONF['logged_in'] = true;
$cookie = $_COOKIE['user'];
$cookie = base64_decode($cookie);
$cookie = explode(":", $cookie);
$username = $cookie[1];
$uid = $cookie[0];
} else {
$username = _PSANON;
// create security code
if (extension_loaded("gd") AND (($gfx_chk == 2) OR ($gfx_chk == 4) OR
($gfx_chk == 5) OR ($gfx_chk == 7))) {
mt_srand ((double)microtime()*1000000);
$maxran = 1000000;
$random_num = mt_rand(0, $maxran);
$security_code = _SECURITYCODE . ': ' . _TYPESECCODE . ': ';
} else {
$random_num = '';
}
}
// if username is greater than desired maximum length then shorten the name for display
if (!$CONF['logged_in']) {
$short_username = $username;
} else {
if ((strlen($username) > $CONF['max_length']) && isset($CONF['max_length'])
&& ($CONF['max_length'] > 0)) {
$short_username = substr($username, 0, $CONF['max_length']);
$short_username .= '...';
} else {
$short_username = $username;
}
}
if ($CONF['logged_in']) {
// retrieve total number of posts made by this user
//$sql = "SELECT COUNT(*) as count FROM {$prefix}_bbposts as a, {$prefix}_users as b WHERE a.poster_id = b.user_id";
$sql = "SELECT COUNT(*) as count FROM {$prefix}_bbposts WHERE poster_id = '{$uid}'";
$result = $db->sql_query($sql);
$numrows = $db->sql_numrows($result);
if ($numrows > 0) {
$row = sql_fetch_array($result);
$total_posts = $row['count'];
} else {
$total_posts = 0;
}
if ($total_posts == 1) {
$lang_posts = _PSPOST;
} else {
$lang_posts = _PSPOSTS;
}
// retrieve total number of private messages read and unread
$total_read = 0;
$total_unread = 0;
$sql = "SELECT COUNT(*) as count, privmsgs_type FROM {$prefix}_bbprivmsgs WHERE privmsgs_to_userid = '{$uid}' GROUP BY privmsgs_type";
$result = $db->sql_query($sql);
$numrows = $db->sql_numrows($result);
if ($numrows > 0) {
for ($i=0; $i < $numrows; $i++) {
$row = sql_fetch_array($result);
if ($row['privmsgs_type'] == 0) {
$total_read = $row['count'];
} elseif ($row['privmsgs_type'] == 5) {
$total_unread += $row['count'];
}
}
}
$block_top =
'
' . $total_posts . ' ' . $lang_posts . '
' ._BWEL. ', ' . $short_username . ' ' . _LOGOUT . '' . _BPM . '
' . _BUNREAD . ': ' . $total_unread . '
' . _BREAD . ': ' . $total_read . ' ';
} else {
$block_top =
' ' ._BWEL. ', ' . $short_username . '';
}
//******************************** Block Middle **************************************
// initialize vars to pass into function getFreshData
$CONF['startdate'] = $startdate;
$CONF['prefix'] = $prefix;
// check whether to cache data for this block
if (isset($CONF['cache_life']) && ($CONF['cache_life'] > 0)) {
if ($CONF['is_admin']) {
$sql = "SELECT content, time FROM {$prefix}_blocks WHERE bkey = 'siadmincache'";
} else {
$sql = "SELECT content, time FROM {$prefix}_blocks WHERE bkey = 'sicache'";
}
$result = $db->sql_query($sql);
$numrows = $db->sql_numrows($result);
if ($numrows > 0) {
$row = sql_fetch_array($result);
//$a = time();
//$b = $row['time'];
//$c = $b - $a;
//echo("time left on cache: $c ");
// if no content or unsure of cache age then update data
if (empty($row['time']) || empty($row['content'])) {
$block_middle = getFreshData($CONF);
// use cached version if data's cache life is still good
} elseif ($row['time'] >= time()) {
//echo("break 1 ");
$block_middle = $row['content'];
// if cache is too old then update data
} else {
//echo("break 2 ");
$block_middle = getFreshData($CONF);
}
// if no cache exists then retrieve current data
} else {
//echo("break 3 ");
$CONF['noentry'] = true;
$block_middle = getFreshData($CONF);
}
// if cache is turned off then retrieve current data
} else {
//echo("break 4 ");
$block_middle = getFreshData($CONF);
}
//******************************** Block Foot **************************************
// calculate server date/time
if ($CONF['showServer'] || ($CONF['showServerAdmin'] && $CONF['is_admin'])) {
$server_time = date("j F Y\nH:i:s T");
$zone = date("Z")/3600;
if ($zone >= 0) {
$zone = "+".$zone;
}
$block_foot = '
'
. _PSSERVDT . ": $server_time (GMT $zone)
";
} else {
$block_foot = '';
}
//******************************* Put It All Together *******************************
$content = $block_top . $block_middle . $block_foot;
//$end_time = microtime();
//$total_time = ($end_time - $start_time);
//$s = substr($total_time,0,7);
//$total_time = "Block loaded in: $s seconds";
//echo($total_time);
//******************************* History of Changes *******************************
/************************************************************/
/* Optimized code, significantly reduced SQL queries, and */
/* added caching to speed up execution and lighten server */
/* load. Added row checking to eliminate ambigious warnings */
/* when no data is returned from database. Added display of */
/* guest ips and a few more configurable settings. Merged */
/* hidden category under visitor category */
/* Modified 6 March 2004 by kipuka http://www.lavapower.com/*/
/* */
/* Added Protector System lookup for excluded ip. */
/* Dont show if excluded - 23 Oct 2003 Marcus aka Mister */
/* website http://protector.warcenter.se */
/* */
/* Added Check for total numbers of letters in a username */
/* If longer then $TEXT_LEN then cut. */
/* Good to make the block keep it's size */
/* - 25 Oct 2003 Marcus aka Mister */
/* website http://protector.warcenter.se */
/* */
/* Added Protector System lookup for registered users for */
/* Admins only (if exist)- 23 Oct 2003 Marcus aka Mister */
/* website http://protector.warcenter.se */
/* */
/* Added $gfx_chk code to allow disabling as per v6.9 code. */
/* 21 October 2003 Gaylen Fraley */
/* */
/* Added 3 new hyperlink things :). First off, if my block */
/* detects that you are using the Resend_Email module, it */
/* will hyperlink the 'Waiting' text to the Resend_Email */
/* block automatically. Then, there is a new module */
/* UserInfoAddons that the block will check for and if found*/
/* will hyperlink the New Today and New Yesterday text and */
/* will display the new users from today and yesterday! */
/* 30 Sept 2003 Gaylen Fraley */
/* website http://www.ravenphpscripts.com */
/* */
/* Added Sam Spade lookup for registered users for Admins */
/* only - 24 Sept 2003 Gaylen Fraley */
/* website http://www.ravenphpscripts.com */
/* */
/* Added 4 user settings - 20 Sept 2003 Gaylen Fraley */
/* Added Hidden User Count - 20 Sept 2003 Gaylen Fraley */
/* website http://www.ravenphpscripts.com */
/* */
/* Added user_avatar - 18 July 2003 Gaylen Fraley */
/* website http://www.ravenphpscripts.com */
/* */
/* Update for PHP-Nuke 6.5 - 30 July 2003 Gaylen Fraley */
/* website http://www.ravenphpscripts.com */
/* */
/* Update for PHP-Nuke 6.5 - 05 March 2003 Gaylen Fraley */
/* website http://www.ravenphpscripts.com */
/* */
/* Updated for PHP-Nuke 5.6 - 18 Jun 2002 NukeScripts */
/* website http://www.nukescripts.com */
/* */
/* Updated for PHP-Nuke 5.5 - 24/03/2002 Rugeri */
/* website http://newsportal.homip.net */
/* */
/* (C) 2002 */
/* All rights beyond the GPL are reserved */
/* */
/* Please give a link back to my site somewhere in your own */
/* */
/************************************************************/
?>