.htaccess / .htpasswd

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
brockuk
-


Joined: 10 May 2003
Posts: 5

PostPosted: Tue May 13, 2003 12:54 am    Post subject: .htaccess / .htpasswd Reply with quote

I wish to add a members only area to my web site using htaccess and htpasswd. I would use the applications featured in abyss but i want automatic member updates. Does htaccess work on Abyss?
If so why cant i get it to work?
Back to top View user's profile Send private message
Deledar
-


Joined: 26 Feb 2003
Posts: 94

PostPosted: Tue May 13, 2003 1:43 am    Post subject: Reply with quote

.htaccess I think only works with Apache, why not use the feature where you can user/password protect your webpage in the Abyss control panel?
Back to top View user's profile Send private message
brockuk
-


Joined: 10 May 2003
Posts: 5

PostPosted: Tue May 13, 2003 4:17 pm    Post subject: htaccess Reply with quote

i want automated membership and i dont think abyss does that! Does any one know of a password script that doesnt use htaccess?
Back to top View user's profile Send private message
rockslammer
-


Joined: 19 Jun 2003
Posts: 5

PostPosted: Thu Jun 26, 2003 7:16 am    Post subject: Re: htaccess Reply with quote

brockuk wrote:
i want automated membership and i dont think abyss does that! Does any one know of a password script that doesnt use htaccess?


read what i posted in the php it doesn't work in the PHP section
http://www.aprelium.com/forum/viewtopic.php?t=1813

I am trying to do the same thing -

I'm using ABYSS is a windows development server - so i dont have to boot into LINUX to run apache.

As far as i can tell, the htaccess is in the main server config file
there are not seperate htaccess and password files in each directory like in Apache.

I tried to use the _AUTH and _PASSWORD routines in PHP but pointed to a file I made called members.dat ( usr:pass) to no avail.

If u have a good script in perl that will do the array and split right for the authorize would you please post it... Ive got a good script running to write the users after some tweeking to get the format user:password in abyss.
this will work to write your users to a file
!/usr/bin/perl
################################################################################
# User manager Version 1.1 #
# Copyright 2001 Ray Jones ray@rjj.uk.co #
# Created 12/11/2001 Last Modified 12/02/2002 #
################################################################################
# COPYRIGHT NOTICE #
# Copyright 2001 Ray Jones All Rights Reserved. #
# #
# User manager may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Ray Jones from any liability that might arise #
# from it's use. #
################################################################################
# CONFIGURE THIS SCRIPT #
# To configure this script you will need to: #
# Modify the $pathtouserfile variable so it points to your database of users. #
# Modify $goodfile to point to a web page you want succesful new users load. #
# Modify $basedir to point to your actual path that holds your home page #
# Modify $sacrificefile to point at any empty and unused file #
# If you use different names for your form fields, you will need to modify the #
# names for $username, $password, $conpass, and $email. #
# FORM ACTION #
# Don't forget to change the URL in your form's action field so it points to #
# this file #
################################################################################
# Bug Fixes in Version 1.1 - 11.02.2002 #
# Two new lines have been added to specify the $basedir and $sacrificefile #
# variables as these were missing in version 1.0 #
################################################################################
# Set Variables

################################################################################
###### Get form fields values and time #
################################################################################

&Parse_Form;
chop;
get_lock();
$pathtouserfile = "dp/members.dat";
$basedir = "C:\\Program%20Files\\Abyss%20Web%20Server\\htdocs";
$sacrificefile = "C:\\Program%20Files\\Abyss%20Web%20Server\\cgi-bin\\dp\sacrifice.txt";
$username = $formdata{'user'};
$password = $formdata{'password'};
$conpass = $formdata{'cpass'};
$goodfile = "http://your domain/ok.html";

################################################################################
###### open user and password file for reading #
################################################################################

open (USER,"< $pathtouserfile");
@userdat=<USER>;
close USER;

################################################################################
##### prepare to test user id and output relevant html files. #
################################################################################

$found=0;
$counter=0;

################################################################################
##### Test for blank entries #
################################################################################

if (($username)&&($password)&&($conpass)) {

} else {
&blankfields;
exit;
}

################################################################################
##### testing for the existence of the parsed user #
################################################################################

foreach $count (@userdat) {
if ($count=~/^$username:/) {
$found=1;
} else {
}
$counter++;
}

################################################################################
##### Test password is confirmed #
################################################################################

if ($password eq $conpass) {
$passwrd=0;
} else {
$passwrd=1;
}

################################################################################
##### Outputting files. Goodfile if succesful, Badfile if unsuccesful #
################################################################################

&get_lock;
if (($passwrd eq "0")&&($found eq "0")) {
open (USER, ">> $pathtouserfile") || die "cannot open the user data file to write";
print USER "${username}:${password}\n";
close USER;
print "content-type:text/html\n\n";
print "<html><head><title>HTML document</title></head><body>";
print "<table width='700' height='400' align='center'> ";
print "<tr>";
print "<td align='center' valign='center'>";
print "<h1><center>Thank you for your purchase $username<center></h1>";
print "<h2><center>Please make a note of your username and password as you will need them to login.<center></h2>";
print " ";
print "<h1><center>Your username is : $username.<center></h1>";
print "<h1><center>Your password is : $password.<center></h1>";
print "<h2><center>Thank you for registering. You may click the link below for the help desk.<center></h2>";
print " ";
print "<h3><center><a href=$goodfile>Click if you need help with the program</a><center></h3>";
print "</td>";
print "</tr>";
print "</body></html>";
exit;
} else {
&userexists;
exit;
}
release_lock();

################################################################################
##### output file Note this section 'stolen' from 'Web Commerce Cookbook' by Gordon
##### McComb. pages 149 to 152. published by Wiley computer publishing 1998.
##### ISBN 0-471-19663-0
################################################################################

sub send_file {
local($file) = @_;
unless(open(FILE,$file)) {
&sys_error("Failed to open file $file\n");
exit;
}
print "Content-type: text/html\n\n";
$line=0;
while (<FILE>) {
$line++;
if ($line eq "78") {
foreach $key (keys %formdata) {
print "<INPUT TYPE=hidden NAME=$key VALUE=$formdata{$key}>\n";
}
} else {
}
print;
}
close(FILE);
}

################################################################################
###### Lock files to prevent multi-use #######
################################################################################

use Fcntl qw(:flock);
my $sacrificial="$basedir$sacrificefile";
sub get_lock {
open(SEM, ">Ssacrificial") || die "Cannot create sacrificial file: $!";
flock(SEM, LOCK_EX) || die "Cannot lock file: $!";
}

################################################################################
###### UnLock files after preventing multi-use #######
################################################################################

sub release_lock {
close(SEM);
}

################################################################################
###### Parse the form #######
################################################################################

sub Parse_Form {
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

if ($ENV{'QUERY_STRING'}) {
@getpairs =split(/&/, $ENV{'QUERY_STRING'});
push(@pairs,@getpairs);
}
} else {
print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}

foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~s/<!--(.|\n)*-->//g;

if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
}
1;


################################################################################
###### Error - blank fields #######
################################################################################

sub blankfields {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'> </td>";
print "<td align='center'> </td>";
print "<td align='center'> </td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'> </td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed registration!!</font></h1>";
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>There are some fields that have not been </h3>";
print "<h3 align='center'>completed.</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</table>";
print "</body>";
print "</html>";
}

################################################################################
###### Error - user exists #######
################################################################################

sub userexists {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'> </td>";
print "<td align='center'> </td>";
print "<td align='center'> </td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'> </td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed registration!!</font></h1>";
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>This username already exists</h3>";
print "<h3 align='center'> or </h3>";
print "<h3 align='center'>your passwords do not match</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</body>";
print "</html>";
}

This is the sign in script - I cant get this bugger to work LOL . If anyone can tweek this and get it to authorize - please post the revision..

#!/usr/bin/perl -w
################################################################################
# User manager Version 1.0 #
# Copyright 2001 Ray Jones ray@rjj.uk.co #
# Created 12/11/2001 Last Modified 12/11/2001 #
################################################################################
# COPYRIGHT NOTICE #
# Copyright 2001 Ray Jones All Rights Reserved. #
# #
# User manager may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Ray Jones from any liability that might arise #
# from it's use. #
################################################################################
# CONFIGURE THIS SCRIPT #
# To configure this script you will need to: #
# Modify the $pathtouserfile variable so it points to your database of users. #
# Modify $successfilepath to point to a web page you want succesful logins to #
# load. A sample page is included with User Manager for completeness only. #
# If you use different names for your form fields, you will need to modify the #
# names for $username and $userpass. #
# FORM ACTION #
# Don't forget to change the URL in your form's action field so it points to #
# this file #
################################################################################
# Set Variables

################################################################################
###### Get form fields values and time #
################################################################################

&Parse_Form;
chop($date=&ctime(time));
get_lock();

################################################################################
###### create variables for script #
################################################################################

$username = $formdata{'user'};
$userpass = $formdata{'password'};
$pathtouserfile = "d:/home/rjjlinks/cgi-bin/user.dat";
$successfilepath = "d:/home/rjjlinks/adduser/success.html";

################################################################################
###### Check the user is not trying to pass a command #
################################################################################

if ($formdata{'user'}=~/\W/ || $formdata{'password'}=~/\W/) {
&illegal;
exit;
} else {
}

################################################################################
###### Check the filled in at least one field #
################################################################################

if (($userpass eq '') && ($username eq '')) {
&noinfo;
exit;
} else {
}

################################################################################
###### Check the user has included a username #
################################################################################

if ($username ne '') {
} else {
&nouser;
exit;
}

################################################################################
###### Check the user has included a password #
################################################################################

if ($userpass ne '') {
} else {
&nopass;
exit;
}
################################################################################
###### open user and password file for reading #
################################################################################

open (USER,"< $pathtouserfile");
@userdat=<USER>;
close USER;

################################################################################
##### prepare to test user id and output relevant html files. #
################################################################################

$found=0;
$counter=0;

################################################################################
##### testing for the existence of the parsed user #
################################################################################

foreach $count (@userdat) {
if ($count=~/^$formdata{'user'}::$formdata{'password'}:/) {
$found=1;
$foundloc=$counter;
} else {
}
$counter++;
}

################################################################################
##### Outputting files. Goodfile if succesful, Badfile if unsuccesful #
################################################################################

if ($found eq "1") {
&send_file($successfilepath);
exit;
} else {
&faillogin;
exit;
}

################################################################################
##### End of CGI script #
################################################################################

################################################################################
##### output file Note this section 'stolen' from 'Web Commerce Cookbook' by Gordon
##### McComb. pages 149 to 152. published by Wiley computer publishing 1998.
##### ISBN 0-471-19663-0
################################################################################

sub send_file {
local($file) = @_;
unless(open(FILE,$file)) {
&sys_error("Failed to open file $file\n");
exit;
}
print "Content-type: text/html\n\n";
$line=0;
while (<FILE>) {
$line++;
if ($line eq "78") {
foreach $key (keys %formdata) {
print "<INPUT TYPE=hidden NAME=$key VALUE=$formdata{$key}>\n";
}
} else {
}
print;
}
close(FILE);
}

################################################################################
###### Lock files to prevent multi-use #######
################################################################################

use Fcntl qw(:flock);
my $sacrificial="$basedir$sacrificefile";
sub get_lock {
open(SEM, ">Ssacrificial") || die "Cannot create sacrificial file: $!";
flock(SEM, LOCK_EX) || die "Cannot lock file: $!";
}

################################################################################
###### UnLock files after preventing multi-use #######
################################################################################

sub release_lock {
close(SEM);
}

################################################################################
###### Parse the form #######
################################################################################

sub Parse_Form {
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

if ($ENV{'QUERY_STRING'}) {
@getpairs =split(/&/, $ENV{'QUERY_STRING'});
push(@pairs,@getpairs);
}
} else {
print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}

foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~s/<!--(.|\n)*-->//g;

if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
}
1;

################################################################################
###### Get the time #######
################################################################################

;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function.
#
# This library is no longer being maintained, and is included for backward
# compatibility with Perl 4 programs which may require it.
#
# In particular, this should not be used as an example of modern Perl
# programming techniques.
#
# Suggested alternative: the POSIX ctime function
;#
;# Waldemar Kebsch, Federal Republic of Germany, November 1988
;# kebsch.pad@nixpbe.UUCP
;# Modified March 1990, Feb 1991 to properly handle timezones
;# $RCSfile: ctime.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:23:47 $
;# Marion Hakanson (hakanson@cse.ogi.edu)
;# Oregon Graduate Institute of Science and Technology
;#
;# usage:
;#
;# #include <ctime.pl> # see the -P and -I option in perl.man
;# $Date = &ctime(time);

CONFIG: {
package ctime;

@DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
@MoY = ('Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec');
}

sub ctime {
package ctime;

local($time) = @_;
local($[) = 0;
local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);

# Determine what time zone is in effect.
# Use GMT if TZ is defined as null, local time if TZ undefined.
# There's no portable way to find the system default timezone.

$TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '';
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
($TZ eq 'GMT') ? gmtime($time) : localtime($time);

# Hack to deal with 'PST8PDT' format of TZ
# Note that this can't deal with all the esoteric forms, but it
# does recognize the most common: [:]STDoff[DST[off][,rule]]

if($TZ=~/^([^:\d+\-,]{3,})([+-]?\d{1,2}(:\d{1,2}){0,2})([^\d+\-,]{3,})?/){
$TZ = $isdst ? $4 : $1;
}
$TZ .= ' ' unless $TZ eq '';

$year += 1900;
sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n",
$DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);
}
1;


################################################################################
###### Error - illegal characters #######
################################################################################

sub illegal {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed Login</font></h1>";
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>Some of the characters you typed</h3>";
print "<h3 align='center'>cannot be used in this form</h3>";
print "<h3 align='center'>please use only alphanumeric text</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</body>";
print "</html>";
}

################################################################################
###### Error - forgot to enter user #######
################################################################################

sub nouser {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed Login</font></h1>";
print $test;
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>You forgot to enter your username</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</body>";
print "</html>";
}

################################################################################
###### Error - failed login #######
################################################################################

sub nopass {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed Login</font></h1>";
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>You forgot to enter your password</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</body>";
print "</html>";
}

################################################################################
###### Error - failed login #######
################################################################################

sub noinfo {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed Login</font></h1>";
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>You left both fields blank</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</body>";
print "</html>";
}


################################################################################
###### Error - illegal characters #######
################################################################################

sub faillogin {

print "content-type:text/html\n\n";
print "<html>";
print "<head>";
print "</head>";
print "<body>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "<td align='center'>&nbsp;</td>";
print "</tr>";
print "</table>";
print "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print "<tr>";
print "<td width='20'>&nbsp;</td>";
print "<td width='370' align='center' valign='top'>";
print "<h1><font color='#000000'>Problem</font></h1>";
print "<h1><font color='#FF0000'>Failed Login</font></h1>";
print "</td>";
print "<td width='10'></td>";
print "<td align='left' valign='top'>";
print "<h1 align='center'>Reason</h1>";
print "<h3 align='center'>The username and password you provided</h3>";
print "<h3 align='center'>has not been authorised. Either you do not</h3>";
print "<h3 align='center'>have a username for this site, or you have</h3>";
print "<h3 align='center'>forgotten your username or password</h3>";
print "<h3 align='center'>";
print "<input type='submit' name='Go Back to Form' value='Try Again'";
print "onclick='javascript:history.back(1)'>";
print "</h3>";
print "</td>";
print "</tr>";
print "</body>";
print "</html>";
}


The found= and the count= yield errors. I dont think the @data works right, doesn't seem to do the split and && to = a good user:pass match. **note <Ssacracicial (*typ-0?)

I haven't had enough time to play with it. Ray's scripts have some good ideas but I have always had to do a lot of modifications. I took the time routine and emailout of the adduser script . My thinking is that - have them do a send mail form first then let sendmail forward a link to the adduser form.shtml with a redirect so that you get good emails.


rock
Back to top View user's profile Send private message
JohnC
-


Joined: 09 Oct 2003
Posts: 34

PostPosted: Thu Oct 09, 2003 5:28 pm    Post subject: Reply with quote

Dunno about making it work, rockslammer - but here is a BIG TIP that will save you heaps of time and effort... use "print qq"

Just type that, then ANY character. Then put all your plain text (and any $vars you want), then close it with the same "special" character and a semi-colon.

This makes Perl work kinda like ASP or PHP (sortof) - you can use plain HTML, and span multiple lines! Also, it allows you to use " and ' chars without escaping them - you ONLY have to escape the "special" character you use to start and end the command with (eg: if you use ~, then to print an ~ you gotta use \~ instead)

for example :

Code:
print qq~
<TABLE>
<TR>
... plain HTML and/or $vars inside here...
</TR>
</TABLE>
~;


Once you use print qq, you'll never use a " again !
Back to top View user's profile Send private message
rockslammer_
-


Joined: 19 Sep 2003
Posts: 6
Location: Michigan

PostPosted: Fri Dec 19, 2003 12:17 am    Post subject: Problem solved--August 2003 Reply with quote

Re: the above suggestion

print qq~
<TABLE>
<TR>
... plain HTML and/or $vars inside here...
</TR>
</TABLE>
~;

That works too, LOL :D
A lot of the scripts that I am converting were
written for UNIX in all arcane code,
start mixing stuff together and it becomes the
lowest common denominator, doesn't a camel
have 2 ____"quotes"____ on his back?
not ASP ish LOL :P



Anyway-

I got this thing to work the end of August, Had to add a _
to my old user name Forgot my PASSWORD ! ROFLMAO.

Now I stumbled across the original post -

So, here is a way to have a new member create an account and
be able to have immediate access.

NOTE: You want to hard code the html of the member's page
into the script.

However, You might use an <IFRAME that displays
a frameset or html page within the script -

WARNING WILL ROBINSON:

Realise that someone can find the URL from the source of
the Perl generated page and hot link to it without logging in if you <IFRAME.

ALSO, any regular html link that is hard coded in can be linked back
to as a favorite, etc...

I have made some of my links .pl files that envelope the refering
URL then match the referer to URL that I want used or redirect a saved
or pasted link to a login page.


Here is the login that works - the write user&&Password delimiters
have to be changed to match the login script

NO CAPITAL LETTERS IN THE user or passsword
are allowed

:: becomes ; and $dummy <> is added at the end

Also, I removed the ctime routine in the script I posted.
It wasn't important and was part of the problem with the
original scripts. White spaces and too many :: delimiters.



This script is logging in 100-300 users a day on Abyss/win NTFS
from a 3300 line file without problems :D

My Abyss server is handling 3000-6000 page requests per
day now. BTW


use CGI::Carp qw( fatalsToBrowser ); #comment ( fatalsToBrowser ) out when you are#
#done configuring as well as the -w in line 1#

#$basedir = "C:\Program Files\Abyss Web Server/htdocs";#path to server's public html#
print "Content-Type: text/html\n\n";
$suppress_characters = "1"; #if you change this to '0' shell commands can be passed#
$exclude = "%&|><:;$ (){}[]^#@!~+='\"?.,|\\*`";

sub parse_form
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM{$name} = $value;
}
}


#check the password user pair for illegal char and validate or reject#
sub check_pass
{
$userid = $FORM{'userid'};
$password = $FORM{'password'};
if ($suppress_characters eq "1") {

if ($userid=~/[$exclude]/ || $password=~/[$exclude]/) {

&illegal;
exit;
}
}

if (length($userid) <= 0 && length($password) <= 0)#reject empty fields#
{
print STDOUT "<CENTER><h2><font color=\"#FF0000\">You are Not Authorized to Access this Page.</font><BR>";
print STDOUT "Reason - EMPTY FIELDS</h2>";
print STDOUT "<P><h3>Go Back to the form and try again</h3></P></CENTER>";
die;
}
open(PASSFILE,"1jdue8ie/sjeu48ek.dat");
#change this to the path to your data file
#use random directory and filename
#as the file needs to be writable to the
#public in the make user pass script
#DO NOT STORE ANY FININCIAL OR OTHER SENSITIVE
#DATA IN THIS FILE - This is just a member login thing-
#It should not be considered secure

$/ = "<>";
$passtrue = 0;
#change the 1st script delimiting parameters
#to match the below
#user;password<>

while (<PASSFILE>)
{
@dummy = split("<>",$_);
@passrec = split(";",$dummy[0]);#the ; could be modified to :: | or : if you have current file to match#
@user = split(" ",$passrec[0]);
@pass = split(" ",$passrec[1]);
if (($user[0] eq $userid) && ($pass[0] eq $password))
{
$passtrue = 1;
last;
}
else
{
$passtrue = 0;
}
}
close(PASSFILE);
}

&parse_form;
&check_pass;
if ($passtrue == 1)
{
select STDOUT;
print "<HTML>";
print STDOUT "<html>\n";
print STDOUT "<head>\n";
print STDOUT "<title></title>\n";
print STDOUT "<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>\n";
print STDOUT "</head>\n";
#MORE HTML STUFF
print STDOUT "</body>\n";
print STDOUT "</html>\n";
}
else
{
print STDOUT "<CENTER><h2><font color=\"#FF0000\">You are Not Authorized to Access this Page.</font><h2>";
print STDOUT "<h3 align='center'>Reason - No such user or password</h3>";
print STDOUT "<h3 align='center'>Illegal Symbols! or..<BR></h3>";
print STDOUT "<h3 align='center'>Your password does not match.";
print STDOUT "<P>Go Back to the form and try again</P></h3></CENTER>";


die;
}

#########################################################################################
###### Error - user is sending illegal characters #####
###### This sub isn't working right - I ran out of patience feel free to fix it and #####
###### email me the fix barry /at compro-serve./com #####
#########################################################################################

sub illegal {
select STDOUT;
print "<HTML>";

print STDOUT "content-type:text/html\n\n";
print STDOUT "<html>";
print STDOUT "<head>";
print STDOUT "</head>";
print STDOUT "<body>";
print STDOUT "<table width='770' border='0' cellspacing='0' cellpadding='0' height='15'>";
print STDOUT "<tr>";
print STDOUT "<td width='20'>&nbsp;</td>";
print STDOUT "<td align='center'>&nbsp;</td>";
print STDOUT "<td align='center'>&nbsp;</td>";
print STDOUT "</tr>";
print STDOUT "</table>";
print STDOUT "<table width='770' border='0' cellspacing='0' cellpadding='0' name='Content' height='265'>";
print STDOUT "<tr>";
print STDOUT "<td width='20'>&nbsp;</td>";
print STDOUT "<td width='370' align='center' valign='top'>";
print STDOUT "<h1><font color='#000000'>IO ERROR<BR>ILLEGAL SYMBOLS</font></h1>";
print STDOUT "<h1><font color='#FF0000'>Failed request</font></h1>";
print STDOUT "</td>";
print STDOUT "<td width='10'></td>";
print STDOUT "<td align='left' valign='top'>";
print STDOUT "<h1 align='center'>Reason</h1>";
print STDOUT "<h3 align='center'>Some symbols are not allowed</h3>";
print STDOUT "<h3 align='center'></h3>";
print STDOUT "<h3 align='center'>Please go back and use alphanumeric characters or _ for a space.</h3>";
print STDOUT "<h3 align='center'>";
print STDOUT "<input type='submit' name='Go Back to Form' value='Try Again'";
print STDOUT "onclick='javascript:history.back(1)'>";
print STDOUT "</h3>";
print STDOUT "</td>";
print STDOUT "</tr>";
print STDOUT "</body>";
print STDOUT "</html>";
}

barry at compro-serve/./com
http://www.compro-serve.com/web/
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group