[PHP] Players online

Hi,

is there a simple script for fetching the total no of players online and waiting in que for the latest trinity core.

Thank you

Here

Config

[CODE]<?php

$port = “”;

$host = “”;

$user = “”;

$pass = “”;

$mangoscharacters = “”;

$mangosrealm = “”;

$cod = ‘utf8’;

?>[/CODE]

[CODE]

<? require_once ( 'config.php'); mysql_connect ("$host","$user","$pass"); mysql_select_db ("$mangoscharacters"); $result = mysql_query ("SELECT name, race, class, level, gender FROM characters WHERE online = 1"); $num_online = mysql_num_rows($result); $class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Brujo",11=>"Druid"); $race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei"); $gender = array(0=>"Male",1=>"Female"); if($num_online < 1) { echo ""; } for($i=0; $i<$num_online; $i++) { $row = mysql_fetch_array($result); $t_name = $row['name']; $t_race = $row['race']; $t_class = $row['class']; $t_lvl = $row['level']; $t_gender = $row['gender']; echo ""; echo ""; echo ""; echo " echo ""; }[/CODE]
Nick: Race: Class: Level: Gender:
No Players Online!
$t_name $race[$t_race] $class[$t_class] $t_lvl $gender[$t_gender]

dude

echo "<td><b>$gender[$t_gender]</b></td> This is for wath ???

@Diantonix:-

thanks a lot…

btw is there a CMS which is already released for the latest trinity?

the sex of the character /emoticons/default_biggrin.png

yes exist better cms and is named MangosWeb Enhanced V3 and i added a link to help out, and maybe is not right place to post it.

no

echo "<td><b>$gender[$t_gender]</b></td>this show err test you see /emoticons/default_wink.png

maybe

echo "<td><b>$gender</b></td>

would work

you really should cache the hole thing into a file…

[CODE]

$filename = ‘…/cache/server_stats.txt’;

if (file_exists($filename)) {

$time_mod =  filemtime($filename);

}

$time_now = time();

if($time_mod > $time_now-60*5) {

include("../cache/server_stats.txt");//....... just include it

}else{

//put your stats here

//write it into a file

$filename = ‘…/cache/server_stats.txt’;

$somecontent = $output;

// Let’s make sure the file exists and is writable first.

if (is_writable($filename)) {

if (!$handle = fopen($filename, 'w')) {

     echo "Cannot open file ($filename)";

     exit;

}

if (fwrite($handle, $somecontent) === FALSE) {

    echo "Cannot write to file ($filename)";

    exit;

}

//Success, wrote to file

fclose($handle);

echo $output;

} else {

die("cache file not writeable.");

}

}[/CODE]

or just write it into a file using a cron job…

Ok this may sound noob of me.

But i cant get this to work, i got the config setup correctly, i put players.php in the same spot as the config, but all im getting is a blank page… im not sure why php is enabled as i do got the account page working just cant get this to work, its probly something im missing any idea’s?.

[CODE]

<? require_once ( 'config.php'); mysql_connect ("$host","$user","$pass"); mysql_select_db ("$mangoscharacters"); $result = mysql_query ("SELECT name, race, class, level, gender FROM characters WHERE online = 1"); $num_online = mysql_num_rows($result); $class = array(1=>"Warrior",2=>"Paladin",3=>"Hunter",4=>"Rogue",5=>"Priest",6=>"Death Knight",7=>"Shaman",8=>"Mage",9=>"Brujo",11=>"Druid"); $race = array(1=>"Human",2=>"Orc",3=>"Dwarf",4=>"Night Elf",5=>"Undead",6=>"Tauren",7=>"Gnome",8=>"Troll",10=>"Blood Elf",11=>"Draenei"); $gender = array(0=>"Male",1=>"Female"); if($num_online < 1) { echo ""; } for($i=0; $i<$num_online; $i++) { $row = mysql_fetch_array($result); $t_name = $row['name']; $t_race = $row['race']; $t_class = $row['class']; $t_lvl = $row['level']; $t_gender = $row['gender']; echo ""; echo ""; echo ""; echo ""; echo ""; } ?>[/CODE]

ok there was some stuff missing this one works though now.

EDIT: for those who are interested what was making it not work… it was just this little piece… if you look here

echo "

echo "

";

}

a "; is missing on echo "

and there was also no ?> at the end “no closings”.

Nick: Race: Class: Level: Gender:
No Players Online!
$t_name $race[$t_race] $class[$t_class] $t_lvl $gender[$t_gender]
$t_lvl $gender[$t_gender]
$t_lvl