
Originally Posted by
renan7899
I really don't think it's necessary to do queries to check GMs nicknames since you, as an admin, will know their nicknames xD
But anyway... nice code, thanks. =)
...lol, hrace009 is becoming a password example :rofl:
hrace009 is the password on my local test server. It was originally based on his release and is now extremely modified and half his, half 343's release...I meant to take that info out of the code, but who cares. I made better new code below.

Originally Posted by
tbnanubis
with that query you get all online gms without even knowing any name or id of them, just by help of the auth table:
Code:
$query_str = "SELECT point.uid, point.zoneid, roles.role_name FROM point INNER JOIN roles ON point.uid = roles.role_id WHERE point.zoneid<>'null' and point.uid in (SELECT DISTINCT auth.userid FROM auth )";
Hmm? I see what this does, but I'm not sure what the auth table data is. Does it only contain the user IDs of the GMs? If so, alright, but what's rid for, if you know?
Also, this query isn't quite right, I fixed it in the below code. You only grabbed the user if they were online, which is going to skip those who are offline.
----------
This is heavily modified even from my earlier one and better documented.
PHP Code:
<?php
define('DB_HOST', 'localhost'); // Database Location
define('DB_USERNAME', 'root'); // Database Username
define('DB_PASSWORD', 'mypws'); // Database Password
define('DB_NAME', 'pws'); // Database Name
define('GM_ONLINE', '<font color="#006600">Online</font>'); // GM online message
define('GM_OFFLINE', '<font color="red">Offline</font>'); // GM offline message
$mysql_connection = @mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or die('MySQL connection failed!');
$mysql_db = @mysql_select_db(DB_NAME, $mysql_connection) or die('MySQL failed to select database!');
$query; // null
$query_str;
$output_info = array();
$output = '';
// Optional Ranks for GMs
$gm_ranks = array(
// 'GM Name' => 'Rank'
'MyCharacter' => 'Rank',
'Rank2 GM' => 'Rank2',
'SomeGuy' => 'Rank3',
);
// 'GM Name' => true | This will filter their name out
// 'GM Name' => false| This will NOT filter their name out
// Leaving it empty will also NOT filter out GMs names
$gm_filter = array( // Any GMs you don't want to show...
'GM Name' => true,
);
// Query
$query_str = "SELECT point.zoneid, roles.role_name FROM point INNER JOIN roles ON point.uid = roles.role_id WHERE point.uid IN (SELECT DISTINCT auth.userid FROM auth)";
// Execute Query
$query = @mysql_query($query_str);
// echo '<pre>' . $query_str . '</pre>'; // You can view the generated query with this
// If query is successful
if ( $query )
{
// if query is not empty, fetch all information
if ( mysql_num_rows($query) )
{
while ( $current_row = mysql_fetch_array($query) )
{
$output_info[] = $current_row;
}
}
}
else
{
echo 'MySQL query failed!';
}
// Output Area
if ( count($output_info) )
{
// echo '<pre>' . print_r($output_info, 1) . '</pre>'; // You can view the data obtained from the database with this
// Iterate through output query data
foreach ( $output_info as $gm => $data )
{
// If GM isn't filtered out
if ( !$gm_filter[$data['role_name']] )
{
// Apply title if user has title
if ( $gm_ranks[$data['role_name']] )
{
$output .= '[' . $gm_ranks[$data['role_name']] . ']';
}
// Output GM name
$output .= htmlentities($data['role_name']) . ' ';
// Output status
if ( $data['zoneid'] )
{
$output .= GM_ONLINE;
}
else
{
$output .= GM_OFFLINE;
}
// Output line break
$output .= '<br />';
}
}
// Print out generated output
echo $output;
}
?>
------------
Renan, I'm going to be adding this (my code) to my php PerfectWorldAPI class. Thank you for getting it started though.