Re: Post to a second CGI script

2002-07-29 Thread Connie Chan

Use cookies is the best choice.
or use frame to hide any URIs as alt.

Rgds,
Connie

- Original Message - 
From: "Jim Lundeen" <[EMAIL PROTECTED]>
To: "begin begin" <[EMAIL PROTECTED]>
Sent: Tuesday, July 30, 2002 8:06 AM
Subject: Post to a second CGI script


> Hello All,
> 
> I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
> and ACTION from an HTML form.  That script looks in a user table in
> MySQL to verify the user.  If valid, it passes them to MENU.CGI with
> LOGIN_USERNAME and a unique session number (USN).
> 
> Here's the question:  How to I "post" the LOGIN_USERNAME and USN to the
> MENU.CGI script?  I don't want the user "carrying" the info around in
> the "Location" bar as "?USN=1234&LOGIN_USERNAME=somebody" -- I want it
> to be part of the user's Perl process if you know what I mean, so that
> if they hit RELOAD the values are still with them.  Too, I don't want
> someone trying to modify the info if it were in the "Location" bar, so
> it needs to be a part of the "post."
> 
> Any advice would be much appreciated!
> 
> Thanks!
> 
> Jim
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Tutorial for sessions

2002-07-29 Thread Ken Cole

Hi,

Is there a good, simple tutorial on using cgi for session control out there anywhere.

Thanks

Ken

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Post to a second CGI script

2002-07-29 Thread Jim Lundeen

Ok, perhaps not the most eloquent of methods, but here's what I did (putting my
little knowledge of JavaScript to use!)...

sub loadmenu
 {
print <
  


  
  
LOADMENU
exit;
 }

So basically, my 1st CGI prints this form to the user's browser and in the same
split second the Javascript does an "auto-submit" function so that the user
never knows that the form was displayed (it wasn't actually, the fields were
all hidden)...

Thanks for your input David & Troy...


David T-G wrote:

> Jim --
>
> ...and then Jim Lundeen said...
> %
> % Hello All,
>
> Hi!
>
> %
> % I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
> % and ACTION from an HTML form.  That script looks in a user table in
> % MySQL to verify the user.  If valid, it passes them to MENU.CGI with
> % LOGIN_USERNAME and a unique session number (USN).
>
> Good enough.
>
> %
> % Here's the question:  How to I "post" the LOGIN_USERNAME and USN to the
> % MENU.CGI script?  I don't want the user "carrying" the info around in
> % the "Location" bar as "?USN=1234&LOGIN_USERNAME=somebody" -- I want it
>
> Right.  That would be ugly.
>
> % to be part of the user's Perl process if you know what I mean, so that
> % if they hit RELOAD the values are still with them.  Too, I don't want
> % someone trying to modify the info if it were in the "Location" bar, so
> % it needs to be a part of the "post."
>
> I can never remember which is POST and which is GET, but just have your
> script pass the data over to MENU.CGI (are you on a Win machine, BTW, or
> do you ALWAYS SHOUT? ;-) in the environment as that-which-is-not-the-url
> method does.
>
> %
> % Any advice would be much appreciated!
>
> HTH & HAND
>
> %
> % Thanks!
> %
> % Jim
> %
>
> :-D
> --
> David T-G  * It's easier to fight for one's principles
> (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
> (work) [EMAIL PROTECTED]
> http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
>
>   
>Part 1.2Type: application/pgp-signature



Re: Post to a second CGI script

2002-07-29 Thread David T-G

Jim --

...and then Jim Lundeen said...
% 
% Hello All,

Hi!


% 
% I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
% and ACTION from an HTML form.  That script looks in a user table in
% MySQL to verify the user.  If valid, it passes them to MENU.CGI with
% LOGIN_USERNAME and a unique session number (USN).

Good enough.


% 
% Here's the question:  How to I "post" the LOGIN_USERNAME and USN to the
% MENU.CGI script?  I don't want the user "carrying" the info around in
% the "Location" bar as "?USN=1234&LOGIN_USERNAME=somebody" -- I want it

Right.  That would be ugly.


% to be part of the user's Perl process if you know what I mean, so that
% if they hit RELOAD the values are still with them.  Too, I don't want
% someone trying to modify the info if it were in the "Location" bar, so
% it needs to be a part of the "post."

I can never remember which is POST and which is GET, but just have your
script pass the data over to MENU.CGI (are you on a Win machine, BTW, or
do you ALWAYS SHOUT? ;-) in the environment as that-which-is-not-the-url
method does.


% 
% Any advice would be much appreciated!

HTH & HAND


% 
% Thanks!
% 
% Jim
% 


:-D
-- 
David T-G  * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg06068/pgp0.pgp
Description: PGP signature


Re: Post to a second CGI script

2002-07-29 Thread Jim Lundeen

Thanks.  I thought of that, but I need to accommodate those who have
disabled Cookies on their browser.  This script is going to be used in a
high traffic web site with many different types of browsers and
configurations thereof, so I need to keep things very basic when it comes
to interacting with the user.

Thanks!



Troy May wrote:

> Use cookies.
>
> -Original Message-
> From: Jim Lundeen [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 29, 2002 5:06 PM
> To: begin begin
> Subject: Post to a second CGI script
>
> Hello All,
>
> I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
> and ACTION from an HTML form.  That script looks in a user table in
> MySQL to verify the user.  If valid, it passes them to MENU.CGI with
> LOGIN_USERNAME and a unique session number (USN).
>
> Here's the question:  How to I "post" the LOGIN_USERNAME and USN to the
> MENU.CGI script?  I don't want the user "carrying" the info around in
> the "Location" bar as "?USN=1234&LOGIN_USERNAME=somebody" -- I want it
> to be part of the user's Perl process if you know what I mean, so that
> if they hit RELOAD the values are still with them.  Too, I don't want
> someone trying to modify the info if it were in the "Location" bar, so
> it needs to be a part of the "post."
>
> Any advice would be much appreciated!
>
> Thanks!
>
> Jim
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Post to a second CGI script

2002-07-29 Thread Troy May

Use cookies.


-Original Message-
From: Jim Lundeen [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 29, 2002 5:06 PM
To: begin begin
Subject: Post to a second CGI script


Hello All,

I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
and ACTION from an HTML form.  That script looks in a user table in
MySQL to verify the user.  If valid, it passes them to MENU.CGI with
LOGIN_USERNAME and a unique session number (USN).

Here's the question:  How to I "post" the LOGIN_USERNAME and USN to the
MENU.CGI script?  I don't want the user "carrying" the info around in
the "Location" bar as "?USN=1234&LOGIN_USERNAME=somebody" -- I want it
to be part of the user's Perl process if you know what I mean, so that
if they hit RELOAD the values are still with them.  Too, I don't want
someone trying to modify the info if it were in the "Location" bar, so
it needs to be a part of the "post."

Any advice would be much appreciated!

Thanks!

Jim



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Post to a second CGI script

2002-07-29 Thread Jim Lundeen

Hello All,

I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
and ACTION from an HTML form.  That script looks in a user table in
MySQL to verify the user.  If valid, it passes them to MENU.CGI with
LOGIN_USERNAME and a unique session number (USN).

Here's the question:  How to I "post" the LOGIN_USERNAME and USN to the
MENU.CGI script?  I don't want the user "carrying" the info around in
the "Location" bar as "?USN=1234&LOGIN_USERNAME=somebody" -- I want it
to be part of the user's Perl process if you know what I mean, so that
if they hit RELOAD the values are still with them.  Too, I don't want
someone trying to modify the info if it were in the "Location" bar, so
it needs to be a part of the "post."

Any advice would be much appreciated!

Thanks!

Jim



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: fetch CGI::Cookie Trouble

2002-07-29 Thread Bob Showalter

> -Original Message-
> From: John Pitchko [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 29, 2002 12:15 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: fetch CGI::Cookie Trouble
> 
> 
> The code is:
> 
>  my $cookie1 = $query->cookie(-name => 'userid', -value => 
> "$username", -expires => '+1D', -secure => 1, -path => '/');
>  my $cookie2 = $query->cookie(-name => 'verify', -value => 
> 'TRUE', -expires => '+1D', -secure => 1, -path => '/');
>  print  $query->header(-type => "text/html", -cookie => 
> [$cookie1, $cookie2]),
>   $query->start_html(-title => "User Verification Successful"),
>   $query->h1("Authorization Successful, User $username"),
>   $query->a({-href=>'/cgi-bin/template.cgi'}, 'Go to main page!!'),
>   
>   my %cookies = $query->cookie(-name => 'userid');
>   my %cookies2 = $query->cookie(-name => 'verify');

You would only assign to a hash if you passed a hashref as the -value
argument when you created the cookie, which you didn't. So just assign
to a scalar:

my $name = $query->cookie(-name => 'userid');

Also, you should retrieve cookies from the request before writing
cookies to the response with $query->header. I'm not sure what the
value of the cookie is if you call header first, but this seems out
of order to me.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: fetch CGI::Cookie Trouble

2002-07-29 Thread John Pitchko

The code is:

 my $cookie1 = $query->cookie(-name => 'userid', -value => "$username", -expires => 
'+1D', -secure => 1, -path => '/');
 my $cookie2 = $query->cookie(-name => 'verify', -value => 'TRUE', -expires => '+1D', 
-secure => 1, -path => '/');
 print  $query->header(-type => "text/html", -cookie => [$cookie1, $cookie2]),
  $query->start_html(-title => "User Verification Successful"),
  $query->h1("Authorization Successful, User $username"),
  $query->a({-href=>'/cgi-bin/template.cgi'}, 'Go to main page!!'),
  
  my %cookies = $query->cookie(-name => 'userid');
  my %cookies2 = $query->cookie(-name => 'verify');
  print %cookies;
  print %cookies2;

I did use the CGI::Cookie package with the fetch subroutine, but I thought I would try 
it using the CGI package. I took this code from the 
http://www.perl.com/doc/manual/html/lib/CGI.html#NETSCAPE_COOKIES. The result is that 
these hashes are empty.

John Pitchko
Data Services
Saskatchewan Government Insurance

>>> Bob Showalter <[EMAIL PROTECTED]> 07/29/02 09:46am >>>
> -Original Message-
> From: John Pitchko [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 29, 2002 9:40 AM
> To: [EMAIL PROTECTED]
> Subject: fetch CGI::Cookie Trouble
> 
> 
> Hey guys,
> 
> I am having trouble when accessing cookies we've created. I 
> am using CGI::Cookie in a script to generate the cookie and 
> send it to the browser. This seems to work fine, as the 
> cookie is then saved and I can see it in my local Cookies 
> folder on my computer. However, when using the fetch 
> CGI::Cookie command, we get:
> 
> Can't call method "value" on an undefined value at 
> /appl/webdocs/cgi-bin/verify.cgi line 45.
> 
> We are using the exact code from the manpage and have no idea 
> why this is happening. Any suggestions?

Help us out by posting the offending code.

I assume you're doing something like this:

# fetch existing cookies
%cookies = fetch CGI::Cookie;
$id = $cookies{'ID'}->value;

If there is no cookie named 'ID', then $cookies{'ID'} would be
undefined, so $cookies{'ID'}->value would be equivalent to

   undef->value;

which is obviously a problem. You really need to make sure you
received a cookie named ID first by something like:

%cookies = fetch CGI::Cookie;
$id = defined($cookies{ID}) && $cookies{ID}->value;

I can't say why you aren't getting the cookie. Make sure everything
is spelled correctly.



RE: fetch CGI::Cookie Trouble

2002-07-29 Thread Bob Showalter

> -Original Message-
> From: John Pitchko [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 29, 2002 9:40 AM
> To: [EMAIL PROTECTED]
> Subject: fetch CGI::Cookie Trouble
> 
> 
> Hey guys,
> 
> I am having trouble when accessing cookies we've created. I 
> am using CGI::Cookie in a script to generate the cookie and 
> send it to the browser. This seems to work fine, as the 
> cookie is then saved and I can see it in my local Cookies 
> folder on my computer. However, when using the fetch 
> CGI::Cookie command, we get:
> 
> Can't call method "value" on an undefined value at 
> /appl/webdocs/cgi-bin/verify.cgi line 45.
> 
> We are using the exact code from the manpage and have no idea 
> why this is happening. Any suggestions?

Help us out by posting the offending code.

I assume you're doing something like this:

# fetch existing cookies
%cookies = fetch CGI::Cookie;
$id = $cookies{'ID'}->value;

If there is no cookie named 'ID', then $cookies{'ID'} would be
undefined, so $cookies{'ID'}->value would be equivalent to

   undef->value;

which is obviously a problem. You really need to make sure you
received a cookie named ID first by something like:

%cookies = fetch CGI::Cookie;
$id = defined($cookies{ID}) && $cookies{ID}->value;

I can't say why you aren't getting the cookie. Make sure everything
is spelled correctly.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: problem with O_RDONLY

2002-07-29 Thread Bob Showalter

> -Original Message-
> From: Soheil Shaghaghi [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 1:43 AM
> To: [EMAIL PROTECTED]
> Subject: problem with O_RDONLY
> 
> 
> Hello everyone,
> I have a program that uses "O_RDONLY" extensively.
> After upgrading to Perl 5.6.1, every time this program is 
> run, I see errors
> in the log files similar to this:
> Argument "O_RDONLY" isn't numeric in subroutine entry at
> /usr/local/lib/perl5/5.6.1/i386-freebsd/DB_File.pm line 259.
> 
> Can anyone please tell me why I get this error, or how to solve it?

The problem's not with DB_File, it's with your calling script.

1. Make sure "use strict;" is in your program at the top.
2. Make sure you "use Fcntl;" to get the definition of O_RDONLY.

If that doesn't make the warning go away, post a small program that
exhibits the problem.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: File upload question

2002-07-29 Thread zentara

On Sun, 28 Jul 2002 00:51:06 -0700 (PDT), [EMAIL PROTECTED] (Nate)
wrote:

>i'm writing a website that requires an upload for pictures. I have figured out how to 
>get the image, upload it to the correct dirctory and save successfully, but the 
>problem comes with the fact that i have to specify the filename. i want to know how 
>to grab the filename from the input of the following script (and by the way, i do not 
>take credit for this script. i've only been programming in perl for about a day)

It's best to use CGI.pm for uploads, it will handle the
filename for you.  In your upload form, set the param file.
See the sample html upload form at the end.
#upload.cgi
###
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;

$CGI::DISABLE_UPLOADS = 0;
my $query = new CGI;
my $upload_dir = "uploads";  #permissions for dir are set
 
my $file = $query->param("file");
my $filename = $file;
$filename =~s/.*[\/\\](.*)/$1/; #some taint checking
 
open (UPLOADFILE, ">$upload_dir/$filename");
while ( <$file> ){
print UPLOADFILE $_;
}
close UPLOADFILE;
 
print $query->header();
print <
 Thanks! 

Thanks for uploading file : $filename!


END_HTML


#upload.html
#

http://zentara.zentara.net/~zentara/cgi-bin/upload.cgi>

 


###


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Automatic URL Rewriting for session tracking?

2002-07-29 Thread zentara

On 28 Jul 2002 13:03:39 -, [EMAIL PROTECTED] (Gfoo) wrote:

>Hello...
>
>I can use Apache::Session to ease the use of sessions in an application I'm 
>developing. Session tracking can be implemented either by using (per-
>session) cookies or by writing the session_id in the GET URL (I' don't want 
>ot use hidden fields on forms to pass the id to next pages).
>
>My question:
>Is there a module or something out there, so that I can use Cookies to hold 
>(and pass) the session_id, but if cookies are disabled to automaticaly 
>append the session_id to the urls, transparently to the developer? I think 
>PHP does that...?

Go to www.stonehenge.com and check out Merlyn's Web Techniques Column
#61, from May 2001.   It describes basic cookie management. You will
have to test for your cookie, if it dosn't exist, then append to url.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




fetch CGI::Cookie Trouble

2002-07-29 Thread John Pitchko

Hey guys,

I am having trouble when accessing cookies we've created. I am using CGI::Cookie in a 
script to generate the cookie and send it to the browser. This seems to work fine, as 
the cookie is then saved and I can see it in my local Cookies folder on my computer. 
However, when using the fetch CGI::Cookie command, we get:

Can't call method "value" on an undefined value at /appl/webdocs/cgi-bin/verify.cgi 
line 45.

We are using the exact code from the manpage and have no idea why this is happening. 
Any suggestions?

Thanks,



John Pitchko
Data Services
Saskatchewan Government Insurance



RE: What's wrong with this code?

2002-07-29 Thread Kipp, James

you never executed the SQL statment
$sth->execute();

> -Original Message-
> From: Soheil Shaghaghi [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 2:05 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: What's wrong with this code?
> 
> 
> Hi everyone,
> Can anyone please tell me what the problem is with this code?
> Every time I run my program with this code in it, I get an 
> error in the log
> files:
> DBD::mysql::st fetchrow_array failed: fetch() without execute() at
> IWeb/sqlengine.pm line 3395.
> 
> 
> 
> sub SQL_Is_Sponsor {
>   my ($link_id) = @_;
>   my $is_sponsor = 0;
> 
>   if($link_id) {
> my $PriviledgeGroupID;
> $SQL = "SELECT account FROM HS_links WHERE id = $link_id";
> $sth = $dbh->prepare($SQL) || IWEB::SQL_ERROR($SQL);
> $rc = $sth->execute || IWEB::SQL_ERROR($SQL);
> 
> my($account) = $sth->fetchrow_array;
> 
> if($account) {
> $SQL = "SELECT PriviledgeGroupID FROM USERU 
> WHERE UserName =
> '$account'";
> $sth = $dbh_bac->prepare($SQL) || 
> IWEB::SQL_ERROR($SQL);
> $PriviledgeGroupID = $sth->fetchrow_array;
> }
> 
> foreach my $level(split(/:/, $global{'yh_sponsor_levels'})) {
> if($PriviledgeGroupID == $level) {
> $is_sponsor = 1;
> }
> }
> 
> return($is_sponsor);
>   }
> }
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: file timestamp monitoring

2002-07-29 Thread Steve Grazzini

Jason Viloria <[EMAIL PROTECTED]> wrote:
> 
> Can someone help me plaease use perl to monitor the timestamp
> of a text file to alert me if it is more than 1 minute old and run 
> an external program if so? 
> 
> I suppose a simple script which runs in cron would do the job but
> maybe someone else has a better solution?
> 

This just wakes up every 5 seconds to check the file.

If you want, figure out how many seconds you have left 
before it could possibly expire, and sleep that long...


#!/usr/bin/perl
# see also perldoc -q daemon

my $file  = 'foo.txt';
my $cmd   = "echo File '$file' has expired.";
my $limit = 60; 

my $already = 0;

while (1) {
my $mtime = (stat $file)[9];

die "file '$file' not found." unless -f _;
next if $mtime == $already;

if (time - $mtime > $limit) {
system($cmd) == 0 or
  warn "'$cmd' exited with status: ", $?>>8;
$already = $mtime;
next;
} 
$already = 0;
} 
continue { 
sleep 5;
}


-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]