#!/usr/bin/perl
# Get the environment variables passe to the script
use DBI;
use CGI qw/:standard :html3 :netscape/;
printheader();
process_file();
print "<br><hr>DONE WITH IMPORT\n";
printending();
exit(0);
##############################################################################
################### GENERIC PAGE SETUP HEADING AND METADATA ###################
##############################################################################
sub printheader() {
$description = "AgentRobin Tri-valley Real Estate";
# print "<!DOCTYPE html '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>";
print "Content-type: text/html\n\n";
print "<HTML xmlns='http://www.w3.org/1999/xhtml'>\n";
print "<HEAD>\n";
print "<TITLE>HELLO</title>\n";
print "</head>\n";
print "<body>\n";
}
################### GENERIC PAGE SETUP ENDING ###################
sub printending {
print "</body>\n";
print "</html>\n";
}
sub process_file() {
$dbh = DBI->connect('dbi:mysql:dreamhome_01_:dobrooks.ipowermysql.com:3306','agentrobin_01_','J0shKr1s') or die("Couldn't connect");
$filename = "REGlossary.txt";
open(MLSLIST, $filename) || die("Could not open file!");
@Lines = <MLSLIST>;
close MLSLIST;
$ncount=@Lines;
print "Starting the import process on $ncount lines<br>\n";
print "<hr>";
$count=0;
for ($x = 0;$x <= $ncount-1;$x++) {
$Lines[$x] =~ s/%([1-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$Lines[$x+1] =~ s/%([1-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$id = $count;
$term = $Lines[$x];
$desc = $Lines[$x+1];
$SQL1 = "INSERT INTO `Glossary` ( `id` , `term` , `desc` , `other`) VALUES ('$id', '$term', '$desc', 'none')";
$sth = $dbh->prepare($SQL1);
$sth->execute;
$count++;
$x=$x+1;
$zline = "$id : $term : $desc";
print "$zline<br>\n\n";
}
$dbh->disconnect;
}