viernes, 22 de septiembre de 2017

php get mp3 file duation

<?php
 $duration=shell_exec("mp3info -p \"%m:%s\n\" $argv[1]");
echo $duration;

?>


 php mp3info.php /var/www/html/dialer/audio/57c081f2de8cd.mp3
0:34
Duration in minutes en seconds


sábado, 16 de septiembre de 2017

php converting from second to minutes

<?php

$time=9;

if($time>60){
$min=($time/60);

if(is_float($min)){

$min=floor($min);
        $min=($min*60);

$sec=($time-$min);
        $min=($min/60);

        echo " $min:$sec Min";


}


else {
echo "$time Min";
}


}

else {
echo "$time Sec";

}
?>


Function mode

<?php

function minutes($time) {

if($time>60){
$min=($time/60);

if(is_float($min)){

$min=floor($min);
        $min=($min*60);

$sec=($time-$min);
        $min=($min/60);

        return " $min:$sec Min";


}


else {

return "$time Min";
}


}

else {
return "$time Sec";

}

}

?>

echo minute(784);

miércoles, 13 de septiembre de 2017

php download file

<?php
$fname=uniqid();
$attachment_location ="/var/spool/asterisk/monitor/OUT102-20170829-085404-1504022044.824.wav";
        if (file_exists($attachment_location)) {
            header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
            header("Cache-Control: public"); // needed for internet explorer
            header("Content-Type: application/wav");
            header("Content-Transfer-Encoding: Binary");
            header("Content-Length:".filesize($attachment_location));
            header("Content-Disposition: attachment; filename=$fname.wav");
            readfile($attachment_location);
            die();
        } else {
            die("Error: File not found.");
        }

?>

miércoles, 6 de septiembre de 2017

STDIN & STDOUT


<?php fwrite(STDOUT, "Please enter your namen");

// Read the input
$name = fgets(STDIN);



fwrite(STDOUT, "Hello $name");

// Exit correctly
exit(0);
?>



echo " hello world " | php stdin.php
result  hello world

<?php
//$stdin = fopen('php://stdin', 'r');
$stdin=stream_get_contents(STDIN);
echo $stdin;
?>

Other method

<?php

echo  " This is the result $argv[1]";

?>

a=$(echo 'ambiorix') | php cmd.php $a
 This is the result ambiorix