sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $lastuser = $row['username']; $lastuid = $row['user_id']; if ((strlen($lastuser) > $CONF['max_length']) && isset($CONF['max_length']) && ($CONF['max_length'] > 0)) { $short_lastuser = substr($lastuser, 0, $CONF['max_length']); $short_lastuser .= '...'; } else { $short_lastuser = $lastuser; } $lastuser_info = ' ' . _BLATEST .': PR  ' . $short_lastuser . '
'; } else { $lastuser_info = ''; } // retrieve number of people who registered yesterday and today if (is_numeric($CONF['gmt_offset'])) { $timezone = 3600*$CONF['gmt_offset']; } else { $timezone = 0; } $todays_date = gmdate("M d, Y", time() + $timezone); $yesterdays_date = gmdate("M d, Y", time() - 86400 + $timezone); $new_today = 0; $new_yesterday = 0; $sql = "SELECT COUNT(*) as count, user_regdate FROM {$prefix}_users WHERE user_regdate LIKE '{$todays_date}' OR user_regdate LIKE '{$yesterdays_date}' GROUP BY user_regdate"; $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['user_regdate'] == $todays_date) { $new_today = $row['count']; } elseif ($row['user_regdate'] == $yesterdays_date) { $new_yesterday = $row['count']; } } } // retrieve number of people who have not activated their accounts yet $sql = "SELECT COUNT(*) as count FROM {$prefix}_users_temp"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $waiting = $row['count']; } else { $waiting = 0; } // retrieve total number of registered users $sql = "SELECT COUNT(*) as count FROM {$prefix}_users"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $overall = $row['count']; } else { $overall = 0; } // retrieve total number of those which are blocked $excluded = 0; $sql = "SELECT COUNT(*) as count FROM {$prefix}_blocked_robot as a, {$prefix}_session as b WHERE a.robot_ip = '$ipE'"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $excluded = $row['count']; } // retrieve total number of visitors and registered users currently online $visitors = 0; $members = 0; $sql = "SELECT COUNT(*) as count, guest FROM {$prefix}_session GROUP BY guest"; $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['guest'] == 1) { if ($row['count'] >= $excluded) { $visitors = $row['count'] - $excluded; } else { $visitors = $row['count']; } } else { $members = $row['count']; } } } // calculate total number online $total = $visitors + $members; $totalplus = $visitors + $members + $excluded; // retrieve the names of registered visitors currently online $users_online = ''; if($CONF['is_admin']) { $sql = "SELECT DISTINCT a.host_addr, b.user_id, b.username, b.user_allow_viewonline FROM {$prefix}_session as a, {$prefix}_users as b WHERE a.uname = b.username ORDER BY a.uname ASC LIMIT 0, {$CONF['max_users']}"; } else { $sql = "SELECT DISTINCT a.host_addr, b.user_id, b.username FROM {$prefix}_session as a, {$prefix}_users as b WHERE a.uname = b.username AND b.user_allow_viewonline = 1 ORDER BY a.uname ASC LIMIT 0, {$CONF['max_users']}"; } $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $users_online .= '
'; for ($i=0; $i < $numrows; $i++) { $row = sql_fetch_array($result); $num = $i + 1; if ($num < 10) { $num = '0' . $num; } $remote_addr = hideIP($row['host_addr'], $CONF); if (strlen($row['username']) > $CONF['max_length']) { $short_username = substr($row['username'],0,$CONF['max_length']); $short_username .= '...'; } else { $short_username = $row['username']; } $users_online .= $num . ': '; if ($CONF['is_admin']) { $users_online .= 'PS '; } if($row['user_allow_viewonline'] == 0 && $CONF['is_admin']) { $users_online .= 'PR PM  ' . $short_username . ' [H]
'; } else { $users_online .= 'PR PM  ' . $short_username . '
'; } } } // retrieve a list of anonymous guests currently online $anon_online = ''; if ($CONF['showGuests'] || ($CONF['showGuestsAdmin'] && $CONF['is_admin'])) { $sql = "SELECT DISTINCT host_addr FROM {$prefix}_session WHERE guest = 1 ORDER BY TIME ASC LIMIT 0, {$CONF['max_anon']}"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $anon_online .= '
'; for ($i=0; $i < $numrows; $i++) { $row = sql_fetch_array($result); $num = $i + 1; if ($num < 10) { $num = '0' . $num; } $remote_addr = hideIP($row['host_addr'], $CONF); $anon_online .= $num . ': '; if ($CONF['is_admin']) { $anon_online .= '' . $remote_addr . '
'; } else { $anon_online .= $remote_addr . '
'; } } } } // overall total hits to the site $hits_total = 0; $sql = "SELECT SUM(hits) as hits FROM {$prefix}_stats_year"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $hits_total = $row['hits']; } // total hits for today and yesterday // hits for today $hits_today = 0; $t_time = time(); $t_year = date("Y", $t_time); $t_month = date("n", $t_time); $t_date = date("j", $t_time); $sql = "SELECT hits FROM {$prefix}_stats_date WHERE year='{$t_year}' AND month='{$t_month}' AND date='{$t_date}'"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $hits_today = $row['hits']; } // hits for yesterday $hits_yesterday = 0; $t_time = time() - 86400; $t_year = date("Y", $t_time); $t_month = date("n", $t_time); $t_date = date("j", $t_time); $sql = "SELECT hits FROM {$prefix}_stats_date WHERE year='{$t_year}' AND month='{$t_month}' AND date='{$t_date}'"; $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows > 0) { $row = sql_fetch_array($result); $hits_yesterday = $row['hits']; } // build the middle section of the block $block_middle = ' ' . _BMEMP . ':
' . $lastuser_info . ' ' . _PSTODAY . ': ' . $new_today . '
 ' . _PSYESTERDAY . ': ' . $new_yesterday . '
 ' . _PSWAIT . ': ' . $waiting . '
 ' . _BOVER . ': ' . $overall . '

 ' . _BVISIT . ':
 ' . _BVIS . ': ' . $visitors . '
 ' . _BMEM . ': ' . $members . '
 ' . _PSEXCLUDED . ': (' . $excluded . ')
 ' . _BTT . ': ' . $totalplus . ' (' . $excluded . ')
' . $users_online . $anon_online . '
' . _WERECEIVED . '
' . $hits_total . '
' . _PAGESVIEWS . '
' . $CONF['startdate'] . '

' . _PSHITS . ' ' . _PSTODAY . ": " . $hits_today . '
' . _PSHITS. ' ' . _PSYESTERDAY . ": " . $hits_yesterday . '
'; 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 . ': ' . _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 . '
' . _NICKNAME . '
' . _PASSWORD . '
' . $security_code . '   
 · ' . _BREG . '
 · ' . _PSLOSTPASSWORD . '

'; } //******************************** 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 */ /* */ /************************************************************/ ?>