Location: PHPKode > projects > MP4WEB > mp4web/index.php
<?
/*
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 genBoton($tipo)
{
	global $main;
	switch($tipo)
	{
		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 "launch":
			$main->setCurrentBlock("BOTON");
			$main->setVariable("LETRA", "images/L.jpg");
			$main->setVariable("BOTON_NAME", "botonlaunch");
			$main->setVariable("COLOR", "#FFCF6B");
			$main->setVariable("RESTO", "aunch");
			$main->parseCurrentBlock("BOTON");
			break;
		case "edit":
			$main->setCurrentBlock("BOTON");
			$main->setVariable("LETRA", "images/E.jpg");
			$main->setVariable("BOTON_NAME", "botonedit");
			$main->setVariable("COLOR", "#10A252");
			$main->setVariable("RESTO", "dit");
			$main->parseCurrentBlock("BOTON");
			break;
		case "delete":
			$main->setCurrentBlock("BOTON");
			$main->setVariable("LETRA", "images/D.jpg");
			$main->setVariable("BOTON_NAME", "botondelete");
			$main->setVariable("COLOR", "#FF8242");
			$main->setVariable("RESTO", "elete");
			$main->parseCurrentBlock("BOTON");
			break;
	}
}

$main = new IntegratedTemplate($dir_mp4web."templates/");
$main->loadTemplatefile("recorder.html", true, true);

$paginaxdefecto=1;

if($HTTP_POST_VARS["boton"]=="Save as New File")
{
	$paginaxdefecto=0;
	$arg = preg_replace ("/[^A-Za-z0-9.]/","",$HTTP_POST_VARS["newfile"]);

	$fp = fopen($dir_mp4web."confs/".$arg, "w");
	fputs ($fp, $HTTP_POST_VARS["conf"]);
	fflush($fp);
	fclose($fp);
	genBoton("edit");
	genBoton("delete");
	genBoton("launch");
}

if(is_numeric($HTTP_POST_VARS["botondelete_x"]))
{
	$paginaxdefecto=0;
	$arg = preg_replace ("/[^A-Za-z0-9.]/","",$HTTP_POST_VARS["file"]);
	$fp = unlink($dir_mp4web."confs/".$arg);
	genBoton("edit");
	genBoton("delete");
	genBoton("launch");
}


if ($dir = @opendir($dir_mp4web."confs/"))
{
  while (($file = readdir($dir)) !== false)
  {
  	if($file=="." or $file=="..") continue;
    	$main->setCurrentBlock("FILE");
	$main->setVariable("FILENAME", $file);
	$main->parseCurrentBlock("FILE");
  }
  closedir($dir);
}


if($HTTP_POST_VARS["boton"]=="Modify")
{
	$paginaxdefecto=0;
	$arg = preg_replace ("/[^A-Za-z0-9.]/","",$HTTP_POST_VARS["conf_name"]);
	$fp = fopen($dir_mp4web."confs/".$arg, "w");
	fputs ($fp, $HTTP_POST_VARS["conf"]);
	fflush($fp);
	fclose($fp);
	genBoton("edit");
	genBoton("delete");
	genBoton("launch");
}

if(is_numeric($HTTP_POST_VARS["botonstop_x"]))
{
	$paginaxdefecto=0;
	exec("killall -HUP mp4live");
	$fp = fopen($dir_mp4web."live","w");
	fputs ($fp, "");
	fflush($fp);
	fclose($fp);
	genBoton("edit");
	genBoton("delete");
	genBoton("launch");
}

if(is_numeric($HTTP_POST_VARS["botonlaunch_x"]))
{
	$paginaxdefecto=0;
	$arg = preg_replace ("/[^A-Za-z0-9.]/","",$HTTP_POST_VARS["file"]);
	if($conf_array=file($dir_mp4web."confs/".$arg))
	{
		for($i=0;$i<count($conf_array);$i++)
		{
			$aux=explode("=",$conf_array[$i]);
			$config[$aux[0]]=$aux[1];
		}
		$fp = fopen($dir_mp4web."live","w");
		fputs ($fp, $HTTP_POST_VARS["file"]);
		fflush($fp);
		fclose($fp);
		exec("/usr/local/bin/mp4live -f ".$dir_mp4web."confs/".$arg." --automatic --headless > /dev/null&");
		$main->setCurrentBlock("VIDEO");
		$main->setVariable("NOMBRE_LIVE", $arg." Launched");
		$main->setVariable("COVER", "pantalla.mov");
		$main->setVariable("URL", trim($darwinServer.str_replace($dirstreaming,"",$config["sdpFile"])));
		if(is_numeric(trim($config["videoRawWidth"])) && is_numeric(trim($config["videoRawHeight"])))
		{
			$main->setVariable("ANCHO", trim($config["videoRawWidth"]));
			$main->setVariable("ALTO", 17+$config["videoRawHeight"]);
		}
		else
		{
			$main->setVariable("ANCHO", 320);
			$main->setVariable("ALTO", 257);
		}
		$main->parseCurrentBlock("VIDEO");
		genBoton("stop");

	}
}
$live_conf=file($dir_mp4web."live");
if(count($live_conf)>0 && !is_numeric($HTTP_POST_VARS["botonlaunch_x"]))
{
	$paginaxdefecto=0;
	if($conf_array=file($dir_mp4web."confs/".$live_conf[0]))
	{
		for($i=0;$i<count($conf_array);$i++)
		{
			$aux=explode("=",$conf_array[$i]);
			$config[$aux[0]]=$aux[1];
		}
		$main->setCurrentBlock("VIDEO");
		$main->setVariable("NOMBRE_LIVE", $live_conf[0]." Launched");
		$main->setVariable("COVER", "pantalla.mov");
		$main->setVariable("URL", trim($darwinServer.str_replace($dirstreaming,"",trim($config["sdpFile"]))));
		$main->setVariable("ANCHO", trim($config["videoRawWidth"]));
		$main->setVariable("ALTO", 17+$config["videoRawHeight"]);
		$main->parseCurrentBlock("VIDEO");
		genBoton("stop");
	}
}
if(is_numeric($HTTP_POST_VARS["botonedit_x"]))
{
	$paginaxdefecto=0;
	$arg = preg_replace ("/[^A-Za-z0-9.]/","",$HTTP_POST_VARS["file"]);
	$conf_array=file($dir_mp4web."confs/".$arg);
	$configuracion = implode("", $conf_array);
	$main->setCurrentBlock("EDIT");
	$main->setVariable("NOMBRE", $arg);
	$main->setVariable("CONFIG", $configuracion);
	$main->parseCurrentBlock("EDIT");
	genBoton("edit");
	genBoton("delete");
	genBoton("launch");
}
if($paginaxdefecto==1)
{
	genBoton("edit");
	genBoton("delete");
	genBoton("launch");
}
$main->show();
?>
Return current item: MP4WEB