[PHP] Problems with header()

2005-06-17 Thread =?iso-8859-1?q?Mart=EDn_Marqu=E9s?=
I have to send a PDF file after a submit on a form. The PDF is well created, 
and I'm sending it to the client with this:

$fpdfName = /tmp/ . session_id() . .pdf;

// Vamos a mandar el PDF
header('Content-type: application/pdf');
// El archivo se va a llamar libreDeuda.pdf
header('Content-Disposition: attachment; filename=libreDeuda' . 
   '.pdf');
// El PDF fuente va a ser $ftexName.
readfile($fpdfName);

The problem is that the PDF file that is sent is corrupted for acroread (xpdf 
reads it like a charme), because, after the end of file (%%EOF) of PDF there 
is an HTML page add to the file.

Is there anyway I can solve this? Is the sintaxis I used for sending a file 
correct?

-- 
 18:49:09 up 11 days,  6:35,  1 user,  load average: 1.14, 1.26, 1.19
-
Martn Marqus| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] text with $

2005-05-09 Thread =?iso-8859-1?q?Mart=EDn_Marqu=E9s?=
El Lun 09 May 2005 11:44, Marek Kilimajer escribió:
 Martín Marqués wrote:
  I have a text variable that contains $ symbols, that when I pass it out 
PHP 
  thinks that the $ mean that a variable name comes right after.
  
  I tried escaping the $ put with no luck. 
  
  Is there something I can do?
  
 
 How did you escape the symbol? You should use backslash: \

Sorry, my misstake. :-(

I was doing: 

srt_replace($,\$,$string);

instead of: 

srt_replace($,\\$,$string);

Forgot to escape the escape caracter! :-D

-- 
 11:45:49 up 37 days, 20:09,  2 users,  load average: 1.37, 1.07, 1.06
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Socket connection reset by pear

2005-05-06 Thread =?iso-8859-1?q?Mart=EDn_Marqu=E9s?=
OK, I found the error. Aparently, the message that I was sending didn't have a 
newline at the end, and so socket_read on the other end failed to complete 
it's task, and finds it self with a conection reset by pear when the client 
tries to write something else.

I found out when looking at the Net_Socket Object in PEAR, and say that the 
was a write() and a writeLine() method in the class, an after trying it out, 
it worked!

Sorry for the noise. :-)

El Vie 06 May 2005 16:48, Martín Marqués escribió:
 El Vie 06 May 2005 01:50, Richard Lynch escribió:
 
 The client code is this:
 
 ?php
 ini_set (display_errors , On );
 if (($socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP))  0) {
   echo socket_create() failed: reason:  . socket_strerror ($socket) .
 \n;
 }
 
 $result = socket_connect($socket, '127.0.0.1', 9100);
 var_dump($result);
 $msg = prueba de socket;
 
 $res = socket_write($socket, $msg, strlen($msg));
 var_dump(socket_strerror(socket_last_error($socket)));
 exit;
 ?
 
 The daemon code is like this:
 
 #!/usr/bin/php
 ?php
 ini_set (display_errors , On );
 
 error_reporting(E_ALL);
 
 /* Allow the script to hang around waiting for connections. */
 set_time_limit(0);
 
 /* Turn on implicit output flushing so we see what we're getting
  * as it comes in. */
 ob_implicit_flush();
 
 $address = '127.0.0.1';
 $port = 9100;
 
 if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))  0) {
   echo socket_create() failed: reason:  . socket_strerror($sock) . \n;
 }
 
 if (($ret = socket_bind($sock, $address, $port))  0) {
   echo socket_bind() failed: reason:  . socket_strerror($ret) . \n;
 }
 
 if (($ret = socket_listen($sock, 5))  0) {
   echo socket_listen() failed: reason:  . socket_strerror($ret) . \n;
 }
 
 do {
   if (($msgsock = socket_accept($sock))  0) {
 echo socket_accept() failed: reason:  . socket_strerror($msgsock) . 
 \n;
 break;
   }
   var_dump($msgsock);
   do {
 if (false === ($buf = socket_read($msgsock, 2048, PHP_NORMAL_READ))) {
   echo socket_read() failed: reason:  . socket_strerror($ret) . \n;
   break 1;
 }
 if (!$buf = trim($buf)) {
   continue;
 }
 if ($buf == 'quit') {
   break;
 }
 if ($buf == 'shutdown') {
   socket_close($msgsock);
   break 2;
 }
   } while (true);
   socket_close($msgsock);
 } while (true);
 
 socket_close($sock);
 ?
 
 But when I try to connect with the PHP client (even executing it with CLI 
 interface) I get this message in the daemons output:
 
 
 Warning: socket_read() unable to read from socket [54]: Connection reset by 
 peer in /root/printSocket.php on line 36
 socket_read() failed: reason: Operation not permitted
 
 
 -- 
  16:32:53 up 35 days,  1:01,  2 users,  load average: 0.70, 0.52, 0.59
 -
 Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
 Centro de Telematica  |  DBA, Programador, Administrador
  Universidad Nacional
   del Litoral
 -
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
 18:11:30 up 35 days,  2:40,  2 users,  load average: 0.74, 0.72, 0.71
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Socket connection reset by pear

2005-05-06 Thread =?iso-8859-1?q?Mart=EDn_Marqu=E9s?=
El Vie 06 May 2005 01:50, Richard Lynch escribió:
 On Thu, May 5, 2005 5:20 am, Martín Marqués said:
  I'm trying to build some communication aside of the server thin client
  stuff,
  with a socket daemon and a socket client.
 
  The daemon is the same that everybody can find in the PHP docs (example
  1).
  The client simply opens a connection to the daemon and writes data using
  the
  socket Object from PEAR (last stable version). The problem is that it
  fails
  to make a socket_read() with this message (on the daemon side):
 
  Warning: socket_read() unable to read from socket [54]: Connection reset
  by
  peer
  in
  /space/home/martin/programacion/siprebi-1.2/ext/impresion/printSocket.php
  on line 42
  socket_read() failed: reason: Operation not permitted
 
 
  If I open a telnet conection to the daemon, everything works like a
  charme. It
  writes and quits OK.
 
  What can be going wrong?
 
 Operation not permitted would make me guess you've got a user read/write
 permissions problem.

Permissions where? On the file that is been executed? Everything looks OK.

 When you open that telnet connection, are you logged in as the same user
 as the PHP user that is running the client script?
 
 I'm guessing not...
 
 You have to clarify, for yourself, which user is doing what when to which
 files/devices/sockets, and what chown permissions are in effect.
 
 That generally makes you go Duh and fix the problem pretty quick.

Well not really. I just tried running both scripts (daemon and client) from 
the same machine, both as root, and I still get a connection reset by pear.

The client code is this:

?php
ini_set (display_errors , On );
if (($socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP))  0) {
  echo socket_create() failed: reason:  . socket_strerror ($socket) .
\n;
}

$result = socket_connect($socket, '127.0.0.1', 9100);
var_dump($result);
$msg = prueba de socket;

$res = socket_write($socket, $msg, strlen($msg));
var_dump(socket_strerror(socket_last_error($socket)));
exit;
?

The daemon code is like this:

#!/usr/bin/php
?php
ini_set (display_errors , On );

error_reporting(E_ALL);

/* Allow the script to hang around waiting for connections. */
set_time_limit(0);

/* Turn on implicit output flushing so we see what we're getting
 * as it comes in. */
ob_implicit_flush();

$address = '127.0.0.1';
$port = 9100;

if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))  0) {
  echo socket_create() failed: reason:  . socket_strerror($sock) . \n;
}

if (($ret = socket_bind($sock, $address, $port))  0) {
  echo socket_bind() failed: reason:  . socket_strerror($ret) . \n;
}

if (($ret = socket_listen($sock, 5))  0) {
  echo socket_listen() failed: reason:  . socket_strerror($ret) . \n;
}

do {
  if (($msgsock = socket_accept($sock))  0) {
echo socket_accept() failed: reason:  . socket_strerror($msgsock) . 
\n;
break;
  }
  var_dump($msgsock);
  do {
if (false === ($buf = socket_read($msgsock, 2048, PHP_NORMAL_READ))) {
  echo socket_read() failed: reason:  . socket_strerror($ret) . \n;
  break 1;
}
if (!$buf = trim($buf)) {
  continue;
}
if ($buf == 'quit') {
  break;
}
if ($buf == 'shutdown') {
  socket_close($msgsock);
  break 2;
}
  } while (true);
  socket_close($msgsock);
} while (true);

socket_close($sock);
?

But when I try to connect with the PHP client (even executing it with CLI 
interface) I get this message in the daemons output:


Warning: socket_read() unable to read from socket [54]: Connection reset by 
peer in /root/printSocket.php on line 36
socket_read() failed: reason: Operation not permitted


-- 
 16:32:53 up 35 days,  1:01,  2 users,  load average: 0.70, 0.52, 0.59
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Socket connection reset by pear

2005-05-05 Thread =?iso-8859-1?q?Mart=EDn_Marqu=E9s?=
I'm trying to build some communication aside of the server thin client stuff, 
with a socket daemon and a socket client.

The daemon is the same that everybody can find in the PHP docs (example 1). 
The client simply opens a connection to the daemon and writes data using the 
socket Object from PEAR (last stable version). The problem is that it fails 
to make a socket_read() with this message (on the daemon side):

Warning: socket_read() unable to read from socket [54]: Connection reset by 
peer 
in /space/home/martin/programacion/siprebi-1.2/ext/impresion/printSocket.php 
on line 42
socket_read() failed: reason: Operation not permitted


If I open a telnet conection to the daemon, everything works like a charme. It 
writes and quits OK.

What can be going wrong?

-- 
 09:11:45 up 33 days, 17:40,  1 user,  load average: 0.64, 0.79, 0.68
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php