Jump to content


Photo

perl/cgi help


  • Please log in to reply
7 replies to this topic

#1 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 02 May 2011 - 09:36 PM

Okay, how do I make this "chat room" registered users only with the code provided bellow:

##############################################
	# reg user check
	
	chmod (0600, "$cgi_path$reg_list");
	open (REGUSERS, "$cgi_path$reg_list");
	@reg_users = <REGUSERS>;
	close (REGUSERS);
	chmod (0200, "$cgi_path$reg_list");
	chomp(@reg_users);
	
	foreach $reg_user (@reg_users){
		($reg_name, $reg_password, $reg_message, $reg_url) = split (/\*/, $reg_user);
		$reg_message =~ s/\s*$//;
		if (($user eq $reg_name) and ($user_password eq $reg_password)){
			if($reg_url) {
				$reg_url =~ s/\s+$//;
				$FORM{'url'} = $reg_url;
			}
			$FORM{'message'} = $reg_message;
			$FORM{'reg'} = 'null';
		}elsif($user eq $reg_name){
			print <<PASSFORM;
$form_body
<CENTER><SMALL><b>$user</b> is a registered nickname.</SMALL></CENTER>
<table align=center><tr><td align=right>Enter password here:</td>
<td><form action="$ENV{'SCRIPT_NAME'}" METHOD=POST>
<input type=password name=password><input type=submit>
<input type=hidden name=username value="$FORM{'username'}">
<input type=hidden name=color value="$FORM{'color'}">
<input type=hidden name=room value="$FORM{'room'}">
<input type=hidden name=to value="$FORM{'to'}">
<input type=hidden name=logon value="">
<input type=hidden name=frames value="$FORM{'frames'}"></td>
<td> or <a href=\"$fileurl/$FORM{'room'}/chatform.html\">return</a>
to the form.</td></tr></table></form>
</body></html>
PASSFORM
			exit;
		}
	}

i can't figure it out :\

what the code that I provided does, if you ARE registered, you have to enter your password, but you can login as a guest or a registered user. I want it registered users ONLY.

Edited by derek.sullivan, 02 May 2011 - 09:37 PM.


#2 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 02 May 2011 - 10:51 PM

How do you login as a guest? If it's a particular username/password, i would check what is in the $reg_list file (whatever that is). If it is some other method, then i don't know. I don't see any guest-specific cases in that code.

Disclaimer: I've never worked with perl.

#3 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 03 May 2011 - 12:19 AM

rc, you type in a username FIRST, then if you are registered it will require your password, otherwise it will log you straight into the chat. Also, I figured out the problem lol

#4 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 03 May 2011 - 11:36 PM

Ok ya, looking at the code that makes sense now. That explains why the elseif part of the conditional in the foreach wasn't looking quite right to me.

Edited by rc69, 03 May 2011 - 11:40 PM.


#5 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 04 May 2011 - 01:07 AM

btw, i'm NOT a fan of perl/cgi programming

#6 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 04 May 2011 - 10:34 PM

Nope, php ftw ;)

Edited by rc69, 04 May 2011 - 10:35 PM.


#7 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 04 May 2011 - 11:08 PM

what is FTW?

#8 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 05 May 2011 - 10:36 AM

for the win :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users