Re: [PHP] Session var read by form C++ CGI prog ?
On Tue, 2 Sep 2003 15:48:46 -0700 (PDT) Chris Shiflett <[EMAIL PROTECTED]> wrote: > --- John Bryan <[EMAIL PROTECTED]> wrote: > > Was/am thinking I could use php to set 'session' variable(s) that > > would also be visible to an existing cpp prog currently invoked > > from a form. > > I missed most of this thread, since it appeared to be off-topic, but you might > consider changing the action attribute of your form to point to a PHP script > that can call your CGI as needed. It's worth trying anyway, and PHP should > already have the right privileges to execute it. > > This PHP script could conveniently access the PHP session (which your CGI could > do also, but with much more hassle) as well as all GET and POST data, and you > could use it as a wrapper to your CGI. This would also make future transitions > easier, if you forsee taking that path. Something I used in the past was a php script communicating with a long running application via sockets: the script would collect data, send it to the app for processing which would pass it back to the php script which fpassthru() back to the client. It was very fast too. > > Hope that helps. > > Chris > > = > Become a better Web developer with the HTTP Developer's Handbook > http://httphandbook.org/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > Regards, Andu Novac -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
Chris is right on both counts. :-) and this is exactly how i do it in my file upload progress bar. best regards raditha Chris Shiflett wrote: --- John Bryan <[EMAIL PROTECTED]> wrote: So looks like I can't have it both ways, i.e. POST and GET Yes, you can. The script blah.php can reference $_GET['foo'] and $_POST['bar']. The values of these variables will be 1 and 2, respectively. Please keep in mind that this is a PHP list... Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- http://www.raditha.com/php/progress.php A progress bar for PHP file uploads. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
--- John Bryan <[EMAIL PROTECTED]> wrote: > Was/am thinking I could use php to set 'session' variable(s) that > would also be visible to an existing cpp prog currently invoked > from a form. I missed most of this thread, since it appeared to be off-topic, but you might consider changing the action attribute of your form to point to a PHP script that can call your CGI as needed. It's worth trying anyway, and PHP should already have the right privileges to execute it. This PHP script could conveniently access the PHP session (which your CGI could do also, but with much more hassle) as well as all GET and POST data, and you could use it as a wrapper to your CGI. This would also make future transitions easier, if you forsee taking that path. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
On Tuesday, September 02, 2003, at 05:12PM, Chris Shiflett <[EMAIL PROTECTED]> wrote: >--- John Bryan <[EMAIL PROTECTED]> wrote: >> So looks like I can't have it both ways, i.e. POST and GET > >Yes, you can. > > > > > >The script blah.php can reference $_GET['foo'] and $_POST['bar']. The values of >these variables will be 1 and 2, respectively. > Thanks, Chris. That's pretty cool. I wish I had time to rewrite this dang cpp prog in php or something that better lends itself to these things. >Please keep in mind that this is a PHP list... > Will do. Was/am thinking I could use php to set 'session' variable(s) that would also be visible to an existing cpp prog currently invoked from a form. j b -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
--- John Bryan <[EMAIL PROTECTED]> wrote: > So looks like I can't have it both ways, i.e. POST and GET Yes, you can. The script blah.php can reference $_GET['foo'] and $_POST['bar']. The values of these variables will be 1 and 2, respectively. Please keep in mind that this is a PHP list... Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
On Tuesday, September 02, 2003, at 02:04PM, Raditha Dissanayake <[EMAIL PROTECTED]> wrote: >Hello, >If you use yes they will be part of the input >stream. What i suggested was you have > then you can >retrieve the query string variable from the env. (at least this works >with perl cgi and i don't see why it shouldn't work with C++ as well). >the only draw back is that you have to process the qstring yourself. > Actually, upon further reading it seems I won't be able to do this. If I pass parameters in this fashion, the web server will make them available in QUERY_STRING, but I need to use the GET method. The form is using the POST method so that the file that is being uploaded and processed gets handed to the cgi program through stdin. So looks like I can't have it both ways, i.e. POST and GET, stdin and query string env var. Thanks, JB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
From: "John Bryan" <[EMAIL PROTECTED]> > The file would already exist on the client side. They are > uploading the file to be processed by this program > MyCppProg.exe, which is invoked as a form 'action'. > This already works, but depends on the Apache variable > REMOTE_USER being set when user logs in, but we > moving to implement a different method for authentication > that involves talking to two different Oracle databases, > password rules, etc., so this REMOTE_USER variable > no longer gets set since we are bypassing Apache's > authentication here. > > So I need to set an 'environment' variable that remains > visible to scripts and progs within the session space, that > can then be grabbed by the MyCppProg.exe, for example > with getenv("MyEnvVar"). It used to use getenv("REMOTE_USER"). > > I'm hoping to not have this variable have to be part of the file that gets uploaded. Ah, I see now. If you're using a file upload box and submitting that form directly to your .exe, then there's probably not much you can do. In order to do this, I think you'll have to "intercept" the file. When the user submits the file, it goes to a PHP script that copies it somewhere. Then see if you can make an exec() call to the system and set the "REMOTE_USER" variable, somehow. I'm not sure on the syntax/possibility of that, it would depend upon your OS. Then make another exec() call to your C++ program and send it the path the the file that was already uploaded. Capture the output and show it to the user or do whatever you normally do. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
On Tuesday, September 02, 2003, at 01:55PM, CPT John W. Holmes <[EMAIL PROTECTED]> wrote: >From: "John Bryan" <[EMAIL PROTECTED]> > >> If so, the problem is that this file that is being uploaded >> via the form to the program MyCppProg.exe gets sent >> as THE input to the prog, apparently as a cgi-type >> parameter through stdin (i.e. cin), so that when I try to >> pass the value as a cgi parameter, it gets inserted INTO >> the file that is being uploaded. > >Does this file already exist or are you looking to create it? It sounds like >you just need to fopen() the file, tack on your "variable" at the end of the >file (in some format) and then let the C++ program load the file, right? > >---John Holmes... The file would already exist on the client side. They are uploading the file to be processed by this program MyCppProg.exe, which is invoked as a form 'action'. This already works, but depends on the Apache variable REMOTE_USER being set when user logs in, but we moving to implement a different method for authentication that involves talking to two different Oracle databases, password rules, etc., so this REMOTE_USER variable no longer gets set since we are bypassing Apache's authentication here. So I need to set an 'environment' variable that remains visible to scripts and progs within the session space, that can then be grabbed by the MyCppProg.exe, for example with getenv("MyEnvVar"). It used to use getenv("REMOTE_USER"). I'm hoping to not have this variable have to be part of the file that gets uploaded. thanks, jb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
On Tuesday, September 02, 2003, at 02:04PM, Raditha Dissanayake <[EMAIL PROTECTED]> wrote: >Hello, >If you use yes they will be part of the input >stream. What i suggested was you have > then you can >retrieve the query string variable from the env. (at least this works >with perl cgi and i don't see why it shouldn't work with C++ as well). >the only draw back is that you have to process the qstring yourself. > Right. That is what I had tried before, using it as a hidden parameter. I will try passing as part of the explicit call to the prog as you describe. thanks, jb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
From: "John Bryan" <[EMAIL PROTECTED]> > If so, the problem is that this file that is being uploaded > via the form to the program MyCppProg.exe gets sent > as THE input to the prog, apparently as a cgi-type > parameter through stdin (i.e. cin), so that when I try to > pass the value as a cgi parameter, it gets inserted INTO > the file that is being uploaded. Does this file already exist or are you looking to create it? It sounds like you just need to fopen() the file, tack on your "variable" at the end of the file (in some format) and then let the C++ program load the file, right? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
Hello, If you use yes they will be part of the input stream. What i suggested was you have then you can retrieve the query string variable from the env. (at least this works with perl cgi and i don't see why it shouldn't work with C++ as well). the only draw back is that you have to process the qstring yourself. best regards raditha John Bryan wrote: Thanks, very much, Raditha. Do you mean to pass my variable as a cgi parameter ? If so, the problem is that this file that is being uploaded via the form to the program MyCppProg.exe gets sent as THE input to the prog, apparently as a cgi-type parameter through stdin (i.e. cin), so that when I try to pass the value as a cgi parameter, it gets inserted INTO the file that is being uploaded. Am I understanding correctly, or did I miss the point ? Thanks, JB On Tuesday, September 02, 2003, at 01:21PM, Raditha Dissanayake <[EMAIL PROTECTED]> wrote: Hi, Had a similar problem when building upload progress bar. Initially i used cookies but that had a few minor hiccups. What you can do is to encode your variables into the query string. This is accessible as part of the env. variables. Since you are familiar with C++ you will get the hang of PHP very quickly. oh and btw the correct way to set a cookie is with session_register(), $_SESSION is used for retrieval. John Bryan wrote: I need to use something like a session variable to make a variable available to an existing form-invoked C++ program which takes as input a file being uploaded. Is this even do-able ??If so, what am I missing here ??? The C++ prog used to use the REMOTE_USER env var set by the web server but we are no longer doing authentication via the webserver itself, so this one does not get set, and I need to set something myself. The C++ prog would had been grabbing this by getenv("REMOTE_USER"). I was trying some php to set a session var 'UPATH' but the UPATH variable doesn't seem to be visible to MyCppProg.exe : --snip-- File to Upload: --snip-- -- John Bryan [EMAIL PROTECTED] http://homepage.mac.com/johnbryan http://homepage.mac.com/aijuan -- http://www.raditha.com/php/progress.php A progress bar for PHP file uploads. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
Oh well, and i thought i knew everything about php :-( Ford, Mike [LSS] wrote: On 02 September 2003 19:22, Raditha Dissanayake wrote: Hi, Had a similar problem when building upload progress bar. Initially i used cookies but that had a few minor hiccups. What you can do is to encode your variables into the query string. This is accessible as part of the env. variables. Since you are familiar with C++ you will get the hang of PHP very quickly. oh and btw the correct way to set a cookie is with session_register(), $_SESSION is used for retrieval. Er, nope. If you have a version of PHP with the $_SESSION array, then you use it for both setting *and* retrieving -- session_register() and friends should *not* be used in this case. (Indeed, there are circumstances where the combination of session_register() with $_SESSION gives broken behaviour.) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- http://www.raditha.com/php/progress.php A progress bar for PHP file uploads. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session var read by form C++ CGI prog ?
On Tuesday, September 02, 2003, at 01:32PM, Ford, Mike [LSS] <[EMAIL PROTECTED]> wrote: >On 02 September 2003 19:22, Raditha Dissanayake wrote: > >> Hi, >> >> Had a similar problem when building upload progress bar. Initially i >> used cookies but that had a few minor hiccups. What you can do is to >> encode your variables into the query string. This is >> accessible as part >> of the env. variables. Since you are familiar with C++ you >> will get the >> hang of PHP very quickly. >> >> oh and btw the correct way to set a cookie is with >> session_register(), >> $_SESSION is used for retrieval. > >Er, nope. If you have a version of PHP with the $_SESSION array, then you use it for >both setting *and* retrieving -- session_register() and friends should *not* be used >in this case. (Indeed, there are circumstances where the combination of >session_register() with $_SESSION gives broken behaviour.) > Right. I am running PHP 4.3.3. Win32 version to be specific, on Win2k server, with Apache 1.3.26. I installed PHP to try and do this trick. JB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session var read by form C++ CGI prog ?
On 02 September 2003 19:22, Raditha Dissanayake wrote: > Hi, > > Had a similar problem when building upload progress bar. Initially i > used cookies but that had a few minor hiccups. What you can do is to > encode your variables into the query string. This is > accessible as part > of the env. variables. Since you are familiar with C++ you > will get the > hang of PHP very quickly. > > oh and btw the correct way to set a cookie is with > session_register(), > $_SESSION is used for retrieval. Er, nope. If you have a version of PHP with the $_SESSION array, then you use it for both setting *and* retrieving -- session_register() and friends should *not* be used in this case. (Indeed, there are circumstances where the combination of session_register() with $_SESSION gives broken behaviour.) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
Thanks, very much, Raditha. Do you mean to pass my variable as a cgi parameter ? If so, the problem is that this file that is being uploaded via the form to the program MyCppProg.exe gets sent as THE input to the prog, apparently as a cgi-type parameter through stdin (i.e. cin), so that when I try to pass the value as a cgi parameter, it gets inserted INTO the file that is being uploaded. Am I understanding correctly, or did I miss the point ? Thanks, JB On Tuesday, September 02, 2003, at 01:21PM, Raditha Dissanayake <[EMAIL PROTECTED]> wrote: >Hi, > >Had a similar problem when building upload progress bar. Initially i >used cookies but that had a few minor hiccups. What you can do is to >encode your variables into the query string. This is accessible as part >of the env. variables. Since you are familiar with C++ you will get the >hang of PHP very quickly. > >oh and btw the correct way to set a cookie is with session_register(), >$_SESSION is used for retrieval. > >John Bryan wrote: > >>I need to use something like a session variable to make a variable available to an >>existing form-invoked C++ program which takes as input a file being uploaded. Is >>this even do-able ??If so, what am I missing here ??? >> >>The C++ prog used to use the REMOTE_USER env var set by the web server but we are no >>longer doing authentication via the webserver itself, so this one does not get set, >>and I need to set something myself. The C++ prog would had been grabbing this by >>getenv("REMOTE_USER"). >> >>I was trying some php to set a session var 'UPATH' but the UPATH variable doesn't >>seem to be visible to MyCppProg.exe : >> >>--snip-- >> >>>$_SESSION['UPATH'] = 'foobar'; >>?> >> >> >> File to Upload: >> >> >>--snip-- -- John Bryan [EMAIL PROTECTED] http://homepage.mac.com/johnbryan http://homepage.mac.com/aijuan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session var read by form C++ CGI prog ?
Hi, Had a similar problem when building upload progress bar. Initially i used cookies but that had a few minor hiccups. What you can do is to encode your variables into the query string. This is accessible as part of the env. variables. Since you are familiar with C++ you will get the hang of PHP very quickly. oh and btw the correct way to set a cookie is with session_register(), $_SESSION is used for retrieval. all the best John Bryan wrote: I need to use something like a session variable to make a variable available to an existing form-invoked C++ program which takes as input a file being uploaded. Is this even do-able ??If so, what am I missing here ??? The C++ prog used to use the REMOTE_USER env var set by the web server but we are no longer doing authentication via the webserver itself, so this one does not get set, and I need to set something myself. The C++ prog would had been grabbing this by getenv("REMOTE_USER"). I was trying some php to set a session var 'UPATH' but the UPATH variable doesn't seem to be visible to MyCppProg.exe : --snip-- File to Upload: --snip-- I am new to php, have been digging around on the web, and not making a lot of headway quickly enough, so I'm asking. Thanks, JB -- http://www.raditha.com/php/progress.php A progress bar for PHP file uploads. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php