Jump to content

Time delay


nayone

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/192182-time-delay/
Share on other sites

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..

Link to comment
https://forums.phpfreaks.com/topic/192182-time-delay/#findComment-1012989
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.