<?
/***********Change this********************/
dl ("../../../../../apps/ssh2-0.10/modules/ssh2.so");
$dbhost = "mysql.research.pdx.edu";
$dbuser = "compute_user";
$dbpass = "FeindexAw3";

$uploaddir = $_SERVER['DOCUMENT_ROOT']."/dev/PRE/tmp/";
/******************************************/

$database = "compute_procs";
$jobtable = "remote_jobs";
$machinetable = "remote_machines";
$commandtable = "remote_commands";
$dbconnection = '';

/***********Change this********************/
$ssh2user = "lukacm";
$ssh2passwd = "vowsheX7";
$ssh2host = "research.pdx.edu";
/******************************************/

$ssh2connection = '';

$MACHINE_TABLE_FIELDS = array("id int(6) NOT NULL primary key auto_increment", "machinename varchar(15) NOT NULL", "iplocation varchar(15) NOT NULL", "availsoft varchar(255) NOT NULL", "busy varchar(30) NOT NULL", "timesnapshot varchar(30) NOT NULL", "state int(6) NOT NULL");

$JOB_TABLE_FIELDS = array("id int(6) NOT NULL primary key auto_increment", "appname varchar(15) NOT NULL", "dlocation varchar(255)", "clocation varchar(255)", "command varchar(255) NOT NULL", "submitdate varchar(30) NOT NULL", "alivetime varchar(30) NOT NULL", "state int(6) NOT NULL", "remote_machines_id int(6)", "FOREIGN KEY (remote_machines_id) REFERENCES remote_machines(id) ON DELETE CASCADE");

$COMMAND_TABLE_FIELDS = array("id int(6) NOT NULL primary key auto_increment", "softname varchar(15) NOT NULL", "command varchar(255) NOT NULL", "parameters varchar(255) NOT NULL", "input_file varchar(30) NOT NULL", "output_file varchar(30) NOT NULL");



$appstrings = array("R" => "/vol/apps/R/R-2.4.0/bin/R -q --no-save < ", "Occam" => "occam");

function extractFields($tablefields){
	$fields = implode(",", $tablefields);
	$fields = trim($fields);
	return $fields;
}

function parseinitfields($userdata){

#$userdata = explode("\n", "$userdata");
$fields = "";
$n = 0;
foreach($userdata as $data){
	if ($n != 0){
        	$temp = explode(" ", $data);
        	if (strlen($temp[0]) > 0 & preg_match("/^`id`/", $temp[0], $matches, PREG_OFFSET_CAPTURE) < 1)
                	$fields = $fields.$temp[0].",";
	}
	$n = $n+1;
}
return rtrim($fields, ",");
}

?>
