Example #1
0
    $end_datetime->setTimezone($tz);
    if ($status_time) {
        $status_datetime = new DateTime("@{$status_time}");
        $status_datetime->setTimezone($tz);
    } else {
        $status_datetime = false;
    }
    $detect_datetime = new DateTime("@{$detect_time}");
    $detect_datetime->setTimezone($tz);
    $impacttime = getTimeString($endtime - $starttime);
    if ($endtime >= $detect_time) {
        $resolvetime = getTimeString($endtime - $detect_time);
    } else {
        $resolvetime = $impacttime;
    }
    $undetecttime = getTimeString($detect_time - $starttime);
    $edit_status = Postmortem::get_event_edit_status($event);
    $content = 'content/edit';
    $curl_client = new CurlClient();
    $show_sidebar = false;
    include 'views/page.php';
});
$app->delete('/events/:id', function ($id) use($app) {
    header("Content-Type: application/json");
    $res = Postmortem::delete_event($id);
    if ($res["status"] == Postmortem::ERROR) {
        $app->response->status(500);
        echo json_encode($res["error"]);
    } else {
        $app->response->status(204);
    }
            if ($best_score_unitsProducedCount == $player_stats['unitsProducedCount']) {
                $player_score_class = "player_high_score";
            }
            printf("\t\t\t\t<td class='%s'>%s</td>%s", $player_score_class, htmlspecialchars($player_stats['unitsProducedCount'], ENT_QUOTES), PHP_EOL);
            $player_score_class = "player_losing_score";
            if ($best_score_resourceHarvestedCount == $player_stats['resourceHarvestedCount']) {
                $player_score_class = "player_high_score";
            }
            printf("\t\t\t\t<td class='%s'>%s</td>%s", $player_score_class, htmlspecialchars($player_stats['resourceHarvestedCount'], ENT_QUOTES), PHP_EOL);
            $player_score = $player_stats['enemyKillCount'] * 100 + $player_stats['unitsProducedCount'] * 50 + $player_stats['resourceHarvestedCount'] / 10;
            $player_score_class = "player_losing_score";
            if ($player_score == $best_score) {
                $player_score_class = "player_high_score";
            }
            printf("\t\t\t\t<td class='%s'>%s</td>%s", $player_score_class, number_format(htmlspecialchars($player_score, ENT_QUOTES), 0), PHP_EOL);
            printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($player_stats['quitBeforeGameEnd'] ? "yes" : "no", ENT_QUOTES), PHP_EOL);
            $quitTime = $player_stats['quitTime'];
            $quitTime = getTimeString($quitTime);
            printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($quitTime, ENT_QUOTES), PHP_EOL);
            echo "\t\t\t" . '</tr>' . PHP_EOL;
        }
        unset($all_player_stats);
        unset($player_stats);
    }
    unset($all_stats);
    unset($stats);
}
echo '		</table>' . PHP_EOL;
//echo '		<p>' . PHP_EOL;
//echo '			<br />' . PHP_EOL;
//echo '		</p>' . PHP_EOL;
Example #3
0
/**
    This method displays the path instructions on the right side of the screen.
    
    @param $path<Path2> the path found by the algorithm
*/
function printPath($path)
{
    global $website;
    $debug = false;
    $count = count($path);
    if ($debug) {
        echo "path count = {$count}<br/>\n";
        if ($count > 1) {
            print_r($path);
        } else {
            echo "path = {$path}<br/>";
        }
    }
    $old_lines = null;
    if ($count > 0) {
        // print consolidated path
        echo "<table border=\"1\">\n<thead>\n";
        echo "<tr><td style=\"text-align: center;padding: 0 2px 0 2px\"><b>Step</b></td>";
        echo "<td class=\"instruction\"><b>Instructions</b></td><td style=\"text-align: center;padding: 0 2px 0 2px\"><b>Time</b></td></tr>\n";
        echo "</thead>\n<tbody>\n";
        $old_lines = null;
        for ($x = 0; $x < $count; $x++) {
            $y = $x + 1;
            $segment = $path[$x];
            if ($debug) {
                echo $segment . "<br/>";
                echo "segment = " . $segment->toString() . "<br/>";
            }
            $marker = $segment->m1;
            $m1_name = $marker->name;
            $m1lat = $marker->getLat();
            $m1lng = $marker->getLng();
            $m2_name = $segment->m2->name;
            $connection = $segment->connection;
            if ($connection == "walking") {
                echo "<tr><td style=\"text-align: center\"><a href=\"javascript:focusOn(new GLatLng({$m1lat},{$m1lng}), map.getZoom());\">[ {$y} ]</a></td><td class=\"instruction\">Walk from <b>{$m1_name}</b> to <b>{$m2_name}</b>. ";
                $rawTime = $segment->t;
                $time_string = getTimeString($rawTime);
                echo "</td><td style=\"text-align: center;padding:1px 2px 1px 2px\">{$time_string}</td></tr>\n";
            } else {
                if ($connection == "transfer") {
                    $lines = $segment->lines;
                    $from_string = "";
                    $to_string = "";
                    for ($i = 0; $i < count($old_lines); $i++) {
                        //if (!in_array($old_lines[$i], $lines)) {
                        $from_string .= "<img width=\"20\" src=\"images/" . $old_lines[$i]->img . "\"/>";
                        //}
                    }
                    for ($i = 0; $i < count($lines); $i++) {
                        //if (!in_array($lines[$i], $old_lines)) {
                        $to_string .= "<img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/>";
                        //}
                    }
                    echo "<tr><td style=\"text-align: center\"><a href=\"javascript:focusOn(new GLatLng({$m1lat},{$m1lng}), map.getZoom());\">[ {$y} ]</a></td><td class=\"instruction\">Transfer from <b>{$m1_name}</b> {$from_string} to <b>{$m2_name}</b> {$to_string}";
                    $rawTime = $segment->t;
                    $time_string = getTimeString($rawTime);
                    echo "</td><td style=\"text-align: center;padding:1px 2px 1px 2px\">{$time_string}</td></tr>\n";
                } else {
                    echo "<tr><td style=\"text-align: center\"><a href=\"javascript:focusOn(new GLatLng({$m1lat},{$m1lng}), map.getZoom());\">[ {$y} ]</a></td><td class=\"instruction\">Take ";
                    $lines = $segment->lines;
                    for ($i = 0; $i < count($lines); $i++) {
                        echo "<a href=\"javascript:void(0);\" onclick=\"window.open('{$website}" . $lines[$i]->url . "');\"><img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/></a>";
                    }
                    echo " from <b>{$m1_name}</b> to <b>{$m2_name}</b>. ";
                    $rawTime = $segment->t;
                    $time_string = getTimeString($rawTime);
                    echo "</td><td style=\"text-align: center;padding:1px 2px 1px 2px\">{$time_string}</td></tr>\n";
                    $old_lines = $lines;
                }
            }
        }
        echo "</tbody>\n</table>\n";
    } else {
        echo "Sorry. No path found.<br/>\n";
    }
}
<?php

//	Copyright (C) 2012 Mark Vejvoda, Titus Tscharntke and Tom Reynolds
//	The Megaglest Team, under GNU GPL v3.0
// ==============================================================
define('INCLUSION_PERMITTED', true);
require_once 'config.php';
require_once 'functions.php';
define('DB_LINK', db_connect());
// consider replacing this by a cron job
cleanupServerList();
$servers_in_db = mysql_query('SELECT a.*,b.framesToCalculatePlaytime FROM glestserver a LEFT JOIN glestgamestats b ON a.gameUUID = b.gameUUID WHERE status <> 3 OR (status = 3 AND a.lasttime > DATE_add(NOW(), INTERVAL - ' . MAX_HOURS_OLD_GAMES . ' hour)) ORDER BY status, a.lasttime DESC, connectedClients > 0 DESC, (networkSlots - connectedClients), ip DESC;');
$all_servers = array();
while ($server = mysql_fetch_array($servers_in_db)) {
    // Game Stats
    $rowIndex = count($all_servers);
    $gameDuration = $server["framesToCalculatePlaytime"];
    $server["gameDuration"] = getTimeString($gameDuration);
    array_push($all_servers, $server);
}
unset($servers_in_db);
unset($server);
db_disconnect(DB_LINK);
unset($linkid);
header('Content-type: application/json');
echo json_encode($all_servers);
unset($all_servers);
function getNextAdminAction($orderID, $status, $index)
{
    $out1 = getLastAction($status);
    $out = $out1->val;
    if (strcasecmp($out, 'received') == 0) {
        $result = json_decode(getDeliverers()->value);
        $out = '<div class="dropdown">   <a class="dropdown-toggle rowlink" data-toggle="dropdown" href="#">
				Assign Order  </a>  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">';
        foreach ($result as $deliElement) {
            $out .= '<li> <a tabindex="-1" href="orderAction.php?action=assign&redirect=admin&orderID=' . $orderID . '&delivererID=' . $deliElement->delivererID . '">';
            $out .= $deliElement->name;
            $out .= '</a></li>';
        }
        $out .= '</ul></div>';
    } else {
        if (strcasecmp($out, 'assign') == 0) {
            $out = '<a href = "orderAction.php?action=picked&orderID=' . $orderID . '&redirect=admin">Pickup Order</a>';
        } else {
            if (strcasecmp($out, 'picked') == 0) {
                $out = '<a href = "orderAction.php?action=delivered&orderID=' . $orderID . '&redirect=admin">Deliver Order</a>';
            } else {
                if (strcasecmp($out, 'delivered') == 0) {
                    $out = 'Order Delivered at ' . getTimeString($out1->time);
                } else {
                    if (strcasecmp($out, 'cancel') == 0) {
                        $out = 'Order Cancelled at ' . getTimeString($out1->time);
                    }
                }
            }
        }
    }
    return $out;
}
/**
    This method displays the path instructions on the left side of the screen.
    
    @param $path<array[Segment]> the path found by the algorithm
*/
function printPath($path, $path_time)
{
    global $website;
    $debug = false;
    $count = count($path);
    if ($debug) {
        echo "[display_functions.php:printPath()]<br/>\n";
        echo "path count = {$count}<br/>\n";
        if ($count > 1) {
            print_r($path);
        } else {
            echo "path = {$path}<br/>";
        }
    }
    $old_lines = null;
    if ($count > 0) {
        // print consolidated path
        $directions_table = new Table(null, "info_table");
        $header_row = new Row(null, "header_row");
        $directions_table->addRow($header_row);
        $header_row->addCell(new Cell("header_cell", "Step"));
        $header_row->addCell(new Cell("header_cell", "Instructions"));
        $header_row->addCell(new Cell("header_cell", "Time"));
        for ($x = 0; $x < $count; $x++) {
            // create the row object
            if (isEven($x)) {
                $row_class = "rowHighlight";
            } else {
                $row_class = "row";
            }
            $row = new Row(null, $row_class);
            $y = $x + 1;
            // grab the segment and all its variables
            $segment = $path[$x];
            if ($debug) {
                echo $segment . "<br/>";
                echo "segment = " . $segment->toString() . "<br/>";
            }
            $marker = $segment->m1;
            $m1_name = $marker->name;
            $m1lat = $marker->getLat();
            $m1lng = $marker->getLng();
            $m2_name = $segment->m2->name;
            $connection = $segment->connection;
            $step_cell = new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$m1lat},{$m1lng}), map.getZoom());", "[ {$y} ]"));
            $instruction_cell = new Cell("instruction");
            $rawTime = $segment->t;
            $time_cell = new Cell("step_cell", getTimeString($rawTime));
            if ($connection == "walking") {
                $instruction_cell->addData("Walk from <b>{$m1_name}</b> to <b>{$m2_name}</b>.");
            } else {
                if ($connection == "transfer") {
                    $lines = $segment->lines;
                    $from_string = "";
                    $to_string = "";
                    for ($i = 0; $i < count($old_lines); $i++) {
                        $from_string .= "<img width=\"20\" src=\"images/" . $old_lines[$i]->img . "\"/>";
                    }
                    for ($i = 0; $i < count($lines); $i++) {
                        $to_string .= "<img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/>";
                    }
                    $instruction_cell->addData("Transfer from <b>{$m1_name}</b> {$from_string} to <b>{$m2_name}</b> {$to_string}");
                } else {
                    // this is a regular segment
                    $output_string = "Take ";
                    $lines = $segment->lines;
                    for ($i = 0; $i < count($lines); $i++) {
                        $output_string .= "<a href=\"javascript:void(0);\" onclick=\"window.open('{$website}" . $lines[$i]->url . "');\"><img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/></a>";
                    }
                    $output_string .= " from <b>{$m1_name}</b> to <b>{$m2_name}</b>.";
                    $instruction_cell->addData($output_string);
                    $old_lines = $lines;
                }
            }
            $row->addCell($step_cell);
            $row->addCell($instruction_cell);
            $row->addCell($time_cell);
            $directions_table->addRow($row);
        }
        $row = new Row(null, "total_row");
        $row->addCell(new Cell(null, ""));
        $row->addCell(new Cell("total", "Total Time:"));
        $row->addCell(new Cell("total_time", getTimeString($path_time)));
        $directions_table->addRow($row);
        echo $directions_table->toString();
    } else {
        echo "Sorry. No path found.<br/>\n";
    }
}
         $status_class = 'finished';
         break;
     default:
         $status_title = 'unknown';
         $status_class = 'unknown';
 }
 if (($status_code == 2 || $status_code == 3) && $server['gameUUID'] != "") {
     $games_with_stats++;
     printf("\t\t\t\t<td title=\"%s\" class=\"%s\"><a id=\"gameStats_%d\" href=\"#\" gameuuid=\"%s\">%s</a>", $server['status'], $status_class, $games_with_stats, $server['gameUUID'], htmlspecialchars($status_title, ENT_QUOTES));
     printf("</td>%s", PHP_EOL);
 } else {
     printf("\t\t\t\t<td title=\"%s\" class=\"%s\">%s</td>%s", $server['status'], $status_class, htmlspecialchars($status_title, ENT_QUOTES), PHP_EOL);
 }
 // Game Stats
 $gameDuration = $server['framesToCalculatePlaytime'];
 $gameDuration = getTimeString($gameDuration);
 printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($gameDuration, ENT_QUOTES), PHP_EOL);
 // country
 if ($server['country'] !== '') {
     $flagfile = 'flags/' . strtolower($server['country']) . '.png';
     if (file_exists($flagfile)) {
         printf("\t\t\t\t<td><img src=\"%s\" title=\"%s\" alt=\"%s country flag\" /></td>%s", $flagfile, $server['country'], $server['country'], PHP_EOL);
     } else {
         printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($server['country'], ENT_QUOTES), PHP_EOL);
     }
 } else {
     printf("\t\t\t\t<td>unknown</td>%s", PHP_EOL);
 }
 // serverTitle
 printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($server['serverTitle'], ENT_QUOTES), PHP_EOL);
 // tech