nayone Posted February 15, 2010 Share Posted February 15, 2010 Hi there Ok just managed to get my head round PHP and upload a couple of text files into two web page trouble is now I want to try and get pages combined and upload the alternative files every say 45 seconds <?php //$file = fopen ("ftp/gsyhdep.txt", "r"); $file = fopen ("http://www.thisisguernsey.co.uk/thirdparty/gsyhdep.txt", "r"); if (!$file) { echo "<p>Unable to open remote file.\n"; exit; } ?> <table cellpadding=0 width=440 cellspacing=5 align=center border=0> <?php while (!feof ($file)) { $line = fgets ($file, 1024); /* this only works if the title and its tags are on one line */ $vessel = substr($line, 2,13); $destination = substr($line, 15,13); $duetime = substr($line, 28,5); $actualtime = substr($line, 36,5); $new_destination = preg_replace('/\s+/', '', $destination); $new_dest = preg_replace('/\s+/', '', $dest); if ($vessel == "Commodore Go "){$vessel="Commodore Goodwill";} if ($vessel == "Condor Vites "){$vessel="Condor Vitesse";} if ($vessel == "Commodore Cl "){$vessel="Commodore Clipper";} if ($vessel == "Huelin Dispa "){$vessel="Huelin Dispatch";} if ($vessel == "Condor Expre "){$vessel="Condor Express";} if ($destination == "Jersey/St Ma "){$destination="Jersey/St Malo";} $new_destination = strtoupper($new_destination); $tomorrow = 0; if ($vessel == "Guernsey Harb"){ echo "<tr><td colspan=4 class='sectionmenucell' valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b> Sailings scheduled for today - $timestamp</b></font></td></tr>"; echo "<tr><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Vessel</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>To</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Time</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Departed</b></font></td></tr>"; $tomorrow = 1;} else if ($destination == "rrow's Depart") { echo "<tr><td colspan=4 class='sectionmenucell' valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b> Sailings scheduled for tomorrow</b></font></td></tr>"; $tomorrow = 2; } if ($dest == "" || $new_destination == $new_dest){ if ($tomorrow == 0){ echo "<tr><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$vessel </font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>$destination </b></font></td><td width=15% valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$duetime </font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$actualtime </font></td></tr>"; }} } fclose($file); echo "</table>"; ?> and <?php //$file = fopen ("/ftp/gsyharr.txt", "r"); $file = fopen ("http://www.thisisguernsey.co.uk/thirdparty/gsyharr.txt", "r"); if (!$file) { echo "<p>Unable to open remote file.\n"; exit; } ?><table cellpadding=0 width=440 cellspacing=5 align=center border=0> <?php while (!feof ($file)) { $line = fgets ($file, 1024); /* this only works if the title and its tags are on one line */ $vessel = substr($line, 2,13); $destination = substr($line, 15,13); $duetime = substr($line, 28,5); $actualtime = substr($line, 36,6); $new_destination = preg_replace('/\s+/', '', $destination); $new_dest = preg_replace('/\s+/', '', $dest); if ($vessel == "Commodore Go "){$vessel="Commodore Goodwill";} if ($vessel == "Condor Vites "){$vessel="Condor Vitesse";} if ($vessel == "Commodore Cl "){$vessel="Commodore Clipper";} if ($vessel == "Huelin Dispa "){$vessel="Huelin Dispatch";} if ($vessel == "Condor Expre "){$vessel="Condor Express";} if ($destination == "Jersey/St Ma "){$destination="Jersey/St Malo";} if ($actualtime == " E"){$actualtime=" ";} $new_destination = strtoupper($new_destination); $tomorrow = 0; if ($vessel == "Guernsey Harb"){ echo "<tr><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Vessel</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>From</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Time</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Arrived</b></font></td></tr>"; $tomorrow = 1;} else if ($destination == "rrow's Arriva") { echo "<tr><td colspan=4 class='sectionmenucell' valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b> Sailings scheduled for tomorrow</b></font></td></tr>"; $tomorrow = 2; } if ($dest == "" || $new_destination == $new_dest){ if ($tomorrow == 0){ echo "<tr><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$vessel </font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>$destination </b></font></td><td width=15% valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$duetime </font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$actualtime </font></td></tr>"; }} } fclose($file); echo "</table>"; ?> any easy way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/192182-time-delay/ Share on other sites More sharing options...
RussellReal Posted February 16, 2010 Share Posted February 16, 2010 every 45 seconds through a command line would be no problem..you just use sleep or maybe even SSH you could do it.. but through an HTTP Request, its impossible without cron.. well not IMPOSSIBLE.. but its impossible to have it run exactly every 45 seconds..unless you have a page view at exact intervals 45 seconds apart.. Quote Link to comment https://forums.phpfreaks.com/topic/192182-time-delay/#findComment-1012989 Share on other sites More sharing options...
nayone Posted February 16, 2010 Author Share Posted February 16, 2010 Many thx will have a look at the sleep option you suggested cheers Alex Quote Link to comment https://forums.phpfreaks.com/topic/192182-time-delay/#findComment-1012999 Share on other sites More sharing options...
RussellReal Posted February 16, 2010 Share Posted February 16, 2010 no problemo Quote Link to comment https://forums.phpfreaks.com/topic/192182-time-delay/#findComment-1013002 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.