Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] Uptime?!
Forum PHP.pl > Forum > Przedszkole
eMaNEX
Witam mam oto takie pytanie ;-)

narazie mam cos takiego
  1. <?php
  2.  
  3. $plik = fopen ("127.0.0.1/ip.php?ip=1.1.1.1", "r");
  4. $uptime = fgets($plik, 2);
  5. switch ($uptime)
  6. {
  7.  case 3:
  8. echo 'GG OFF';
  9. break;
  10.  default:
  11. echo 'eee';
  12. break;
  13. }
  14. fclose($plik);
  15.  
  16. ?>


Jak mam zrobić by pobierało dane tzn.
NP Ze skryptu zamieszczonym w ip.php
3 albo nic ;p
3 - server wylączony

Chciałbym aby zliczał uptime , niekoniecznie linux.
Jak to zrobic?
Guest
i cos takiego

  1. <?
  2. $logfile = dirname(__FILE__)."/mail.log";
  3.  
  4. if (file_exists ( $logfile )) {
  5.  if ( (time() - filectime( $logfile ))<10 ){
  6.  header("Refresh: 2; url=''");
  7.  print "process running....<br><br>\n\n";
  8.  $logcontents = file($logfile);
  9.  foreach (array_reverse($logcontents) as $line) {
  10.  print $line."<br>\n";
  11.  }
  12.  } else {
  13.  print "process finished!<br><br>\n\n";
  14.  $logcontents = file($logfile);
  15.  foreach ($logcontents as $line) {
  16.  print $line."<br>\n";
  17.  }
  18.  unlink ($logfile);
  19.  }
  20. } else {
  21. echo "\n\n";
  22. echo "startig process...<br><br>\n\n";
  23. $log = fopen($logfile, "a") or die("error opening log\n");
  24. for ($i=0; $i<20; $i++) {
  25.  $thisline = "iteration $i";
  26.  fputs($log, $thisline."\n");
  27.  print $thisline."<br>\n";
  28.  ob_flush();
  29.  flush();
  30.  sleep(1);
  31. }
  32. fclose ($log);
  33. }
  34. ?>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.