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

<?php

// Establish connection parameters
//
	$hostname = "astraea2";   //declaring variables for mysql access
	$databasename = "probe_l0_process"; //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'] !=8 )
  {
		die("Check arguments: Need fileName, startTime, stopTime, fileSize, archiveBit\n") ;
	}

// Assign command line input variables
//
	$fileName = $_SERVER['argv'][1] ;
	$startTime = $_SERVER['argv'][2] . " " . $_SERVER['argv'][3] ;
	$stopTime = $_SERVER['argv'][4] . " " . $_SERVER['argv'][5] ;
	$fileSize = $_SERVER['argv'][6] ;
	$archiveBit = $_SERVER['argv'][7] ;

	/*
	print "fileName = " . $fileName . "\n" ;
	print "startTime = " . $startTime . "\n" ;
	print "stopTime = " . $stopTime . "\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
//
	$db_input = "insert into VC_Files_Processed (FileName,ProcessStartTime,ProcessStopTime,FileSize,Archive)
	values (\"$fileName\",\"$startTime\",\"$stopTime\",\"$fileSize\",\"$archiveBit\")" ;
	mysql_query($db_input)
		or die("Could not query: " . mysql_error());

// Get ID of input line for addition into Pkt data
//
	$db_input = "select last_insert_id()";
	$results = mysql_query($db_input)
		or die("Could not query: " . mysql_error());
	$checkresults = mysql_fetch_array($results) ;
	$lineID = $checkresults[0] ;
	//print "lineID = " . $lineID . "\n" ;
	print $lineID ;
?>
