%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www_old/music/diplomka/diplomka/
Upload File :
Create Path :
Current File : //var/www_old/music/diplomka/diplomka/sync.php

<?php
function startsWith($haystack, $needle)
{
    $length = strlen($needle);
    return (substr($haystack, 0, $length) === $needle);
}

function endsWith($haystack, $needle)
{
    $length = strlen($needle);
    if ($length == 0) {
        return true;
    }

    return (substr($haystack, -$length) === $needle);
}

function fsize($size)
{
    $jedn = array("bytes", "Kbytes", "Mbytes", "Gbytes", "Tbytes", "Pbytes");
    //$size = filesize($name);
    $i = 0;
    while($size > 1023)
    {
        $size /= 1024;
        $i++;
    }
    return sprintf("%0.2f %s", $size, $jedn[$i]);
}

$f = fopen("input://", "r");
while(!feof($f))
{
    $line = fgets($f);
    if(startsWith($line, 'sent '))
    {
        list($sent, $received, $speed) = sscanf($line, "sent %d bytes  received %d bytes  %f bytes/sec");
        $sent = fsize($sent);
        $received = fsize($received);
        $speed = fsize($speed);
        $line = "sent $sent bytes  received $received bytes  $speed bytes/sec";
    }
    if(startsWith($line, 'total size '))
    {
        list($total, $speedup) = sscanf($line, "total size is %d  speedup is %f");
        $total = fsize($total);
        $line = "total size is $total  speedup is $speedup";
    }
    echo $line;
}
fclose($f);

Zerion Mini Shell 1.0