// **************************************************************
function ErrorBreak($msg) {
die("\n\n*FEHLER* " . $msg . "\n\n");
}
// **************************************************************
function WML_Begin() {
print '' . "\n";
print '' . "\n";
print '' . "\n";
print '' . "\n";
print '' .
"\n";
print '' . "\n";
print '' . "\n";
}
// **************************************************************
function WML_End() {
print '
' . "\n";
}
// ************************************************************** CONST
define("BUF_SIZE", "4096");
define("COUNTER_INIT", "5");
define("MAX_LEN", "2048");
define("SRCH1", "
");
// ************************************************************** VAR
// ************************************************************** MAIN
header("content-type: text/vnd.wap.wml");
$fName = "https://www.kraehseite.de/cgi-bin/wpz.pl";
// $fName = getenv("TEMP") . "\\1\\test.html";
// $fName = getenv("TEMP") . "\\1\\test_lang.html";
$counter = COUNTER_INIT;
do {
$inFile = fopen($fName,"r") or
ErrorBreak("URL \"$fName\" nicht gefunden");
// print("OK \n");
$htmlText = "";
while (!feof($inFile)) {
$buffer = fgets($inFile, BUF_SIZE); //
$htmlText = $htmlText . $buffer;
}
fclose ($inFile);
// print($htmlText);
$counter = $counter - 1;
} while ((strlen($htmlText) > MAX_LEN) and ($counter > 0)); //
if ($counter == 0) :
$htmlText = "";
$witz = "FEHLER: TEXT ZU LANG";
else:
$witz = "";
endif;
$pos = strpos($htmlText, SRCH1);
if ($pos) {
$witz = substr($htmlText, $pos+strlen(SRCH1));
$pos = strpos($witz, " | ");
$witz = substr($witz, 0, $pos-1);
$witz = trim($witz);
//
->
$witz = str_replace("
", "
", $witz);
// Umlaute wandeln
$witz = str_replace(
array("ä", "ö", "ü", "Ä", "Ö", "Ü",
"ß"),
array("ä", "ö", "ü", "Ä", "Ö", "Ü",
"ß"),
$witz);
}
WML_Begin();
print($witz);
print("\n");
WML_End();
?>