php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8999 difference ftp_fget() cgi and module
Submitted: 2001-01-30 07:16 UTC Modified: 2001-08-16 19:47 UTC
From: rolf dot lehmann at datura dot ch Assigned:
Status: Not a bug Package: FTP related
PHP Version: 4.0.4pl1 OS: Windows
Private report: No CVE-ID: None
 [2001-01-30 07:16 UTC] rolf dot lehmann at datura dot ch
Until now I was using PHP4 in CGI-Mode. Now I want to change to Apache Module. So I made the nessecary changes in httpd.conf and rebotted the Windows 2000 server.

Since PHP is running as an Apache Module, the function ftp_fget() doesn't work correctly anymore.

I read a jpg from a FTP Server and display it with the <img> tag. In Module Mode the file is transferred and the width and height is correct, but the content is wrong (wrong colors in the completely wrong places). When PHP is running in cgi mode, everything is correct.

Thanks for any help, Rolf.

Code Sample:

class Foto_class
{

  var $fotoname;

  function Foto_class( $verwender )
  {
    global $const_ftp_host, $const_ftp_user, $const_ftp_passwd, $const_ftp_dir;
    $select_file = "foto.jpg";
    $ftp = ftp_connect( $const_ftp_host );
    if ( $ftp )
    {
      ftp_login( $ftp, $const_ftp_user, urldecode( $const_ftp_passwd ) );
    }
    if ( $const_ftp_dir == "" )
    {
      $const_ftp_dir = FTP_DIRROOT;
    }
    $const_ftp_dir = $const_ftp_dir . FTP_DIRROOT . $verwender;
    if ( ( ! $ftp ) || ( ! @ftp_chdir( $ftp, $const_ftp_dir ) ) )
    {
      @ftp_quit( $ftp );
    }
    else
    {
      srand( ( double ) microtime() * 1000000 );
      $randval = rand();
      $tmpfile = $select_file . "." . $randval;
      $showfile = $this->filename( $tmpfile );
      $fp = fopen( $showfile, "w" );
      if ( ! @ftp_fget( $ftp, $fp, $select_file, FTP_BINARY ) )
      {
        ftp_quit( $ftp );
      }
      else
      {
        ftp_quit( $ftp );
        $this->fotoname = $showfile;
      }
      @fclose( $fp );
    }
  }

  function filename($f_name)
  {
    $dir = "./temp/sess_".session_id();
    if (!file_exists($dir)) mkdir($dir,0700);
    return $dir."/".$f_name;
  }

  function out()
  {
    return $this->fotoname;
  }

}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-21 21:29 UTC] andy@php.net
If it works as a CGI, I say just go back to the CGI version.

But, if you don't then answer these questions.

-Does it still happen in the latest version of PHP?
-Are there any error messages (either on the page or logs)
 [2001-08-14 20:11 UTC] jmoore@php.net
can you provide some indepth information about your setup please and a script less than ten lines that also produces the bug.

- James
 [2001-08-16 19:47 UTC] sniper@php.net
You opened the target file in 'w' mode when you should
have opened it in 'wb' (binary) mode.

Not a bug.

--Jani

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 23:03:34 2021 UTC