Beispiel #1
0
function start_host($parser, $tagname, $attrs)
{
    global $metrics, $cluster, $hosts_up, $hosts_down, $self, $grid;
    static $metricname;
    switch ($tagname) {
        case "GANGLIA_XML":
            preamble($attrs);
            break;
        case "GRID":
            $self = $attrs['NAME'];
            $grid = $attrs;
            break;
        case "CLUSTER":
            $cluster = $attrs;
            break;
        case "HOST":
            if (host_alive($attrs, $cluster)) {
                $hosts_up = $attrs;
            } else {
                $hosts_down = $attrs;
            }
            break;
        case "METRIC":
            $metricname = rawurlencode($attrs['NAME']);
            $metrics[$metricname] = $attrs;
            break;
        case "EXTRA_DATA":
            break;
        case "EXTRA_ELEMENT":
            if (isset($attrs['NAME']) && isset($attrs['VAL']) && $attrs['NAME'] == "GROUP") {
                if (isset($metrics[$metricname]['GROUP'])) {
                    $group_array = array_merge((array) $attrs['VAL'], $metrics[$metricname]['GROUP']);
                } else {
                    $group_array = (array) $attrs['VAL'];
                }
                $attribarray = array($attrs['NAME'] => $attrs['VAL']);
                $metrics[$metricname] = array_merge($metrics[$metricname], $attribarray);
                $metrics[$metricname]['GROUP'] = $group_array;
            } else {
                $attribarray = array($attrs['NAME'] => $attrs['VAL']);
                $metrics[$metricname] = array_merge($metrics[$metricname], $attribarray);
            }
            break;
        default:
            break;
    }
}
Beispiel #2
0
            $query = pg_query($pg_conn, "UPDATE csci399_ass2 " . "SET played = played + 1 " . "WHERE name = '" . $user . "';");
            $query = pg_query($pg_conn, "UPDATE csci399_ass2 " . "SET played = played + 1 " . "WHERE name = 'computer';");
            if ($computer->yourawinner) {
                $query = pg_query($pg_conn, "UPDATE csci399_ass2 " . "SET won = won + 1 " . "WHERE name ='" . $user . "';");
            } else {
                $query = pg_query($pg_conn, "UPDATE csci399_ass2 " . "SET won = won + 1 " . "WHERE name ='computer';");
            }
            $message = $computer->message;
        }
        $board = $computer->getboard();
    }
} else {
    $board = 'eeeeeeee' . 'eeeeeeee' . 'eeeeeeee' . 'eeewbeee' . 'eeebweee' . 'eeeeeeee' . 'eeeeeeee' . 'eeeeeeee';
}
setcookie('othello', $board, $expiry);
preamble("Playing a game of Othello");
print "\t<FORM ACTION=\"game.php\" METHOD=\"post\">\n" . "\t<TABLE BORDER=\"2\" RULES=\"GROUPS\" FRAME=\"sides\"" . "SUMMARY=\"Playing Othello\" ALIGN=\"center\">\n";
if ($message) {
    print "\t\t<CAPTION>" . $message . "</CAPTION>\n";
} else {
    print "\t\t<CAPTION>Your turn</CAPTION>\n";
}
print "\t\t<THEAD>\n" . "\t\t<TBODY>\n";
$n_rows = 8;
$n_cols = 8;
$b = "black.png";
$w = "white.png";
$e = "blank.png";
for ($i = 0; $i < $n_rows; $i++) {
    print "\t\t\t<TR>\n";
    for ($j = 0; $j < $n_cols; $j++) {
Beispiel #3
0
<?php

require 'common.php';
preamble("Othello league standings");
$query = pg_query($pg_conn, "SELECT * FROM csci399_ass2;");
if (pg_num_rows($query)) {
    print "\t<TABLE BORDER=\"2\" RULES=\"GROUPS\" FRAME=\"sides\"" . "SUMMARY=\"Othello League Standings\" ALIGN=\"center\">\n" . "\t\t<CAPTION>League Standings</CAPTION>\n" . "\t\t<THEAD>\n" . "\t\t\t<TR>\n" . "\t\t\t\t<TH>Name:</TH>\n" . "\t\t\t\t<TH>Played:</TH>\n" . "\t\t\t\t<TH>Won:</TH>\n" . "\t\t\t</TR>\n" . "\t\t<TBODY>\n";
    while ($row = pg_fetch_assoc($query)) {
        print "\t\t\t<TR>\n" . "\t\t\t\t<TD>" . $row['name'] . "</TD>\n" . "\t\t\t\t<TD ALIGN=\"RIGHT\">" . $row['played'] . "</TD>\n" . "\t\t\t\t<TD ALIGN=\"RIGHT\">" . $row['won'] . "</TD>\n" . "\t\t\t</TR>\n";
    }
    print "\t</TABLE>\n";
}
print "<P><A HREF=\"othello.php\">Return to main page</A>\n";
postamble();
Beispiel #4
0
<?php

require 'common.php';
preamble("Welcome to the league of Othello players");
print "\t\t<H2>What would you like to do?</H2>\n" . "\t\t<UL>\n" . "\t\t\t<LI><A HREF=\"league.php\">View league standings.</A></LI>\n" . "\t\t\t<LI><A HREF=\"game.php\">Have a game.</A></LI>\n" . "\t\t</UL>\n";
postamble();