}
 // make a directory in the output folder for each language
 foreach ($language_files as $l) {
     if (!file_exists($output_base . $l)) {
         mkdir($output_base . $l, 0777, true);
     }
 }
 foreach ($language_files as $key => $l) {
     $index_files = array();
     rewind($fh);
     $header = fgetcsv($fh);
     // move cursor past header row
     // iterate through all rows of the csv
     $lfh = false;
     while ($line = fgets($fh, 9999999)) {
         $line = csvstring_to_array($line, ',', '"', "\n");
         if (!sizeof($line)) {
             continue;
         }
         // this is a blank line between groups
         $index_file_name = basename($file, ".csv");
         $key_name = $line[0];
         // have we see this before? no == make new file
         if (!in_array($index_file_name, $index_files)) {
             $index_files[] = $index_file_name;
             // no -- make new file, close existing if open (not 1st)
             if ($lfh !== false) {
                 write($lfh, "?>");
                 fclose($lfh);
             }
             $lfh = fopen($output_base . $l . '/' . $index_file_name . '.php', 'w');
Exemplo n.º 2
0
ELSE // ---------------------------------------------------------------------------------------------------------------------
{
	fseek($h,0);
	//
	$categories = strict_query("SELECT id, abbr FROM categories");
	$cats = array();
	while ($rcat=cased_mysql_fetch_array($categories))
		$cats[$rcat["abbr"]] = $rcat["id"];
	//
	$ncomp = 0;
	$nimp = 0;
	$errors = "";
	$headersdone = FALSE;
	while (($line = fgets($h))!==FALSE)
	{
		$line = csvstring_to_array(trim($line));
		if (!$headersdone)
		{
			$col = 0;
			foreach ($line as $value)
			{
				$value = strtolower($value);
				if (isset($headers[$value])) 
					$headers[$value] = $col;
				elseif (isset($cats[$value]))
				{
					$cats[$col] = $cats[$value];
					addEve($cats[$value]);
				}
					
				$col++;