OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: php-general-digest-helplists.php.net
Date: Wed May 22 2002 - 11:05:40 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    php-general Digest 22 May 2002 16:05:40 -0000 Issue 1360

    Topics (messages 98680 through 98756):

    Re: The $PATH to enlightenment
            98680 by: Brad Hubbard

    Re: Function
            98681 by: Sqlcoders.com Programming Dept
            98682 by: Kevin Waterson
            98684 by: Miguel Cruz

    make install issues
            98683 by: Evan Nemerson

    Re: Full-Duplex communication
            98685 by: Vinod Panicker
            98686 by: Evan Nemerson
            98687 by: Evan Nemerson
            98688 by: Miguel Cruz
            98689 by: Evan Nemerson
            98690 by: Miguel Cruz
            98691 by: Vinod Panicker
            98692 by: Richard Archer
            98694 by: Vinod Panicker
            98700 by: Richard Archer
            98701 by: Vinod Panicker
            98702 by: Miguel Cruz
            98704 by: Miguel Cruz
            98707 by: Vinod Panicker

    Mcrypt: Blowfish or Twofish or no fish? Part 2
            98693 by: Jimmy Lantz
            98695 by: Vinod Panicker
            98697 by: Ray Hunter
            98746 by: Thalis A. Kalfigopoulos

    Servers, servers and more servers
            98696 by: Stephen Tredrea
            98698 by: Miguel Cruz
            98699 by: Ray Hunter

    Re: Mcrypt: Blowfish or Twofish or no fish?
            98703 by: John Horton

    check if image was clicked
            98705 by: andrew.foxtrot.kiev.ua
            98706 by: Miguel Cruz

    Re: Mcrypt: Blowfish or Twofish or no fish? part 3
            98708 by: Jimmy Lantz
            98710 by: Vinod Panicker
            98711 by: John Horton
            98712 by: John Horton
            98714 by: Vinod Panicker
            98718 by: John Horton
            98720 by: Vinod Panicker

    php4isapi
            98709 by: Brian McGarvie

    Problem with install php 4.2.1
            98713 by: Roman Duriancik

    Executebale code from a databse
            98715 by: Peter
            98716 by: Dan Hardiker
            98721 by: Michael Virnstein

    variables
            98717 by: Roman Duriancik
            98719 by: Michael Virnstein
            98722 by: Eugene Lee

    Smart Navigation
            98723 by: Fred Forsyth
            98726 by: Justin French
            98727 by: Justin French

    Re: Accessing PHP globals from a module.
            98724 by: Eric Veldhuyzen
            98736 by: Rasmus Lerdorf

    Re: JavaScript vs. Header redirect
            98725 by: Michael Virnstein

    Whats Function like response.redirect
            98728 by: RoyD.bercacakra.com
            98729 by: 1LT John W. Holmes
            98730 by: Jon Haworth

    Re: substr....what does this mean? (newbie)
            98731 by: Michael Virnstein

    Session vs MySQL-dbase
            98732 by: Yves Daemen
            98733 by: Yves Daemen

    ODBC for Informix
            98734 by: Kevin Meredith

    voting using text files
            98735 by: Nick Wilson
            98737 by: 1LT John W. Holmes
            98745 by: Justin French

    Using the pdf tags.
            98738 by: Jeff Hatcher

    read from flatfile and convert
            98739 by: r
            98741 by: Robert Cummings
            98742 by: 1LT John W. Holmes

    Re: in_array problems (another pair of eyes?)
            98740 by: Johnson, Kirk

    Re: Mcrypt: Blowfish or Twofish or no fish? part 4
            98743 by: J Smith

    ereg_replace problems
            98744 by: Zac Hillier

    Help .. deprecated messages
            98747 by: Dtsig
            98751 by: 1LT John W. Holmes
            98755 by: Dtsig

    Re: How to simultaneously send HTML *and* start download?
            98748 by: D. D. Brierton

    ini_set('display_errors',1) not working.
            98749 by: Jeff Bearer

    Online PHP training course
            98750 by: Simon Ritchie

    PHP & PGP
            98752 by: Boaz Yahav
            98753 by: John Horton

    Re: upload problem...
            98754 by: Jas

    Passing an array on
            98756 by: John Fishworld

    Administrivia:

    To subscribe to the digest, e-mail:
            php-general-digest-subscribelists.php.net

    To unsubscribe from the digest, e-mail:
            php-general-digest-unsubscribelists.php.net

    To post to the list, e-mail:
            php-generallists.php.net

    ----------------------------------------------------------------------

    attached mail follows:


    On Wed, 22 May 2002 12:59, Martin Towell did align ASCII characters thusly:
    > putenv() and getenv() if it's for just one page

    Ok, that'll do it for one page, thanks. I was thinking of something for an
    entire site, any other ideas?

    This is running on (RH) Linux BTW.

    Cheers,
    Brad

    attached mail follows:


    Hi there!,
    When you include information from an include file, PHP treats the text as
    inline code if you use the include() function.

    In other words, if you use code like this:
    <?php
    include 'file.php';
    ?>

    Then any functions inside file.php will be available just as if you'd
    copy/pasted them in.

    If file.php contained:
    function echoThis($this_text){
        echo($this_text);
    }

    then you could type

    <?php
    include 'file.php';

    echoThis("I am some text");
    ?>

    and whatever echoThis() is coded to do will happen just as if the file
    looked like this:

    <?php
    function echoThis($this_text){
        echo($this_text);
    }

    echoThis("I am some text");
    ?>

    For more information, see http://www.php.net/manual/en/function.include.php

    HTH,
    Dw

    Sqlcoders.com Dynamic data driven web solutions
    ----- Original Message -----
    From: "Rodrigo" <tagzerotagzero.com>
    To: "'Php Lista'" <php-generallists.php.net>
    Sent: May 21 2002 08:48 PM
    Subject: [PHP] Function

    Hi guys I'm trying to use a function on na .inc file, how should I do?

    How should I write the function and what should I write on the file so
    that the function file is "Included" to be used on a function call on
    the php file?

    I appreciate any kind of sample code.

    Thanx,
    Rodrigo de Oliveira Costa

    attached mail follows:


    On Wed, 22 May 2002 00:48:24 -0300
    "Rodrigo" <tagzerotagzero.com> wrote:

    > Hi guys I_m trying to use a function on na .inc file, how should I do?
    >
    > How should I write the function and what should I write on the file so
    > that the function file is _Included_ to be used on a function call on
    > the php file?

    in the file you want to include, lets call it inc.php, put..
    <?php
    function blah(){
    echo 'blah';
    ?>

    then in your main file put
    <?php
    // include the file
    include("inc.php");

    // now we can call the function normally just as if it was written
    // where the include statement is

    blah();

    ?>

    ciao

    attached mail follows:


    On Wed, 22 May 2002, Sqlcoders.com Programming Dept wrote:
    > When you include information from an include file, PHP treats the text as
    > inline code if you use the include() function.
    >
    > In other words, if you use code like this:
    > <?php
    > include 'file.php';
    > ?>
    >
    > Then any functions inside file.php will be available just as if you'd
    > copy/pasted them in.
    >
    > If file.php contained:
    > function echoThis($this_text){
    > echo($this_text);
    > }

    Just make sure your included file also starts with <? and ends with ?>

    miguel

    attached mail follows:


    $ make install
    /usr/local/php4/build/shtool install -c -m 0755 php /usr/local/bin/php-cgi
    cp: cannot stat `php': No such file or directory
    make: *** [install-sapi] Error 1

    Any ideas? Configured with mcrypt, mhash, sockets, and ftp. Everything before
    this works perfect.

    Thanks in advance,
    Evan Nemerson

    attached mail follows:


    Hi,

    It still seems like I havent made the problem clear enough.

    I am aware of the print(), echo() and flush() functions and what
    they do. It does not fit in as a solution. Let me explain my
    problem more elaborately -
    The client calls a PHP script, script_a.php on the Apache web
    server, using a Keep-Alive connection. The script returns some
    response to the client which it uses. Now since the connection is
    a Keep-alive, apache still has it open for reading and writing.
    When the client wants to call other scripts, it just sends the
    request over the same connection. Now the thing is that if the
    server needs to send some ASYNCHRONOUS data to the client, without
    the client requesting for anything, a normal PHP script wont be
    able to do it, since the script would get executed by the web
    server ONLY on a client request (coz thats the way HTTP works).
    Now what i was thinking was - if i could get hold of the socket
    that is being used by apache to send data to the client, I could
    effectively write() to it, from a C++ app or a PHP script (which
    gets invoked from lets say another server). print(), echo() etc
    are functions that write to the output stream, which is opened as
    a result of the clients request, by the web server.

    I want the ability to write to a socket thats been created earlier
    - i want to steal it from Apache, so that i can use it when and
    where i like.

    Functions like echo() and print() are not going to work here, i
    will have to use write() so that i can specify the socket to which
    the data has to be written!

    Hope the problem is understood now.

    Now for your question -
    When the client wants to send data to the server, it just has to
    open a socket connection with the web server, and issue a GET or a
    POST request! if the connection is a keep-alive connection, and
    it has already been created, the client just has to do a GET or a
    POST without the need to connect().

    This mechanism, where the client frequently connects() to the
    server and checks for messages is called polling. One way of
    reducing the high overhead of this is to reuse the connection by
    using a keep-alive connection. A still better improvement would
    be to remove the need for a poll altogether, by doing something
    (thats what my question is all about) on the server so that it can
    send data asynchronously to the server.

    Tx,
    Vinod.

    On Wed, 22 May 2002 Bogdan Stancescu wrote :
    >For your specific problem, I think Mr. Lemos has provided a
    >viable solution (using print() or echo() and flush() whenever you
    >need to, instead of grabbing the socket and write() to it). My
    >problem however is how you envision solving the communication the
    >other way around (i.e. when the CLIENT wants to send data to the
    >server).
    >
    >Bogdan
    >
    >Vinod Panicker wrote:
    >
    >>Hi,
    >>
    >>Tx for your very prompt reply.
    >>
    >>Yeah, I'll post the solution as soon as I find it someplace.
    >>
    >>Let me outline the problem in more detail -
    >>
    >>Client (VC++) calls a PHP script on the server, specifies the
    >>connection type as Keep-Alive. The PHP script, somehow (still a
    >>big question) gets the socket on which the apache server has
    >>received the client request (so that it can send data to the
    >>client later) and stores it in a database.
    >>
    >>Now whenever another PHP script wants to send data
    >>asynchronously to the client, it gets the socket from the
    >>database, and just calls a write() on it. Since the connection
    >>is still open (Keep-Alive), the client receives the information,
    >>and doesnt have to poll the server periodically.
    >>
    >>The application of this is indeed destined for a messaging
    >>product, and could benefit a lot of other areas as well.
    >>
    >>The only thing that is needed is the socket from apache.
    >>
    >>Someone somewhere knows how to get this done, i'm sure :)
    >>
    >>Possibly a hack into the PHP module can get this done, i'm open
    >>to suggestions.
    >>
    >>Tx,
    >>Vinod.
    >>
    >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    >>
    >>>Hi!
    >>>
    >>>I'm looking for an answer to your questions as well, so if you
    >>>do find a solution on other lists, could you please post it
    >>>here as well?
    >>>
    >>>Regarding the issue, your proposal wouldn't make for
    >>>full-duplex as far as I understand since I don't see how the
    >>>client would be able to send any data on the same connection
    >>>_after_ getting connected.
    >>>
    >>>What are you using on the other end of the pipe (on the
    >>>client)? Plain HTML? Flash? Java? Something else?
    >>>
    >>>Bogdan
    >>>
    >>>Vinod Panicker wrote:
    >>>
    >>>>Hi,
    >>>>
    >>>>We have developed a client-server application where the server
    >>>>needs to send asynchronous data to the client. Now since we
    >>>>are using Apache/PHP/MySQL, the client needs to poll the
    >>>>server periodically for information.
    >>>>
    >>>>I was thinking if there was some way to get around this basic
    >>>>problem. I understand that this is how things are supposed to
    >>>>work, but it would be just great if i could PUSH data from the
    >>>>server to the client, using HTTP.
    >>>>
    >>>>Since HTTP is a request/response based protocol, Apache would
    >>>>not send any data to the client asynchronously. So what i was
    >>>>thinking was - If i tell the server to allow Keep-Alive
    >>>>connections, and increase the timeout value and max requests,
    >>>>I would effectively have a constant TCP connection. Now the
    >>>>only problem would be of sending asynchronous data to the
    >>>>client. Solution? Here goes - If there was some way in which
    >>>>i could get hold of the file descriptor(socket) that is being
    >>>>used by apache to write data to the client, then i could, from
    >>>>a PHP script also send any data to the client using the socket
    >>>>functions of PHP since i already have the socket with me.
    >>>>
    >>>>This would mean that the client doesnt have to poll the server
    >>>>for data any more... and if the connection does get closed,
    >>>>the client could reconnect to the server asking for another
    >>>>keep-alive connection.
    >>>>
    >>>>Now I know that this is probably the wrong place to put such a
    >>>>query - maybe the apache list would have been better. But
    >>>>since I'm using PHP out here, i thought i'd give it a try.
    >>>>
    >>>>Does the solution sound very outlandish? Are there any
    >>>>pitfalls? And finally, how do i get hold of the socket?
    >>>
    >
    >
    >
    >
    >-- PHP General Mailing List (http://www.php.net/)
    >To unsubscribe, visit: http://www.php.net/unsub.php
    >

    _________________________________________________________
    Click below to visit monsterindia.com and review jobs in India or
    Abroad
    http://monsterindia.rediff.com/jobs

    attached mail follows:


    Vinod,

    Interesting...

    Okay unless I'm mistaken, what you want to do can't be accomplished through
    PHP. However, you may want to take a look at libnet.
    http://www.packetfactory.net/Projects/Libnet/

    I've always wanted someone to create a PHP interface for this- unfortunatly my
    C isn't quite there yet, but I'm working on it...

    Have fun!

    On Tuesday 21 May 2002 22:55 pm, Vinod Panicker wrote:
    > Hi,
    >
    > It still seems like I havent made the problem clear enough.
    >
    > I am aware of the print(), echo() and flush() functions and what
    > they do. It does not fit in as a solution. Let me explain my
    > problem more elaborately -
    > The client calls a PHP script, script_a.php on the Apache web
    > server, using a Keep-Alive connection. The script returns some
    > response to the client which it uses. Now since the connection is
    > a Keep-alive, apache still has it open for reading and writing.
    > When the client wants to call other scripts, it just sends the
    > request over the same connection. Now the thing is that if the
    > server needs to send some ASYNCHRONOUS data to the client, without
    > the client requesting for anything, a normal PHP script wont be
    > able to do it, since the script would get executed by the web
    > server ONLY on a client request (coz thats the way HTTP works).
    > Now what i was thinking was - if i could get hold of the socket
    > that is being used by apache to send data to the client, I could
    > effectively write() to it, from a C++ app or a PHP script (which
    > gets invoked from lets say another server). print(), echo() etc
    > are functions that write to the output stream, which is opened as
    > a result of the clients request, by the web server.
    >
    > I want the ability to write to a socket thats been created earlier
    > - i want to steal it from Apache, so that i can use it when and
    > where i like.
    >
    > Functions like echo() and print() are not going to work here, i
    > will have to use write() so that i can specify the socket to which
    > the data has to be written!
    >
    > Hope the problem is understood now.
    >
    > Now for your question -
    > When the client wants to send data to the server, it just has to
    > open a socket connection with the web server, and issue a GET or a
    > POST request! if the connection is a keep-alive connection, and
    > it has already been created, the client just has to do a GET or a
    > POST without the need to connect().
    >
    > This mechanism, where the client frequently connects() to the
    > server and checks for messages is called polling. One way of
    > reducing the high overhead of this is to reuse the connection by
    > using a keep-alive connection. A still better improvement would
    > be to remove the need for a poll altogether, by doing something
    > (thats what my question is all about) on the server so that it can
    > send data asynchronously to the server.
    >
    >
    > Tx,
    > Vinod.
    >
    > On Wed, 22 May 2002 Bogdan Stancescu wrote :
    > >For your specific problem, I think Mr. Lemos has provided a
    > >viable solution (using print() or echo() and flush() whenever you
    > >need to, instead of grabbing the socket and write() to it). My
    > >problem however is how you envision solving the communication the
    > >other way around (i.e. when the CLIENT wants to send data to the
    > >server).
    > >
    > >Bogdan
    > >
    > >Vinod Panicker wrote:
    > >>Hi,
    > >>
    > >>Tx for your very prompt reply.
    > >>
    > >>Yeah, I'll post the solution as soon as I find it someplace.
    > >>
    > >>Let me outline the problem in more detail -
    > >>
    > >>Client (VC++) calls a PHP script on the server, specifies the
    > >>connection type as Keep-Alive. The PHP script, somehow (still a
    > >>big question) gets the socket on which the apache server has
    > >>received the client request (so that it can send data to the
    > >>client later) and stores it in a database.
    > >>
    > >>Now whenever another PHP script wants to send data
    > >>asynchronously to the client, it gets the socket from the
    > >>database, and just calls a write() on it. Since the connection
    > >>is still open (Keep-Alive), the client receives the information,
    > >>and doesnt have to poll the server periodically.
    > >>
    > >>The application of this is indeed destined for a messaging
    > >>product, and could benefit a lot of other areas as well.
    > >>
    > >>The only thing that is needed is the socket from apache.
    > >>
    > >>Someone somewhere knows how to get this done, i'm sure :)
    > >>
    > >>Possibly a hack into the PHP module can get this done, i'm open
    > >>to suggestions.
    > >>
    > >>Tx,
    > >>Vinod.
    > >>
    > >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    > >>>Hi!
    > >>>
    > >>>I'm looking for an answer to your questions as well, so if you
    > >>>do find a solution on other lists, could you please post it
    > >>>here as well?
    > >>>
    > >>>Regarding the issue, your proposal wouldn't make for
    > >>>full-duplex as far as I understand since I don't see how the
    > >>>client would be able to send any data on the same connection
    > >>>_after_ getting connected.
    > >>>
    > >>>What are you using on the other end of the pipe (on the
    > >>>client)? Plain HTML? Flash? Java? Something else?
    > >>>
    > >>>Bogdan
    > >>>
    > >>>Vinod Panicker wrote:
    > >>>>Hi,
    > >>>>
    > >>>>We have developed a client-server application where the server
    > >>>>needs to send asynchronous data to the client. Now since we
    > >>>>are using Apache/PHP/MySQL, the client needs to poll the
    > >>>>server periodically for information.
    > >>>>
    > >>>>I was thinking if there was some way to get around this basic
    > >>>>problem. I understand that this is how things are supposed to
    > >>>>work, but it would be just great if i could PUSH data from the
    > >>>>server to the client, using HTTP.
    > >>>>
    > >>>>Since HTTP is a request/response based protocol, Apache would
    > >>>>not send any data to the client asynchronously. So what i was
    > >>>>thinking was - If i tell the server to allow Keep-Alive
    > >>>>connections, and increase the timeout value and max requests,
    > >>>>I would effectively have a constant TCP connection. Now the
    > >>>>only problem would be of sending asynchronous data to the
    > >>>>client. Solution? Here goes - If there was some way in which
    > >>>>i could get hold of the file descriptor(socket) that is being
    > >>>>used by apache to write data to the client, then i could, from
    > >>>>a PHP script also send any data to the client using the socket
    > >>>>functions of PHP since i already have the socket with me.
    > >>>>
    > >>>>This would mean that the client doesnt have to poll the server
    > >>>>for data any more... and if the connection does get closed,
    > >>>>the client could reconnect to the server asking for another
    > >>>>keep-alive connection.
    > >>>>
    > >>>>Now I know that this is probably the wrong place to put such a
    > >>>>query - maybe the apache list would have been better. But
    > >>>>since I'm using PHP out here, i thought i'd give it a try.
    > >>>>
    > >>>>Does the solution sound very outlandish? Are there any
    > >>>>pitfalls? And finally, how do i get hold of the socket?
    > >
    > >-- PHP General Mailing List (http://www.php.net/)
    > >To unsubscribe, visit: http://www.php.net/unsub.php
    >
    > _________________________________________________________
    > Click below to visit monsterindia.com and review jobs in India or
    > Abroad
    > http://monsterindia.rediff.com/jobs

    attached mail follows:


    Vinod,

    Interesting...

    Okay unless I'm mistaken, what you want to do can't be accomplished through
    PHP. However, you may want to take a look at libnet.
    http://www.packetfactory.net/Projects/Libnet/

    I've always wanted someone to create a PHP interface for this- unfortunatly my
    C isn't quite there yet, but I'm working on it...

    Have fun!

    On Tuesday 21 May 2002 22:55 pm, Vinod Panicker wrote:
    > Hi,
    >
    > It still seems like I havent made the problem clear enough.
    >
    > I am aware of the print(), echo() and flush() functions and what
    > they do. It does not fit in as a solution. Let me explain my
    > problem more elaborately -
    > The client calls a PHP script, script_a.php on the Apache web
    > server, using a Keep-Alive connection. The script returns some
    > response to the client which it uses. Now since the connection is
    > a Keep-alive, apache still has it open for reading and writing.
    > When the client wants to call other scripts, it just sends the
    > request over the same connection. Now the thing is that if the
    > server needs to send some ASYNCHRONOUS data to the client, without
    > the client requesting for anything, a normal PHP script wont be
    > able to do it, since the script would get executed by the web
    > server ONLY on a client request (coz thats the way HTTP works).
    > Now what i was thinking was - if i could get hold of the socket
    > that is being used by apache to send data to the client, I could
    > effectively write() to it, from a C++ app or a PHP script (which
    > gets invoked from lets say another server). print(), echo() etc
    > are functions that write to the output stream, which is opened as
    > a result of the clients request, by the web server.
    >
    > I want the ability to write to a socket thats been created earlier
    > - i want to steal it from Apache, so that i can use it when and
    > where i like.
    >
    > Functions like echo() and print() are not going to work here, i
    > will have to use write() so that i can specify the socket to which
    > the data has to be written!
    >
    > Hope the problem is understood now.
    >
    > Now for your question -
    > When the client wants to send data to the server, it just has to
    > open a socket connection with the web server, and issue a GET or a
    > POST request! if the connection is a keep-alive connection, and
    > it has already been created, the client just has to do a GET or a
    > POST without the need to connect().
    >
    > This mechanism, where the client frequently connects() to the
    > server and checks for messages is called polling. One way of
    > reducing the high overhead of this is to reuse the connection by
    > using a keep-alive connection. A still better improvement would
    > be to remove the need for a poll altogether, by doing something
    > (thats what my question is all about) on the server so that it can
    > send data asynchronously to the server.
    >
    >
    > Tx,
    > Vinod.
    >
    > On Wed, 22 May 2002 Bogdan Stancescu wrote :
    > >For your specific problem, I think Mr. Lemos has provided a
    > >viable solution (using print() or echo() and flush() whenever you
    > >need to, instead of grabbing the socket and write() to it). My
    > >problem however is how you envision solving the communication the
    > >other way around (i.e. when the CLIENT wants to send data to the
    > >server).
    > >
    > >Bogdan
    > >
    > >Vinod Panicker wrote:
    > >>Hi,
    > >>
    > >>Tx for your very prompt reply.
    > >>
    > >>Yeah, I'll post the solution as soon as I find it someplace.
    > >>
    > >>Let me outline the problem in more detail -
    > >>
    > >>Client (VC++) calls a PHP script on the server, specifies the
    > >>connection type as Keep-Alive. The PHP script, somehow (still a
    > >>big question) gets the socket on which the apache server has
    > >>received the client request (so that it can send data to the
    > >>client later) and stores it in a database.
    > >>
    > >>Now whenever another PHP script wants to send data
    > >>asynchronously to the client, it gets the socket from the
    > >>database, and just calls a write() on it. Since the connection
    > >>is still open (Keep-Alive), the client receives the information,
    > >>and doesnt have to poll the server periodically.
    > >>
    > >>The application of this is indeed destined for a messaging
    > >>product, and could benefit a lot of other areas as well.
    > >>
    > >>The only thing that is needed is the socket from apache.
    > >>
    > >>Someone somewhere knows how to get this done, i'm sure :)
    > >>
    > >>Possibly a hack into the PHP module can get this done, i'm open
    > >>to suggestions.
    > >>
    > >>Tx,
    > >>Vinod.
    > >>
    > >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    > >>>Hi!
    > >>>
    > >>>I'm looking for an answer to your questions as well, so if you
    > >>>do find a solution on other lists, could you please post it
    > >>>here as well?
    > >>>
    > >>>Regarding the issue, your proposal wouldn't make for
    > >>>full-duplex as far as I understand since I don't see how the
    > >>>client would be able to send any data on the same connection
    > >>>_after_ getting connected.
    > >>>
    > >>>What are you using on the other end of the pipe (on the
    > >>>client)? Plain HTML? Flash? Java? Something else?
    > >>>
    > >>>Bogdan
    > >>>
    > >>>Vinod Panicker wrote:
    > >>>>Hi,
    > >>>>
    > >>>>We have developed a client-server application where the server
    > >>>>needs to send asynchronous data to the client. Now since we
    > >>>>are using Apache/PHP/MySQL, the client needs to poll the
    > >>>>server periodically for information.
    > >>>>
    > >>>>I was thinking if there was some way to get around this basic
    > >>>>problem. I understand that this is how things are supposed to
    > >>>>work, but it would be just great if i could PUSH data from the
    > >>>>server to the client, using HTTP.
    > >>>>
    > >>>>Since HTTP is a request/response based protocol, Apache would
    > >>>>not send any data to the client asynchronously. So what i was
    > >>>>thinking was - If i tell the server to allow Keep-Alive
    > >>>>connections, and increase the timeout value and max requests,
    > >>>>I would effectively have a constant TCP connection. Now the
    > >>>>only problem would be of sending asynchronous data to the
    > >>>>client. Solution? Here goes - If there was some way in which
    > >>>>i could get hold of the file descriptor(socket) that is being
    > >>>>used by apache to write data to the client, then i could, from
    > >>>>a PHP script also send any data to the client using the socket
    > >>>>functions of PHP since i already have the socket with me.
    > >>>>
    > >>>>This would mean that the client doesnt have to poll the server
    > >>>>for data any more... and if the connection does get closed,
    > >>>>the client could reconnect to the server asking for another
    > >>>>keep-alive connection.
    > >>>>
    > >>>>Now I know that this is probably the wrong place to put such a
    > >>>>query - maybe the apache list would have been better. But
    > >>>>since I'm using PHP out here, i thought i'd give it a try.
    > >>>>
    > >>>>Does the solution sound very outlandish? Are there any
    > >>>>pitfalls? And finally, how do i get hold of the socket?
    > >
    > >-- PHP General Mailing List (http://www.php.net/)
    > >To unsubscribe, visit: http://www.php.net/unsub.php
    >
    > _________________________________________________________
    > Click below to visit monsterindia.com and review jobs in India or
    > Abroad
    > http://monsterindia.rediff.com/jobs

    attached mail follows:


    I don't think you're going to get Apache to hand you the socket.

    However, you can write a program using the standalone (CGI) PHP
    interpreter that will act like a server - check out
    http://php.net/socket_create_listen for more info.

    You could redirect from your standard web server to your listening PHP app
    running on another port. You'll then have to implement at least a subset
    of the HTTP protocol in order to get browsers to talk to you.

    Unfortunately, since you can't - to the best of my knowledge - fork a PHP
    program, you're going to have to do your own homebrew threading which will
    make life slightly complicated.

    miguel

    On 22 May 2002, Vinod Panicker wrote:
    > It still seems like I havent made the problem clear enough.
    >
    > I am aware of the print(), echo() and flush() functions and what
    > they do. It does not fit in as a solution. Let me explain my
    > problem more elaborately -
    > The client calls a PHP script, script_a.php on the Apache web
    > server, using a Keep-Alive connection. The script returns some
    > response to the client which it uses. Now since the connection is
    > a Keep-alive, apache still has it open for reading and writing.
    > When the client wants to call other scripts, it just sends the
    > request over the same connection. Now the thing is that if the
    > server needs to send some ASYNCHRONOUS data to the client, without
    > the client requesting for anything, a normal PHP script wont be
    > able to do it, since the script would get executed by the web
    > server ONLY on a client request (coz thats the way HTTP works).
    > Now what i was thinking was - if i could get hold of the socket
    > that is being used by apache to send data to the client, I could
    > effectively write() to it, from a C++ app or a PHP script (which
    > gets invoked from lets say another server). print(), echo() etc
    > are functions that write to the output stream, which is opened as
    > a result of the clients request, by the web server.
    >
    > I want the ability to write to a socket thats been created earlier
    > - i want to steal it from Apache, so that i can use it when and
    > where i like.
    >
    > Functions like echo() and print() are not going to work here, i
    > will have to use write() so that i can specify the socket to which
    > the data has to be written!
    >
    > Hope the problem is understood now.
    >
    > Now for your question -
    > When the client wants to send data to the server, it just has to
    > open a socket connection with the web server, and issue a GET or a
    > POST request! if the connection is a keep-alive connection, and
    > it has already been created, the client just has to do a GET or a
    > POST without the need to connect().
    >
    > This mechanism, where the client frequently connects() to the
    > server and checks for messages is called polling. One way of
    > reducing the high overhead of this is to reuse the connection by
    > using a keep-alive connection. A still better improvement would
    > be to remove the need for a poll altogether, by doing something
    > (thats what my question is all about) on the server so that it can
    > send data asynchronously to the server.
    >
    >
    > Tx,
    > Vinod.
    >
    > On Wed, 22 May 2002 Bogdan Stancescu wrote :
    > >For your specific problem, I think Mr. Lemos has provided a
    > >viable solution (using print() or echo() and flush() whenever you
    > >need to, instead of grabbing the socket and write() to it). My
    > >problem however is how you envision solving the communication the
    > >other way around (i.e. when the CLIENT wants to send data to the
    > >server).
    > >
    > >Bogdan
    > >
    > >Vinod Panicker wrote:
    > >
    > >>Hi,
    > >>
    > >>Tx for your very prompt reply.
    > >>
    > >>Yeah, I'll post the solution as soon as I find it someplace.
    > >>
    > >>Let me outline the problem in more detail -
    > >>
    > >>Client (VC++) calls a PHP script on the server, specifies the
    > >>connection type as Keep-Alive. The PHP script, somehow (still a
    > >>big question) gets the socket on which the apache server has
    > >>received the client request (so that it can send data to the
    > >>client later) and stores it in a database.
    > >>
    > >>Now whenever another PHP script wants to send data
    > >>asynchronously to the client, it gets the socket from the
    > >>database, and just calls a write() on it. Since the connection
    > >>is still open (Keep-Alive), the client receives the information,
    > >>and doesnt have to poll the server periodically.
    > >>
    > >>The application of this is indeed destined for a messaging
    > >>product, and could benefit a lot of other areas as well.
    > >>
    > >>The only thing that is needed is the socket from apache.
    > >>
    > >>Someone somewhere knows how to get this done, i'm sure :)
    > >>
    > >>Possibly a hack into the PHP module can get this done, i'm open
    > >>to suggestions.
    > >>
    > >>Tx,
    > >>Vinod.
    > >>
    > >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    > >>
    > >>>Hi!
    > >>>
    > >>>I'm looking for an answer to your questions as well, so if you
    > >>>do find a solution on other lists, could you please post it
    > >>>here as well?
    > >>>
    > >>>Regarding the issue, your proposal wouldn't make for
    > >>>full-duplex as far as I understand since I don't see how the
    > >>>client would be able to send any data on the same connection
    > >>>_after_ getting connected.
    > >>>
    > >>>What are you using on the other end of the pipe (on the
    > >>>client)? Plain HTML? Flash? Java? Something else?
    > >>>
    > >>>Bogdan
    > >>>
    > >>>Vinod Panicker wrote:
    > >>>
    > >>>>Hi,
    > >>>>
    > >>>>We have developed a client-server application where the server
    > >>>>needs to send asynchronous data to the client. Now since we
    > >>>>are using Apache/PHP/MySQL, the client needs to poll the
    > >>>>server periodically for information.
    > >>>>
    > >>>>I was thinking if there was some way to get around this basic
    > >>>>problem. I understand that this is how things are supposed to
    > >>>>work, but it would be just great if i could PUSH data from the
    > >>>>server to the client, using HTTP.
    > >>>>
    > >>>>Since HTTP is a request/response based protocol, Apache would
    > >>>>not send any data to the client asynchronously. So what i was
    > >>>>thinking was - If i tell the server to allow Keep-Alive
    > >>>>connections, and increase the timeout value and max requests,
    > >>>>I would effectively have a constant TCP connection. Now the
    > >>>>only problem would be of sending asynchronous data to the
    > >>>>client. Solution? Here goes - If there was some way in which
    > >>>>i could get hold of the file descriptor(socket) that is being
    > >>>>used by apache to write data to the client, then i could, from
    > >>>>a PHP script also send any data to the client using the socket
    > >>>>functions of PHP since i already have the socket with me.
    > >>>>
    > >>>>This would mean that the client doesnt have to poll the server
    > >>>>for data any more... and if the connection does get closed,
    > >>>>the client could reconnect to the server asking for another
    > >>>>keep-alive connection.
    > >>>>
    > >>>>Now I know that this is probably the wrong place to put such a
    > >>>>query - maybe the apache list would have been better. But
    > >>>>since I'm using PHP out here, i thought i'd give it a try.
    > >>>>
    > >>>>Does the solution sound very outlandish? Are there any
    > >>>>pitfalls? And finally, how do i get hold of the socket?
    > >>>
    > >
    > >
    > >
    > >
    > >-- PHP General Mailing List (http://www.php.net/)
    > >To unsubscribe, visit: http://www.php.net/unsub.php
    > >
    >
    > _________________________________________________________
    > Click below to visit monsterindia.com and review jobs in India or
    > Abroad
    > http://monsterindia.rediff.com/jobs
    >
    >
    >

    attached mail follows:


    1st thing: sorry about the double-post. i don't know why that happened. If
    this one gets double posted too, i apologize in advance.

    2nd: php.net/pcntl

    On Tuesday 21 May 2002 23:30 pm, Miguel Cruz wrote:
    > I don't think you're going to get Apache to hand you the socket.
    >
    > However, you can write a program using the standalone (CGI) PHP
    > interpreter that will act like a server - check out
    > http://php.net/socket_create_listen for more info.
    >
    > You could redirect from your standard web server to your listening PHP app
    > running on another port. You'll then have to implement at least a subset
    > of the HTTP protocol in order to get browsers to talk to you.
    >
    > Unfortunately, since you can't - to the best of my knowledge - fork a PHP
    > program, you're going to have to do your own homebrew threading which will
    > make life slightly complicated.
    >
    > miguel
    >
    > On 22 May 2002, Vinod Panicker wrote:
    > > It still seems like I havent made the problem clear enough.
    > >
    > > I am aware of the print(), echo() and flush() functions and what
    > > they do. It does not fit in as a solution. Let me explain my
    > > problem more elaborately -
    > > The client calls a PHP script, script_a.php on the Apache web
    > > server, using a Keep-Alive connection. The script returns some
    > > response to the client which it uses. Now since the connection is
    > > a Keep-alive, apache still has it open for reading and writing.
    > > When the client wants to call other scripts, it just sends the
    > > request over the same connection. Now the thing is that if the
    > > server needs to send some ASYNCHRONOUS data to the client, without
    > > the client requesting for anything, a normal PHP script wont be
    > > able to do it, since the script would get executed by the web
    > > server ONLY on a client request (coz thats the way HTTP works).
    > > Now what i was thinking was - if i could get hold of the socket
    > > that is being used by apache to send data to the client, I could
    > > effectively write() to it, from a C++ app or a PHP script (which
    > > gets invoked from lets say another server). print(), echo() etc
    > > are functions that write to the output stream, which is opened as
    > > a result of the clients request, by the web server.
    > >
    > > I want the ability to write to a socket thats been created earlier
    > > - i want to steal it from Apache, so that i can use it when and
    > > where i like.
    > >
    > > Functions like echo() and print() are not going to work here, i
    > > will have to use write() so that i can specify the socket to which
    > > the data has to be written!
    > >
    > > Hope the problem is understood now.
    > >
    > > Now for your question -
    > > When the client wants to send data to the server, it just has to
    > > open a socket connection with the web server, and issue a GET or a
    > > POST request! if the connection is a keep-alive connection, and
    > > it has already been created, the client just has to do a GET or a
    > > POST without the need to connect().
    > >
    > > This mechanism, where the client frequently connects() to the
    > > server and checks for messages is called polling. One way of
    > > reducing the high overhead of this is to reuse the connection by
    > > using a keep-alive connection. A still better improvement would
    > > be to remove the need for a poll altogether, by doing something
    > > (thats what my question is all about) on the server so that it can
    > > send data asynchronously to the server.
    > >
    > >
    > > Tx,
    > > Vinod.
    > >
    > > On Wed, 22 May 2002 Bogdan Stancescu wrote :
    > > >For your specific problem, I think Mr. Lemos has provided a
    > > >viable solution (using print() or echo() and flush() whenever you
    > > >need to, instead of grabbing the socket and write() to it). My
    > > >problem however is how you envision solving the communication the
    > > >other way around (i.e. when the CLIENT wants to send data to the
    > > >server).
    > > >
    > > >Bogdan
    > > >
    > > >Vinod Panicker wrote:
    > > >>Hi,
    > > >>
    > > >>Tx for your very prompt reply.
    > > >>
    > > >>Yeah, I'll post the solution as soon as I find it someplace.
    > > >>
    > > >>Let me outline the problem in more detail -
    > > >>
    > > >>Client (VC++) calls a PHP script on the server, specifies the
    > > >>connection type as Keep-Alive. The PHP script, somehow (still a
    > > >>big question) gets the socket on which the apache server has
    > > >>received the client request (so that it can send data to the
    > > >>client later) and stores it in a database.
    > > >>
    > > >>Now whenever another PHP script wants to send data
    > > >>asynchronously to the client, it gets the socket from the
    > > >>database, and just calls a write() on it. Since the connection
    > > >>is still open (Keep-Alive), the client receives the information,
    > > >>and doesnt have to poll the server periodically.
    > > >>
    > > >>The application of this is indeed destined for a messaging
    > > >>product, and could benefit a lot of other areas as well.
    > > >>
    > > >>The only thing that is needed is the socket from apache.
    > > >>
    > > >>Someone somewhere knows how to get this done, i'm sure :)
    > > >>
    > > >>Possibly a hack into the PHP module can get this done, i'm open
    > > >>to suggestions.
    > > >>
    > > >>Tx,
    > > >>Vinod.
    > > >>
    > > >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    > > >>>Hi!
    > > >>>
    > > >>>I'm looking for an answer to your questions as well, so if you
    > > >>>do find a solution on other lists, could you please post it
    > > >>>here as well?
    > > >>>
    > > >>>Regarding the issue, your proposal wouldn't make for
    > > >>>full-duplex as far as I understand since I don't see how the
    > > >>>client would be able to send any data on the same connection
    > > >>>_after_ getting connected.
    > > >>>
    > > >>>What are you using on the other end of the pipe (on the
    > > >>>client)? Plain HTML? Flash? Java? Something else?
    > > >>>
    > > >>>Bogdan
    > > >>>
    > > >>>Vinod Panicker wrote:
    > > >>>>Hi,
    > > >>>>
    > > >>>>We have developed a client-server application where the server
    > > >>>>needs to send asynchronous data to the client. Now since we
    > > >>>>are using Apache/PHP/MySQL, the client needs to poll the
    > > >>>>server periodically for information.
    > > >>>>
    > > >>>>I was thinking if there was some way to get around this basic
    > > >>>>problem. I understand that this is how things are supposed to
    > > >>>>work, but it would be just great if i could PUSH data from the
    > > >>>>server to the client, using HTTP.
    > > >>>>
    > > >>>>Since HTTP is a request/response based protocol, Apache would
    > > >>>>not send any data to the client asynchronously. So what i was
    > > >>>>thinking was - If i tell the server to allow Keep-Alive
    > > >>>>connections, and increase the timeout value and max requests,
    > > >>>>I would effectively have a constant TCP connection. Now the
    > > >>>>only problem would be of sending asynchronous data to the
    > > >>>>client. Solution? Here goes - If there was some way in which
    > > >>>>i could get hold of the file descriptor(socket) that is being
    > > >>>>used by apache to write data to the client, then i could, from
    > > >>>>a PHP script also send any data to the client using the socket
    > > >>>>functions of PHP since i already have the socket with me.
    > > >>>>
    > > >>>>This would mean that the client doesnt have to poll the server
    > > >>>>for data any more... and if the connection does get closed,
    > > >>>>the client could reconnect to the server asking for another
    > > >>>>keep-alive connection.
    > > >>>>
    > > >>>>Now I know that this is probably the wrong place to put such a
    > > >>>>query - maybe the apache list would have been better. But
    > > >>>>since I'm using PHP out here, i thought i'd give it a try.
    > > >>>>
    > > >>>>Does the solution sound very outlandish? Are there any
    > > >>>>pitfalls? And finally, how do i get hold of the socket?
    > > >
    > > >-- PHP General Mailing List (http://www.php.net/)
    > > >To unsubscribe, visit: http://www.php.net/unsub.php
    > >
    > > _________________________________________________________
    > > Click below to visit monsterindia.com and review jobs in India or
    > > Abroad
    > > http://monsterindia.rediff.com/jobs

    attached mail follows:


    Ah, yes - http://php.net/pcntl_fork

    Well there you go, then - everything required to create a server in PHP.

    miguel

    On Tue, 21 May 2002, Evan Nemerson wrote:

    > 1st thing: sorry about the double-post. i don't know why that happened. If
    > this one gets double posted too, i apologize in advance.
    >
    > 2nd: php.net/pcntl
    >
    > On Tuesday 21 May 2002 23:30 pm, Miguel Cruz wrote:
    > > I don't think you're going to get Apache to hand you the socket.
    > >
    > > However, you can write a program using the standalone (CGI) PHP
    > > interpreter that will act like a server - check out
    > > http://php.net/socket_create_listen for more info.
    > >
    > > You could redirect from your standard web server to your listening PHP app
    > > running on another port. You'll then have to implement at least a subset
    > > of the HTTP protocol in order to get browsers to talk to you.
    > >
    > > Unfortunately, since you can't - to the best of my knowledge - fork a PHP
    > > program, you're going to have to do your own homebrew threading which will
    > > make life slightly complicated.
    > >
    > > miguel
    > >
    > > On 22 May 2002, Vinod Panicker wrote:
    > > > It still seems like I havent made the problem clear enough.
    > > >
    > > > I am aware of the print(), echo() and flush() functions and what
    > > > they do. It does not fit in as a solution. Let me explain my
    > > > problem more elaborately -
    > > > The client calls a PHP script, script_a.php on the Apache web
    > > > server, using a Keep-Alive connection. The script returns some
    > > > response to the client which it uses. Now since the connection is
    > > > a Keep-alive, apache still has it open for reading and writing.
    > > > When the client wants to call other scripts, it just sends the
    > > > request over the same connection. Now the thing is that if the
    > > > server needs to send some ASYNCHRONOUS data to the client, without
    > > > the client requesting for anything, a normal PHP script wont be
    > > > able to do it, since the script would get executed by the web
    > > > server ONLY on a client request (coz thats the way HTTP works).
    > > > Now what i was thinking was - if i could get hold of the socket
    > > > that is being used by apache to send data to the client, I could
    > > > effectively write() to it, from a C++ app or a PHP script (which
    > > > gets invoked from lets say another server). print(), echo() etc
    > > > are functions that write to the output stream, which is opened as
    > > > a result of the clients request, by the web server.
    > > >
    > > > I want the ability to write to a socket thats been created earlier
    > > > - i want to steal it from Apache, so that i can use it when and
    > > > where i like.
    > > >
    > > > Functions like echo() and print() are not going to work here, i
    > > > will have to use write() so that i can specify the socket to which
    > > > the data has to be written!
    > > >
    > > > Hope the problem is understood now.
    > > >
    > > > Now for your question -
    > > > When the client wants to send data to the server, it just has to
    > > > open a socket connection with the web server, and issue a GET or a
    > > > POST request! if the connection is a keep-alive connection, and
    > > > it has already been created, the client just has to do a GET or a
    > > > POST without the need to connect().
    > > >
    > > > This mechanism, where the client frequently connects() to the
    > > > server and checks for messages is called polling. One way of
    > > > reducing the high overhead of this is to reuse the connection by
    > > > using a keep-alive connection. A still better improvement would
    > > > be to remove the need for a poll altogether, by doing something
    > > > (thats what my question is all about) on the server so that it can
    > > > send data asynchronously to the server.
    > > >
    > > >
    > > > Tx,
    > > > Vinod.
    > > >
    > > > On Wed, 22 May 2002 Bogdan Stancescu wrote :
    > > > >For your specific problem, I think Mr. Lemos has provided a
    > > > >viable solution (using print() or echo() and flush() whenever you
    > > > >need to, instead of grabbing the socket and write() to it). My
    > > > >problem however is how you envision solving the communication the
    > > > >other way around (i.e. when the CLIENT wants to send data to the
    > > > >server).
    > > > >
    > > > >Bogdan
    > > > >
    > > > >Vinod Panicker wrote:
    > > > >>Hi,
    > > > >>
    > > > >>Tx for your very prompt reply.
    > > > >>
    > > > >>Yeah, I'll post the solution as soon as I find it someplace.
    > > > >>
    > > > >>Let me outline the problem in more detail -
    > > > >>
    > > > >>Client (VC++) calls a PHP script on the server, specifies the
    > > > >>connection type as Keep-Alive. The PHP script, somehow (still a
    > > > >>big question) gets the socket on which the apache server has
    > > > >>received the client request (so that it can send data to the
    > > > >>client later) and stores it in a database.
    > > > >>
    > > > >>Now whenever another PHP script wants to send data
    > > > >>asynchronously to the client, it gets the socket from the
    > > > >>database, and just calls a write() on it. Since the connection
    > > > >>is still open (Keep-Alive), the client receives the information,
    > > > >>and doesnt have to poll the server periodically.
    > > > >>
    > > > >>The application of this is indeed destined for a messaging
    > > > >>product, and could benefit a lot of other areas as well.
    > > > >>
    > > > >>The only thing that is needed is the socket from apache.
    > > > >>
    > > > >>Someone somewhere knows how to get this done, i'm sure :)
    > > > >>
    > > > >>Possibly a hack into the PHP module can get this done, i'm open
    > > > >>to suggestions.
    > > > >>
    > > > >>Tx,
    > > > >>Vinod.
    > > > >>
    > > > >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    > > > >>>Hi!
    > > > >>>
    > > > >>>I'm looking for an answer to your questions as well, so if you
    > > > >>>do find a solution on other lists, could you please post it
    > > > >>>here as well?
    > > > >>>
    > > > >>>Regarding the issue, your proposal wouldn't make for
    > > > >>>full-duplex as far as I understand since I don't see how the
    > > > >>>client would be able to send any data on the same connection
    > > > >>>_after_ getting connected.
    > > > >>>
    > > > >>>What are you using on the other end of the pipe (on the
    > > > >>>client)? Plain HTML? Flash? Java? Something else?
    > > > >>>
    > > > >>>Bogdan
    > > > >>>
    > > > >>>Vinod Panicker wrote:
    > > > >>>>Hi,
    > > > >>>>
    > > > >>>>We have developed a client-server application where the server
    > > > >>>>needs to send asynchronous data to the client. Now since we
    > > > >>>>are using Apache/PHP/MySQL, the client needs to poll the
    > > > >>>>server periodically for information.
    > > > >>>>
    > > > >>>>I was thinking if there was some way to get around this basic
    > > > >>>>problem. I understand that this is how things are supposed to
    > > > >>>>work, but it would be just great if i could PUSH data from the
    > > > >>>>server to the client, using HTTP.
    > > > >>>>
    > > > >>>>Since HTTP is a request/response based protocol, Apache would
    > > > >>>>not send any data to the client asynchronously. So what i was
    > > > >>>>thinking was - If i tell the server to allow Keep-Alive
    > > > >>>>connections, and increase the timeout value and max requests,
    > > > >>>>I would effectively have a constant TCP connection. Now the
    > > > >>>>only problem would be of sending asynchronous data to the
    > > > >>>>client. Solution? Here goes - If there was some way in which
    > > > >>>>i could get hold of the file descriptor(socket) that is being
    > > > >>>>used by apache to write data to the client, then i could, from
    > > > >>>>a PHP script also send any data to the client using the socket
    > > > >>>>functions of PHP since i already have the socket with me.
    > > > >>>>
    > > > >>>>This would mean that the client doesnt have to poll the server
    > > > >>>>for data any more... and if the connection does get closed,
    > > > >>>>the client could reconnect to the server asking for another
    > > > >>>>keep-alive connection.
    > > > >>>>
    > > > >>>>Now I know that this is probably the wrong place to put such a
    > > > >>>>query - maybe the apache list would have been better. But
    > > > >>>>since I'm using PHP out here, i thought i'd give it a try.
    > > > >>>>
    > > > >>>>Does the solution sound very outlandish? Are there any
    > > > >>>>pitfalls? And finally, how do i get hold of the socket?
    > > > >
    > > > >-- PHP General Mailing List (http://www.php.net/)
    > > > >To unsubscribe, visit: http://www.php.net/unsub.php
    > > >
    > > > _________________________________________________________
    > > > Click below to visit monsterindia.com and review jobs in India or
    > > > Abroad
    > > > http://monsterindia.rediff.com/jobs
    >
    >

    attached mail follows:


    Thanks for the reply Miguel, but here i'm not trying to implement
    my own multi-threaded server - exactly the reason why i'm using
    Apache / PHP.

    I could have made a listening server which is based on a
    multi-threaded or multi-forked model, but the time and
    complexities involved would be huge. Thats why I chose Apache /
    PHP.

    Now if what i'm asking for can be done, developers can easily
    leverage existing efficient server technologies (Apache) to build
    their own App servers.

    I know that there is no existing function in PHP that would allow
    it to retrieve the socket from Apache ;), all i'm asking for is a
    hack that would allow me to do it.

    I thought that i'd just as well post it on the mailing list before
    diving into the source code and trying to figure out for myself.
    No point trying to re-invent the wheel, right?

    Evan, that lib will allow me to create my own packets, but which
    socket do i send it to? Thats been the question all along.

    I think this is getting really interesting :)

    Tx,
    Vinod.

    On Wed, 22 May 2002 Miguel Cruz wrote :
    >I don't think you're going to get Apache to hand you the
    >socket.
    >
    >However, you can write a program using the standalone (CGI) PHP
    >interpreter that will act like a server - check out
    >http://php.net/socket_create_listen for more info.
    >
    >You could redirect from your standard web server to your
    >listening PHP app
    >running on another port. You'll then have to implement at least a
    >subset
    >of the HTTP protocol in order to get browsers to talk to you.
    >
    >Unfortunately, since you can't - to the best of my knowledge -
    >fork a PHP
    >program, you're going to have to do your own homebrew threading
    >which will
    >make life slightly complicated.
    >
    >miguel
    >
    >On 22 May 2002, Vinod Panicker wrote:
    > > It still seems like I havent made the problem clear enough.
    > >
    > > I am aware of the print(), echo() and flush() functions and
    >what
    > > they do. It does not fit in as a solution. Let me explain
    >my
    > > problem more elaborately -
    > > The client calls a PHP script, script_a.php on the Apache
    >web
    > > server, using a Keep-Alive connection. The script returns
    >some
    > > response to the client which it uses. Now since the
    >connection is
    > > a Keep-alive, apache still has it open for reading and
    >writing.
    > > When the client wants to call other scripts, it just sends
    >the
    > > request over the same connection. Now the thing is that if
    >the
    > > server needs to send some ASYNCHRONOUS data to the client,
    >without
    > > the client requesting for anything, a normal PHP script wont
    >be
    > > able to do it, since the script would get executed by the
    >web
    > > server ONLY on a client request (coz thats the way HTTP
    >works).
    > > Now what i was thinking was - if i could get hold of the
    >socket
    > > that is being used by apache to send data to the client, I
    >could
    > > effectively write() to it, from a C++ app or a PHP script
    >(which
    > > gets invoked from lets say another server). print(), echo()
    >etc
    > > are functions that write to the output stream, which is opened
    >as
    > > a result of the clients request, by the web server.
    > >
    > > I want the ability to write to a socket thats been created
    >earlier
    > > - i want to steal it from Apache, so that i can use it when
    >and
    > > where i like.
    > >
    > > Functions like echo() and print() are not going to work here,
    >i
    > > will have to use write() so that i can specify the socket to
    >which
    > > the data has to be written!
    > >
    > > Hope the problem is understood now.
    > >
    > > Now for your question -
    > > When the client wants to send data to the server, it just has
    >to
    > > open a socket connection with the web server, and issue a GET
    >or a
    > > POST request! if the connection is a keep-alive connection,
    >and
    > > it has already been created, the client just has to do a GET
    >or a
    > > POST without the need to connect().
    > >
    > > This mechanism, where the client frequently connects() to
    >the
    > > server and checks for messages is called polling. One way
    >of
    > > reducing the high overhead of this is to reuse the connection
    >by
    > > using a keep-alive connection. A still better improvement
    >would
    > > be to remove the need for a poll altogether, by doing
    >something
    > > (thats what my question is all about) on the server so that it
    >can
    > > send data asynchronously to the server.
    > >
    > >
    > > Tx,
    > > Vinod.
    > >
    > > On Wed, 22 May 2002 Bogdan Stancescu wrote :
    > > >For your specific problem, I think Mr. Lemos has provided a
    > > >viable solution (using print() or echo() and flush() whenever
    >you
    > > >need to, instead of grabbing the socket and write() to it).
    >My
    > > >problem however is how you envision solving the communication
    >the
    > > >other way around (i.e. when the CLIENT wants to send data to
    >the
    > > >server).
    > > >
    > > >Bogdan
    > > >
    > > >Vinod Panicker wrote:
    > > >
    > > >>Hi,
    > > >>
    > > >>Tx for your very prompt reply.
    > > >>
    > > >>Yeah, I'll post the solution as soon as I find it
    >someplace.
    > > >>
    > > >>Let me outline the problem in more detail -
    > > >>
    > > >>Client (VC++) calls a PHP script on the server, specifies
    >the
    > > >>connection type as Keep-Alive. The PHP script, somehow
    >(still a
    > > >>big question) gets the socket on which the apache server
    >has
    > > >>received the client request (so that it can send data to
    >the
    > > >>client later) and stores it in a database.
    > > >>
    > > >>Now whenever another PHP script wants to send data
    > > >>asynchronously to the client, it gets the socket from the
    > > >>database, and just calls a write() on it. Since the
    >connection
    > > >>is still open (Keep-Alive), the client receives the
    >information,
    > > >>and doesnt have to poll the server periodically.
    > > >>
    > > >>The application of this is indeed destined for a messaging
    > > >>product, and could benefit a lot of other areas as well.
    > > >>
    > > >>The only thing that is needed is the socket from apache.
    > > >>
    > > >>Someone somewhere knows how to get this done, i'm sure :)
    > > >>
    > > >>Possibly a hack into the PHP module can get this done, i'm
    >open
    > > >>to suggestions.
    > > >>
    > > >>Tx,
    > > >>Vinod.
    > > >>
    > > >>On Tue, 21 May 2002 Bogdan Stancescu wrote :
    > > >>
    > > >>>Hi!
    > > >>>
    > > >>>I'm looking for an answer to your questions as well, so if
    >you
    > > >>>do find a solution on other lists, could you please post
    >it
    > > >>>here as well?
    > > >>>
    > > >>>Regarding the issue, your proposal wouldn't make for
    > > >>>full-duplex as far as I understand since I don't see how
    >the
    > > >>>client would be able to send any data on the same
    >connection
    > > >>>_after_ getting connected.
    > > >>>
    > > >>>What are you using on the other end of the pipe (on the
    > > >>>client)? Plain HTML? Flash? Java? Something else?
    > > >>>
    > > >>>Bogdan
    > > >>>
    > > >>>Vinod Panicker wrote:
    > > >>>
    > > >>>>Hi,
    > > >>>>
    > > >>>>We have developed a client-server application where the
    >server
    > > >>>>needs to send asynchronous data to the client. Now since
    >we
    > > >>>>are using Apache/PHP/MySQL, the client needs to poll the
    > > >>>>server periodically for information.
    > > >>>>
    > > >>>>I was thinking if there was some way to get around this
    >basic
    > > >>>>problem. I understand that this is how things are
    >supposed to
    > > >>>>work, but it would be just great if i could PUSH data from
    >the
    > > >>>>server to the client, using HTTP.
    > > >>>>
    > > >>>>Since HTTP is a request/response based protocol, Apache
    >would
    > > >>>>not send any data to the client asynchronously. So what i
    >was
    > > >>>>thinking was - If i tell the server to allow Keep-Alive
    > > >>>>connections, and increase the timeout value and max
    >requests,
    > > >>>>I would effectively have a constant TCP connection. Now
    >the
    > > >>>>only problem would be of sending asynchronous data to
    >the
    > > >>>>client. Solution? Here goes - If there was some way in
    >which
    > > >>>>i could get hold of the file descriptor(socket) that is
    >being
    > > >>>>used by apache to write data to the client, then i could,
    > from
    > > >>>>a PHP script also send any data to the client using the
    >socket
    > > >>>>functions of PHP since i already have the socket with
    >me.
    > > >>>>
    > > >>>>This would mean that the client doesnt have to poll the
    >server
    > > >>>>for data any more... and if the connection does get
    >closed,
    > > >>>>the client could reconnect to the server asking for
    >another
    > > >>>>keep-alive connection.
    > > >>>>
    > > >>>>Now I know that this is probably the wrong place to put
    >such a
    > > >>>>query - maybe the apache list would have been better.
    >But
    > > >>>>since I'm using PHP out here, i thought i'd give it a
    >try.
    > > >>>>
    > > >>>>Does the solution sound very outlandish? Are there any
    > > >>>>pitfalls? And finally, how do i get hold of the socket?
    > > >>>
    > > >
    > > >
    > > >
    > > >
    > > >-- PHP General Mailing List (http://www.php.net/)
    > > >To unsubscribe, visit: http://www.php.net/unsub.php
    > > >
    > >
    > > _________________________________________________________
    > > Click below to visit monsterindia.com and review jobs in India
    >or
    > > Abroad
    > > http://monsterindia.rediff.com/jobs
    > >
    > >
    > >
    >
    >
    >--
    >PHP General Mailing List (http://www.php.net/)
    >To unsubscribe, visit: http://www.php.net/unsub.php
    >

    _________________________________________________________
    Click below to visit monsterindia.com and review jobs in India or
    Abroad
    http://monsterindia.rediff.com/jobs

    attached mail follows:


    At 5:55 AM +0000 22/5/02, Vinod Panicker wrote:

    >I want the ability to write to a socket thats been created earlier
    >- i want to steal it from Apache, so that i can use it when and
    >where i like.

    Why not just keep your script running and have it send more data
    to the browser whenever it becomes available. The browser will
    add the new data to the page on display.

    With some clever use of DHTML you could probably make the existing
    content be updated with the new material.

    When a browser wants to trigger an update it will close the
    existing connection and open a new one. Your running script will
    be killed by apache and your new one would build a base page and
    start streaming the data in it's place.

    I see nothing here more complicated than a long-running script and
    perhaps sessions to manage the browser-initiated connections.

     ...Richard.

    attached mail follows:


    What i have at the other end is a Instant Messenger client :)

    Cant have the script running till the time the user logs out can
    i? And also, different activities are triggered on the server
    asynchronously (presence status, instant messages, notifications)
    which has to be sent to the client.

    Tx,
    Vinod.

    On Wed, 22 May 2002 Richard Archer wrote :
    >At 5:55 AM +0000 22/5/02, Vinod Panicker wrote:
    >
    > >I want the ability to write to a socket thats been created
    >earlier
    > >- i want to steal it from Apache, so that i can use it when
    >and
    > >where i like.
    >
    >Why not just keep your script running and have it send more
    >data
    >to the browser whenever it becomes available. The browser will
    >add the new data to the page on display.
    >
    >With some clever use of DHTML you could probably make the
    >existing
    >content be updated with the new material.
    >
    >When a browser wants to trigger an update it will close the
    >existing connection and open a new one. Your running script
    >will
    >be killed by apache and your new one would build a base page
    >and
    >start streaming the data in it's place.
    >
    >I see nothing here more complicated than a long-running script
    >and
    >perhaps sessions to manage the browser-initiated connections.
    >
    > ...Richard.
    >
    >--
    >PHP General Mailing List (http://www.php.net/)
    >To unsubscribe, visit: http://www.php.net/unsub.php
    >

    _________________________________________________________
    Click below to visit monsterindia.com and review jobs in India or
    Abroad
    http://monsterindia.rediff.com/jobs

    attached mail follows:


    At 7:01 AM +0000 22/5/02, Vinod Panicker wrote:

    >What i have at the other end is a Instant Messenger client :)

    Which is presumably accepting some form of HTML or at least a
    stream of data sent over HTTP and displaying the data. If it's
    notdoing this, Apache is almost certainly the wrong platform
    for the server!!

    So, just keep on streaming the data to the client. Keep the
    script running and keep on sending the message.

    If you need to have the client send a status stream to the
    server, have it trigger a new message which will be received
    by a second script on the server. This script would insert the
    new status for that client in a database and the long-running
    script would periodically poll the database and act upon
    whatever status info it finds. Might not be "instant" update,
    but that's dependent on how often you poll for change of status.

    >Cant have the script running till the time the user logs out can
    >i?

    Why not? You're planning on sending data to them until they log
    out, so why not keep one script running?

     ...R.

    attached mail follows:


    Hi Richard,

    Thanks for your suggestion.

    Yes, Apache is the wrong platform for the server. What would be
    ideal is a custom designed TCP based multi-threaded server.

    Since we had lots of constraints, we went in for Apache / PHP.
    What i'm trying to do is to reduce the number of compromises being
    made in this architecture.

    If i have a long running script, the script is still "polling" the
    database, wasting precious server CPU cycles. Having an open
    socket on which the server calls select() is much less CPU
    intensive.

    "Instant" is how the response should be. Thats why i'm clamouring
    for the socket so that i can send data directly to the client,
     from a C++ binary or maybe another script.

    And to have the script running for hours, i would have to change
    the script timeout to a ludicrous setting, which would leave open
    many more possiblities for other problems.

    Tx,
    Vinod.

    On Wed, 22 May 2002 Richard Archer wrote :
    >At 7:01 AM +0000 22/5/02, Vinod Panicker wrote:
    >
    > >What i have at the other end is a Instant Messenger client :)
    >
    >Which is presumably accepting some form of HTML or at least a
    >stream of data sent over HTTP and displaying the data. If it's
    >notdoing this, Apache is almost certainly the wrong platform
    >for the server!!
    >
    >So, just keep on streaming the data to the client. Keep the
    >script running and keep on sending the message.
    >
    >If you need to have the client send a status stream to the
    >server, have it trigger a new message which will be received
    >by a second script on the server. This script would insert the
    >new status for that client in a database and the long-running
    >script would periodically poll the database and act upon
    >whatever status info it finds. Might not be "instant" update,
    >but that's dependent on how often you poll for change of
    >status.
    >
    >
    > >Cant have the script running till the time the user logs out
    >can
    > >i?
    >
    >Why not? You're planning on sending data to them until they log
    >out, so why not keep one script running?
    >
    > ...R.
    >
    >--
    >PHP General Mailing List (http://www.php.net/)
    >To unsubscribe, visit: http://www.php.net/unsub.php
    >

    _________________________________________________________
    Click below to visit monsterindia.com and review jobs in India or
    Abroad
    http://monsterindia.rediff.com/jobs

    attached mail follows:


    On 22 May 2002, Vinod Panicker wrote:
    > "Instant" is how the response should be. Thats why i'm clamouring
    > for the socket so that i can send data directly to the client,
    > from a C++ binary or maybe another script.

    If you're willing to write C code, I'd suggest posing your question in
    comp.infosystems.www.servers.unix, where people will be happy to tell you
    about Apache APIs that may be of use.

    miguel

    attached mail follows:


    On Wed, 22 May 2002, Miguel Cruz wrote:
    > On 22 May 2002, Vinod Panicker wrote:
    >> "Instant" is how the response should be. Thats why i'm clamouring
    >> for the socket so that i can send data directly to the client,
    >> from a C++ binary or maybe another script.
    >
    > If you're willing to write C code, I'd suggest posing your question in
    > comp.infosystems.www.servers.unix, where people will be happy to tell you
    > about Apache APIs that may be of use.

    And, to be honest, the listen-fork model is so simple that it's not as if
    you're doing a whole lot of work implementing it in PHP. You're looking at
    about 15 lines of code for a model case.

    miguel

    attached mail follows:


    Just subscribed to comp.infosystems....

    True, the listen-fork model would hardly be any lines of code, but
    the changes that will have to be done to the client and the server
    would be enormous. We are talking abt a production system here
    which needs to be optimised. I cant honestly go ahead for a
    solution that would involve such a huge re-write :( though i'd
    love to do that using PHP.

    Just wanted to take the chance to give a huge CONGRATS to the PHP
    dev team for making such an AMAZING server-side scripting
    language. Beats the shit out of anything else (personal opinion
    :))

    And looking at the pace at which the development and feature
    additions are going on, wont be long before we have our very own
    "PHP-OS" !!! (for all i know, it might be already there)

    Keep up the great work guys!

    Tx,
    Vinod.

    On Wed, 22 May 2002 Miguel Cruz wrote :
    >On Wed, 22 May 2002, Miguel Cruz wrote:
    > > On 22 May 2002, Vinod Panicker wrote:
    > >> "Instant" is how the response should be. Thats why i'm
    >clamouring
    > >> for the socket so that i can send data directly to the
    >client,
    > >> from a C++ binary or maybe another script.
    > >
    > > If you're willing to write C code, I'd suggest posing your
    >question in
    > > comp.infosystems.www.servers.unix, where people will be happy
    >to tell you
    > > about Apache APIs that may be of use.
    >
    >And, to be honest, the listen-fork model is so simple that it's
    >not as if
    >you're doing a whole lot of work implementing it in PHP. You're
    >looking at
    >about 15 lines of code for a model case.
    >
    >miguel
    >
    >
    >--
    >PHP General Mailing List (http://www.php.net/)
    >To unsubscribe, visit: http://www.php.net/unsub.php
    >

    _________________________________________________________
    Click below to visit monsterindia.com and review jobs in India or
    Abroad
    http://monsterindia.rediff.com/jobs

    attached mail follows:


    Thanx for the suggestions!
    Someone mentioned that I could use MD5 and then encrypt the hash,
    how would I ever decrypt that? Is'nt MD5 a 1-way thing only?

    Another question?
    Should I go for bigger keylength or bigger blocksize or both? What makes
    for the best encryption?

    / Jim

    (and before someone suggest that I read the book Applied cryptography it's
    already orderd and on it's way :-) )

    attached mail follows:


    Yes Jimmy, you are correct. MD5 is a one-way hash. Its used for
    getting a unique fingerprint of some data (like files / passwords
    etc) so that it can be compared with another MD5 hash.

    Thats the point of a hashing algorithm like MD5 and SHA1 - you
    should never need to decrypt the data.

    Refer to how Digital signatures and PKI works - they use MD5
    hashes.

    The next question - A bigger keylength means stronger encryption -
    but it also means more CPU cycles.

    A bigger blocksize means that bigger chunks of data are encrypted
    at a time.

    Its always a balance that needs to be found over here - you cant
    use a keylength that is 2048 bits - it will give u the strongest
    encryption, but it will also take a lot of time.

    Tx,
    Vinod.

    On Wed, 22 May 2002 Jimmy Lantz wrote :
    >Thanx for the suggestions!
    >Someone mentioned that I could use MD5 and then encrypt the
    >hash,
    >how would I ever decrypt that? Is'nt MD5 a 1-way thing only?
    >
    >Another question?
    >Should I go for bigger keylength or bigger blocksize or both?
    >What makes for the best encryption?
    >
    >/ Jim
    >
    >(and before someone suggest that I read the book Applied
    >cryptography it's already orderd and on it's way :-) )
    >
    >
    >-- PHP General Mailing List (http://www.php.net/)
    >To unsubscribe, visit: http://www.php.net/unsub.php
    >

    _________________________________________________________
    Click below to visit monsterindia.com and review jobs in India or
    Abroad
    http://monsterindia.rediff.com/jobs

    attached mail follows:


    Jimmy,

    You could md5 something and send it encrypted and then verify the md5,
    something similar to sharing keys...md5 is similar to a key...i use it
    as something similar to kerberos...

    And yes, MD5 is a one-way hash...which comes in handy...

    Just remember that bigger is almost always better. I would suggest
    trying all three (blocksize, keylength, and both) and see which one
    works best for you. You should see how your system deals with it and
    then decide...I like to have bigger keylenghts personally...

    Thanks,

    Ray Hunter

    -----Original Message-----
    From: Jimmy Lantz [mailto:jimmy.lantzlusidor.com]
    Sent: Wednesday, May 22, 2002 12:58 AM
    To: php-generallists.php.net
    Subject: [PHP] Mcrypt: Blowfish or Twofish or no fish? Part 2

    Thanx for the suggestions!
    Someone mentioned that I could use MD5 and then encrypt the hash, how
    would I ever decrypt that? Is'nt MD5 a 1-way thing only?

    Another question?
    Should I go for bigger keylength or bigger blocksize or both? What makes

    for the best encryption?

    / Jim

    (and before someone suggest that I read the book Applied cryptography
    it's
    already orderd and on it's way :-) )

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

    attached mail follows:


    On Wed, 22 May 2002, Jimmy Lantz wrote:

    > Thanx for the suggestions! > Someone mentioned that I could use MD5 and then encrypt the hash, > how would I ever decrypt that? Is'nt MD5 a 1-way thing only? > > Another question? > Should I go for bigger keylength or bigger blocksize or both? What makes > for the best encryption?

    Does it really make a difference? I'm not exactly crypto-literate, but the idea is to encrypt the thing so that it's not visible by Foo Bar even if he does break into your system. If someone is competent enough to break Mcrypt's 128/256bit cyphers, then it doesn't really matter if you use the "weak" or the "strong" ones. I've used 256bit Rijndael in CBC mode, but I wouldn't feel more/less safe if it was CFB or if it was 3DES.

    Just my 2c.

    --thalis

    > > / Jim > > (and before someone suggest that I read the book Applied cryptography it's > already orderd and on it's way :-) )

    attached mail follows:


    I'm trying to put together an architecture for a web environment and have a newbie question regarding PHP and application servers... I have decided to use Apache and MySQL running on Linux, using PHP for server side scripting. Were does an application server fit into this and is it necessary? I know that if I had chosen to use ColdFusion for my scripting environment that this is an application server but I don't know where one fits in with PHP, Apache and Linux. Thnx, Stephen

    attached mail follows:


    On Wed, 22 May 2002, Stephen Tredrea wrote: > I'm trying to put together an architecture for a web environment and > have a newbie question regarding PHP and application servers... > > I have decided to use Apache and MySQL running on Linux, using PHP for > server side scripting. Were does an application server fit into this and > is it necessary? I know that if I had chosen to use ColdFusion for my > scripting environment that this is an application server but I don't > know where one fits in with PHP, Apache and Linux.

    The application server model doesn't work that well with PHP. At best performance it integrates fairly tightly with the web server (Apache, etc.).

    How much you need to think about this depends on the type of application you're planning for. It's quite likely that buzzword compliance won't really get you anything and can be safely ignored.

    miguel

    attached mail follows:


    When referring to an application server many times people are refereeing to a server that is running something like J2EE or EJBs or .NET with XML. They are actual applications running behind a web server. Some examples are BEA, WebSphere, or Jonas for Java apps. I have no idea about .net, not into that... If you are looking for a good Java one I suggest Jonas which is open source (free) and is fairly decent. I have used it for running applications with apache and tomcat running together... The Java apps with Jonas need to have something handle the web front-end which is Tomcat for apache....

    Thanks,

    Ray Hunter

    -----Original Message----- From: Stephen Tredrea [mailto:stephen.tredreacom-du-it.com] Sent: Wednesday, May 22, 2002 1:06 AM To: php-generallists.php.net Subject: [PHP] Servers, servers and more servers

    I'm trying to put together an architecture for a web environment and have a newbie question regarding PHP and application servers... I have decided to use Apache and MySQL running on Linux, using PHP for server side scripting. Were does an application server fit into this and is it necessary? I know that if I had chosen to use ColdFusion for my scripting environment that this is an application server but I don't know where one fits in with PHP, Apache and Linux. Thnx, Stephen

    attached mail follows:


    Hi, I believe that twofish has been successfully broken, so use blowfish instead. Typically, for encrypting files you will use an algorithm like blowfish in cbc mode (as opposed to ebc mode) but I don't know if Mcrypt supports this. Also, when creating the hash of the file, it is probably best to use SHA-1 instead of MD5, as there appears to be some concern with MD5 over it's compression function. HTH JH

    -----Original Message----- From: Jimmy Lantz [mailto:jimmy.lantzlusidor.com] Sent: 21 May 2002 17:28 To: php-generallists.php.net Subject: [PHP] Mcrypt: Blowfish or Twofish or no fish?

    Hi, started playing with Mcrypt and just wanted to ask which encryption method makes the stronger encryption? (I can supply the necesary keylength). Should I go for MCRYPT_BLOWFISH or MCRYPT_TWOFISH? Or no fish at all :)

    So what do I need it for? I'm going to use it encrypting files, sizes varies between some 100 k's and 4-5 mb's. / Jim

    Paranoia + A system w/o users = Safe system :)

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

    attached mail follows:


    Hi all, I have two images on my html form - one for submit and the other for skip with name="mode_skip". In my php script I want to check if user clicked on skip image but isset($_REQUEST["mode_skip"]) and !empty($_REQUEST["mode_skip"]) seems to always return true. In URL submitted I saw ...&mode_skip.x=X&mode_skip.y=Y. How can I determin if skip image was clicked. Thank you in advance.

    Regards,

    Andrew

    attached mail follows:


    On Wed, 22 May 2002 andrewfoxtrot.kiev.ua wrote: > I have two images on my html form - one for submit and the other for skip > with name="mode_skip". > In my php script I want to check if user clicked on skip image but > isset($_REQUEST["mode_skip"]) and !empty($_REQUEST["mode_skip"]) seems to > always return true. > In URL submitted I saw ...&mode_skip.x=X&mode_skip.y=Y. > How can I determin if skip image was clicked.

    It'll probably be $_REQUEST['mode_skip_x'] (and .._y if you're interested in the particular coordinates).

    miguel

    attached mail follows:


    >I believe that twofish has been successfully broken, so use blowfish >instead. Typically, for encrypting files you will use an algorithm like >blowfish in cbc mode (as opposed to ebc mode) but I don't know if Mcrypt >supports this. Also, when creating the hash of the file, it is probably best >to use SHA-1 instead of MD5, as there appears to be some concern with MD5 >over it's compression function. >HTH >JH

    It helps :) I have been looking into Blowfish with cbc mode :) If I use SHA-1 it's still no way to dehash it during decryption of the file, so I fail to see the use of Hashing in fileencryption. Could someone enlighten me? / Jim

    attached mail follows:


    There is no use of hashing in file-encryption except to use it as a check - to see if the decrypted file matches the original file. To do this check, you can use either MD5 or SHA1. The choice is urs.

    If ur looking for a good encryption algorithm, you might want to consider AES (Rijndael). It supports encryption using different key sizes as well as all modes.

    You can take your pick from ECB / CBC also. For binary file encryption, i would recommend ECB mode. For text files, it would be better that you use CBC mode.

    Tx, Vinod.

    On Wed, 22 May 2002 Jimmy Lantz wrote : > > >>I believe that twofish has been successfully broken, so use >>blowfish >>instead. Typically, for encrypting files you will use an >>algorithm like >>blowfish in cbc mode (as opposed to ebc mode) but I don't know >>if Mcrypt >>supports this. Also, when creating the hash of the file, it is >>probably best >>to use SHA-1 instead of MD5, as there appears to be some concern >>with MD5 >>over it's compression function. >>HTH >>JH > >It helps :) >I have been looking into Blowfish with cbc mode :) >If I use SHA-1 it's still no way to dehash it during decryption >of the file, >so I fail to see the use of Hashing in fileencryption. >Could someone enlighten me? >/ Jim > > >-- PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php >

    _________________________________________________________ Click below to visit monsterindia.com and review jobs in India or Abroad http://monsterindia.rediff.com/jobs

    attached mail follows:


    File hashing is used to take a hash of the clear text. In this way, you can append the hash to the encrypted text. When decrypting, you remove this hash, decrypt the rest of the file, hash this decrypted file and see if the two hashes match up. If they don't then an incorrect key was used with the algorithm (or the data was corrupted somehow). Hashes are typically used as sanity checks in this way. JH

    -----Original Message----- From: Jimmy Lantz [mailto:jimmy.lantzlusidor.com] Sent: 22 May 2002 09:31 To: php-generallists.php.net Subject: RE: [PHP] Mcrypt: Blowfish or Twofish or no fish? part 3

    >I believe that twofish has been successfully broken, so use blowfish >instead. Typically, for encrypting files you will use an algorithm like >blowfish in cbc mode (as opposed to ebc mode) but I don't know if Mcrypt >supports this. Also, when creating the hash of the file, it is probably best >to use SHA-1 instead of MD5, as there appears to be some concern with MD5 >over it's compression function. >HTH >JH

    It helps :) I have been looking into Blowfish with cbc mode :) If I use SHA-1 it's still no way to dehash it during decryption of the file, so I fail to see the use of Hashing in fileencryption. Could someone enlighten me? / Jim

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

    attached mail follows:


    why use AES? Blowfish can have a 448 bit key size! Also, why use ebc mode with all the problems which come with it? JH

    -----Original Message----- From: Vinod Panicker [mailto:thisisvinodrediffmail.com] Sent: 22 May 2002 10:06 To: Jimmy Lantz Cc: php-generallists.php.net Subject: Re: RE: [PHP] Mcrypt: Blowfish or Twofish or no fish? part 3

    There is no use of hashing in file-encryption except to use it as a check - to see if the decrypted file matches the original file. To do this check, you can use either MD5 or SHA1. The choice is urs.

    If ur looking for a good encryption algorithm, you might want to consider AES (Rijndael). It supports encryption using different key sizes as well as all modes.

    You can take your pick from ECB / CBC also. For binary file encryption, i would recommend ECB mode. For text files, it would be better that you use CBC mode.

    Tx, Vinod.

    On Wed, 22 May 2002 Jimmy Lantz wrote : > > >>I believe that twofish has been successfully broken, so use >>blowfish >>instead. Typically, for encrypting files you will use an >>algorithm like >>blowfish in cbc mode (as opposed to ebc mode) but I don't know >>if Mcrypt >>supports this. Also, when creating the hash of the file, it is >>probably best >>to use SHA-1 instead of MD5, as there appears to be some concern >>with MD5 >>over it's compression function. >>HTH >>JH > >It helps :) >I have been looking into Blowfish with cbc mode :) >If I use SHA-1 it's still no way to dehash it during decryption >of the file, >so I fail to see the use of Hashing in fileencryption. >Could someone enlighten me? >/ Jim > > >-- PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php >

    _________________________________________________________ Click below to visit monsterindia.com and review jobs in India or Abroad http://monsterindia.rediff.com/jobs

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

    attached mail follows:


    And why not use AES, which is an industry standard and having being proven as the best encryption algorithm in recent times?

    http://csrc.nist.gov/encryption/aes/aesfact.html

    As far as ECB mode is concerned, I dont know what problems you are talking about. I'm aware that the data gets encrypted in independed blocks and its easier to crack it, but its faster than other modes.

    Tx, Vinod.

    On Wed, 22 May 20