MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/web/web/web/b2432/agentrobin.com/
File Upload :
Current < : /hermes/sb_web/web/web/web/b2432/agentrobin.com/run_sql.pl

#!/usr/bin/perl

# Get the environment variables passe to the script


use DBI; 
use CGI qw/:standard :html3 :netscape/;


$db_user     = "agentrobin_01_";
$db_pass     = "J0shKr1s";
$dsn_name    = 'dbi:mysql:dreamhome_01_:dobrooks.ipowermysql.com:3306';
$filename="";

@FormValues = split(/&/, $ENV{QUERY_STRING});
$FV1 = @FormValues;
for ($x=0;$x<=$FV1-1;$x++) {

	@Attributes = split(/=/,$FormValues[$x]);

	if ($Attributes[0] eq "filename") { 
		$filename=$Attributes[1]; $filename =~ tr/+/ /; $filename =~ s/%([1-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	}
}


printheader();

print "PROCESSING FILE $filename<br>\n";

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() {

	if ($filename eq "") {
		print "NO FILENAME\<br>\n";
	} else {
		open(MLSLIST, $filename) || die("Could not open file!");
		@Lines = <MLSLIST>;
		close MLSLIST;

		$dbh = DBI->connect('dbi:mysql:dreamhome_01_:dobrooks.ipowermysql.com:3306','agentrobin_01_','J0shKr1s') or die("Couldn't connect"); 




		$ncount=@Lines;
		print "Starting the import process on $ncount lines<br>\n";
		print "<hr>";
	

	
		$count=0;

# $ncount-1

		for ($x = 0;$x <= $ncount-1;$x++) {

			$SQL="$Lines[$x]";
			print "$x --  $Lines[$x]<br>\n";
			$sth = $dbh->prepare($SQL);
			$sth->execute;    
			$count++;
		} 

	}
	TEST1:
	$dbh->disconnect;
	print "Records Updated ..... $count<br>";

}