require_once 'config.php';
require_once 'classes/class.mysqli_database.php';
require_once 'classes/class.misc.php';
require_once 'classes/class.taxamatch.php';
require_once 'classes/class.tnrs_aggregator.php';
$options = getopt("s:m:p:c:l:f:o:");
$source = $options["s"];
$file = $options["f"];
$classification = isset($options["l"]) ? $options["l"] : "";
$search_mode = isset($options["m"]) ? $options["m"] : "";
$parse_only = isset($options["p"]) ? $options["p"] : "";
$count = isset($options["c"]) ? $options["c"] : "0";
$outfile = isset($options["o"]) ? $options["o"] : "";
$cache = false;
$source = explode(",", $source);
$db = select_source($source, $classification);
$header = TnrsAggregator::$field;
if (isset($count)) {
    array_unshift($header, "ID");
}
$outfh = fopen($outfile, 'w') or die("can't open outputfile");
fputcsv($outfh, $header);
$handle = fopen($file, "r");
while (($field = fgetcsv($handle, 1000, ",")) !== FALSE) {
    if (!isset($field[0]) || $field[0] == '') {
        continue;
    }
    $ta = new TnrsAggregator($db);
    $tm = new Taxamatch($db);
    $tm->set('debug_flag', '');
    $tm->set('output_type', '');
Example #2
0
 /**
  * This is the function that process the input csv file and does the work.
  * @param string $output_type : output type
  */
 public function process($output_type = 'file')
 {
     // Assign File
     if (file_exists($this->data['input_file'])) {
         $this->handle_input = fopen($this->data['input_file'], "r");
     } else {
         return false;
     }
     $this->handle_output = fopen($this->data['output_file'], "w");
     // Build Header
     $this->build_new_header();
     // Writes column header in 1st row of output.
     $this->write_header();
     /**
      *	This will run through the whole data and build the Higer Taxa with
      * parentID relationship to be used in the final species list.
      */
     $db = select_source($this->data['source']);
     $search_mode = 'normal';
     while (($row = fgetcsv($this->handle_input, 100000, $this->file_delimiter)) !== FALSE) {
         // Call taxamatch and process row
         $tm = new Taxamatch($db);
         if ($tm->process($row[$this->scientificNameIndex], $search_mode)) {
             $tm->generateResponse($cache);
         }
         $data = $tm->getData('flat');
         if (is_array($data)) {
             foreach ($data as $r) {
                 fputcsv($this->handle_output, array_merge($row, $r), $this->file_delimiter);
             }
         }
     }
     fclose($this->handle_output);
     fclose($this->handle_input);
 }
require_once './classes/class.nearmatch.php';
require_once './classes/class.normalize.php';
$expected = array('name');
// Initialize allowed variables
foreach ($expected as $formvar) {
    ${$formvar} = isset(${"_{$_SERVER['REQUEST_METHOD']}"}[$formvar]) ? ${"_{$_SERVER['REQUEST_METHOD']}"}[$formvar] : NULL;
}
// checks for authorities/config file
if ($name != '' && file_exists('../authorities/' . $name)) {
    include '../authorities/' . $name;
    if (count($config)) {
        foreach ($config as $key => $value) {
            ${$key} = $value;
        }
        // database connection
        $db = select_source($table_name);
        // checks for csv file and creates tables with the postfix
        $postfix = '_' . $table_name;
        if (file_exists('../authorities/' . $filename)) {
            createTables($postfix, $db);
            // import data from the csv
            $handle = fopen('../authorities/' . $filename, "r");
            $master = array();
            $genus_query_array = array();
            $author_array = array();
            // Skip first row
            $data = fgetcsv($handle, 1000, ",");
            while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                // Handling Auth abbrevations
                if (trim($data[$authority]) != '') {
                    $query = sprintf("INSERT INTO auth_abbrev%s (`AUTH_ABBR`, `AUTH_FULL`) VALUES ('%s','%s')", mysql_escape_string($postfix), mysql_escape_string($data[$authority]), mysql_escape_string($data[$authority]));
Example #4
0
	if ( isset( $_REQUEST['cmd'] ) ) {
		$cmd = $_REQUEST['cmd'];
	} else {
		$cmd = 'search';
	}
	
	switch($cmd) {
		case 'search_results':
	
			$output = '';
			$source = $_REQUEST['source'];
			$searchtxt = $_REQUEST['search_txt'];
			$search_mode = 'normal';
			$debug = 0;
	
			$db = select_source( $source );
			$tm = new Taxamatch($db);
	
			$tm->set('debug_flag',$debug);
			$tm->set('output_type',strtolower($output));
			if($tm->process($searchtxt , $search_mode, $cache )) {
				$tm->generateResponse($cache);
			}
			$data = $tm->getData();
	
			$debug = $tm->debug;
?>
<ul title="Results" class="panel" >


 <div class="panel" title="Results" id="results" style="left: 0%;" selected="true">