Changeset 5228

Show
Ignore:
Timestamp:
02/18/06 05:15:53 (2 years ago)
Author:
GamerZ
Message:

Update

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wp-useronline/trunk/useronline.php

    r5123 r5228  
    3232 
    3333 
     34### Function: WP-UserOnline Menu 
     35add_action('admin_menu', 'useronline_menu'); 
     36function useronline_menu() { 
     37      if (function_exists('add_submenu_page')) { 
     38            add_submenu_page('index.php',  __('WP-UserOnline'),  __('WP-UserOnline'), 1, 'useronline.php', 'display_useronline'); 
     39      } 
     40} 
     41 
     42 
    3443### Search Bots Name 
    35 $bots = array('Google Bot' => 'googlebot', 'Google Bot' => 'google', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'ubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com bot' => 'become.com', 'Technorati Blog Bot'=>'technorati'); 
     44$bots = array('Google Bot' => 'googlebot', 'Google Bot' => 'google', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'ubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com bot' => 'become.com', 'Technorati Blog Bot' => 'technorati'); 
    3645 
    3746 
     
    124133 
    125134### Function: Display UserOnline 
    126 function get_useronline($user = 'User', $users = 'Users', $display = true) { 
    127       global $useronline; 
    128       // Display User Online 
    129       if($display) { 
    130             if($useronline > 1) { 
    131                   echo "<b>$useronline</b> $users ".__('Online'); 
    132             } else { 
    133                   echo "<b>$useronline</b> $user ".__('Online'); 
    134             } 
    135       } else { 
    136             return $useronline; 
    137       } 
    138 
    139  
     135if(!function_exists('get_useronline')) { 
     136      function get_useronline($user = 'User', $users = 'Users', $display = true) { 
     137            global $useronline; 
     138            // Display User Online 
     139            if($display) { 
     140                  if($useronline > 1) { 
     141                        echo "<b>$useronline</b> $users ".__('Online'); 
     142                  } else { 
     143                        echo "<b>$useronline</b> $user ".__('Online'); 
     144                  } 
     145            } else { 
     146                  return $useronline; 
     147            } 
     148      } 
     149
    140150 
    141151### Function: Display Max UserOnline 
     
    238248            _e('No User Is Browsing This Page'); 
    239249      } 
     250} 
     251 
     252 
     253### Function: Check IP 
     254function check_ip($ip) { 
     255      if(!empty($_COOKIE[USER_COOKIE]) && ($ip != 'unknown')) { 
     256            return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)"; 
     257      } 
     258} 
     259 
     260 
     261### Function: Display UserOnline For Admin 
     262function display_useronline() { 
     263      global $wpdb, $bots; 
     264      // Reassign Bots Name 
     265      $bots_name = array(); 
     266      foreach($bots as $botname => $botlookfor) { 
     267            $bots_name[] = $botname; 
     268      } 
     269 
     270      // Get The Users Online 
     271      $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline"); 
     272 
     273      // Variables Variables Variables 
     274      $members = array(); 
     275      $guests = array(); 
     276      $bots = array(); 
     277      $total_users = 0; 
     278      $total_members = 0; 
     279      $total_guests = 0; 
     280      $total_bots = 0; 
     281      $nicetext_users = ''; 
     282      $nicetext_members = ''; 
     283      $nicetext_guests = ''; 
     284      $nicetext_bots = ''; 
     285 
     286      // Process Those User Who Is Online 
     287      if($usersonline) { 
     288            foreach($usersonline as $useronline) { 
     289                  if($useronline->username == 'Guest') { 
     290                        $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
     291                        $total_guests++; 
     292                  } elseif(in_array($useronline->username, $bots_name)) { 
     293                        $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
     294                        $total_bots++; 
     295                  } else { 
     296                        $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
     297                        $total_members++; 
     298                  } 
     299            } 
     300            $total_users = ($total_guests+$total_bots+$total_members); 
     301      } 
     302 
     303      //  Nice Text For Users 
     304      if($total_users > 1) { 
     305            $nicetext_users = $total_users.' '.__('Users'); 
     306      } else { 
     307            $nicetext_users = $total_users.' '.__('User'); 
     308      } 
     309 
     310      //  Nice Text For Members 
     311      if($total_members > 1) { 
     312            $nicetext_members = $total_members.' '.__('Members'); 
     313      } else { 
     314            $nicetext_members = $total_members.' '.__('Member'); 
     315      } 
     316 
     317 
     318      //  Nice Text For Guests 
     319      if($total_guests > 1) {  
     320            $nicetext_guests = $total_guests.' '.__('Guests'); 
     321      } else { 
     322            $nicetext_guests = $total_guests.' '.__('Guest');  
     323      } 
     324 
     325      //  Nice Text For Bots 
     326      if($total_bots > 1) { 
     327            $nicetext_bots = $total_bots.' '.__('Bots');  
     328      } else { 
     329            $nicetext_bots = $total_bots.' '.__('Bot');  
     330      } 
     331?> 
     332      <div class="wrap"> 
     333            <h2>UserOnline Stats</h2> 
     334            <p>There are a total of <b><?php echo $nicetext_users; ?></b> online now.</p> 
     335            <p>Out of which, there are <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p> 
     336            <p>Most users ever online was <b><?php get_most_useronline(); ?></b> on <b><?php get_most_useronline_date(); ?></b></p> 
     337      </div> 
     338            <?php 
     339                  // Print Out Members 
     340                  if($total_members > 0) { 
     341                        echo  '<div class="wrap"><h2>'.$nicetext_members.' '.__('Online Now').'</h2>'."\n"; 
     342                  } 
     343                  $no=1; 
     344                  if($members) { 
     345                        foreach($members as $member) { 
     346                              echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n"; 
     347                              $no++; 
     348                        } 
     349                        echo '</div>'; 
     350                  } 
     351                  // Print Out Guest 
     352                  if($total_guests > 0) { 
     353                        echo  '<div class="wrap"><h2>'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n"; 
     354                  } 
     355                  $no=1; 
     356                  if($guests) { 
     357                        foreach($guests as $guest) { 
     358                              echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n"; 
     359                              $no++; 
     360                        } 
     361                        echo '</div>'; 
     362                  } 
     363                  // Print Out Bots 
     364                  if($total_bots > 0) { 
     365                        echo  '<div class="wrap"><h2>'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n"; 
     366                  } 
     367                  $no=1; 
     368                  if($bots) { 
     369                        foreach($bots as $bot) { 
     370                              echo '<p><b>#'.$no.' - '.$bot['username'].'</b> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i', $bot['timestamp']).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</p>'."\n"; 
     371                              $no++; 
     372                        } 
     373                        echo '</div>'; 
     374                  } 
     375                  if($total_users == 0) { 
     376                        echo  '<div class="wrap"><h2>'.__('No One Is Online Now').'</h2></div>'."\n"; 
     377                  } 
     378            ?> 
     379<?php 
    240380} 
    241381 
  • wp-useronline/trunk/wp-useronline.php

    r5121 r5228  
    9494      $nicetext_bots = $total_bots.' '.__('Bot');  
    9595} 
    96  
    97 ### Function: Check IP 
    98 function check_ip($ip) { 
    99       if(!empty($_COOKIE[USER_COOKIE]) && ($ip != 'unknown')) { 
    100             return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)"; 
    101       } 
    102 } 
    10396?> 
    10497<?php get_header(); ?> 
     
    107100            <p>Out of which, there are <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p> 
    108101            <p>Most users ever online was <b><?php get_most_useronline(); ?></b> on <b><?php get_most_useronline_date(); ?></b></p> 
    109             <table width="100%" border="0" cellspacing="1" cellpadding="5"> 
    110102            <?php 
    111103                  // Print Out Members 
    112104                  if($total_members > 0) { 
    113                         echo  '<tr><td><h2 class="pagetitle">'.$nicetext_members.' '.__('Online Now').'</h2></td></tr>'."\n"; 
     105                        echo  '<h2 class="pagetitle">'.$nicetext_members.' '.__('Online Now').'</h2>'."\n"; 
    114106                  } 
    115107                  $no=1; 
    116108                  if($members) { 
    117109                        foreach($members as $member) { 
    118                               echo '<tr>'."\n"; 
    119                               echo '<td><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</td>'."\n"; 
    120                               echo '</tr>'."\n"; 
    121                               $no++; 
     110                              echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n"; 
     111                                    $no++; 
    122112                        } 
    123113                  } 
    124114                  // Print Out Guest 
    125115                  if($total_guests > 0) { 
    126                         echo  '<tr><td><h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2></td></tr>'."\n"; 
     116                        echo  '<h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n"; 
    127117                  } 
    128118                  $no=1; 
    129119                  if($guests) { 
    130120                        foreach($guests as $guest) { 
    131                               echo '<tr>'."\n"; 
    132                               echo '<td><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</td>'."\n"; 
    133                               echo '</tr>'."\n"; 
     121                              echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n"; 
    134122                              $no++; 
    135123                        } 
     
    137125                  // Print Out Bots 
    138126                  if($total_bots > 0) { 
    139                         echo  '<tr><td><h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2></td></tr>'."\n"; 
     127                        echo  '<h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n"; 
    140128                  } 
    141129                  $no=1; 
    142130                  if($bots) { 
    143131                        foreach($bots as $bot) { 
    144                               echo '<tr>'."\n"; 
    145                               echo '<td><b>#'.$no.' - '.$bot['username'].'</b> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i', $bot['timestamp']).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</td>'."\n"; 
    146                               echo '</tr>'."\n"; 
     132                              echo '<p><b>#'.$no.' - '.$bot['username'].'</b> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i', $bot['timestamp']).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</p>'."\n"; 
    147133                              $no++; 
    148134                        } 
    149135                  } 
    150136                  if($total_users == 0) { 
    151                         echo  '<tr><td><h2 class="pagetitle">'.__('No One Is Online Now').'</h2></td></tr>'."\n"; 
     137                        echo  '<h2 class="pagetitle">'.__('No One Is Online Now').'</h2>'."\n"; 
    152138                  } 
    153139            ?>