require 'header.inc';
check_auth($_SERVER['PHP_SELF']); // checks for required access
// Checks guild war times
$time_string = date("Hi");
$agit_dates = explode(",", $CONFIG_agit_days);
$agit_starts = explode(",",$CONFIG_agit_start);
$agit_ends = explode(",",$CONFIG_agit_end);
if ($STORED_level < 2 && $CONFIG_server_type > 0) {
if (in_array(date("w"), $agit_dates)) { //checks if it is a WoE day
$agit_index = array_search(date("w"), $agit_dates); //index of day -> corresponds to time index
$agit_starttime = $agit_starts[$agit_index]; if (!$agit_starttime) { $agit_starttime = $agit_starts[count($agit_starts)-1]; }
$agit_endtime = $agit_ends[$agit_index]; if (!$agit_endtime) { $agit_endtime = $agit_ends[count($agit_ends)-1]; }
if (($time_string > $agit_starttime) && ($time_string < $agit_endtime)) {
redir("index.php", $lang['onlineguildwar']);
}
}
}
//Who's Online
if (!$GET_map) {
if ($CONFIG_server_type == 0) {
$query = sprintf(SHOW_ONLINE, "", ONLINE_WITH_GM, "");
$query2 = sprintf(SHOW_ONLINE, "", ONLINE_WITHOUT_GM, "");
}
else {
if ($STORED_level > 2) {
$query = sprintf(SHOW_ONLINE, SHOW_POSITION, ONLINE_WITH_GM, "");
$query2 = sprintf(SHOW_ONLINE, SHOW_POSITION, ONLINE_WITHOUT_GM, "");
}
else {
$query = sprintf(SHOW_ONLINE, "", ONLINE_WITH_GM, "");
$query2 = sprintf(SHOW_ONLINE, "", ONLINE_WITHOUT_GM, "");
}
}
EchoHead(80);
echo "
";
display_online($query, $query2);
}
else {
EchoHead(80);
echo "
";
printf($lang['onlineusersmap'], $GET_map);
echo "
";
if (strlen($GET_map) > 15) {
redir("index.php", $lang['onlineinvalid']);
add_user_entry("Possible SQL injection attempt in whosonline.php");
}
if ($STORED_level > 2) {
$query = sprintf(SHOW_ONLINE, SHOW_POSITION, ONLINE_WITH_GM, sprintf(CONDITION_MAP, $GET_map));
$query2 = sprintf(SHOW_ONLINE, SHOW_POSITION, ONLINE_WITHOUT_GM, sprintf(CONDITION_MAP, $GET_map));
}
else {
$query = sprintf(SHOW_ONLINE, "", ONLINE_WITH_GM, sprintf(CONDITION_MAP, $GET_map));
$query2 = sprintf(SHOW_ONLINE, "", ONLINE_WITHOUT_GM, sprintf(CONDITION_MAP, $GET_map));
}
display_online($query, $query2);
}
require 'footer.inc';
function display_online($input_query, $input_query2) {
global $CONFIG_server_type, $STORED_level, $lang;
$result[0] = execute_query($input_query, "whosonline.php");
$result[1] = execute_query($input_query2, "whosonline.php");
if ($result[0]->RowCount() == 0 && $result[1]->RowCount() == 0) {
echo "
";
}
else {
if ($CONFIG_server_type == 0) {
echo "
";
}
else {
echo "
";
if ($STORED_level > 2) {
echo "
";
}
echo "
";
}
for ($i = 0; $i < 2; $i++) {
while ($line = $result[$i]->FetchRow()) {
echo "
";
foreach ($line as $display_index => $col_value) {
if ($CONFIG_server_type == 0) {
if ($display_index == 3) {
$col_value = $col_value == 1? "Male" : "Female";
}
elseif ($display_index == 4) {
$col_value = convert_ip($col_value);
}
}
else {
if ($display_index == 0) { continue; }
if (($display_index == 1) && ($STORED_level > 2) ) {
$col_value = "{$line[1]}";
}
elseif ($display_index == 2) {
$col_value = determine_class($line[2]);
}
elseif ($display_index == 5 && $STORED_level <= 2) {
$map_name = substr($line[5], 0, strlen($line[5]) - 4);
$col_value = "{$line[5]}";
}
elseif ($display_index == 7 && $STORED_level > 2) {
$map_name = substr($line[7], 0, strlen($line[7]) - 4);
$col_value = "{$line[7]}";
}
}
if ($i == 0) {
echo "
";
}
else {
echo "
}
}
echo "
";
}
}
}
echo "