kney Posted April 20, 2011 Share Posted April 20, 2011 Hi, I currently have this code: <?php function respond_xml($status, $message) { $out = new XMLWriter(); $out->openURI("php://output"); $out->setIndent(true); $out->startDocument("1.0", "ISO-8859-1"); $out->startElement("statuscheck"); $out->writeElement("status", $status); $out->writeElement("message", $message); $out->endElement(); $out->endDocument(); $out->flush(); } function main() { header("Content-type: text/xml"); if (!isset($_GET["file"])) respond_xml("ERROR", "File parameter missing"); else if (file_exists($_GET["file"])) return respond_xml("OK", "File exists"); else return respond_xml("NOT OK", "File does not exist"); } main(); ?> This code works and gives a correct XML response when you type in for example "http://localhost:8080/php/script.php?file=test" it's says: <statuscheck> <status>NOT OK</status> <message>File does not exist</message> </statuscheck> Now, I need it to be able to check it every 5 seconds so i've use this code header("Refresh: 5; URL=http://localhost:8080/php/script.php?file=test"); Here's my problem: The first 5 or 10 tries it should say "file not found". After the 10th try it should automatically say "file found". BUT it should also time out after like 50 tries and it hasn't found the file. But i don't know how to do this.. Link to comment https://forums.phpfreaks.com/topic/234234-check-for-files-php-with-xml-response/ Share on other sites More sharing options...
kney Posted April 20, 2011 Author Share Posted April 20, 2011 anyone? Link to comment https://forums.phpfreaks.com/topic/234234-check-for-files-php-with-xml-response/#findComment-1203930 Share on other sites More sharing options...
kney Posted April 21, 2011 Author Share Posted April 21, 2011 nobody can figure this out? Link to comment https://forums.phpfreaks.com/topic/234234-check-for-files-php-with-xml-response/#findComment-1204357 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.