'Who\'s Online', 'pi_version' => '1.0', 'pi_author' => 'Jeff Barsky', 'pi_author_url' => 'http://www.miasmaofmusings.com', 'pi_description' => 'Creates a configurable list of who is online, with supporting member info.', 'pi_usage' => whos_online::usage() ); class Whos_online { // Open Class var $return_data = ''; function Whos_online() { // Open Cat_lister Function // Set Globals and Variables global $TMPL, $DB, $LOC; $return = ''; $tagdata = ''; $fields = array( 'group_id','screen_name','email','url','location','occupation', 'interests','bday_d','bday_m','bday_y','avatar_filename', 'avatar_width','avatar_height','photo_filename','photo_width', 'photo_height','join_date','last_visit','last_entry_date', 'last_comment_date','last_forum_post_date','last_activity', 'total_entries','total_comments','total_forum_topics', 'total_forum_posts' ); $aa = 0; $ap = 0; // Fetch Parameters $max_select = (!$TMPL->fetch_param('max_select') ) ? "0" : $TMPL->fetch_param('max_select') ; $jd_format = (!$TMPL->fetch_param('jd_format') ) ? "m/d/Y" : $TMPL->fetch_param('jd_format') ; $le_format = (!$TMPL->fetch_param('le_format') ) ? "m/d/Y" : $TMPL->fetch_param('le_format') ; $lc_format = (!$TMPL->fetch_param('lc_format') ) ? "m/d/Y" : $TMPL->fetch_param('lc_format') ; $lv_format = (!$TMPL->fetch_param('lv_format') ) ? "m/d/Y" : $TMPL->fetch_param('lv_format') ; $lf_format = (!$TMPL->fetch_param('lf_format') ) ? "m/d/Y" : $TMPL->fetch_param('lf_format') ; $la_format = (!$TMPL->fetch_param('la_format') ) ? "m/d/Y" : $TMPL->fetch_param('la_format') ; $alt_image = (!$TMPL->fetch_param('alt_image') ) ? "alt/image.jpg|50|50" : $TMPL->fetch_param('alt_image') ; $alt_avatar = (!$TMPL->fetch_param('alt_avatar') ) ? "alt/avatar.jpg|50|50" : $TMPL->fetch_param('alt_avatar') ; $alt_loc = (!$TMPL->fetch_param('alt_loc') ) ? "Somewhere, USA" : $TMPL->fetch_param('alt_loc') ; // Validate Imported Data // Convert the archaic "date formating" to PHP formatting $jd_format = ereg_replace('%','',$jd_format); $le_format = ereg_replace('%','',$le_format); $lc_format = ereg_replace('%','',$lc_format); $lv_format = ereg_replace('%','',$lv_format); $lf_format = ereg_replace('%','',$lf_format); $la_format = ereg_replace('%','',$la_format); $max_select = ereg('[:alpha:][:punct:]', $max_select ) ? "0" : $max_select; // Expand "Alt" variables (This is so much easier in PERL) $x = split('[|]', $alt_image) ; $alt_image = $x[0]; $alt_imgw = $x[1]; $alt_imgh = $x[2]; $x = split('[|]', $alt_avatar); $alt_avatar = $x[0]; $alt_avaw = $x[1]; $alt_avah = $x[2]; // Create Query $sql = "Select "; foreach ($fields as $tmp) { $sql .= $tmp.", "; } // Clean off end of Query $sql = substr($sql, 0, (strlen($sql)-2)); // More of the query $sql .= " FROM exp_members, exp_online_users WHERE exp_online_users.member_id = exp_members.member_id"; // Limit List To X if ($max_select >= 1){ $sql .= " LIMIT ".$max_select; } // Run That Query $query = $DB->query($sql); // First Bail Out Point if ( $query->num_rows == 0 ) { return false; } // Prepare data for output, interate over rows foreach ($query->result as $row) { // Ok, get the TEMPLATE data, this will have to be "Clean" with each // interation so to have a place to put data. $tagdata = $TMPL->tagdata; // Run Date Logic (I do this here because it is easier to parse for "0" than "M/D/Y" // I use "join_date" as default since all users have to have a join date. $row['last_entry_date'] = ($row['last_entry_date'] == "0") ? $row['join_date'] : $row['last_entry_date'] ; $row['last_comment_date'] = ($row['last_comment_date'] == "0") ? $row['join_date'] : $row['last_comment_date'] ; $row['last_visit'] = ($row['last_visit'] == "0") ? $row['join_date'] : $row['last_visit'] ; $row['last_forum_post_date'] = ($row['last_forum_post_date'] == "0") ? $row['join_date'] : $row['last_forum_post_date'] ; $row['last_activity'] = ($row['last_activity'] == "0") ? $row['join_date'] : $row['last_activity'] ; // Prepare data for output, interate over cells foreach($row as $key => $val){ // OK, I have the data exposed at last, lets make the changes to // the data that need to be made: // Change Dates and Location $val = ($key == "join_date") ? date($jd_format, $val) : $val; $val = ($key == "last_entry_date") ? date($le_format, $val) : $val; $val = ($key == "last_comment_date") ? date($lc_format, $val) : $val; $val = ($key == "last_visit") ? date($lv_format, $val) : $val; $val = ($key == "last_forum_post_date") ? date($lf_format, $val) : $val; $val = ($key == "last_activity") ? date($la_format, $val) : $val; $val = ($key == "location" && $val == "") ? $alt_loc : $val ; // Change out Photo Alternative Data if ($key == "photo_filename" && $val == ""){ $val = $alt_image; $ap = 1; } $val = ($key == "photo_width" && $ap) ? $alt_imgw : $val ; $val = ($key == "photo_height" && $ap) ? $alt_imgh : $val ; // Change out Avatar Alternative Data if ($key == "avatar_filename" && $val == ""){ $val = $alt_avatar; $aa = 1; } $val = ($key == "avatar_width" && $aa) ? $alt_avaw : $val ; $val = ($key == "avatar_height" && $aa) ? $alt_avah : $val ; // Move the new values back to array: $row[$key] = $val; } // Reset Flags $ap = "0"; $aa = "0"; // Now that I have changed the data, plug it into the output string // so it looks pretty and makes sense: foreach ($fields as $tmp){ $qtmp = "{".$tmp."}"; $tagdata = ereg_replace("$qtmp", $row[$tmp], $tagdata); } // Now concontate this row to the next row preparing for output $return .= $tagdata; } // Output all the data for output $this->return_data = $return; } // Close Cat_lister Function function usage() { // Open Usage ob_start(); ?> ------------------------------------ WHAT THIS DOES: ------------------------------------ This allows you to display a list of people currently online with more information than just a name. This is not ordered in any way (this version) but will allow you to limit the number shown as well. This does not support conditionals within the tag (yet). Personally I use it just to show the avatar of everyone who is online right now, but ovbiously there is room for more uses than just that. The real time nature of the plugin is nice because it is constantly changing the display, adds interest. ------------------------------------ BASIC USAGE: ------------------------------------ {exp:whos_online} Available Fields: {group_id}, {screen_name}, {email}, {url}, {location}, {occupation} {interests}, {bday_d}, {bday_m}, {bday_y}, {avatar_filename}, {avatar_width}, {avatar_height}, {photo_filename}, {photo_width}, {photo_height}, {join_date}, {last_visit}, {last_entry_date}, {last_comment_date} {last_forum_post_date}, {last_activity}, {total_entries}, {total_comments} {total_forum_topics}, {total_forum_posts} {/exp:whos_online} ------------------------------------ EXAMPLE OF USAGE: ------------------------------------