Well below is the entire plugin, I didn’t make any changes to it:
<?php
/*
Plugin Name: Useronline
Plugin URI: https://www.lesterchan.net/portfolio/programming.php
Description: Adds A Useronline Feature To WordPress
Version: 1.2
Author: GaMerZ
Author URI: https://www.lesterchan.net
*/
function get_IP() {
if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip_address = $_SERVER["REMOTE_ADDR"];
} else {
$ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
if(strpos($ip_address, ',') !== false) {
$ip_address = explode(',', $ip_address);
$ip_address = $ip_address[0];
}
return $ip_address;
}
function useronline($user = 'User', $users = 'Users') {
global $wpdb, $tableuseronline, $cookiehash;
// Search Bots
$bots = array('Google Bot' => 'googlebot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'ask jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'inktomi', 'Turnitin.com' => 'turnitinbot');
// Useronline Settings
$timeoutseconds = 300;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
// Check Members
if(isset($_COOKIE['comment_author_'.$cookiehash])) {
$memberonline = trim($_COOKIE['comment_author_'.$cookiehash]);
$where = "WHERE username='$memberonline'";
// Check Guests
} else {
$memberonline = 'Guest';
$where = "WHERE ip='".get_IP()."'";
}
// Check For Bot
foreach ($bots as $name => $lookfor) {
if (strpos($_SERVER['HTTP_USER_AGENT'], $lookfor) !== false) {
$memberonline = $name;
$where = "WHERE ip='".get_IP()."'";
}
}
// Make Page
$make_page = addslashes(single_post_title('', false));
if(empty($make_page)) {
$make_page = addslashes(get_bloginfo('sitename'));
}
// Update User First
$update_user = $wpdb->query("UPDATE $tableuseronline SET timestamp='$timestamp',ip='".get_IP()."',location='$make_page',url='".$_SERVER['REQUEST_URI']."' $where");
// If No User Insert It
if(!$update_user) {
$insert_user = $wpdb->query("INSERT INTO $tableuseronline VALUES ('$timestamp','$memberonline','".get_IP()."','$make_page','".$_SERVER['REQUEST_URI']."')");
}
$delete_users = $wpdb->query("DELETE FROM $tableuseronline WHERE timestamp<$timeout");
$useronline = $wpdb->get_var("SELECT COUNT(*) FROM $tableuseronline");
if($useronline > 1) {
$useronline = "<b>$useronline</b> $users Online";
} else {
$useronline = "<b>$useronline</b> $user Online";
}
return $useronline;
}
?>
And it used to work until I put on the coppermine plugin.
The coppermine plugin is using a separate database that I have for my pictures.