Hello,

Thank you to everyone who as reponsed very good pointers, Tachyon-II thank you for the advice, we authenicate through IP based,
so lets say a University has access to the website which we see as one IP but many users are viewing the site this is acceptable.
We will later add cookie's but we must first crawl before we can walk.

I also took note of your code you posted and again thank you.
How ever I'm still having the same issue, I have tried a number of differant
options based on your example and did some googling on some leads but nothing seems to work for me.

So to make it easilier I have added pretty much everything and converted to your example so your not guessing on what I'm trying to do.

package Apache2::Authclients;
use strict;
use DBI;
use CGI qw(:standard);
use Apache2::RequestRec (); # for $r->content_type
use Apache2::Connection (); # for $c->remote_ip
use Apache2::SubRequest (); # for $r->internal_redirect
use Apache2::Const -compile => ':common';


sub handler
{
my $r = shift;
my $c = $r->connection();


if ( check_ip($c->remote_ip(), $r->dir_config('product')) )
{
$r->internal_redirect($r->uri);
}
else {
$r->internal_redirect('/path/to/login');
}


sub check_ip
{
my ($ip, $product) = @_;
my $user;
my $conn = DBI->connect("DBI:Sybase:<NAME-DATABASE-SERVER>", "<USERNAME>", "<PASSWORD>") || die DBI->errstr;
$conn->do("<NAME-DATABASE>") || die DBI->errstr;
my $qry = "exec <STORED-PROCEDURE> '" . $ip . "','" . $product . "'";
my $smt = $conn->prepare($qry) || die DBI->errstr;
$smt->execute() || die DBI->errstr;
while(my $var = $smt->fetchrow_arrayref)
{
$user = $var->[0];
}


$smt = undef;
$conn->disconnect;
return $user;
}
}
1;

I have also included my apache Dir.

<VirtualHost *>
DocumentRoot /var/www/html/<product>
ServerName <product_DNS_Name>


<Directory "/var/www/html/<product>">
SetHandler modperl
PerlSetVar product <product>
PerlResponseHandler Apache2::Authclients


allow from all
Options +Indexes
</Directory>


ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Apache/2.0.55
mod_perl/2.0.2
Perl/v5.8.7


I'm not totally sure on if the apache Dir is correctly done so I have included this as well.


The DBI is used to make a connection to the database which checks for IP and product access, it returns a 0 or 1.
For the CGI I need because of the dir_config.

Again thank you all for taking the time to look at my issues.
this is the first time I have really asked issues like this on a forum and I must say I am impressed with everyones enthusiasm to help with quick response times.

cheers
overworked

In reply to Re^2: Apache2 Mod_perl 2 without a endless loop of redirect by overworked
in thread Apache2 Mod_perl 2 without a endless loop of redirect by overworked

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.