show_esempi.php
<?php
$head='<!DOCTYPE public "-//w3c//dtd html 4.01 transitional//en\"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Esempio: ' . $_GET["page"] . '</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>';
$tail = '</body>
</html>';
$page = $_GET["page"];
$path = dirname($_SERVER["SCRIPT_FILENAME"]);
$path .= "/esempi";
$htmlpage = $page . ".html";
$errore = -1;
if ( file_exists ($page))
if ( (! file_exists ($htmlpage)) or filemtime($page) != filemtime($htmlpage)) {
$host = $_SERVER["HTTP_HOST"];
$url = "/~gim/ro/simplesso.php";
exec ("$path/prova_simplesso $host $url $page", $html, $return_value);
if ( $return_value == 0)
touch ($htmlpage, filemtime($page));
else
$errore = 1;
}
switch ($errore) {
case -1:
if (! file_exists ($htmlpage))
$html = $head . "<H1>ERRORE: parametri errati o file $page inesistente.</H1>" . $tail;
else
$html = implode ('', file ($htmlpage));
break;
case 0:
$html = implode ('', file ($htmlpage));
break;
case 1:
$html = $head . "<H1>ERRORE: 'prova_simplesso` non può essere eseguito o non riesce a terminare regolarmente.</H1>" . $tail;
break;
}
print $html;
?>