<?php

//$file = fopen("log.txt", "w");   /// BORRAR LOG
//fwrite($file, "Error $error". PHP_EOL);
//fclose($file);

$config = require ('config.php');
$rutafotos=$config['rutafotos2'];
$rutavideo=$config['rutavideo'];
$conexion=$config['conexion']; 

$conn = pg_pconnect("$conexion");

$sql="delete from videotemp";
$result = pg_query($conn, $sql);
$sql="delete from control where control='VIDEO'";
$result = pg_query($conn, $sql);

$output = array();


$fxx=$_GET["fotos"];
$name=$_GET["name"];

$namevideo='V_'.$name.'.mp4';


$fotos=explode(',',$_GET["fotos"]);	
$nfotos = count($fotos);

for($x = 0; $x < $nfotos; $x++) {
	
	$foto=$rutafotos.'/'.$fotos[$x];
	$sql="insert into videotemp (foto,videoname) values('$foto','$namevideo')";
	$result = pg_query($conn, $sql);
	
}	

$sql="insert into control (control) values('VIDEO')";
$result = pg_query($conn, $sql);

pg_close($conn);
echo 'OK'
?>