#!/usr/local/bin/perl
#########################################################
#                                                       #
#                     RedirectPro                       #
#                                                       #
#########################################################
#                                                       #
#                      convert.pl                       #
#                                                       #
#   If you are upgrading from a previous version of     #
#   RedirectPro, configure, upload, CHMOD 755, and      #
#   run this script *once* to convert your old data     #
#   system into the new one.                            #
#                                                       #
#   If you have any further questions, direct them to   #
#   the support forum at http://www.go2cgi.com/         #
#                                                       #
#########################################################
#                                                       #
#         Copyright © 1999 W. Dustin Alligood           #
#                                                       #
#########################################################

# The path to the directory the user's accounts are
# placed in
$redirect='/data1/hypermart.net/go2/redirect';

# The path to the redirect script relative to the
# user's subdirectory
$rescript='../redirect.pl';

# Extention used to tell the server to parse for SSI
$ext='shtml';

# The path to the datafile
$datafile='/data1/hypermart.net/go2/redirect/data.txt';

# Change nothing below this line
#########################################################


print "Content-type: text/html\n\n";
print "<html><head><title>Datafile Converter</title></head><body><h2>Datafile Converter</h2><hr><br>\n";

open(DATA,"<$datafile");
	@subs=<DATA>;
close(DATA);

foreach $mbr (@subs){
	@data=split(/\|/,"$mbr");
	if(@data[3] ne ''){
		mkdir("$redirect/@data[0]", 0777);
		open(INDEX,">$redirect/@data[0]/index.$ext");
			if(@data[3] eq "popup"){
				print INDEX "<script language=\"JavaScript\"><!--\n";
				print INDEX "<!--#include virtual=\"$rescript?ad=popup&ct=@data[9]\"-->\n";
				print INDEX "//--></script>\n\n";
				print INDEX "<html><head><title>@data[2]</title><meta description=\"@data[7]\"><meta keyword=\"@data[8]\"></head>\n";
				print INDEX "<frameset rows=\"100%,*\" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>\n";
				print INDEX "<frame src=\"@data[1]\" NAME=\"MAIN_FRAME\" SCROLLING=\"AUTO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=3 MARGINWIDTH=3>\n";
				print INDEX "</frameset></html>\n\n";
			}elsif(@data[3] eq "delay"){
				print INDEX "<html><head><title>@data[2]</title><meta description=\"@data[7]\"><meta keyword=\"@data[8]\"><meta http-Equiv=\"refresh\" content=\"8; url=@data[1]\"></head><body>\n";
				print INDEX "<table border=0 width=100% height=95%><tr><td valign=middle><!--#include virtual=\"$rescript?ad=delay&ct=@data[9]\"-->\n";
				print INDEX "<p><center>Please wait while you're taken to <a href=\"$fild{'u'}\">@data[2]</a>.</center></p>\n";
				print INDEX "</td></tr></table></body></html>\n\n";
			}elsif(@data[3] eq "frame"){
				print INDEX "<html><head><title>@data[2]</title><meta description=\"@data[7]\"><meta keyword=\"@data[8]\"></head>\n";
				print INDEX "<frameset rows=\"62,*\" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>\n";
				print INDEX "<frame src=\"<!--#include virtual=\"$rescript?ad=frame&ct=@data[9]\"-->\" NAME=\"AD_FRAME\" SCROLLING=\"NO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0>\n";
				print INDEX "<frame src=\"@data[1]\" NAME=\"MAIN_FRAME\" SCROLLING=\"AUTO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=3 MARGINWIDTH=3>\n";
				print INDEX "</frameset></html>\n\n";
			}else{
				print INDEX "<html><head><title>@data[2]</title><meta description=\"@data[7]\"><meta keyword=\"@data[8]\"></head>\n";
				print INDEX "<frameset rows=\"100%,*\" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>\n";
				print INDEX "<frame src=\"@data[1]\" NAME=\"MAIN_FRAME\" SCROLLING=\"AUTO\" NORESIZE FRAMEBORDER=0 BORDER=0 MARGINHEIGHT=3 MARGINWIDTH=3>\n";
				print INDEX "</frameset></html>\n\n";
			}
		close(INDEX);
		chmod("$redirect/@data[0]/index.$ext",0777);
		print "@data[0] conversion completed<br>\n";
	}
}

print "<br><br><hr><br><h2>Finished</h2></body></html>\n";