Gå til innhold

noen som vet va som er galt med ?


Anbefalte innlegg

<?php

// Format Filesizes

 

function format_size($size) {

$a = array("B", "KB", "MB", "GB", "TB", "PB");

 

$pos = 0;

 

while ($size >= 1024) {

$size /= 1024;

$pos++;

}

 

return number_format($size, 2, ".",",")." ".$a[$pos];

}

 

 

// Format Uptime

 

function format_uptime($uptime) {

 

$result = "";

$min = $uptime / 60;

$hours = $min / 60;

$seconds = $sec / 60;

#$days = floor($hours / 24);

$hours = floor($hours - ($days * 24));

$min = floor($min - ($days * 60 * 24) - ($hours * 60));

 

if ($days == 1) {

$result .= "$days day, ";

} elseif ($days != 0) {

$result .= "$days days, ";

}

 

if ($hours == 1) {

$result .= "$hours hour, ";

} elseif ($hours != 0) {

$result .= "$hours hours, ";

}

 

 

if ($min == 1) {

$result .= "$min minute";

} else {

$result .= "$min minutes";

}

 

 

 

return $result;

 

}

 

$raw = netstat -e;

$network = explode("\n", $raw );

 

$bytes = explode(" ",$network[4]);

$packets = explode(" ",$network[5]);

$cnt = 0;

 

for ($i=0;$i<count($packets);$i++){

 

if ($packets[$i]=="") continue;

if ($cnt==2) $packet_recv = number_format($packets[$i], 0, ".",",");

elseif ($cnt==3) $packet_sent = number_format($packets[$i], 0, ".",",");

$cnt++;

}

 

$cnt = 0;

for ($i=0;$i<count($bytes);$i++){

 

if ($bytes[$i]=="") continue;

if ($cnt==1) $byte_recv = format_size($bytes[$i]);

elseif ($cnt==2) $byte_sent = format_size($bytes[$i]);

$cnt++;

}

 

unset($raw, $network, $bytes, $packets, $cnt, $i);

 

$curr_time = time();

$start_time = filemtime("C:\\pagefile.sys"); // Make sure this is set to your PAGEFILE!

$uptime = $curr_time - $start_time;

$uptime = format_uptime($uptime);

 

?>

 

Place that anywhere in your code, at the top will work.

 

To display the stats, you need to ECHO them.

 

<?php

 

echo $uptime; // System Uptime

 

echo $packet_sent; // Packets Sent

 

echo $packet_recv; // Packets Received

 

echo $byte_sent; // Bytes Sent**

 

echo $byte_recv; // Bytes Received**

 

?>

noen som vet va som er galt med den ? det kommer:

Notice: Use of undefined constant netstat - assumed 'netstat' in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 55

 

Notice: Use of undefined constant e - assumed 'e' in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 55

 

Notice: Undefined offset: 4 in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 58

 

Notice: Undefined offset: 5 in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 59

 

Notice: Undefined variable: sec in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 25

 

Notice: Undefined variable: days in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 27

 

Notice: Undefined variable: days in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 28

 

Notice: Undefined variable: days in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 30

 

Notice: Undefined variable: days in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 32

Place that anywhere in your code, at the top will work. To display the stats, you need to ECHO them.

Notice: Undefined variable: packet_sent in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 96

 

Notice: Undefined variable: packet_recv in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 98

 

Notice: Undefined variable: byte_sent in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 100

 

Notice: Undefined variable: byte_recv in C:\Programfiler\Apache Group\Apache2\htdocs\k.php on line 102

Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...