I am not sure if this is the right form or not, but I figured it fit best here. I know you guys are smart programmers and problem solvers so I thought I would try to get this figured out here.
I have a script that creates a community, and it gives each user space almost like geocites. I run banners on their pages, but if they upload a picture and someone goes right to that pic, then it won't show a banner. I have a solution from the users that use the community same script I have but what they suggestion won't quite work. They suggestion I use a parse.cgi file, and then use .htaccess to run a popup banner on any file that don't have my banner on it now.
ok, here is the parse.cgi file they told me about:
#!/usr/bin/perl
# this is the url for your banner file for the popup
# this directory should be above or on a different domain then
# the directory you are parsing or you'll get a bad loop
# banner.html will also be called from this directory
$config{'BANNER_URL'} = 'http://www.yourdomain.com/banner';
# this is the path to your banner directory where banner.html
# which contains your banner code is located
$config{'BANNER_PATH'} = '/home/sites/path/to/banners';
# this is the path to the base of your web directory
# this probably will match the code in your htaccess/http.conf file
$config{'BASE_DIR'} = "/home/sites/path/to/base";
$|=1;
print "Content-type: text/html\n\n";
## GET FILE CALLED ###
if ($ENV{'REQUEST_URI'} =~ /\/$/) {
$ENV{'REQUEST_URI'} = $ENV{'REQUEST_URI'} . "index.html";
}
### GET AND STRIP PATH INFO ###
$ENV{'REQUEST_URI'} =~ s/\.(s*)html\/(.*)$/\.$1html/gi;
my $path_info = $2;
### GET AND STRIP QUERY INFO ###
$ENV{'REQUEST_URI'} =~ s/\?(.*)$//gi;
my $query_info = $2;
### SET BASE DIRECTORY PLUS FILE ###
my $base_dir = $config{'BASE_DIR'} . $ENV{'REQUEST_URI'};
#### OPEN FILE ####
undef $/;
open (DAT,"<$base_dir") || print("nope $base_dir");
my $content = <DAT>;
close (DAT);
if ($content =~ m/<%PRINT_BANNER%>/i) {
unless($content =~ m/<!--<%PRINT_BANNER%>-->/i) {
open (BANNER,"$config{'BANNER_PATH'}/banner.html") || print("nope $config{'BANNER_PATH'}/banner.html");
my $replace = <BANNER>;
close (BANNER);
$content =~ s/<%PRINT_BANNER%>/$replace/gi;
}
else { &popup; }
}
else { &popup; }
sub popup {
# generate random window name
srand(time);
my $window;
my @passset = ('a'..'z', 'A'..'Z', '1'..'9');
for (my $i = 0; $i < 10; $i++) {
my $randum_num = int(rand($#passset + 1));
$window .= @passset[$randum_num];
}
$content .= qq~
<script language='Javascript'>
function WinOpen(src)
{
OpenWin = window.open(src, '$window')
OpenWin.focus()
}
<!--
window.open('$config{'BANNER_URL'}/banner.html',
'$window',
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,wid th=520,hei-ght=110');
// -->
</SCRIPT>
~;
}
$html .= $content;
print $html;
And here is the .htacess file they told me to use:
RewriteEngine on
RewriteRule \/(.*(\.htm|\.html|\.shtml|.{0}))$ /location_to/parse.cgi [T=application/x-httpd-cgi]
Now it works. If I go to the parse.cgi file, it will bring up a pop-up banner, but if I go to my members pages, html or pics it give me a 500 error. Does anyone see anything wrong with these two pieces of code that would cause all my file not to show up and give a error. I think it has to do with the .htaccess file in my members diretory. Everything work up to that point, and everything worked before I put it in my members directory.
Any help would be appreciated.
Jamie
I have a script that creates a community, and it gives each user space almost like geocites. I run banners on their pages, but if they upload a picture and someone goes right to that pic, then it won't show a banner. I have a solution from the users that use the community same script I have but what they suggestion won't quite work. They suggestion I use a parse.cgi file, and then use .htaccess to run a popup banner on any file that don't have my banner on it now.
ok, here is the parse.cgi file they told me about:
#!/usr/bin/perl
# this is the url for your banner file for the popup
# this directory should be above or on a different domain then
# the directory you are parsing or you'll get a bad loop
# banner.html will also be called from this directory
$config{'BANNER_URL'} = 'http://www.yourdomain.com/banner';
# this is the path to your banner directory where banner.html
# which contains your banner code is located
$config{'BANNER_PATH'} = '/home/sites/path/to/banners';
# this is the path to the base of your web directory
# this probably will match the code in your htaccess/http.conf file
$config{'BASE_DIR'} = "/home/sites/path/to/base";
$|=1;
print "Content-type: text/html\n\n";
## GET FILE CALLED ###
if ($ENV{'REQUEST_URI'} =~ /\/$/) {
$ENV{'REQUEST_URI'} = $ENV{'REQUEST_URI'} . "index.html";
}
### GET AND STRIP PATH INFO ###
$ENV{'REQUEST_URI'} =~ s/\.(s*)html\/(.*)$/\.$1html/gi;
my $path_info = $2;
### GET AND STRIP QUERY INFO ###
$ENV{'REQUEST_URI'} =~ s/\?(.*)$//gi;
my $query_info = $2;
### SET BASE DIRECTORY PLUS FILE ###
my $base_dir = $config{'BASE_DIR'} . $ENV{'REQUEST_URI'};
#### OPEN FILE ####
undef $/;
open (DAT,"<$base_dir") || print("nope $base_dir");
my $content = <DAT>;
close (DAT);
if ($content =~ m/<%PRINT_BANNER%>/i) {
unless($content =~ m/<!--<%PRINT_BANNER%>-->/i) {
open (BANNER,"$config{'BANNER_PATH'}/banner.html") || print("nope $config{'BANNER_PATH'}/banner.html");
my $replace = <BANNER>;
close (BANNER);
$content =~ s/<%PRINT_BANNER%>/$replace/gi;
}
else { &popup; }
}
else { &popup; }
sub popup {
# generate random window name
srand(time);
my $window;
my @passset = ('a'..'z', 'A'..'Z', '1'..'9');
for (my $i = 0; $i < 10; $i++) {
my $randum_num = int(rand($#passset + 1));
$window .= @passset[$randum_num];
}
$content .= qq~
<script language='Javascript'>
function WinOpen(src)
{
OpenWin = window.open(src, '$window')
OpenWin.focus()
}
<!--
window.open('$config{'BANNER_URL'}/banner.html',
'$window',
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,wid th=520,hei-ght=110');
// -->
</SCRIPT>
~;
}
$html .= $content;
print $html;
And here is the .htacess file they told me to use:
RewriteEngine on
RewriteRule \/(.*(\.htm|\.html|\.shtml|.{0}))$ /location_to/parse.cgi [T=application/x-httpd-cgi]
Now it works. If I go to the parse.cgi file, it will bring up a pop-up banner, but if I go to my members pages, html or pics it give me a 500 error. Does anyone see anything wrong with these two pieces of code that would cause all my file not to show up and give a error. I think it has to do with the .htaccess file in my members diretory. Everything work up to that point, and everything worked before I put it in my members directory.
Any help would be appreciated.
Jamie
Comment