Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.95 KB | None | 0 0
  1. <?php
  2.  
  3. echo "Nombre Campana    : ".$form_state[values][submitted][1]; echo "<br/>";
  4. echo "Pais              : ".$form_state[values][submitted][2]; echo "<br/>";
  5. echo "Audio             : ".$form_state[values][submitted][3]; echo "<br/>";
  6. echo "Achivo cvs        : ".$form_state[values][submitted][4]; echo "<br/>";
  7. echo "Telefono correo   : ".$form_state[values][submitted][5]; echo "<br/>";
  8. echo "Fecha de Inicio   : ".$form_state[values][submitted][6]; echo "<br/>";
  9. echo "Fecha de Mes      : ".$form_state[values][submitted][6][0]; echo "<br/>";
  10. echo "Fecha de Dia      : ".$form_state[values][submitted][6][1]; echo "<br/>";
  11. echo "Fecha de Anio   : ".$form_state[values][submitted][6][2]; echo "<br/>";
  12.  
  13. echo "Fecha de Fin      : ".$form_state[values][submitted][7]; echo "<br/>";
  14. echo "Fecha de Mes      : ".$form_state[values][submitted][7][0]; echo "<br/>";
  15. echo "Fecha de Dia      : ".$form_state[values][submitted][7][1]; echo "<br/>";
  16. echo "Fecha de Anio      : ".$form_state[values][submitted][7][2]; echo "<br/>";
  17.  
  18.  
  19.  
  20. echo "Hora Incio        : ".$form_state[values][submitted][8]; echo "<br/>";
  21. echo "Hora Incio        : ".$form_state[values][submitted][8][hour]; echo "<br/>";
  22. echo "Hora Incio        : ".$form_state[values][submitted][8][minute]; echo "<br/>";
  23. echo "Hora Incio        : ".$form_state[values][submitted][8][2]; echo "<br/>";
  24.  
  25. echo "Hora Fin          : ".$form_state[values][submitted][9]; echo "<br/>";
  26. echo "Hora Fin          : ".$form_state[values][submitted][9][hour]; echo "<br/>";
  27. echo "Hora Fin          : ".$form_state[values][submitted][9][minute]; echo "<br/>";
  28. echo "Hora Fin          : ".$form_state[values][submitted][9][2]; echo "<br/>";
  29. echo "Retorno           : ".$form_state[values][submitted][10]; echo "<br/>";
  30. echo "Traslado Operador : ".$form_state[values][submitted][11]; echo "<br/>";
  31. echo "Numero a llamar   : ".$form_state[values][submitted][12]; echo "<br/>";
  32. echo "Tipo de Campa;a   : ".$form_state[values][submitted][13]; echo "<br/>";
  33.  
  34.  
  35. //Telefono 1enviar: Desde Guate
  36. //Telefono 2enviar: Guatemala
  37. //Telefono 3enviar: Audio 1
  38. //Telefono 4enviar: a:0:{}
  39. //Telefono 5enviar: example@example.com
  40. //Telefono 6enviar: Array
  41. //Telefono 7enviar: Array
  42. //Telefono 8enviar: Array
  43. //Telefono 9enviar: Array
  44. //Telefono 10enviar: 22883732
  45. //Telefono 11enviar: 42234
  46. //Telefono 12enviar: 42110696
  47. //Telefono 13enviar: Anuncio
  48.  
  49.  
  50. $dbhost = 'localhost';
  51. $dbuser = 'telgrupo_at';
  52. $dbpass = 'E[;T79ds&7!s';
  53. $dbname = 'telgrupo_at';
  54.  
  55.  
  56. //include ('../configSuccess.php');
  57. //include('../opendbSuccess.php');
  58. $fecha_hoy = date('Y').'-'.date('m').'-'.date('d').' '.date('h').':'.date('m').':'.date('s');
  59. $reintentar  = $_POST['reintento_de_llamada'];
  60. $transfer    = $_POST['tranfer'];
  61. $fechainicio = $_POST['fecha_inicio'];
  62. $fechafinal  = $_POST['fecha_final'];
  63. $horainicio  = $_POST['hora_inicio'];
  64. $horafinal   = $_POST['hora_final'];
  65. $empresa     = $_POST['empresa'];
  66. $email       = $_POST['mail'];
  67. $contactos   = $_POST['contactos'];
  68. $caller_id   = $_POST['caller_id'];
  69. $nombre      = $_POST['nombre'];
  70. $tipo2       = $_POST['tipo'];
  71. $idaudio     = $_POST['campana_audio'];
  72. $pais        = $_POST['pais'];
  73. $archivocsv  = $HTTP_POST_FILES['numerosf']['name'];
  74.  
  75.  
  76.  
  77.  
  78. if ($tipo2=="anuncio") {
  79.    $tipo = 1;
  80.    }
  81. else{
  82.    $tipo=2;  
  83. }
  84.  
  85. $stmt = "select id,codigo,nombre from paises where id=1";
  86. $stmt0 = "select    id,audio from audios where id=".$idaudio;
  87. $stmt3 = "SELECT a.caller_id, a.email, a.retorno, b.username, c.nombre, a.prefijo, LOWER(d.nombre) nombre ";
  88. $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";
  89.  
  90. $stmt7  = "select max(id)+1 id from campanas" ;
  91. $query = mysql_query($stmt,$conn);
  92. $query0 = mysql_query($stmt0,$conn);
  93. $query3 = mysql_query($stmt3,$conn);
  94. $query7 = mysql_query($stmt7);
  95. $r=mysql_fetch_array($query,MYSQL_ASSOC);
  96.      $codigoArea= $r["codigo"];
  97.      $pais=$r["id"];
  98.  
  99. $r0=mysql_fetch_array($query0,MYSQL_ASSOC);
  100.      $audio= $r["audio"];
  101.      $audiosinwav = substr($audio,strlen($audio)-4,strlen($audio));
  102.      $idaudio=$r["idaudio"];
  103.  
  104. $r3=mysql_fetch_array($query3,MYSQL_ASSOC);
  105.      $username  = $rs3["username"];
  106.      $caller_id = $rs3["caller_id"];
  107.      $empresa   = $rs3["empresa"];
  108.      $retorno   = $r3["retorno"];
  109.      $mail      = $r3["mail"];
  110.      $prefijo   = $r3["prefijo"];
  111.      $provider  = $r3["nombre"];   
  112.      
  113. $stmt6  = "select max(id) id from llamadas" ;
  114. $query6 = mysql_query($stmt6);
  115. $r6=mysql_fetch_array($query6,MYSQL_ASSOC);
  116. $idllamada = $r6["id"];
  117.  
  118.  
  119. $r7=mysql_fetch_array($query7,MYSQL_ASSOC);
  120.           $idcampana = $r7["id"];
  121.  
  122. //insertamos una nueva campaña
  123. $stmt4  ="   INSERT INTO campanas values(".$idcampana.",'',1,1,".$prefijo.",".$pais."," ;
  124. $stmt4.=" '".$audio."','".$nombre."',".$tipo.",'".$provider."',";
  125. $stmt4.=" '".$fechainicio."','".$fechafinal."','','".$horainicio."','".$horafinal."','',1,5,1,";
  126. $stmt4.=" '".$email."','0','".$contactos."','".$fecha_hoy."','".$fecha_hoy."');";
  127. mysql_query($stmt4,$conn);
  128.  
  129.            
  130.             $start = $fechainicio.$horainicio;
  131.             $end   = $fechafinal.$horafinal;
  132.  
  133. if (strlen($_POST['numeros'])> 0) {
  134. //generacion de archivos .call
  135. $numeros = trim($_POST['numeros']);
  136.         $numeros = explode(',', $numeros);
  137.         $i = 0;
  138.         while ($i < count($numeros)) {
  139.         $i+=1;
  140.         //foreach($numeros as $numero):
  141.        
  142.         $idllamada+=1;
  143.        
  144.         $stmt5 = "INSERT INTO llamadas(id,campanas_id, numero_destino, proveedor_name,operador,prefijo,duracion,created_at, updated_at) values(";
  145.         $stmt5.=  " ".$idllamada.",".$idcampana.",".$numeros[$i].",'".$provider."','','".$prefijo."',0,'".$fecha_hoy."','".$fecha_hoy."');";
  146.         mysql_query($stmt5,$conn);
  147.                        
  148.             $idCall = 'call'.$idllamada.'.call';
  149.            
  150.             if (strlen($transfer) > 0) {
  151.                $tvalor = 1;
  152.             } else {
  153.                $tvalor = 0;
  154.             }
  155.            
  156.             $rvalor =0;
  157.             $retorno = 0;
  158.             $caller_id="23120996";
  159.              echo "numero enviado: ".$numeros[$i]; echo "<br/>";
  160.             $tempo=$numeros[$i];   
  161.             $content = "Channel: LOCAL/$prefijo$codigoArea$tempo@$provider\n";
  162.             $content.= "CallerID: $caller_id\n";
  163.             $content.= "MaxRetries: 5\n";
  164.             $content.= "RetryTime: 300\n";
  165.             $content.= "WaitTime: 20\n";
  166.             $content.= "Archive: Yes\n";
  167.             $content.= "Context: procesos\n";
  168.             $content.= "Extension: s\n";
  169.             $content.= "Priority: 1\n";
  170.             $content.= "Set:audio=vm-intro\n";
  171.             $content.= "Set:type=$tipo\n";
  172.             $content.= "Set:transfervar=$tvalor\n";  // 0 no venia 1 si esta llena
  173.             $content.= "Set:transfernum=$transfer\n"; // numero
  174.             $content.= "Set:returnvar=$rvalor\n";  //0 audio 1 numero
  175.             $content.= "Set:return=$retorno\n";    //nombre audio sin wav o numero
  176.             $content.= "Set:start=$start\n";
  177.             $content.= "Set:end=$end\n";
  178.             $content.= "Set:idllamada=$idllamada\n";
  179.             $content.= "Set:pais=$codigoArea\n";
  180.             $content.= "Set:prefijo=$prefijo\n";
  181.            
  182.             $file_call = "/home/telgrupo/public_html/tmp/$idCall";
  183.             $call=fopen($file_call,"a+") or
  184.             die("Problemas en la creacion");
  185.             fputs($call, $content);
  186.             fclose($call);
  187.             //$content.= "Extension: s\Priority: 1\n";
  188.             //$time = $date['year'].$date['month'].$date['day'].date('h').date('m');
  189.             //$time = $fechainicio.$horainicio;
  190.             //exec("touch -t ".$time." ".$file_call);
  191.        
  192.  
  193.            
  194.             if(is_dir("/var/spool/asterisk/outgoing/")):
  195.                 exec('mv '.$file_call.' /var/spool/asterisk/outgoing/');
  196.             endif;
  197.        
  198.         //endforeach
  199.  
  200.  }
  201. } else {
  202. $path="/home/telgrupo/public_html/";
  203. if (is_uploaded_file($HTTP_POST_FILES['numerosf']['tmp_name']))
  204. {
  205. $path = $path . basename( $HTTP_POST_FILES['numerosf']['name']);
  206. move_uploaded_file($HTTP_POST_FILES['numerosf']['tmp_name'], "$path");
  207. }
  208. else { echo "Error al subir el archivo"; }
  209.  
  210. $fp = fopen ( "$path" , "r" );
  211. while (( $data = fgetcsv ( $fp , 1000 , "," )) !== FALSE ) { // Mientras hay líneas que leer...
  212.  
  213. $j = 0;
  214. foreach($data as $row) {
  215.  
  216.  $idllamada+=1;
  217.        
  218.         $stmt5 = "INSERT INTO llamadas(id,campanas_id, numero_destino, proveedor_name,operador,prefijo,duracion,created_at, updated_at) values(";
  219.         $stmt5.=  " ".$idllamada.",".$idcampana.",".$row.",'".$provider."','','".$prefijo."',0,'".$fecha_hoy."','".$fecha_hoy."');";
  220.         mysql_query($stmt5,$conn);
  221.                        
  222.             $idCall = 'call'.$idllamada.'.call';
  223.            
  224.             if (strlen($transfer) > 0) {
  225.                $tvalor = 1;
  226.             } else {
  227.                $tvalor = 0;
  228.             }
  229.             $rvalor =0;
  230.             $retorno = 0;
  231.             $caller_id="23120996";
  232.              echo "numero enviado: ".$row; echo "<br/>";
  233.             $tempo=$row;   
  234.             $content = "Channel: LOCAL/$prefijo$codigoArea$tempo@$provider\n";
  235.             $content.= "CallerID: $caller_id\n";
  236.             $content.= "MaxRetries: 5\n";
  237.             $content.= "RetryTime: 300\n";
  238.             $content.= "WaitTime: 20\n";
  239.             $content.= "Archive: Yes\n";
  240.             $content.= "Context: procesos\n";
  241.             $content.= "Extension: s\n";
  242.             $content.= "Priority: 1\n";
  243.             $content.= "Set:audio=vm-intro\n";
  244.             $content.= "Set:type=$tipo\n";
  245.             $content.= "Set:transfervar=$tvalor\n";    // 0 no venia 1 si esta llena
  246.             $content.= "Set:transfernum=$transfer\n";  // numero
  247.             $content.= "Set:returnvar=$rvalor\n";      //0 audio 1 numero
  248.             $content.= "Set:return=$retorno\n";        //nombre audio sin wav o numero
  249.             $content.= "Set:start=$start\n";
  250.             $content.= "Set:end=$end\n";
  251.             $content.= "Set:idllamada=$idllamada\n";
  252.             $content.= "Set:pais=$codigoArea\n";
  253.             $content.= "Set:prefijo=$prefijo\n";
  254.            
  255.             $file_call = "/home/telgrupo/public_html/tmp/$idCall";
  256.             $call=fopen($file_call,"a+") or
  257.             die("Problemas en la creacion");
  258.             fputs($call, $content);
  259.             fclose($call);
  260.             //$content.= "Extension: s\Priority: 1\n";
  261.             //$time = $date['year'].$date['month'].$date['day'].date('h').date('m');
  262.             //$time = $fechainicio.$horainicio;
  263.             //exec("touch -t ".$time." ".$file_call);
  264.        
  265.  
  266.            
  267.             if(is_dir("/var/spool/asterisk/outgoing/")):
  268.                 exec('mv '.$file_call.' /var/spool/asterisk/outgoing/');
  269.             endif;
  270.  
  271. echo "Campo $j: $row<br>"; // Muestra todos los campos de la fila actual
  272. $j++ ;
  273. }
  274.  
  275. }
  276. fclose ( $fp );
  277.  
  278. }
  279.  echo "audio : ".$audio; echo "<br/>";
  280.  echo "stmt: ".$stmt; echo "<br />";
  281.  echo "fecha_hoy: ".$fecha_hoy; echo "<br />";
  282.  echo "reintentar :".$reintentar ; echo "<br />";
  283.  echo "traslado :".$traslado; echo "<br />";
  284.  echo "fecha_inicio: ".$fechainicio; echo "<br />";
  285.  echo "fecha_final: ".$fechafinal; echo "<br />";
  286.  echo "hora_inicio: ".$horainicio; echo "<br />";
  287.  echo "hora_final: ".$horafinal; echo "<br />";
  288.  echo "empresa: ".$empresa; echo "<br />";
  289.  echo "email: ".$email; echo "<br />";
  290.  echo "contactos: ".$contactos; echo "<br />";
  291.  echo "caller_id: ".$caller_id; echo "<br />";
  292.  echo "nombre: ".$nombre; echo "<br />";
  293.  echo "tipo2: ".$tipo2; echo "<br />";
  294.  echo "tipo: ".$tipo; echo "<br />";
  295.  echo "audio :".$idaudio; echo "<br />";
  296.  echo "audiosinwav: ".$audiosinwav; echo "<br />";
  297.  echo "stmt5: ".$stmt5; echo "<br />";
  298.  echo "stmt4: ".$stmt4; echo "<br />";
  299.  echo "archivoscsv :".$archivocsv; echo "<br />";
  300.  echo "archivo call: ".$content;
  301. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement