Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

dbf2mysql parameter, WWWXXXAPC, wwwxxxAPC, How to unsubscrube from dategen spam, docmd.close 2585, WWWXXXDOCO, nu vot, dhcpd lease file "binding state", WWWXXXDOCO, how to setup procmail to process html2text

Links

XODOX
Impressum

#1: perl cgi vs php

Posted on 2008-01-21 22:20:21 by philip.kingsten

Hello phpers,

I have a task I want to carry out in php 4.3 rather than perl 5.6.
Maybe you people can help me?
What I need to do is to catch a URL on a linux box htpp://IP/something?LinkId=1234
then I want to pop up a form to prompt for username and password.
then I need to do a MD5 hex hash ie 'test' gives
5f4dcc3b5aa765d61d8327deb882cf99
then I want the browser to point to https://IP/something?LinkId=1234&name=xxx&password=MD5hash

I have very nearly done this in perl

Like so:
use Digest::MD5 qw(md5 md5_hex md5_base64);
my $LinkId = param( 'LinkId' );
print header,
start_html('Enter Logon Details'),
h1('Enter Details'),
# h1($CustomerId),
start_form (-action => "http://195.168.1.21//cgi-bin/tool3.cgi", -
method=>'GET'),
"What's your name? ",textfield('name'),p,
"What's your password? ",password_field('password'),p,
hidden(-name => "LinkId", -default => '$LinkId').
submit,
end_form,
hr;

That actually works, but the tool3.cgi although it has the 3 variables
populated as required password, the MD5 hash, username and LinkId and
I can build the https URL as required I cannot get the redirect to
work.

I either get an unhelpful error message cannot execute tool3.cgi or
nothing happens.

So I would like you php people to give me some help - cos it is after
9 pm in the UK and this is supposed to be deployed tomorrow morning
1st thing. As much help as you wish - from nothing cos you think I
should read the manual and browse the tutorials (quite right too- I
will when I get some time) or few pointers to get me started or maybe
even some code ...

Thanks in anticipation ;-)

Phil

Report this message

#2: Re: perl cgi vs php

Posted on 2008-01-23 02:30:24 by nothingsoriginalontheinternet

On Jan 21, 4:20 pm, philip.kings...@yahoo.com wrote:
> What I need to do is to catch a URL on a linux box htpp://IP/something?LinkId=1234
> then I want to pop up a form to prompt for username and password.
> then I need to do a MD5 hex hash ie 'test' gives
> 5f4dcc3b5aa765d61d8327deb882cf99
> then I want the browser to point tohttps://IP/something?LinkId=1234&name=xxx&password=MD5hash

Hi Phil, I don't know if this is too late but --

Unless you want to use a shebang line, you should have PHP set up to
respond to all .php requests in your server first. The (non fast-) cgi
binary way of doing this in Apache would be to put this in .htaccess:

AddHandler php-cgi .php
Action php-cgi /path/to/php.cgi

A PHP script would differ from whatever perl html module you are using
there because you actually jump between PHP code and output (html)
code, so you want something like this:

------------------------------
<?php
if( isset( $_POST['name'] ) )
{
//...check password or whatever...

//forward request
header( "location: something?
LinkId={$_GET['LinkId']}&name={$_POST['name']}&pass=" .
md5( $_POST['password'] ) );
exit;
}
elseif( isset( $_GET['name'] ) )
{
//do whatever you wanted to do when authenticated
}
else { ?>
<form>
...
</form>
<?php } ?>
-----------------------------

Now you should take that example and figure out what is different
about how you need it, I.E. you probably want it to redirect to some
other URI instead of the same "something", and there should be enough
information in the example to figure out how to do that stuff.

Good Luck,
-Michael Placentra II | ZCE

Report this message