<?php
$ext=$_GET["ext"];
$fecha=$_GET["fecha"];
if (isset($_GET["lang"])) $lang=$_GET["lang"];
else $lang="en";
$alarm=strtotime($fecha);
echo("FECHA: $fecha<br>ALARM: $alarm");
$wuc_data="channel: Local/$ext@originate-skipvm
maxretries: 3
retrytime: 60
waittime: 60
callerid: Wake Up Call <*68>
set: CHANNEL(language)=$lang
application: AGI
data: wakeconfirm.php
AlwaysDelete: Yes
Archive: Yes
";
$wuc_file="/var/spool/asterisk/tmp/wuc.$alarm.ext.$ext.call";
$wuc_file_2="/var/spool/asterisk/outgoing/wuc.$alarm.ext.$ext.call";
$handler=fopen($wuc_file, 'w') or die('No se peude crear:  '.$wuc_file);
fwrite($handler, $wuc_data);
fclose($handler);
touch($wuc_file, $alarm, $alarm);
rename($wuc_file, $wuc_file_2);
?>