Foros del Web » Programando para Internet » PHP »

fprintf() ¬¬

Estas en el tema de fprintf() ¬¬ en el foro de PHP en Foros del Web. Hola me baje un script de PHP que en linux apache y gnokii puedo enviar un sms... Bueno como siempre los errores surgen. en el ...
  #1 (permalink)  
Antiguo 08/06/2010, 15:05
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
fprintf() ¬¬

Hola me baje un script de PHP que en linux apache y gnokii puedo enviar un sms...
Bueno como siempre los errores surgen.
en el explorer no sale ningun error pero en el LOG de apache si:
Código:
 PHP Notice:  Use of undefined constant stderr - assumed 'stderr' in /var/www/hola.php on line 52, referer: http://localhost/hola.php
PHP Warning:  fprintf() expects parameter 1 to be resource, string given in /var/www/hola.php on line 52, referer: http://localhost/hola.php
El script es el siguiente:

Código PHP:
Ver original
  1. <?php
  2.  echo siteHeader();
  3.  $option = $_POST["status_page"];
  4.  switch($option){
  5.         case "":
  6.                   echo showForm();
  7.                 break;
  8.         case "sms_sender":
  9.                         pipes(ValidateNumber( $_POST["phone_number"]), $_POST["sms_message"]);
  10.                 break;
  11.  }
  12.  function showForm(){
  13.         $frontEnd =
  14.         "<div align=center>" .
  15.         "<form name=smssender method=post action=\"$_SERVER[PHP_SELF]\" >".
  16.                 "<table  class=MAINFORM>".
  17.                 "<tr> <td colspan=2 >Envia SMS</td> </tr>".
  18.                 "<tr> <td colspan=2></td> </tr>".
  19.                 "<tr> <td class=NAME_FIELD>Telefono:</td>  <td><input type=text name=phone_number size=70 maxlenght=16 class=TEXT_BOX></td> </tr>".
  20.                 "<tr> <td class=NAME_FIELD>Mensaje:</td>  <td><textarea name=sms_message cols=60 rows=5 class=TEXT_AREA></textarea></td> </tr>".
  21.                 "<tr> <td></td>  <td><input type=button name=send_message value='Enviar' onClick='javascript:document.forms[0].submit();' class=TXT_BUTTON></td> </tr>".
  22.                 "<input type=hidden name=status_page value=\"sms_sender\" >".
  23.                 "</table>".
  24.         "</form>" .
  25.         "</div>";
  26.         return $frontEnd;              
  27.  }
  28.  function siteHeader(){
  29.         $header = "<link rel=stylesheet type=text/css /*href=estilo.css*/>";
  30.         return $header;
  31.  }
  32.         function pipes($number="", $message=""){
  33.         if(is_numeric($number)!="" and is_string($message) and $message!=""){
  34.                         error_reporting(E_ALL);
  35.                         $echo_pipe = popen(" echo \"$message\" ", 'r');
  36.                         $gnokii_pipe = popen("gnokii --sendsms $number -r", 'w');
  37.                    if ((!$echo_pipe) || (!$gnokii_pipe)) {
  38.                                 fprintf(stderr, "One or both pipes failed.\n");
  39.                                 return EXIT_FAILURE;
  40.                     }
  41.                     $bytes_read = 0;
  42.                     while ($buffer = fread($echo_pipe, 2096)) {
  43.                                 fwrite($gnokii_pipe, $buffer);
  44.                                 $bytes_read += strlen($buffer);
  45.                     }
  46.                     $status_function = 0;
  47.                     if (pclose($echo_pipe) != 0) {
  48.                                 fprintf(stderr, "Could not run 'echo', or other error.\n");
  49.                                 $status_function++;
  50.                     }
  51.                     if (pclose($gnokii_pipe) != 0) {
  52.                                 fprintf(stderr, "Could not run 'festival', or other error.\n");
  53.                                 $status_function++;
  54.                     }
  55.                     if($status_function>=2){
  56.                         echo sms_successful($number, $message);
  57.                     }
  58.                         echo sms_successful($number, $message);
  59.                 }
  60.         }
  61.         function sms_successful($number="", $message=""){
  62.                 return "<div align=center>" .
  63.                 "<table class=MAINFORM><tr class=successful><td colspan=2>Mensaje enviado exitosamente</td></tr>" .
  64.                 "<tr><td class=name_field>Telefono: </td><td class=value_field>$number</td></tr>" .
  65.                 "<tr><td class=name_field>Mensaje: </td><td class=value_field>$message</td></tr>" .
  66.                 "</table>" .
  67.                 "</div>";      
  68.         }
  69.        function ValidateNumber($number ){
  70.                 return eregi_replace("[^0-9]", "", $number);
  71.         }
  72. ?>
Linea 52
fprintf(stderr, "Could not run 'echo', or other error.\n");


Bueno gracias por su tiempo
  #2 (permalink)  
Antiguo 08/06/2010, 16:26
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: fprintf() ¬¬

lee lo siguiente...
http://php.net/manual/en/wrappers.php.php

Código PHP:
define('stderr''php://stderr'); 
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 08/06/2010, 17:02
Avatar de SirDuque  
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Respuesta: fprintf() ¬¬

GRax pateketrueke
Siempre presente!

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:21.