<?
/*
MP4WEB (c) César González Revilla
hide@address.com
This code is covered by GPL License
http://www.gnu.org/copyleft/gpl.html
*/
require_once("configure.php");
require_once("HTML/IT.php");
function getDirList($dirName)
{
global $files;
global $count_files;
$d = dir($dirName);
while($entry = $d->read())
{
if ($entry != "." && $entry != "..")
{
if (is_dir($dirName."/".$entry))
{
getDirList($dirName."/".$entry);
}
else
{
$files[$count_files]=$dirName."/".$entry."\n";
$count_files++;
}
}
}
$d->close();
return($salida_ficheros);
}
function genBoton($tipo)
{
global $main;
switch($tipo)
{
case "play":
$main->setCurrentBlock("BOTON");
$main->setVariable("LETRA", "images/play.jpg");
$main->setVariable("BOTON_NAME", "botonplay");
$main->setVariable("COLOR", "#FFCF6B");
$main->setVariable("RESTO", "lay");
$main->parseCurrentBlock("BOTON");
break;
case "stop":
$main->setCurrentBlock("BOTON");
$main->setVariable("LETRA", "images/S.jpg");
$main->setVariable("BOTON_NAME", "botonstop");
$main->setVariable("COLOR", "#00BEFF");
$main->setVariable("RESTO", "top");
$main->parseCurrentBlock("BOTON");
break;
case "pause":
$main->setCurrentBlock("BOTON");
$main->setVariable("LETRA", "images/pause.jpg");
$main->setVariable("BOTON_NAME", "botonpause");
$main->setVariable("COLOR", "#10A252");
$main->setVariable("RESTO", "ause");
$main->parseCurrentBlock("BOTON");
break;
case "delete":
$main->setCurrentBlock("BOTON");
$main->setVariable("LETRA", "images/D.jpg");
$main->setVariable("BOTON_NAME", "botondelete");
$main->setVariable("EVENT", "onClick=\"return advertir('Do you really want to delete the file?');\"");
$main->setVariable("COLOR", "#FF8242");
$main->setVariable("RESTO", "elete");
$main->parseCurrentBlock("BOTON");
break;
}
}
$main = new IntegratedTemplate($dir_mp4web."templates/");
$main->loadTemplatefile("player.html", true, true);
$paginaxdefecto=1;
if(is_numeric($HTTP_POST_VARS["botondelete_x"]))
{
$paginaxdefecto=0;
$cmd="rm ".$dirstreaming.$HTTP_POST_VARS["file"];
exec($cmd);
genBoton("play");
genBoton("stop");
genBoton("delete");
}
$count_files=0;
$files=array();
getDirList($dirstreaming);
for($i=0;$i<count($files);$i++)
{
if(!ereg(".mp4$",trim($files[$i]))) continue;
$main->setCurrentBlock("FILE");
$main->setVariable("FILENAME", str_replace($dirstreaming,"",$files[$i]));
$main->parseCurrentBlock("FILE");
}
if(is_numeric($HTTP_POST_VARS["botonplay_x"]))
{
$paginaxdefecto=0;
$info_video=exec("/usr/local/bin/mp4info ".$dirstreaming.$HTTP_POST_VARS["file"]." | grep video");
ereg("([0-9]*)([x])([0-9]*)", $info_video, $out_video);
$main->setCurrentBlock("VIDEO");
$main->setVariable("NOMBRE_FILE", "Playing ".$HTTP_POST_VARS["file"]);
$main->setVariable("COVER", "pantalla.mov");
$main->setVariable("URL", $darwinServer.str_replace($dirstreaming,"",$HTTP_POST_VARS["file"]));
$main->setVariable("ANCHO", $out_video[1]);
$main->setVariable("ALTO", $out_video[3]+17);
$main->parseCurrentBlock("VIDEO");
genBoton("play");
genBoton("stop");
}
if($paginaxdefecto==1)
{
genBoton("play");
genBoton("delete");
}
$main->show();
?>