Ejemplo n.º 1
0
<?php

require_once "../../config.php";
require_once "webauto.php";
use Goutte\Client;
line_out("Grading PHP-Intro Assignment 3");
$url = getUrl('http://www.php-intro.com/assn/guess/guess.php');
if ($url === false) {
    return;
}
$grade = 0;
error_log("ASSN03 " . $url);
line_out("Retrieving " . htmlent_utf8($url) . "...");
flush();
$client = new Client();
$client->setMaxRedirects(5);
// Yes, one gigantic unindented try/catch block
$passed = 5;
$titlefound = false;
try {
    $crawler = $client->request('GET', $url);
    $html = $crawler->html();
    $OUTPUT->togglePre("Show retrieved page", $html);
    $retval = webauto_check_title($crawler);
    if ($retval === true) {
        $titlefound = true;
    } else {
        error_out($retval);
    }
    line_out("Looking for 'Missing guess parameter'");
    if (stripos($html, 'Missing guess parameter') > 0) {