Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "Nombre Campana : ".$form_state[values][submitted][1]; echo "<br/>";
- echo "Pais : ".$form_state[values][submitted][2]; echo "<br/>";
- echo "Audio : ".$form_state[values][submitted][3]; echo "<br/>";
- echo "Achivo cvs : ".$form_state[values][submitted][4]; echo "<br/>";
- echo "Telefono correo : ".$form_state[values][submitted][5]; echo "<br/>";
- echo "Fecha de Inicio : ".$form_state[values][submitted][6]; echo "<br/>";
- echo "Fecha de Mes : ".$form_state[values][submitted][6][0]; echo "<br/>";
- echo "Fecha de Dia : ".$form_state[values][submitted][6][1]; echo "<br/>";
- echo "Fecha de Anio : ".$form_state[values][submitted][6][2]; echo "<br/>";
- echo "Fecha de Fin : ".$form_state[values][submitted][7]; echo "<br/>";
- echo "Fecha de Mes : ".$form_state[values][submitted][7][0]; echo "<br/>";
- echo "Fecha de Dia : ".$form_state[values][submitted][7][1]; echo "<br/>";
- echo "Fecha de Anio : ".$form_state[values][submitted][7][2]; echo "<br/>";
- echo "Hora Incio : ".$form_state[values][submitted][8]; echo "<br/>";
- echo "Hora Incio : ".$form_state[values][submitted][8][hour]; echo "<br/>";
- echo "Hora Incio : ".$form_state[values][submitted][8][minute]; echo "<br/>";
- echo "Hora Incio : ".$form_state[values][submitted][8][2]; echo "<br/>";
- echo "Hora Fin : ".$form_state[values][submitted][9]; echo "<br/>";
- echo "Hora Fin : ".$form_state[values][submitted][9][hour]; echo "<br/>";
- echo "Hora Fin : ".$form_state[values][submitted][9][minute]; echo "<br/>";
- echo "Hora Fin : ".$form_state[values][submitted][9][2]; echo "<br/>";
- echo "Retorno : ".$form_state[values][submitted][10]; echo "<br/>";
- echo "Traslado Operador : ".$form_state[values][submitted][11]; echo "<br/>";
- echo "Numero a llamar : ".$form_state[values][submitted][12]; echo "<br/>";
- echo "Tipo de Campa;a : ".$form_state[values][submitted][13]; echo "<br/>";
- //Telefono 1enviar: Desde Guate
- //Telefono 2enviar: Guatemala
- //Telefono 3enviar: Audio 1
- //Telefono 4enviar: a:0:{}
- //Telefono 5enviar: example@example.com
- //Telefono 6enviar: Array
- //Telefono 7enviar: Array
- //Telefono 8enviar: Array
- //Telefono 9enviar: Array
- //Telefono 10enviar: 22883732
- //Telefono 11enviar: 42234
- //Telefono 12enviar: 42110696
- //Telefono 13enviar: Anuncio
- $dbhost = 'localhost';
- $dbuser = 'telgrupo_at';
- $dbpass = 'E[;T79ds&7!s';
- $dbname = 'telgrupo_at';
- //include ('../configSuccess.php');
- //include('../opendbSuccess.php');
- $fecha_hoy = date('Y').'-'.date('m').'-'.date('d').' '.date('h').':'.date('m').':'.date('s');
- $reintentar = $_POST['reintento_de_llamada'];
- $transfer = $_POST['tranfer'];
- $fechainicio = $_POST['fecha_inicio'];
- $fechafinal = $_POST['fecha_final'];
- $horainicio = $_POST['hora_inicio'];
- $horafinal = $_POST['hora_final'];
- $empresa = $_POST['empresa'];
- $email = $_POST['mail'];
- $contactos = $_POST['contactos'];
- $caller_id = $_POST['caller_id'];
- $nombre = $_POST['nombre'];
- $tipo2 = $_POST['tipo'];
- $idaudio = $_POST['campana_audio'];
- $pais = $_POST['pais'];
- $archivocsv = $HTTP_POST_FILES['numerosf']['name'];
- if ($tipo2=="anuncio") {
- $tipo = 1;
- }
- else{
- $tipo=2;
- }
- $stmt = "select id,codigo,nombre from paises where id=1";
- $stmt0 = "select id,audio from audios where id=".$idaudio;
- $stmt3 = "SELECT a.caller_id, a.email, a.retorno, b.username, c.nombre, a.prefijo, LOWER(d.nombre) nombre ";
- $stmt3.= " FROM sf_guard_user_profile a, sf_guard_user b, empresas c, proveedores d WHERE a.id=b.id AND a.empresas_id = c.id AND a.id=2 AND a.proveedor1 = d.id";
- $stmt7 = "select max(id)+1 id from campanas" ;
- $query = mysql_query($stmt,$conn);
- $query0 = mysql_query($stmt0,$conn);
- $query3 = mysql_query($stmt3,$conn);
- $query7 = mysql_query($stmt7);
- $r=mysql_fetch_array($query,MYSQL_ASSOC);
- $codigoArea= $r["codigo"];
- $pais=$r["id"];
- $r0=mysql_fetch_array($query0,MYSQL_ASSOC);
- $audio= $r["audio"];
- $audiosinwav = substr($audio,strlen($audio)-4,strlen($audio));
- $idaudio=$r["idaudio"];
- $r3=mysql_fetch_array($query3,MYSQL_ASSOC);
- $username = $rs3["username"];
- $caller_id = $rs3["caller_id"];
- $empresa = $rs3["empresa"];
- $retorno = $r3["retorno"];
- $mail = $r3["mail"];
- $prefijo = $r3["prefijo"];
- $provider = $r3["nombre"];
- $stmt6 = "select max(id) id from llamadas" ;
- $query6 = mysql_query($stmt6);
- $r6=mysql_fetch_array($query6,MYSQL_ASSOC);
- $idllamada = $r6["id"];
- $r7=mysql_fetch_array($query7,MYSQL_ASSOC);
- $idcampana = $r7["id"];
- //insertamos una nueva campaña
- $stmt4 =" INSERT INTO campanas values(".$idcampana.",'',1,1,".$prefijo.",".$pais."," ;
- $stmt4.=" '".$audio."','".$nombre."',".$tipo.",'".$provider."',";
- $stmt4.=" '".$fechainicio."','".$fechafinal."','','".$horainicio."','".$horafinal."','',1,5,1,";
- $stmt4.=" '".$email."','0','".$contactos."','".$fecha_hoy."','".$fecha_hoy."');";
- mysql_query($stmt4,$conn);
- $start = $fechainicio.$horainicio;
- $end = $fechafinal.$horafinal;
- if (strlen($_POST['numeros'])> 0) {
- //generacion de archivos .call
- $numeros = trim($_POST['numeros']);
- $numeros = explode(',', $numeros);
- $i = 0;
- while ($i < count($numeros)) {
- $i+=1;
- //foreach($numeros as $numero):
- $idllamada+=1;
- $stmt5 = "INSERT INTO llamadas(id,campanas_id, numero_destino, proveedor_name,operador,prefijo,duracion,created_at, updated_at) values(";
- $stmt5.= " ".$idllamada.",".$idcampana.",".$numeros[$i].",'".$provider."','','".$prefijo."',0,'".$fecha_hoy."','".$fecha_hoy."');";
- mysql_query($stmt5,$conn);
- $idCall = 'call'.$idllamada.'.call';
- if (strlen($transfer) > 0) {
- $tvalor = 1;
- } else {
- $tvalor = 0;
- }
- $rvalor =0;
- $retorno = 0;
- $caller_id="23120996";
- echo "numero enviado: ".$numeros[$i]; echo "<br/>";
- $tempo=$numeros[$i];
- $content = "Channel: LOCAL/$prefijo$codigoArea$tempo@$provider\n";
- $content.= "CallerID: $caller_id\n";
- $content.= "MaxRetries: 5\n";
- $content.= "RetryTime: 300\n";
- $content.= "WaitTime: 20\n";
- $content.= "Archive: Yes\n";
- $content.= "Context: procesos\n";
- $content.= "Extension: s\n";
- $content.= "Priority: 1\n";
- $content.= "Set:audio=vm-intro\n";
- $content.= "Set:type=$tipo\n";
- $content.= "Set:transfervar=$tvalor\n"; // 0 no venia 1 si esta llena
- $content.= "Set:transfernum=$transfer\n"; // numero
- $content.= "Set:returnvar=$rvalor\n"; //0 audio 1 numero
- $content.= "Set:return=$retorno\n"; //nombre audio sin wav o numero
- $content.= "Set:start=$start\n";
- $content.= "Set:end=$end\n";
- $content.= "Set:idllamada=$idllamada\n";
- $content.= "Set:pais=$codigoArea\n";
- $content.= "Set:prefijo=$prefijo\n";
- $file_call = "/home/telgrupo/public_html/tmp/$idCall";
- $call=fopen($file_call,"a+") or
- die("Problemas en la creacion");
- fputs($call, $content);
- fclose($call);
- //$content.= "Extension: s\Priority: 1\n";
- //$time = $date['year'].$date['month'].$date['day'].date('h').date('m');
- //$time = $fechainicio.$horainicio;
- //exec("touch -t ".$time." ".$file_call);
- if(is_dir("/var/spool/asterisk/outgoing/")):
- exec('mv '.$file_call.' /var/spool/asterisk/outgoing/');
- endif;
- //endforeach
- }
- } else {
- $path="/home/telgrupo/public_html/";
- if (is_uploaded_file($HTTP_POST_FILES['numerosf']['tmp_name']))
- {
- $path = $path . basename( $HTTP_POST_FILES['numerosf']['name']);
- move_uploaded_file($HTTP_POST_FILES['numerosf']['tmp_name'], "$path");
- }
- else { echo "Error al subir el archivo"; }
- $fp = fopen ( "$path" , "r" );
- while (( $data = fgetcsv ( $fp , 1000 , "," )) !== FALSE ) { // Mientras hay lÃneas que leer...
- $j = 0;
- foreach($data as $row) {
- $idllamada+=1;
- $stmt5 = "INSERT INTO llamadas(id,campanas_id, numero_destino, proveedor_name,operador,prefijo,duracion,created_at, updated_at) values(";
- $stmt5.= " ".$idllamada.",".$idcampana.",".$row.",'".$provider."','','".$prefijo."',0,'".$fecha_hoy."','".$fecha_hoy."');";
- mysql_query($stmt5,$conn);
- $idCall = 'call'.$idllamada.'.call';
- if (strlen($transfer) > 0) {
- $tvalor = 1;
- } else {
- $tvalor = 0;
- }
- $rvalor =0;
- $retorno = 0;
- $caller_id="23120996";
- echo "numero enviado: ".$row; echo "<br/>";
- $tempo=$row;
- $content = "Channel: LOCAL/$prefijo$codigoArea$tempo@$provider\n";
- $content.= "CallerID: $caller_id\n";
- $content.= "MaxRetries: 5\n";
- $content.= "RetryTime: 300\n";
- $content.= "WaitTime: 20\n";
- $content.= "Archive: Yes\n";
- $content.= "Context: procesos\n";
- $content.= "Extension: s\n";
- $content.= "Priority: 1\n";
- $content.= "Set:audio=vm-intro\n";
- $content.= "Set:type=$tipo\n";
- $content.= "Set:transfervar=$tvalor\n"; // 0 no venia 1 si esta llena
- $content.= "Set:transfernum=$transfer\n"; // numero
- $content.= "Set:returnvar=$rvalor\n"; //0 audio 1 numero
- $content.= "Set:return=$retorno\n"; //nombre audio sin wav o numero
- $content.= "Set:start=$start\n";
- $content.= "Set:end=$end\n";
- $content.= "Set:idllamada=$idllamada\n";
- $content.= "Set:pais=$codigoArea\n";
- $content.= "Set:prefijo=$prefijo\n";
- $file_call = "/home/telgrupo/public_html/tmp/$idCall";
- $call=fopen($file_call,"a+") or
- die("Problemas en la creacion");
- fputs($call, $content);
- fclose($call);
- //$content.= "Extension: s\Priority: 1\n";
- //$time = $date['year'].$date['month'].$date['day'].date('h').date('m');
- //$time = $fechainicio.$horainicio;
- //exec("touch -t ".$time." ".$file_call);
- if(is_dir("/var/spool/asterisk/outgoing/")):
- exec('mv '.$file_call.' /var/spool/asterisk/outgoing/');
- endif;
- echo "Campo $j: $row<br>"; // Muestra todos los campos de la fila actual
- $j++ ;
- }
- }
- fclose ( $fp );
- }
- echo "audio : ".$audio; echo "<br/>";
- echo "stmt: ".$stmt; echo "<br />";
- echo "fecha_hoy: ".$fecha_hoy; echo "<br />";
- echo "reintentar :".$reintentar ; echo "<br />";
- echo "traslado :".$traslado; echo "<br />";
- echo "fecha_inicio: ".$fechainicio; echo "<br />";
- echo "fecha_final: ".$fechafinal; echo "<br />";
- echo "hora_inicio: ".$horainicio; echo "<br />";
- echo "hora_final: ".$horafinal; echo "<br />";
- echo "empresa: ".$empresa; echo "<br />";
- echo "email: ".$email; echo "<br />";
- echo "contactos: ".$contactos; echo "<br />";
- echo "caller_id: ".$caller_id; echo "<br />";
- echo "nombre: ".$nombre; echo "<br />";
- echo "tipo2: ".$tipo2; echo "<br />";
- echo "tipo: ".$tipo; echo "<br />";
- echo "audio :".$idaudio; echo "<br />";
- echo "audiosinwav: ".$audiosinwav; echo "<br />";
- echo "stmt5: ".$stmt5; echo "<br />";
- echo "stmt4: ".$stmt4; echo "<br />";
- echo "archivoscsv :".$archivocsv; echo "<br />";
- echo "archivo call: ".$content;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement