in pgo/cases/drupal/TrainingCaseHandler.php [68:101]
public function setupUrls()
{
$this->nginx->up();
$url = "http://" . $this->getHttpHost() . ":" . $this->getHttpPort();
$s = file_get_contents($url);
$this->nginx->down(true);
echo "Generating training urls.\n";
$lst = array();
if (preg_match_all(", href=\"([^\"]+)\",", $s, $m)) {
foreach ($m[1] as $u) {
$p = parse_url($u, PHP_URL_PATH);
if (strlen($p) >= 2 && "/" == $p[0] && "/" != $p[1] && !in_array(substr($p, -3), array("css", "xml", "ico"))) {
$ur = "http://" . $this->getHttpHost() . ":" . $this->getHttpPort() . $u;
if (!in_array($ur, $lst)) {
$lst[] = $ur;
}
}
}
}
if (empty($lst)) {
printf("\033[31m WARNING: Training URL list is empty, check the regex and the possible previous error messages!\033[0m\n");
}
$fn = $this->getJobFilename();
$s = implode("\n", $lst);
if (strlen($s) !== file_put_contents($fn, $s)) {
throw new Exception("Couldn't write '$fn'.");
}
}