#!/usr/local/pkg/php/bin/php -q

<?php

// Establish connection parameters
//
	$hostname = "astraea2";   //declaring variables for mysql access
	$databasename = "epo_ucla_rmd_mirror"; //all these values are 
																				 //unavailable to the user 
																				 //and thus secure
	$username = "thmsoc";   //these will have to be set for all search 
													//forms that access the mysql database
	$password = "ishkabibel";

	if ($_SERVER['argc'] !=9) {
		die("Check arguments: Need RsyncDir StartTime, StopTime, NFiles, TotSize, and XferRate\n") ;
	}

// Assign command line input variables
//
	$RsyncDir = $_SERVER['argv'][1] ;
	$StartTime = $_SERVER['argv'][2] . " " . $_SERVER['argv'][3] ;
	$StopTime = $_SERVER['argv'][4] . " " . $_SERVER['argv'][5] ;
	$NFiles = $_SERVER['argv'][6] ;
	$TotSize = $_SERVER['argv'][7] ;
	$XferRate = $_SERVER['argv'][8] ;

	/*
	print "rsync stats:\n" ;
	print "RsyncDir = " . $RsyncDir . "\n" ;
	print "StartTime = " . $StartTime . "\n" ;
	print "StopTime = " . $StopTime . "\n" ;
	print "NFiles = " . $NFiles . "\n" ;
	print "TotSize = " . $TotSize . "\n" ;
	print "XferRate = " . $XferRate . "\n" ;
	*/
	
// Make connection to MySQL server
//
$databaselink = mysql_connect($hostname, $username, $password) 
		or die("Could not connect: " . mysql_error());

// Select particular database
//
	mysql_select_db($databasename, $databaselink) or die("Could not use database: $databasename");

// Construct and insert new input
//
	//print "Performing db insert\n" ;
	$db_input = "insert into epo_ucla_rmd_rsync_stats (RsyncDir,StartTime,StopTime,NFiles,TotSize,XferRate) values (\"$RsyncDir\",\"$StartTime\",\"$StopTime\",\"$NFiles\",\"$TotSize\",\"$XferRate\")" ;
	mysql_query($db_input)
		or die("Could not query: " . mysql_error());
?>
