Changeset 6286

Show
Ignore:
Timestamp:
08/12/06 17:47:30 (2 years ago)
Author:
GamerZ
Message:

NEW: UserOnline? Is Now Embedded Into A Page, And Hence No More Integrating Of UserOnline? Page
NEW: Changed In WP-UserOnline? Structure: Members Mean Registered Users and Guests Mean Comment Authors

Files:

Legend:

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

    r6254 r6286  
    211211                  <p><b>Development:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/browser/wp-useronline/" title="http://dev.wp-plugins.org/browser/wp-useronline/">http://dev.wp-plugins.org/browser/wp-useronline/</a></p> 
    212212                  <p><b>Support Forums:</b><br /><b>&raquo;</b> <a href="http://forums.lesterchan.net/viewforum.php?f=10" title="http://forums.lesterchan.net/viewforum.php?f=10">http://forums.lesterchan.net/viewforum.php?f=10</a></p> 
    213                   <p><b>Updated:</b><br /><b>&raquo;</b> 1st August 2006</p> 
     213                  <p><b>Updated:</b><br /><b>&raquo;</b> 1st October 2006</p> 
     214                  <p><b>Note:</b><br /><b>&raquo;</b>  I have changed some of WP-UserOnline's structure, So if there is any bug, please contact me immediately.</p> 
    214215                  <div class="SubSubTitle">Changelog</div> 
    215216                  <ul> 
    216217                        <li> 
    217                               <b>Version 2.05 (01-08-2006)</b> 
    218                               <ul> 
     218                              <b>Version 2.05 (01-10-2006)</b> 
     219                              <ul> 
     220                                    <li>NEW: UserOnline Is Now Embedded Into A Page, And Hence No More Integrating Of UserOnline Page</li> 
     221                                    <li>NEW: Changed In WP-UserOnline Structure: Members Mean Registered Users and Guests Mean Comment Authors</li> 
    219222                                    <li>NEW: get_users_browsing_site(false) And get_users_browsing_page(false) Will Now Return An Array Containing Total Users, Total Members, Total Guests and Total Bots Online</li> 
     223                                    <li>NEW: Added Widget Title Option To WP-UserOnline Widget</li> 
    220224                                    <li>FIXED: Invalid IP Error</li> 
    221225                                    <li>FIXED: If Site URL Doesn't Match WP Option's Site URL, WP-UserOnline Will Not Work</li> 
     
    304308                        </li> 
    305309                        <li> 
    306                               Delete
     310                              Delete file if exists
    307311                              <blockquote>File: wp-useronline.php</blockquote> 
    308312                        </li> 
    309313                        <li> 
    310314                              Open <b>wp-content/plugins</b> Folder 
    311                         </li> 
    312                         <li> 
    313                               Delete: 
    314                               <blockquote>File: useronline.php</blockquote> 
    315315                        </li> 
    316316                        <li> 
    317317                              Put: 
    318318                              <blockquote>Folder: useronline</blockquote> 
     319                        </li> 
     320                        <li> 
     321                              Delete file if exists: 
     322                              <blockquote>File: useronline.php</blockquote> 
     323                        </li> 
     324                        <li> 
     325                              Open <b>wp-content/plugins/useronline</b> Folder 
     326                        </li> 
     327                        <li> 
     328                              Delete file if exists: 
     329                              <blockquote>File: wp-useronline.php</blockquote> 
    319330                        </li> 
    320331                        <li> 
     
    330341            <div id="Usage" style="display: none;"> 
    331342                  <div class="SubTitle">&raquo; Usage Instructions</div> 
    332                   <div class="SubSubTitle">General Usage</div> 
     343                  <div class="SubSubTitle">General Usage (Without Widget)</div> 
    333344                  <ol> 
    334345                        <li> 
     
    348359                              </blockquote> 
    349360                        </li> 
    350                         <li> 
    351                               Tutorial On How To Integrate wp-useronline.php With Your Theme: 
    352                               <blockquote><a href="http://www.lesterchan.net/wordpress/tutorials/integrating/" target="_blank">http://www.lesterchan.net/wordpress/tutorials/integrating/</a></blockquote> 
     361                  </ol> 
     362                  <div class="SubSubTitle">General Usage (With Widget)</div> 
     363                  <ol> 
     364                        <li> 
     365                              <b>Activate</b> WP-UserOnline Widget Plugin 
     366                        </li> 
     367                        <li> 
     368                              Go to 'WP-Admin -> Presentation -> Sidebar Widgets' 
     369                        </li> 
     370                        <li> 
     371                              <b>Drag</b> the UserOnline Widget to your sidebar 
     372                        </li> 
     373                        <li> 
     374                              You can <b>configure</b> the UserOnline Widget by clicking on the configure icon 
     375                        </li> 
     376                        <li> 
     377                              Click 'Save changes' 
     378                        </li> 
     379                        <li> 
     380                              Scroll down for instructions on how to create a <b>UserOnline Page</b>. 
     381                        </li> 
     382                  </ol> 
     383                  <div class="SubSubTitle">UserOnline Page</div> 
     384                  <ol> 
     385                        <li> 
     386                              Go to 'WP-Admin -> Write -> Write Page' 
     387                        </li> 
     388                        <li> 
     389                              Type any title you like in the post's title area 
     390                        </li> 
     391                        <li> 
     392                              Type '<b>&lt;page_useronline&gt</b>' in the post's content area (without the quotes) 
     393                        </li> 
     394                        <li> 
     395                              Type '<b>useronline</b>' in the post's slug area (without the quotes) 
     396                        </li> 
     397                        <li> 
     398                              Click 'Publish' 
    353399                        </li> 
    354400                  </ol> 
  • wp-useronline/trunk/useronline/useronline-options.php

    r6244 r6286  
    3434            $useronline_bots[trim($useronline_bots_keys[$i])] = trim($useronline_bots_vals[$i]); 
    3535      } 
     36      $useronline_url = addslashes(trim($_POST['useronline_url'])); 
    3637      $update_useronline_queries = array(); 
    3738      $update_useronline_text = array(); 
    3839      $update_useronline_queries[] = update_option('useronline_timeout', $useronline_timeout); 
    3940      $update_useronline_queries[] = update_option('useronline_bots', $useronline_bots); 
     41      $update_useronline_queries[] = update_option('useronline_url', $useronline_url); 
    4042      $update_useronline_text[] = __('Useronline Timeout'); 
    4143      $update_useronline_text[] = __('Useronline Bots'); 
     44      $update_useronline_text[] = __('Useronline URL'); 
    4245      $i=0; 
    4346      $text = ''; 
     
    7780                              </td> 
    7881                        </tr> 
     82                         <tr valign="top"> 
     83                              <th align="left" width="30%"><?php _e('UserOnline URL'); ?></th> 
     84                              <td align="left"> 
     85                                    <input type="text" name="useronline_url" value="<?php echo get_settings('useronline_url'); ?>" size="50" /><br />URL To UserOnline Page. 
     86                              </td> 
     87                        </tr> 
    7988                        <tr valign="top">  
    8089                              <th align="left" width="30%"><?php _e('Bots Name/User Agent'); ?></th> 
  • wp-useronline/trunk/useronline/useronline-widget.php

    r6244 r6286  
    3838            extract($args); 
    3939            $options = get_option('widget_useronline'); 
    40             $title = __('UserOnline'); 
     40            $title = htmlspecialchars($options['title']); 
    4141            echo $before_widget.$before_title.$title.$after_title; 
    4242            if (function_exists('useronline')) { 
     
    5959            $options = get_option('widget_useronline'); 
    6060            if (!is_array($options)) { 
    61                   $options = array('display_usersbrowsingsite' => '0'); 
     61                  $options = array('display_usersbrowsingsite' => '0', 'title' => 'UserOnline'); 
    6262            } 
    6363            if ($_POST['useronline-submit']) { 
    6464                  $options['display_usersbrowsingsite'] = intval($_POST['useronline-usersbrowsingsite']); 
     65                  $options['title'] = strip_tags(stripslashes($_POST['useronline-title'])); 
    6566                  update_option('widget_useronline', $options); 
    6667            } 
     68            echo '<p style="text-align: left;"><label for="useronline-title">Widget Title:</label>&nbsp;&nbsp;&nbsp;<input type="text" id="useronline-title" name="useronline-title" value="'.htmlspecialchars($options['title']).'" />'; 
    6769            echo '<p style="text-align: center;"><label for="useronline-usersbrowsingsite">Display Users Browsing Site Under Users Online Count?</label></p>'."\n"; 
    6870            echo '<p style="text-align: center;"><input type="radio" id="useronline-usersbrowsingsite" name="useronline-usersbrowsingsite" value="1"'; 
     
    7678      // Register Widgets 
    7779      register_sidebar_widget('UserOnline', 'widget_useronline'); 
    78       register_widget_control('UserOnline', 'widget_useronline_options', 350, 100); 
     80      register_widget_control('UserOnline', 'widget_useronline_options', 350, 120); 
    7981} 
    8082 
  • wp-useronline/trunk/useronline/useronline.php

    r6254 r6286  
    9090add_action('wp_head', 'useronline'); 
    9191function useronline() { 
    92       global $wpdb, $useronline, $user_identity
     92      global $wpdb, $useronline
    9393      // Useronline Settings 
    9494      $timeoutseconds = get_settings('useronline_timeout'); 
     
    9898      $url = addslashes(urlencode($_SERVER['REQUEST_URI'])); 
    9999      $useragent = $_SERVER['HTTP_USER_AGENT']; 
    100  
    101       // Check For Members 
    102       if(!empty($_COOKIE['comment_author_'.COOKIEHASH]))  { 
    103             $memberonline = addslashes(trim($_COOKIE['comment_author_'.COOKIEHASH])); 
    104             $where = "WHERE username='$memberonline'"; 
    105       // Check For Admins 
    106       } elseif(!empty($user_identity)) { 
    107             $memberonline = addslashes($user_identity); 
    108             $where = "WHERE username='$memberonline'"; 
    109       // Check For Guests 
    110       } else {  
    111             $memberonline = 'Guest'; 
    112             $where = "WHERE ip='$ip'"; 
    113       } 
     100      $current_user = wp_get_current_user(); 
     101 
    114102      // Check For Bot 
    115103      $bots = get_settings('useronline_bots'); 
    116104      foreach ($bots as $name => $lookfor) {  
    117105            if (stristr($useragent, $lookfor) !== false) {  
    118                   $memberonline = addslashes($name); 
    119                   $where = "WHERE ip='$ip'"; 
     106                  $user_id = 0; 
     107                  $display_name = addslashes($name); 
     108                  $user_name = addslashes($lookfor);         
     109                  $type = 'bot'; 
     110                  $where = "WHERE ip = '$ip'"; 
     111                  $bot_found = true; 
    120112                  break; 
    121113            }  
    122114      } 
     115 
     116      // If No Bot Is Found, Then We Check Members And Guests 
     117      if(!$bot_found) { 
     118            // Check For Member 
     119            if($current_user->ID > 0) { 
     120                  $user_id = $current_user->ID; 
     121                  $display_name = addslashes($current_user->display_name); 
     122                  $user_name = addslashes($current_user->user_login);          
     123                  $type = 'member'; 
     124                  $where = "WHERE userid = '$user_id'"; 
     125            // Check For Comment Author (Guest) 
     126            } elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) { 
     127                  $user_id = 0; 
     128                  $display_name = addslashes(trim($_COOKIE['comment_author_'.COOKIEHASH])); 
     129                  $user_name = "guest_$display_name";        
     130                  $type = 'guest'; 
     131                  $where = "WHERE ip = '$ip'"; 
     132            // Check For Guest 
     133            } else { 
     134                  $user_id = 0; 
     135                  $display_name = 'Guest'; 
     136                  $user_name = "guest";          
     137                  $type = 'guest'; 
     138                  $where = "WHERE ip = '$ip'"; 
     139            } 
     140      } 
     141 
     142      // Get User Agent 
    123143      $useragent = addslashes($useragent); 
    124144 
     
    138158       
    139159      // Insert Users 
    140       $insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$memberonline', '$useragent', '$ip', '$make_page', '$url')"); 
     160      $insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$user_id', '$user_name', '$display_name', '$useragent', '$ip', '$make_page', '$url', '$type')"); 
    141161 
    142162      // Count Users Online 
     
    158178      function get_useronline($user = 'User', $users = 'Users', $display = true) { 
    159179            global $useronline; 
     180            $useronline_url = get_settings('useronline_url'); 
    160181            // Display User Online 
    161182            if($display) { 
    162183                  if($useronline > 1) { 
    163                         echo '<a href="'.get_settings('siteurl').'/wp-content/plugins/useronline/wp-useronline.php"><b>'.number_format($useronline).'</b> '.$users.' '.__('Online').'</a>'."\n"; 
     184                        echo '<a href="'.$useronline_url.'"><b>'.number_format($useronline).'</b> '.$users.' '.__('Online').'</a>'."\n"; 
    164185                  } else { 
    165                         echo '<a href="'.get_settings('siteurl').'/wp-content/plugins/useronline/wp-useronline.php"><b>'.$useronline.'</b> '.$user.' '.__('Online').'</a>'."\n"; 
     186                        echo '<a href="'.$useronline_url.'"><b>'.$useronline.'</b> '.$user.' '.__('Online').'</a>'."\n"; 
    166187                  } 
    167188            } else { 
     
    186207### Function: Display Max UserOnline Date 
    187208if(!function_exists('get_most_useronline_date')) { 
    188       function get_most_useronline_date($date_format = 'jS F Y, H:i', $display =true) { 
     209      function get_most_useronline_date($display = true, $date_format = 'jS F Y, H:i') { 
    189210            $most_useronline_timestamp = get_settings('useronline_most_timestamp'); 
    190211            $most_useronline_date = gmdate($date_format, $most_useronline_timestamp); 
     
    204225      // Get Users Browsing Site 
    205226      $page_url = addslashes(urlencode($_SERVER['REQUEST_URI'])); 
    206       $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline"); 
     227      $users_browse = $wpdb->get_results("SELECT displayname, type FROM $wpdb->useronline ORDER BY type"); 
    207228 
    208229      // Variables 
    209230      $members = array(); 
     231      $guests = array(); 
     232      $bots = array(); 
    210233      $total_users = 0; 
    211234      $total_members = 0; 
     
    218241      // If There Is Users Browsing, Then We Execute 
    219242      if($users_browse) { 
    220             // Reassign Bots Name 
    221             $bots = get_settings('useronline_bots'); 
    222             $bots_name = array(); 
    223             foreach($bots as $botname => $botlookfor) { 
    224                   $bots_name[] = $botname; 
    225             } 
    226243            // Get Users Information 
    227244            foreach($users_browse as $user_browse) { 
    228                   if($user_browse->username == 'Guest') { 
    229                         $total_guests++; 
    230                   } elseif(in_array($user_browse->username, $bots_name)) { 
    231                         $total_bots++; 
    232                   } else { 
    233                         $members[] = stripslashes($user_browse->username); 
    234                         $total_members++; 
     245                  switch($user_browse->type) { 
     246                        case 'member': 
     247                              $members[] = stripslashes($user_browse->displayname); 
     248                              $total_members++; 
     249                              break; 
     250                        case 'guest':                                    
     251                              $guests[] = stripslashes($user_browse->displayname); 
     252                              $total_guests++; 
     253                              break; 
     254                        case 'bot': 
     255                              $bots[] = stripslashes($user_browse->displayname); 
     256                              $total_bots++; 
     257                              break; 
    235258                  } 
    236259            } 
     
    289312      // Get Users Browsing Page 
    290313      $page_url = addslashes(urlencode($_SERVER['REQUEST_URI'])); 
    291       $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline WHERE url = '$page_url'"); 
     314      $users_browse = $wpdb->get_results("SELECT displayname, type FROM $wpdb->useronline WHERE url = '$page_url' ORDER BY type"); 
    292315 
    293316      // Variables 
    294317      $members = array(); 
     318      $guests = array(); 
     319      $bots = array(); 
    295320      $total_users = 0; 
    296321      $total_members = 0; 
     
    311336            // Get Users Information 
    312337            foreach($users_browse as $user_browse) { 
    313                   if($user_browse->username == 'Guest') { 
    314                         $total_guests++; 
    315                   } elseif(in_array($user_browse->username, $bots_name)) { 
    316                         $total_bots++; 
    317                   } else { 
    318                         $members[] = stripslashes($user_browse->username); 
    319                         $total_members++; 
     338                  switch($user_browse->type) { 
     339                        case 'member': 
     340                              $members[] = stripslashes($user_browse->displayname); 
     341                              $total_members++; 
     342                              break; 
     343                        case 'guest':                                    
     344                              $guests[] = stripslashes($user_browse->displayname); 
     345                              $total_guests++; 
     346                              break; 
     347                        case 'bot': 
     348                              $bots[] = stripslashes($user_browse->displayname); 
     349                              $total_bots++; 
     350                              break; 
    320351                  } 
    321352            } 
     
    386417### Function: Check IP 
    387418function check_ip($ip) { 
    388    $ip2long = ip2long($ip); 
    389    if(is_user_logged_in() && ($ip != 'unknown') && $ip == long2ip($ip2long) && $ip2long !== false) { 
    390       return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)"; 
    391    } 
     419      $current_user = wp_get_current_user(); 
     420      $user_level = intval($current_user->wp_user_level); 
     421      $ip2long = ip2long($ip); 
     422      if($user_level == 10 && ($ip != 'unknown') && $ip == long2ip($ip2long) && $ip2long !== false) { 
     423            return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)"; 
     424      } 
     425
     426 
     427 
     428### Function Check If User Is Online 
     429function is_online($user_login) {  
     430      global $wpdb; 
     431      $is_online = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline WHERE username = '$user_login' LIMIT 1"); 
     432      return intval($is_online); 
    392433} 
    393434 
     
    398439            $country_code = wp_ozh_getCountryCode(0, $ip); 
    399440            $country_name = wp_ozh_getCountryName(0, $ip); 
     441            $country_mirror = ''; 
     442            $mirrors = array("http://frenchfragfactory.net/images", "http://www.lesterchan.net/wordpress/images/flags"); 
    400443            if($country_name != 'Private') { 
    401                   $temp = '<img src="http://frenchfragfactory.net/images/flag_'.$country_code.'.gif" alt="'.$country_name.'" />'; 
     444                  foreach($mirrors as $mirror) { 
     445                        if(file($mirror.'/flag_sg.gif')) { 
     446                              $country_mirror = $mirror; 
     447                              break; 
     448                        } 
     449                  } 
     450                  $temp = '<img src="'.$mirror.'/flag_'.$country_code.'.gif" alt="'.$country_name.'" />'; 
    402451                  if($display_countryname) { 
    403452                        $temp .= $country_name; 
     
    415464function display_useronline() { 
    416465      global $wpdb; 
    417       // Reassign Bots Name 
    418       $bots = get_settings('useronline_bots'); 
    419       $bots_name = array(); 
    420       foreach($bots as $botname => $botlookfor) { 
    421             $bots_name[] = $botname; 
    422       } 
    423  
    424466      // Get The Users Online 
    425       $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline"); 
     467      $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline ORDER BY type"); 
    426468 
    427469      // Variables Variables Variables 
     
    441483      if($usersonline) { 
    442484            foreach($usersonline as $useronline) { 
    443                   if($useronline->username == 'Guest') { 
    444                         $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
    445                         $total_guests++; 
    446                   } elseif(in_array($useronline->username, $bots_name)) { 
    447                         $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
    448                         $total_bots++; 
    449                   } else { 
    450                         $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
    451                         $total_members++; 
     485                  switch($useronline->type) { 
     486                        case 'member': 
     487                              $members[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     488                              $total_members++; 
     489                              break; 
     490                        case 'guest':                                    
     491                              $guests[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     492                              $total_guests++; 
     493                              break; 
     494                        case 'bot': 
     495                              $bots[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     496                              $total_bots++; 
     497                              break; 
    452498                  } 
    453499            } 
     
    482528      } else { 
    483529            $nicetext_bots = number_format($total_bots).' '.__('Bots');  
     530      } 
     531 
     532      // Check Whether WP-Stats Is Activated 
     533      $wp_stats = false; 
     534      if(function_exists('get_totalposts')) { 
     535            $wp_stats = true; 
    484536      } 
    485537?> 
     
    496548                  $no=1; 
    497549                  if($members) { 
    498                         $wp_stats = false; 
    499                         if(function_exists('get_totalposts')) { 
    500                               $wp_stats = true; 
    501                         } 
    502550                        foreach($members as $member) { 
    503551                              if($wp_stats) { 
    504                                     echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.ip2nation_country($member['ip']).check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n"; 
     552                                    echo '<p><b>#'.$no.' - <a href="'.get_settings('siteurl').'/wp-content/plugins/stats/wp-stats.php?author='.$member['display_name'].'">'.$member['display_name'].'</a></b> '.ip2nation_country($member['ip']).check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n"; 
    505553                              } else { 
    506554                                    echo '<p><b>#'.$no.' - '.$member['username'].'</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"; 
     
    509557                        } 
    510558                  } 
     559                  if($total_members > 0) { 
     560                        echo '</div>'; 
     561                  } 
     562 
    511563                  // Print Out Guest 
    512564                  if($total_guests > 0) { 
     
    516568                  if($guests) { 
    517569                        foreach($guests as $guest) { 
    518                               echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.ip2nation_country($guest['ip']).check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n"; 
     570                              if($wp_stats) { 
     571                                    echo '<p><b>#'.$no.' - <a href="'.get_settings('siteurl').'/wp-content/plugins/stats/wp-stats.php?author='.$guest['display_name'].'">'.$guest['display_name'].'</a></b> '.ip2nation_country($guest['ip']).check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n"; 
     572                              } else { 
     573                                    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"; 
     574                              } 
    519575                              $no++; 
    520576                        } 
     577                  } 
     578                  if($total_guests > 0) { 
    521579                        echo '</div>'; 
    522580                  } 
     581 
    523582                  // Print Out Bots 
    524583                  if($total_bots > 0) { 
     
    528587                  if($bots) { 
    529588                        foreach($bots as $bot) { 
    530                               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"; 
     589                              echo '<p><b>#'.$no.' - '.$bot['display_name'].'</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"; 
    531590                              $no++; 
    532591                        } 
     592                  } 
     593                  if($total_bots > 0) { 
    533594                        echo '</div>'; 
    534595                  } 
     596 
     597                  // Print Out No One Is Online Now 
    535598                  if($total_users == 0) { 
    536599                        echo  '<div class="wrap"><h2>'.__('No One Is Online Now').'</h2></div>'."\n"; 
    537600                  } 
    538             echo '</div>'; 
     601
     602 
     603 
     604### Function: Place Polls Archive In Content 
     605add_filter('the_content', 'place_useronlinepage', '12'); 
     606function place_useronlinepage($content){ 
     607     $content = preg_replace( "/\<page_useronline\>/ise", "useronline_page()", $content);  
     608    return $content; 
     609
     610 
     611 
     612### Function: UserOnline Page 
     613function useronline_page() { 
     614      global $wpdb; 
     615      // Get The Users Online 
     616      $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline ORDER BY type"); 
     617 
     618      // Variables Variables Variables 
     619      $useronline_output = ''; 
     620      $members = array(); 
     621      $guests = array(); 
     622      $bots = array(); 
     623      $total_users = 0; 
     624      $total_members = 0; 
     625      $total_guests = 0; 
     626      $total_bots = 0; 
     627      $nicetext_users = ''; 
     628      $nicetext_members = ''; 
     629      $nicetext_guests = ''; 
     630      $nicetext_bots = ''; 
     631 
     632      // Process Those User Who Is Online 
     633      if($usersonline) { 
     634            foreach($usersonline as $useronline) { 
     635                  switch($useronline->type) { 
     636                        case 'member': 
     637                              $members[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     638                              $total_members++; 
     639                              break; 
     640                        case 'guest':                                    
     641                              $guests[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     642                              $total_guests++; 
     643                              break; 
     644                        case 'bot': 
     645                              $bots[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     646                              $total_bots++; 
     647                              break; 
     648                  } 
     649            } 
     650            $total_users = ($total_guests+$total_bots+$total_members); 
     651      } 
     652 
     653      // Nice Text For Users 
     654      if($total_users == 1) { 
     655            $nicetext_users = $total_users.' '.__('User'); 
     656      } else { 
     657            $nicetext_users = number_format($total_users).' '.__('Users'); 
     658      } 
     659 
     660      //  Nice Text For Members 
     661      if($total_members == 1) { 
     662            $nicetext_members = $total_members.' '.__('Member'); 
     663      } else { 
     664            $nicetext_members = number_format($total_members).' '.__('Members'); 
     665      } 
     666 
     667 
     668      // Nice Text For Guests 
     669      if($total_guests == 1) {  
     670            $nicetext_guests = $total_guests.' '.__('Guest'); 
     671      } else { 
     672            $nicetext_guests = number_format($total_guests).' '.__('Guests');  
     673      } 
     674 
     675      //  Nice Text For Bots 
     676      if($total_bots == 1) { 
     677            $nicetext_bots = $total_bots.' '.__('Bot');  
     678      } else { 
     679            $nicetext_bots = number_format($total_bots).' '.__('Bots');  
     680      } 
     681 
     682      // Check Whether WP-Stats Is Activated 
     683      $wp_stats = false; 
     684      if(function_exists('get_totalposts')) { 
     685            $wp_stats = true; 
     686      } 
     687      $useronline_output .= '<p>'; 
     688      if ($total_users == 1) {  
     689            $useronline_output .= __('There is ');  
     690      } else {  
     691            $useronline_output .= __('There are a total of '); 
     692      } 
     693      $useronline_output .= "<b>$nicetext_users</b> online now: <b>$nicetext_members</b>, <b>$nicetext_guests</b> and <b>$nicetext_bots</b>.</p>\n"; 
     694      $useronline_output .= "<p>Most users ever online were <b>".get_most_useronline(false)."</b>, on <b>".get_most_useronline_date(false)."</b></p>\n"; 
     695      // Print Out Members 
     696      if($total_members > 0) { 
     697            $useronline_output .=   '<h2 class="pagetitle">'.$nicetext_members.' '.__('Online Now').'</h2>'."\n"; 
     698      } 
     699      $no=1; 
     700      if($members) { 
     701            foreach($members as $member) { 
     702                  if($wp_stats) { 
     703                        $useronline_output .= '<p><b>#'.$no.' - <a href="'.get_settings('siteurl').'/wp-content/plugins/stats/wp-stats.php?author='.$member['display_name'].'">'.$member['display_name'].'</a></b> '.ip2nation_country($member['ip']).check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n"; 
     704                  } else { 
     705                        $useronline_output .= '<p><b>#'.$no.' - '.$member['username'].'</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"; 
     706                  } 
     707                  $no++; 
     708            } 
     709      } 
     710 
     711      // Print Out Guest 
     712      if($total_guests > 0) { 
     713            $useronline_output .= '<h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n"; 
     714      } 
     715      $no=1; 
     716      if($guests) { 
     717            foreach($guests as $guest) { 
     718                  if($wp_stats) { 
     719                        $useronline_output .= '<p><b>#'.$no.' - <a href="'.get_settings('siteurl').'/wp-content/plugins/stats/wp-stats.php?author='.$guest['display_name'].'">'.$guest['display_name'].'</a></b> '.ip2nation_country($guest['ip']).check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n"; 
     720                  } else { 
     721                        $useronline_output .= '<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"; 
     722                  } 
     723            } 
     724      } 
     725 
     726      // Print Out Bots 
     727      if($total_bots > 0) { 
     728            $useronline_output .= '<h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n"; 
     729      } 
     730      $no=1; 
     731      if($bots) { 
     732            foreach($bots as $bot) { 
     733                  $useronline_output .= '<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"; 
     734                  $no++; 
     735            } 
     736      } 
     737 
     738      // Print Out No One Is Online Now 
     739      if($total_users == 0) { 
     740            $useronline_output .= '<h2 class="pagetitle">'.__('No One Is Online Now').'</h2>'."\n"; 
     741      } 
     742 
     743      // Output UserOnline Page 
     744      return $useronline_output; 
    539745} 
    540746 
     
    551757      $create_table = "CREATE TABLE $wpdb->useronline (". 
    552758                                          " timestamp int(15) NOT NULL default '0',". 
    553                                           " username varchar(50) NOT NULL default '',". 
     759                                          " userid int(10) NOT NULL default '0',". 
     760                                          " username varchar(255) NOT NULL default '',". 
     761                                          " displayname varchar(255) NOT NULL default '',". 
    554762                                          " useragent varchar(255) NOT NULL default '',". 
    555763                                          " ip varchar(40) NOT NULL default '',".                                   
    556764                                          " location varchar(255) NOT NULL default '',". 
    557765                                          " url varchar(255) NOT NULL default '',". 
     766                                          " type enum('member','guest','bot') NOT NULL default 'guest',". 
    558767                                          " UNIQUE KEY useronline_id (timestamp,username,ip,useragent))"; 
    559768      maybe_create_table($wpdb->useronline, $create_table); 
     
    563772      add_option('useronline_timeout', 300, 'Timeout In Seconds'); 
    564773      add_option('useronline_bots', $bots, 'Bots Name/Useragent'); 
     774      // Database Upgrade For WP-UserOnline 2.05 
     775      add_option('useronline_url', get_settings('siteurl').'/useronline/', 'UserOnline Page URL'); 
    565776} 
    566777?> 
  • wp-useronline/trunk/useronline/wp-useronline.php

    r6244 r6286  
    2727} 
    2828 
    29 ### Reassign Bots Name 
    30 $bots = get_settings('useronline_bots'); 
    31 $bots_name = array(); 
    32 foreach($bots as $botname => $botlookfor) { 
    33       $bots_name[] = $botname; 
    34 } 
    35  
    3629### Get The Users Online 
    37 $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline"); 
     30$usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline ORDER BY type"); 
    3831 
    3932### Variables Variables Variables 
     
    5346if($usersonline) { 
    5447      foreach($usersonline as $useronline) { 
    55             if($useronline->username == 'Guest') { 
    56                   $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
    57                   $total_guests++; 
    58             } elseif(in_array($useronline->username, $bots_name)) { 
    59                   $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
    60                   $total_bots++; 
    61             } else { 
    62                   $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url))); 
    63                   $total_members++; 
     48            switch($useronline->type) { 
     49                  case 'member': 
     50                        $members[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     51                        $total_members++; 
     52                        break; 
     53                  case 'guest':                                    
     54                        $guests[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     55                        $total_guests++; 
     56                        break; 
     57                  case 'bot': 
     58                        $bots[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes($useronline->url)); 
     59                        $total_bots++; 
     60                        break; 
    6461            } 
    6562      } 
     
    9592      $nicetext_bots = number_format($total_bots).' '.__('Bots');  
    9693} 
     94 
     95### Check Whether WP-Stats Is Activated 
     96$wp_stats = false; 
     97if(function_exists('get_totalposts')) { 
     98      $wp_stats = true; 
     99} 
    97100?> 
    98101<?php get_header(); ?> 
     
    107110                  $no=1; 
    108111                  if($members) { 
    109                         $wp_stats = false; 
    110                         if(function_exists('get_totalposts')) { 
    111                               $wp_stats = true; 
    112                         } 
    113112                        foreach($members as $member) { 
    114113                              if($wp_stats) { 
    115                                     echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.ip2nation_country($member['ip']).check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n"; 
     114                                    echo '<p><b>#'.$no.' - <a href="'.get_settings('home