i gotta wierd one, maybe it's just me being daft...

i'm under the impression that max execution time / set_time_limit() is
server specific, and completely independant of what computer is being served
the pages?

my server is apache 1.3 running php 4.3 on win 2k...

when i run the script from a windows machine, it runs fine. my line that
does a set_time_limit(10) works and the script happily runs for about 2
minutes while a loop does some file copying (across the network to the
server, and independant of whatever machine called the script).

however, if i run the same script from my little iMac (shudders) then it'll
give me a script timeout saying it's gone over the max execution time of 10.
now i know that set_time_limit(10) is being run, as the server default is
30. it just doesn't seem to be resetting this value in the PHP loop. but
surely that's impossible, as it should be all server side?

secondly, i have a timer that (using javascript) writes to the html page how
long the script has been running, and an estimate of how long is left to
run. again, perfect timing on the PC, but when run from the Mac, the timer
counts 1 second roughly every 2 seconds. again, surely this is impossible as
time functions are run from the server???

the other strange thing, if i have the script running off a PC, and the Mac
then also runs it, it'll time perfectly... it'll still time out, but it'll
atleast count proper seconds...

here's a rough idea of the code... i've cut out most of the crap that it
does to give you an idea of what's happening, ignore any syntax errors, as
the script does work... the flush() works nicely to update my form fields
with javascript so i can see the live results of the script working... and
see the problems with how mac seems to be handling it.

anyway, any ideas would be very appreciated, as i don't want to have to
fudge it and stick set_time_limit(1000) at the beginning of the page :(

-----------code-----------

<?
function getmicrotime($start){
   list($usec, $sec) = explode(" ",microtime());
   return (($sec-$start) + (float)$usec);
}
$start = getmicrotime($start);
$absStart = getmicrotime($start);
?>
<html>
<head>
 <title>Imposition Uploader</title>
 <script language="JavaScript">

 function name(label)
 {
  document.all.currentName.value=label;
 }
 function add(name)
 {
  document.all[name].value++;
 }
 function time(estimate,taken)
 {
  document.all.timeEstimate.value=estimate;
  document.all.timeTaken.value=taken;
 }

 </script>
</head>
<body>
<?
    echo"current working file: <input type=\"text\" name=\"currentName\"
/><br />";
    echo"total files read: <input type=\"text\" name=\"allTotal\"
value=\"0\" /><br />";
    echo"total files copied: <input type=\"text\" name=\"copyTotal\"
value=\"0\" /><br />";
    echo"total errors: <input type=\"text\" name=\"errorTotal\" value=\"0\"
/><br />";
    echo"total edits: <input type=\"text\" name=\"editTotal\" value=\"0\"
/><br />";
    echo"db records deleted: <input type=\"text\" name=\"dbDel\" value=\"0\"
/><br />";
    echo"db records updated: <input type=\"text\" name=\"dbAdd\" value=\"0\"
/><br />";
    echo"new db records: <input type=\"text\" name=\"dbNew\" value=\"0\"
/><br />";
    echo"<br /><br />";
    echo"estimated time: <input type=\"text\" name=\"timeEstimate\"
value=\"0\" /><br />";
    echo"time taken: <input type=\"text\" name=\"timeTaken\" value=\"0\"
/><br />";
    flush();
    //read in a csv file line by line
    foreach($csv as $record)
    {
     $counter++;
     set_time_limit(10); //this doesn't work for mac!!!!!!!!!!
      if(file_exists($file))
      {
            //do some file copying across the network. $file is located on
NFS and copied to the server...
            //also run some extra functions to update our form counters with
JS
      }
      $estimate = round(($sofar/$counter)*$rows);
      $sofar = round(getmicrotime($start));
      echo "time('$estimate','$sofar');";
      echo "</script>";
      flush();
     }
?>
</body>
</html>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to