#!/usr/local/bin/php -q $data ) { $title = $data["title"]; $level = $data["level"]; $last_visit = $data["last_visit"]; $name = $data["name"]; $race = $data["race"]; $last_login = date("F d Y H:i:s.", $last_visit ); $player_info .= "
$name $title [ $race ] Last visit: $last_login
\n"; //increment total number of players $total_players++; //last visited: $now = time(); if( $now - $last_visit <= 1800 ) $active_players++; else $inactive_players++; } } } //open up our page that should have already been created with the header call above $fp = fopen($html_page,"a"); $page_info = "There are: $total_players Total Players
$active_players are active and $inactive_players are inactive

Player List:
$player_info
"; fputs($fp, $page_info); fclose($fp); /************************* * end page output area * *************************/ echo "All done! Go visit your site =)\n"; /************************ * SUPPORTIVE FUNCTIONS ************************/ function read_pfile( $file ) { if( !file_exists( $file ) ) { echo "$file file doesn't exist"; exit; } $handle = fopen($file, "r"); if( !$handle ) { echo "unable to open $file\n"; exit; } $contents = ""; while (!feof($handle)) { $contents .= fread($handle, 4096); } fclose($handle); return $contents; } function parse_pfile($file) { $contents = read_pfile($file); $player_data = ""; /* bool check to make sure we don't double up on this pfile contents * We want the first occurence of "Name", "Title", etc.. */ $bool_name = $bool_title = $bool_race = $bool_desc = $bool_level = 0; //go thread each line now $hold = explode("\n", $contents); foreach( $hold as $line ) { //seperate the identifier in this line $line_split = split(" ", $line); $identifier = $line_split[0]; switch( $identifier ) { case 'Name': if( !$bool_name ) { $name = fread_string( "Name", $line ); $player_data["$name"]["name"] = $name; $bool_name = 1; //while here, go ahead and find out when we //last logged in $last_visit = date( filemtime( $file ) ); $player_data["$name"]["last_visit"] = $last_visit; } break; case 'Levl': if( !$bool_level ) { $level = fread_number( "Levl", $line ); $player_data["$name"]["level"] = $level; $bool_level = 1; } break; case 'Desc': if( !$bool_desc ) { $description = fread_string( "Desc", $line ); $player_data["$name"]["description"] = $description; $bool_desc = 1; } break; case 'Race': if( !$bool_race ) { $race = ucwords( fread_string( "Race", $line ) ); $player_data["$name"]["race"] = $race; $bool_race = 1; } break; case 'Titl': if( !$bool_title ) { $title = fread_string( "Titl", $line ); $player_data["$name"]["title"] = $title; $bool_title = 1; } break; } } if( is_array( $player_data ) ) { return $player_data; } return; } function fread_string( $identifier, $string ) { if( empty( $identifier ) ) return ""; return (trim( ereg_replace( "$identifier ", "", substr( $string, 0, -1 ) ))); } function fread_number( $identifier, $string ) { if( empty( $identifier ) ) return ""; return( ereg_replace("$identifier ", "", trim($string) )); } function output_page_header() { global $html_page; $fp = fopen($html_page, "w+"); if( !$fp ) { echo "Unable to open the website page: $html_page\n"; return; } $date = date("D M j h:i a"); $page_output ="\n\nPlayer List
Last Updated on $date
"; fputs($fp, $page_output); } ?>