parse() 공개 메소드

Parse CSV file or string
public parse ( $input = null, $offset = null, $limit = null, $conditions = null ) : nothing
리턴 nothing
예제 #1
6
 protected function parse_file($file)
 {
     $csv = new \parseCSV();
     $csv->delimiter = ";";
     $csv->parse($file);
     if ($this->tag_ok) {
         $tableHead = "<div  class='table-respond'><table><thead><tr><th>Titre</th><th>Album</th></tr></thead><tbody>";
     } else {
         $tableHead = "<div  class='table-respond'><table><thead><tr><th>Titre</th><th>Artiste</th><th>Album</th></tr></thead><tbody>";
     }
     $tableEnd = "</tbody></table></div>";
     $tableBody = "";
     foreach ($csv->data as $key => $row) {
         $annee = "";
         $groupe = "";
         if ($this->tag_ok) {
             if (isset($row['Groupe']) && strpos(html_entity_decode($row['Groupe']), html_entity_decode($this->tag_name)) !== false) {
                 if ($row['Année']) {
                     $annee = "<span class='playlist_year'> (" . $row['Année'] . ")</span>";
                 }
                 $tableBody .= "<tr><td>" . $row['Titre'] . "</td><td>" . $row['Album'] . $annee . "</td></tr>";
             }
         } else {
             if ($row['URL']) {
                 if ($row['Groupe']) {
                     $groupe = "<a href='" . $row['URL'] . "' title='" . $row['URL'] . "' target='_blank'>" . $row['Groupe'] . "</a>";
                 } else {
                     $row['Titre'] = "<a href='" . $row['URL'] . "' title='" . $row['URL'] . "' target='_blank'>" . $row['Titre'] . "</a>";
                 }
             } else {
                 $groupe = $row['Groupe'];
             }
             if ($row['Année']) {
                 $annee = "<span class='playlist_year'> (" . $row['Année'] . ")</span>";
             }
             $tableBody .= "<tr><td>" . $row['Titre'] . "</td><td>" . $groupe . "</td><td>" . $row['Album'] . $annee . "</td></tr>";
         }
     }
     $ret = $tableHead . $tableBody . $tableEnd;
     return $ret;
 }
 public function read()
 {
     global $default_charset;
     $filePath = $this->getFilePath();
     $status = $this->createTable();
     if (!$status) {
         return false;
     }
     $csv = new parseCSV();
     $csv->delimiter = $this->request->get('delimiter');
     $csv->parse($filePath);
     $data = $csv->data;
     $fieldMapping = $this->request->get('field_mapping');
     if (!$this->request->get('has_header')) {
         $firstRow = array_keys($data[0]);
         array_unshift($data, $firstRow);
     }
     foreach ($data as $row_data) {
         $row_data_index = array_values($row_data);
         $mappedData = array();
         $allValuesEmpty = true;
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldValue = $row_data_index[$index];
             $mappedData[$fieldName] = $fieldValue;
             if ($this->request->get('file_encoding') != $default_charset) {
                 $mappedData[$fieldName] = $this->convertCharacterEncoding($fieldValue, $this->request->get('file_encoding'), $default_charset);
             }
             if (!empty($fieldValue)) {
                 $allValuesEmpty = false;
             }
         }
         if ($allValuesEmpty) {
             continue;
         }
         $fieldNames = array_keys($mappedData);
         $fieldValues = array_values($mappedData);
         $this->addRecordToDB($fieldNames, $fieldValues);
     }
 }
 /**
  * @param $inputData
  * @return MerchantDataListing[]
  */
 public function processData($inputData)
 {
     $inputData = mb_convert_encoding($inputData, "utf-8", "windows-1252");
     $csv = new \parseCSV();
     //$csv->encoding('Windows-1252', 'UTF-8');
     $csv->delimiter = "\t";
     $csv->parse($inputData);
     $itemList = array();
     foreach ($csv->data as $row) {
         $item = new MerchantDataListing();
         $item->setData($row);
         $itemList[] = $item;
     }
     return $itemList;
 }
예제 #4
0
function parseFind($csvFile, $afm, $surname)
{
    // init vars
    $empOffset = 5;
    $anadrData = [];
    // parse csv & find employee
    $csv = new parseCSV();
    $csv->encoding('iso8859-7', 'UTF-8');
    $csv->delimiter = ";";
    $csv->heading = false;
    // find employee T.M.
    $csv->offset = $empOffset;
    $condition = '8 is ' . $afm . ' AND 1 contains ' . grstrtoupper($surname);
    $csv->conditions = $condition;
    $csv->parse($csvFile);
    $parsed = $csv->data;
    // enhanced check of surname (instead of 'contains' in fullname)
    if ($parsed) {
        $tmp = explode(' ', $parsed[0][1]);
        $fileSurname = $tmp[0];
        if (strcmp(grstrtoupper($surname), $fileSurname) != 0) {
            return ['parsed' => [], 'month' => []];
        }
    }
    // find month
    $csv->offset = 1;
    $csv->conditions = '19 contains ΜΙΣΘΟΔΟΣΙΑ';
    $csv->parse($csvFile);
    //$csv->fields =[19];
    $data = $csv->data;
    $tmp = explode(' ', $data[0][19]);
    $month = $tmp[2] . '_' . $tmp[3];
    // find anadromika (if any)
    $csv->offset = $empOffset;
    $csv->conditions = '';
    $csv->parse($csvFile);
    $data = $csv->data;
    $i = $foundFrom = $foundTo = 0;
    foreach ($data as $row) {
        if (array_key_exists('8', $row) && $afm == $row[8] && !$foundFrom) {
            $foundFrom = $i;
        }
        if ($foundFrom && !$foundTo && array_key_exists('8', $row)) {
            if ($row[8] != '' && $row[8] != $afm) {
                $foundTo = $i - 1;
            }
        }
        $i++;
    }
    $tempData = array_slice($data, $foundFrom, $foundTo - $foundFrom + 1);
    foreach ($tempData as $line) {
        if ($line[10] == 'ΑΝΑΔΡΟΜΙΚΑ') {
            $anadrData = $line;
        }
    }
    if (count($anadrData) > 0) {
        array_push($parsed, $anadrData);
    }
    return ['parsed' => $parsed, 'month' => $month];
}
<?php

require_once 'check.php';
$csv = new parseCSV();
$csv->parse('../00_ADMIN_CSV_FOLDER/bodytype_service_pricing_minutes.csv');
$bodytype_service = array($csv->data);
$csv->parse('../00_ADMIN_CSV_FOLDER/extra_pricing_minutes.csv');
$extra_pricing = array($csv->data);
$csv->parse('../00_ADMIN_CSV_FOLDER/service_discounts.csv');
$service_discounts = array($csv->data);
예제 #6
0
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
//require ("../../php/sessionStartAndCheck.php");
# include parseCSV class.
require_once '../parsecsv.lib.php';
# create new parseCSV object.
$csv = new parseCSV();
# Example conditions:
// $csv->conditions = 'title contains paperback OR title contains hardcover';
// $csv->conditions = 'author does not contain dan brown';
// $csv->conditions = 'rating < 4 OR author is John Twelve Hawks';
// $csv->conditions = 'rating > 4';
// $csv->conditions = 'Data is empty';
// $csv->conditions = 'Data is not empty';
$csv->parse('../out/test.csv', 0, 1000);
// At max 1000 lines.
if ($csv->error_info) {
    print_r($csv->error_info);
}
?>
<!doctype html>
<html>
<head>
  <meta charset='utf-8'>
  <title>Conditional formatting - Handsontable</title>

  <!--
  Loading Handsontable dependencies.
  Please note that some dependencies are optional:
   - bootstrap-typeahead.js - is required only if you need the autocomplete feature
 public static function importCSV()
 {
     $csv_mimetypes = array('text/csv', 'text/plain', 'application/csv', 'text/comma-separated-values', 'application/excel', 'application/vnd.ms-excel', 'application/vnd.msexcel', 'text/anytext', 'application/octet-stream', 'application/txt', 'application/vnd.google-apps.spreadsheet');
     foreach ($_FILES as $file) {
         if (in_array($file['type'], $csv_mimetypes)) {
             require_once plugin_dir_path(__FILE__) . "/parseCSV.php";
             $csv = new parseCSV();
             if ($_POST["first_row"] == "false") {
                 $csv->heading = false;
             }
             $csv->parse($file['tmp_name']);
             echo json_encode($csv->data);
         } else {
             echo json_encode(array("error" => "File Must be a CSV"));
         }
         die;
     }
 }
예제 #8
0
} else {
    $subdir .= "/generated_documents/";
}
if (!is_dir($upload_dir . $subdir)) {
    mkdir($upload_dir . $subdir, 0700, true);
}
$filename = create_filename() . ".pdf";
$pdf = new FPDF2File();
$pdf->Open($upload_dir . $subdir . $filename);
$pdf->SetAutoPageBreak(false, 0);
$pdf->SetMargins(0, 0, 0);
//$pdf->AliasNbPages();
$csvHeaders = array();
if ($server->outData['data'][1]['datasource_file_name'] !== "") {
    if (isset($server->outData['data'][1]['datasource_file_name'])) {
        $csv->parse(".." . $server->outData['data'][1]['datasource_data_path'] . $server->outData['data'][1]['datasource_file_name'], 0, 1000);
        // At max 1000 lines.
        //Leon 24-03-14 - Add this back in, and add error handling into the page designer to print a handy error message to the user
        //if($csv->error_info) {
        //	die(array("error" => 1, "details" => print_r($csv->error_info, 1)) );
        //}
        foreach ($csv->titles as $key => $header) {
            $csvHeaders[] = "<" . $header . ">";
        }
        if (count($csv->data) == 0) {
            $csv->data[] = array();
        }
    } else {
        $csv->data[] = array();
    }
}
예제 #9
0
 /**
  * @todo Implement truncate
  *
  */
 function import()
 {
     set_time_limit(0);
     $file = $this->controller->data[$this->modelName]['csv']['tmp_name'];
     $truncate = $this->controller->data[$this->modelName]['truncate'];
     $model = $this->controller->{$this->modelName};
     // truncate the table.
     if ($truncate) {
         #$model->contain();
         $model->deleteAll(array(1 => 1));
     }
     // parseCSV does lots of magic to fill $csv->data
     App::import('Vendor', 'advindex.parseCSV', array('file' => 'parsecsv-0.3.2' . DS . 'parsecsv.lib.php'));
     $csv = new parseCSV();
     $csv->parse($file);
     // Process data.
     $fields = array_flip($this->settings['fields']);
     $errors = array();
     $created = $updated = 0;
     // Callbacks.
     $hasBeforeCallback = method_exists($model, 'beforeImport');
     $hasAfterCallback = method_exists($model, 'afterImport');
     foreach ($csv->data as $line => $row) {
         // start again
         $model->create();
         // get row
         $row2 = array();
         foreach ($row as $field => $val) {
             $alias = $model->alias;
             if (strpos($field, '.') !== false) {
                 list($alias, $field) = explode('.', $field);
             }
             $row2[$alias][$field] = $val;
         }
         $row = $row2;
         unset($row2);
         // format row
         if ($hasBeforeCallback) {
             $modelData = $model->beforeImport($row);
         } else {
             $modelData = $this->genericBeforeImport($row);
         }
         // try and find an existing row.
         $update = false;
         $conditions = array();
         $contain = array();
         foreach ($this->settings['update_if_fields'] as $field) {
             if (!empty($modelData[$field])) {
                 $conditions[$field] = $modelData[$field];
             }
         }
         if ($conditions && ($record = $model->find('first', compact('conditions', 'contain')))) {
             $modelData[$model->primaryKey] = $record[$this->modelName][$model->primaryKey];
             $update = true;
         }
         if ($saved = $model->saveAll($modelData)) {
             $update ? $updated++ : $created++;
             if ($hasAfterCallback) {
                 $model->afterImport($modelData);
             }
         } else {
             $errors[$line] = $model->validationErrors;
         }
     }
     $this->controller->Session->write('Advindex.' . $this->modelName . '.import', compact('created', 'updated', 'errors'));
     $this->controller->redirect(array('action' => 'index'));
 }
예제 #10
0
 private function createDBDataSource($filename, $options, $subdir, $file_path)
 {
     global $session, $sql;
     $query = "INSERT INTO datasources (created_at, updated_at, user_id, name, data_path, file_name, `headers`, `lines`)\n\t\t\t\t  VALUES(?, NOW(), ?, ?, ?, ?, ?, ?)";
     $stmt = $sql->link->prepare($query);
     if (!$stmt) {
         die('Invalid query: ' . $sql->link->error);
     } else {
         $csv = new parseCSV();
         $realUserPath = realpath($file_path);
         if (filesize($realUserPath) > 0) {
             $csv->parse($realUserPath, 0, 10000);
             // At max 10000 lines.
             $csvDataRows = $csv->unparse($csv->data, $csv->titles, null, null, null, true);
         } else {
             $csvDataRows = array(array(""));
         }
         $lines = count($csvDataRows) - 1;
         $headers = json_encode($csv->titles);
         $subdirSQL = $options['upload_url'] . $subdir;
         $time = getCurrentDateTime();
         $userID = $this->session->get_user_var('id');
         $stmt->bind_param('sissssi', $time, $userID, $filename, $subdirSQL, $filename, $headers, $lines);
         $resultFromExec = $stmt->execute();
         if ($resultFromExec) {
             $affectedRows = $stmt->affected_rows;
         }
         /* free result */
         $stmt->free_result();
         $stmt->close();
     }
     return array("lines" => $lines, "headers" => implode(", ", array_filter($csv->titles)));
 }
<?php

header('Content-Type: application/json');
require_once '../parsecsv-for-php/parsecsv.lib.php';
$csv = new parseCSV();
$csv->parse('../../../00_ADMIN_CSV_FOLDER/extra_pricing_minutes.csv');
echo json_encode($csv->data);
예제 #12
0
    <?php 
$algumacoisa = new ManageFile();
$algumacoisa->setDir('arquivos/' . $course . '/' . $turma);
$alunos = $algumacoisa->readDir('nome', 'asc');
foreach ($alunos as $aluno) {
    if ($aluno['nome'] == '.' || $aluno['nome'] == '..') {
        $key = array_search($aluno, $alunos);
        unset($alunos[$key]);
    }
}
if ($alunos == null) {
    echo '<h4>Não há ninguém cadastrado nessa turma</h4>';
}
$outra = new parseCSV();
$outra->delimiter = ';';
$outra->parse('dados.csv');
$dados_alunos = $outra->data;
foreach ($dados_alunos as $chave => $dado) {
    $nome[$chave] = $dado['nome'];
}
array_multisort($nome, SORT_ASC, $dados_alunos);
foreach ($dados_alunos as $dados) {
    foreach ($alunos as $aluno) {
        $aluno_nome = explode('.', $aluno['nome']);
        if ($dados['matricula'] == $aluno_nome[0]) {
            $dados_deste_aluno = $dados;
        }
    }
    ?>
        <div class="col-sm-4">
            <div class="panel panel-primary">
예제 #13
0
 /**
     Loads lang list from Languages.txt file and fill its parameters
     Note: can not fill po files
 */
 protected function AddLangsFromTxt()
 {
     $languagelistFileName = $this->infoDir . 'Languages/Languages.txt';
     // r1434 - today
     if (!file_exists($languagelistFileName)) {
         debug("File {$languagelistFileName} does not exixts!<br/>");
         $languagelistFileName = $this->infoDir . 'src/Languages/Languages.txt';
         // r1302 - r1433
     }
     if (!file_exists($languagelistFileName)) {
         debug("File {$languagelistFileName} does not exixts!<br/>");
         debug("No file to process found !<br/>");
         return false;
     }
     debug("Processing file {$languagelistFileName}.<br/>");
     // load language.txt
     $csv = new parseCSV();
     $csv->delimiter = ";";
     $csv->parse($languagelistFileName);
     foreach ($csv->data as $csvLine) {
         if (!isset($csvLine) || !is_array($csvLine) || count($csvLine) < 1) {
             continue;
         }
         $indexedArray = array_values($csvLine);
         if ($indexedArray[0][0] == '#') {
             // to do process if everithing else match - aka commented out lang
             continue;
         }
         $ret = array();
         switch (count($csvLine)) {
             case 6:
                 /*echo "<br /><pre>";
                   var_dump($indexedArray);
                   echo "</pre>";
                   /*if (preg_match("/^[-01]/", $indexedArray[0])) {
                       $ret['Enabled']=$indexedArray[0];
                       $ret['Code']=$indexedArray[1];
                       //$ret['Lang']=$indexedArray[2];
                       $ret['Flags']=$indexedArray[3];
                       $ret['LangName']=$indexedArray[4];
                       $ret['Credits']=$indexedArray[5];
                   } else {
                       $ret['Code']=$indexedArray[0];
                       //$ret['Lang']=$indexedArray[1];
                       $ret['Enabled']=$indexedArray[2];
                       //$ret['Flags']=$indexedArray[3];
                       $ret['LangName']=$indexedArray[4];
                       //$ret['Credits']=$indexedArray[5];
                       // Credits should be loaded from other file ... (vars)
                   }//*/
                 // 21716 -
                 $ret['Code'] = trim($indexedArray[0]);
                 $ret['WixLang'] = trim($indexedArray[1]);
                 //$ret['LCID']=trim($indexedArray[2]);
                 $ret['SC'] = trim($indexedArray[3]);
                 $ret['LangName'] = trim($indexedArray[4]);
                 $ret['Credits'] = trim($indexedArray[5]);
                 break;
             case 7:
                 $ret['Enabled'] = trim($indexedArray[0]);
                 $ret['Code'] = trim($indexedArray[1]);
                 $ret['WixLang'] = trim($indexedArray[2]);
                 $ret['Lang'] = trim($indexedArray[3]);
                 $ret['Flags'] = trim($indexedArray[4]);
                 $ret['LangName'] = trim($indexedArray[5]);
                 $ret['Credits'] = trim($indexedArray[6]);
         }
         if (count($ret) > 0) {
             $this->UpdateLang($ret);
         }
     }
 }
예제 #14
0
 public function parse()
 {
     include_once JPATH_SITE . '/components/com_acctexp/lib/parsecsv/parsecsv.lib.php';
     $csv = new parseCSV();
     $csv->heading = false;
     $this->rows = $csv->parse($this->filepath);
     if ($csv->parse($this->filepath)) {
         $this->rows = $csv->data;
         return true;
     } else {
         return false;
     }
 }
예제 #15
0
 if (!isset($tema)) {
     $nomex = strtoupper($i3GEOuploaddbfnomex);
     $nomey = strtoupper($i3GEOuploaddbfnomey);
     //converte de csv para dbf
     if ($i3GEOuploaddbftipoarquivo != "dbf") {
         if ($i3GEOuploaddbftipoarquivo == "csvpv") {
             $separador = ";";
         }
         if ($i3GEOuploaddbftipoarquivo == "csvv") {
             $separador = ",";
         }
         include_once dirname(__FILE__) . "/../../pacotes/phpxbase/api_conversion.php";
         include_once dirname(__FILE__) . "/../../pacotes/parsecsv/parsecsv.lib.php";
         $csv = new parseCSV();
         $csv->delimiter = $separador;
         $dados = $csv->parse($dirmap . "/" . $ArquivoDest);
         $conta = 0;
         $xy = array();
         $colunas = array_keys($csv->data[0]);
         foreach ($colunas as $i) {
             $i = strtoupper($i);
             $i = trim($i);
             if ($i != $nomex && $i != $nomey) {
                 $i = str_replace("_", "", $i);
                 $i = str_replace("-", "", $i);
                 if (strlen($i) > 10) {
                     $i = substr($i, 0, 7) . $conta++;
                 }
                 $def[] = array($i, "C", "255");
             } else {
                 $def[] = array($i, "C", "255");
 function getData()
 {
     global $mainframe, $option;
     $mainframe =& JFactory::getApplication();
     $document =& JFactory::getDocument();
     $lang = JFactory::getLanguage();
     if ($this->debug_info) {
         $this->pane =& JPane::getInstance('sliders');
         echo $this->pane->startPane('pane');
     }
     // die einstellungen der user holen
     $option = JRequest::getCmd('option');
     $params = JComponentHelper::getParams($option);
     $jlxmlfile = JPATH_ADMINISTRATOR . DS . 'components' . DS . $option . DS . 'config.xml';
     $jRegistry = new JRegistry();
     $jRegistry->loadString($params->toString('ini'), 'ini');
     //   echo 'Die aktuelle Sprache lautet: ' . $lang->getName() . '<br>';
     $teile = explode("-", $lang->getTag());
     $country = Countries::convertIso2to3($teile[1]);
     //   echo 'Das aktuelle Land lautet: ' . $country . '<br>';
     $option = JRequest::getCmd('option');
     $project = $mainframe->getUserState($option . 'project', 0);
     $lmoimportuseteams = $mainframe->getUserState($option . 'lmoimportuseteams');
     $whichfile = $mainframe->getUserState($option . 'whichfile');
     $mainframe->enqueueMessage(JText::_('welches land ? ' . $country), '');
     $mainframe->enqueueMessage(JText::_('welche art der datei ? ' . $whichfile), '');
     $delimiter = $mainframe->getUserState($option . 'delimiter');
     $post = JRequest::get('post');
     $this->_league_new_country = $country;
     $exportpositioneventtype = array();
     $exportplayer = array();
     $exportpersons = array();
     $exportpersonstemp = array();
     $exportclubs = array();
     $exportclubsstandardplayground = array();
     $exportplaygroundclubib = array();
     $exportteams = array();
     $exportteamstemp = array();
     $exportteamplayer = array();
     $exportprojectteam = array();
     $exportprojectteams = array();
     $exportreferee = array();
     $exportprojectposition = array();
     $exportposition = array();
     $exportparentposition = array();
     $exportplayground = array();
     $exportplaygroundtemp = array();
     $exportteamplaygroundtemp = array();
     $exportround = array();
     $exportmatch = array();
     $exportmatchplayer = array();
     $exportmatchevent = array();
     $exportevent = array();
     $exportpositiontemp = array();
     $exportposition = array();
     $exportparentposition = array();
     $exportprojectposition = array();
     $exportmatchreferee = array();
     $exportmatchplan = array();
     $temp_match_number = array();
     $startline = 0;
     // echo 'post <br>';
     // echo '<pre>';
     // print_r($post[projects]);
     // echo '</pre>';
     if (isset($post['projects'])) {
         $this->_project_id = $post['projects'];
     }
     $file = JPATH_SITE . DS . 'tmp' . DS . 'joomleague_import.csv';
     $mainframe->enqueueMessage(JText::_('datei = ' . $file), '');
     //$mainframe->enqueueMessage(JText::_('csv result<br><pre>'.print_r($csvdata->data,true).'</pre>'   ),'');
     if ($whichfile == 'playerfile') {
         $startline = 9;
     } elseif ($whichfile == 'matchfile') {
         $startline = 1;
     } elseif ($whichfile == 'icsfile') {
         // kalender file vom bfv anfang
         $ical = new ical();
         $ical->parse($file);
         $icsfile = $ical->get_all_data();
         if ($this->debug_info) {
             echo $this->pane->startPanel('icsfile', 'icsfile');
             $this->dump_header("icsfile");
             $this->dump_variable("icsfile", $icsfile);
             echo $this->pane->endPanel();
             echo $this->pane->startPanel('icsfile termine', 'icsfile termine');
             $this->dump_header("icsfile termine");
             $this->dump_variable("icsfile termine", $icsfile['VEVENT']);
             echo $this->pane->endPanel();
             //echo 'icsfile -> <br /><pre>~'.print_r($icsfile,true).'~</pre><br />';
             //echo 'icsfile termine -> <br /><pre>~'.print_r($icsfile['VEVENT'],true).'~</pre><br />';
         }
         //
         $lfdnumber = 0;
         $lfdnumberteam = 1;
         $lfdnumbermatch = 1;
         $lfdnumberplayground = 1;
         for ($a = 0; $a < sizeof($icsfile['VEVENT']); $a++) {
             $icsfile['VEVENT'][$a]['UID'] = $lfdnumbermatch;
             $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['match_date'] = date('Y-m-d', $icsfile['VEVENT'][$a]['DTSTART']) . " " . date('H:i', $icsfile['VEVENT'][$a]['DTSTART']);
             // paarung
             $teile = explode("\\,", $icsfile['VEVENT'][$a]['SUMMARY']);
             $teile2 = explode("-", $teile[0]);
             if (empty($lfdnumber)) {
                 $projectname = trim($teile[1]);
             }
             $text = $teile[0];
             $anzahltrenner = substr_count($text, '-');
             //echo 'ich habe -> '.$anzahltrenner.' trennzeichen <br>';
             if ($anzahltrenner > 1) {
                 $convert = array('-SV' => ':SV', '-SVO' => ':SVO', '-FC' => ':FC', '-TSV' => ':TSV', '-JFG' => ':JFG', '-TV' => ':TV', '-ASV' => ':ASV', '-SSV' => ':SSV', '-(SG)' => ':(SG)', '-SpVgg' => ':SpVgg', '-VfB' => ':VfB', '-FSV' => ':FSV', '-BSK' => ':BSK');
                 if (preg_match("/-SV/i", $teile[0]) || preg_match("/-SVO/i", $teile[0]) || preg_match("/-TSV/i", $teile[0]) || preg_match("/-JFG/i", $teile[0]) || preg_match("/-TV/i", $teile[0]) || preg_match("/-ASV/i", $teile[0]) || preg_match("/-SSV/i", $teile[0]) || preg_match("/-(SG)/i", $teile[0]) || preg_match("/-SpVgg/i", $teile[0]) || preg_match("/-VfB/i", $teile[0]) || preg_match("/-FSV/i", $teile[0]) || preg_match("/-BSK/i", $teile[0]) || preg_match("/-FC/i", $teile[0])) {
                     $teile[0] = str_replace(array_keys($convert), array_values($convert), $teile[0]);
                     $teile2 = explode(":", $teile[0]);
                 } else {
                     $pos = strrpos($teile[0], "-");
                     //echo 'letzte position -> '.$pos.' trennzeichen <br>';
                     $teile2[0] = substr($teile[0], 0, $pos);
                     $teile2[1] = substr($teile[0], $pos + 1, 100);
                 }
             }
             $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['heim'] = trim($teile2[0]);
             $valueheim = trim($teile2[0]);
             //$exportteamplaygroundtemp[$valueheim] = $valueplayground;
             $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['gast'] = trim($teile2[1]);
             $valuegast = trim($teile2[1]);
             // heimmannschaft
             if (array_key_exists($valueheim, $exportteamstemp)) {
             } else {
                 $exportteamstemp[$valueheim] = $lfdnumberteam;
                 $lfdnumberteam++;
             }
             // gastmannschaft
             if (array_key_exists($valuegast, $exportteamstemp)) {
             } else {
                 $exportteamstemp[$valuegast] = $lfdnumberteam;
                 $lfdnumberteam++;
             }
             if (isset($icsfile['VEVENT'][$a]['LOCATION'])) {
                 // sportanlage neu
                 $teile = explode("\\,", $icsfile['VEVENT'][$a]['LOCATION']);
                 if (sizeof($teile) === 4) {
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground'] = trim($teile[0]);
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_strasse'] = trim($teile[1]);
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_plz'] = trim($teile[2]);
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_ort'] = trim($teile[3]);
                     $valueplayground = trim($teile[0]);
                     $address = trim($teile[1]);
                     $zipcode = trim($teile[2]);
                     $city = trim($teile[3]);
                 } else {
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground'] = '';
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_strasse'] = trim($teile[0]);
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_plz'] = trim($teile[1]);
                     $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_ort'] = trim($teile[2]);
                     $valueplayground = $valueheim;
                     $address = trim($teile[0]);
                     $zipcode = trim($teile[1]);
                     $city = trim($teile[2]);
                 }
             }
             if ($valueplayground) {
                 $exportteamplaygroundtemp[$valueheim] = $valueplayground;
                 if (array_key_exists($valueplayground, $exportplaygroundtemp)) {
                 } else {
                     $exportplaygroundtemp[$valueplayground] = $lfdnumberplayground;
                     $temp = new stdClass();
                     $temp->id = $lfdnumberplayground;
                     $temp->name = $valueplayground;
                     $temp->short_name = $valueplayground;
                     $temp->alias = $valueplayground;
                     $temp->club_id = $exportteamstemp[$valueheim];
                     $temp->address = $address;
                     $temp->zipcode = $zipcode;
                     $temp->city = $city;
                     $temp->country = $country;
                     $temp->max_visitors = 0;
                     $exportplayground[] = $temp;
                     $lfdnumberplayground++;
                 }
             }
             if (empty($lfdnumber)) {
                 $temp = new stdClass();
                 $temp->name = $projectname;
                 $temp->exportRoutine = '2010-09-19 23:00:00';
                 $this->_datas['exportversion'] = $temp;
                 $temp = new stdClass();
                 $temp->name = '';
                 $this->_datas['season'] = $temp;
                 $temp = new stdClass();
                 $temp->name = $projectname;
                 $temp->alias = $projectname;
                 $temp->short_name = $projectname;
                 $temp->middle_name = $projectname;
                 $temp->country = $country;
                 $this->_datas['league'] = $temp;
                 $temp = new stdClass();
                 $temp->name = $projectname;
                 $temp->serveroffset = 0;
                 $temp->project_type = 'SIMPLE_LEAGUE';
                 $this->_datas['project'] = $temp;
             }
             $lfdnumber++;
             $lfdnumbermatch++;
         }
         ksort($exportmatchplan);
         if ($this->debug_info) {
             echo $this->pane->startPanel('icsfile exportmatchplan', 'icsfile exportmatchplan');
             $this->dump_header("icsfile exportmatchplan");
             $this->dump_variable("icsfile exportmatchplan", $exportmatchplan);
             echo $this->pane->endPanel();
             echo $this->pane->startPanel('icsfile exportteamstemp', 'icsfile exportteamstemp');
             $this->dump_header("icsfile exportteamstemp");
             $this->dump_variable("icsfile exportteamstemp", $exportteamstemp);
             echo $this->pane->endPanel();
             //echo 'icsfile exportmatchplan -> <br /><pre>~'.print_r($exportmatchplan,true).'~</pre><br />';
             //echo 'icsfile exportteamstemp -> <br /><pre>~'.print_r($exportteamstemp,true).'~</pre><br />';
         }
         // teams verarbeiten
         foreach ($exportteamstemp as $key => $value) {
             // team
             $temp = new stdClass();
             $temp->id = $value;
             $temp->club_id = $value;
             $temp->name = $key;
             $temp->middle_name = $key;
             $temp->short_name = $key;
             $temp->info = '';
             $temp->extended = '';
             $exportteams[] = $temp;
             $standard_playground = $exportteamplaygroundtemp[$key];
             $standard_playground_nummer = $exportplaygroundtemp[$standard_playground];
             // club
             $temp = new stdClass();
             $temp->id = $value;
             $temp->name = $key;
             $temp->country = $country;
             $temp->extended = '';
             $temp->standard_playground = $standard_playground_nummer;
             $exportclubs[] = $temp;
             // projektteam
             $temp = new stdClass();
             $temp->id = $value;
             $temp->team_id = $value;
             $temp->project_team_id = $value;
             $temp->is_in_score = 1;
             $temp->standard_playground = $standard_playground_nummer;
             $exportprojectteams[] = $temp;
         }
         $anzahlteams = sizeof($exportteamstemp);
         $mainframe->enqueueMessage(JText::_('wir haben ' . $anzahlteams . ' teams f&uuml;r die berechnung der spieltage und paarungen pro spieltag'), '');
         if ($anzahlteams % 2 == 0) {
             $anzahltage = ($anzahlteams - 1) * 2;
             $anzahlpaarungen = $anzahlteams / 2;
         } else {
             $anzahltage = ($anzahlteams - 1) * 2;
             $anzahlpaarungen = ($anzahlteams - 1) / 2;
         }
         $mainframe->enqueueMessage(JText::_('wir haben ' . $anzahltage . ' spieltage'), '');
         $mainframe->enqueueMessage(JText::_('wir haben ' . $anzahlpaarungen . ' paarungen pro spieltag'), '');
         // echo "icsfile exportplaygroundtemp<pre>";
         // print_r($exportplaygroundtemp);
         // echo "</pre>";
         // so jetzt die runden erstellen
         for ($a = 1; $a <= $anzahltage; $a++) {
             $temp = new stdClass();
             $temp->id = $a;
             $temp->roundcode = $a;
             $temp->name = $a . '- Spieltag';
             $temp->alias = $a . '-spieltag';
             $temp->round_date_first = '';
             $temp->round_date_last = '';
             $exportround[$a] = $temp;
         }
         // so jetzt die spiele erstellen
         $lfdnumbermatch = 1;
         $lfdnumberpaarung = 1;
         $lfdnumberspieltag = 1;
         foreach ($exportmatchplan as $key => $value) {
             // echo "icsfile spiele erstellen<pre>";
             // print_r($value);
             // echo "</pre>";
             $tempmatch = new stdClass();
             $tempmatch->id = $lfdnumbermatch;
             $tempmatch->match_number = $lfdnumbermatch;
             $tempmatch->published = 1;
             $tempmatch->count_result = 1;
             $tempmatch->show_report = 1;
             $tempmatch->team1_result = '';
             $tempmatch->team2_result = '';
             $tempmatch->summary = '';
             $tempmatch->match_date = $value['match_date'];
             if (isset($value['playground'])) {
                 if (array_key_exists($value['playground'], $exportplaygroundtemp)) {
                     $tempmatch->playground_id = $exportplaygroundtemp[$value['playground']];
                 }
             }
             $tempmatch->projectteam1_id = $exportteamstemp[$value['heim']];
             $tempmatch->projectteam2_id = $exportteamstemp[$value['gast']];
             $tempmatch->round_id = $lfdnumberspieltag;
             $exportmatch[] = $tempmatch;
             if ($lfdnumberpaarung == $anzahlpaarungen) {
                 $lfdnumberpaarung = 0;
                 $lfdnumberspieltag++;
             }
             $lfdnumbermatch++;
             $lfdnumberpaarung++;
         }
         // daten übergeben
         $this->_datas['round'] = array_merge($exportround);
         $this->_datas['match'] = array_merge($exportmatch);
         $this->_datas['team'] = array_merge($exportteams);
         $this->_datas['projectteam'] = array_merge($exportprojectteams);
         $this->_datas['club'] = array_merge($exportclubs);
         $this->_datas['playground'] = array_merge($exportplayground);
         /**
          * das ganze für den standardimport aufbereiten
          */
         $output = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
         // open the project
         $output .= "<project>\n";
         // set the version of JoomLeague
         $output .= $this->_addToXml($this->_setJoomLeagueVersion());
         // set the project datas
         if (isset($this->_datas['project'])) {
             $output .= $this->_addToXml($this->_setProjectData($this->_datas['project']));
         }
         // set league data of project
         if (isset($this->_datas['league'])) {
             $output .= $this->_addToXml($this->_setLeagueData($this->_datas['league']));
         }
         // set season data of project
         if (isset($this->_datas['season'])) {
             $output .= $this->_addToXml($this->_setSeasonData($this->_datas['season']));
         }
         // set the rounds data
         if (isset($this->_datas['round'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['round'], 'Round'));
         }
         // set the teams data
         if (isset($this->_datas['team'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['team'], 'JL_Team'));
         }
         // set the clubs data
         if (isset($this->_datas['club'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['club'], 'Club'));
         }
         // set the matches data
         if (isset($this->_datas['match'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['match'], 'Match'));
         }
         // set the positions data
         if (isset($this->_datas['position'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['position'], 'Position'));
         }
         // set the positions parent data
         if (isset($this->_datas['parentposition'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['parentposition'], 'ParentPosition'));
         }
         // set position data of project
         if (isset($this->_datas['projectposition'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectposition'], 'ProjectPosition'));
         }
         // set the matchreferee data
         if (isset($this->_datas['matchreferee'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['matchreferee'], 'MatchReferee'));
         }
         // set the person data
         if (isset($this->_datas['person'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['person'], 'Person'));
         }
         // set the projectreferee data
         if (isset($this->_datas['projectreferee'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectreferee'], 'ProjectReferee'));
         }
         // set the projectteam data
         if (isset($this->_datas['projectteam'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectteam'], 'ProjectTeam'));
         }
         // set playground data of project
         if (isset($this->_datas['playground'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['playground'], 'Playground'));
         }
         // close the project
         $output .= '</project>';
         // mal als test
         $xmlfile = $output;
         $file = JPATH_SITE . DS . 'tmp' . DS . 'joomleague_import.jlg';
         JFile::write($file, $xmlfile);
     }
     // kalender file vom bfv ende
     $teamid = 1;
     $this->fileName = JFile::read($file);
     $this->lines = file($file);
     if ($this->lines) {
         $row = 0;
         if ($whichfile == 'playerfile') {
             // test
             // spielplan anfang
             # tab delimited, and encoding conversion
             $csv = new parseCSV();
             $csv->encoding('UTF-16', 'UTF-8');
             //$csv->delimiter = "\t";
             switch ($delimiter) {
                 case ";":
                     $csv->delimiter = ";";
                     break;
                 case ",":
                     $csv->delimiter = ",";
                     break;
                 default:
                     $csv->delimiter = "\t";
                     break;
             }
             $startrow = $jRegistry->get('cfg_dfbnet_player_startrow') - 2;
             $csv->parse($file, $startrow);
             //$mainframe->enqueueMessage(JText::_('result<br><pre>'.print_r($csv->data,true).'</pre>'   ),'');
             // anfang schleife csv file
             for ($a = 0; $a < sizeof($csv->data); $a++) {
                 $temp = new stdClass();
                 $temp->id = 0;
                 $temp->knvbnr = $csv->data[$a][$jRegistry->get('cfg_dfbnet_player_passnummer')];
                 $temp->lastname = $csv->data[$a][$jRegistry->get('cfg_dfbnet_player_firstname')];
                 $temp->firstname = $csv->data[$a][$jRegistry->get('cfg_dfbnet_player_lastname')];
                 $temp->info = $csv->data[$a][$jRegistry->get('cfg_dfbnet_player_info')];
                 $datetime = strtotime($csv->data[$a][$jRegistry->get('cfg_dfbnet_player_birthday')]);
                 $temp->birthday = date('Y-m-d', $datetime);
                 $temp->country = $country;
                 $temp->nickname = '';
                 $temp->position_id = '';
                 //$temp->lastname = utf8_encode ($temp->lastname);
                 //$temp->firstname = utf8_encode ($temp->firstname);
                 $exportplayer[] = $temp;
             }
             // spielerdatei
             $temp = new stdClass();
             $temp->name = 'playerfile';
             $temp->exportRoutine = '2010-09-19 23:00:00';
             $this->_datas['exportversion'] = $temp;
             $this->_datas['person'] = array_merge($exportplayer);
         } elseif ($whichfile == 'matchfile') {
             // spielplan anfang
             # tab delimited, and encoding conversion
             $csv = new parseCSV();
             $csv->encoding('UTF-16', 'UTF-8');
             //$csv->delimiter = "\t";
             switch ($delimiter) {
                 case ";":
                     $csv->delimiter = ";";
                     break;
                 case ",":
                     $csv->delimiter = ",";
                     break;
                 default:
                     $csv->delimiter = "\t";
                     break;
             }
             $csv->parse($file);
             if (sizeof($csv->data) == 0) {
                 $mainframe->enqueueMessage(JText::_('falsches Dateiformat'), 'Error');
                 $importcsv = false;
             } else {
                 //$mainframe->enqueueMessage(JText::_('result<br><pre>'.print_r($csv->data[0],true).'</pre>'   ),'');
                 //$mainframe->enqueueMessage(JText::_('result<br><pre>'.print_r($csv->data,true).'</pre>'   ),'');
                 $importcsv = true;
             }
             $lfdnumber = 0;
             $lfdnumberteam = 1;
             $lfdnumbermatch = 1;
             $lfdnumberplayground = 1;
             $lfdnumberperson = 1;
             $lfdnumbermatchreferee = 1;
             // anfang schleife csv file
             for ($a = 0; $a < sizeof($csv->data); $a++) {
                 if (empty($lfdnumber)) {
                     $temp = new stdClass();
                     $temp->name = $csv->data[$a][$jRegistry->get('cfg_dfbnet_verband_name')];
                     $temp->exportRoutine = '2010-09-19 23:00:00';
                     $this->_datas['exportversion'] = $temp;
                     $temp = new stdClass();
                     $temp->name = $csv->data[$a][$jRegistry->get('cfg_dfbnet_season_name')];
                     $this->_datas['season'] = $temp;
                     $temp = new stdClass();
                     $temp->name = $csv->data[$a][$jRegistry->get('cfg_dfbnet_league_name')] . ' ' . $csv->data[$a][$jRegistry->get('cfg_dfbnet_staffel_number')];
                     $temp->country = $country;
                     $this->_datas['league'] = $temp;
                     $temp = new stdClass();
                     $temp->id = 1;
                     $temp->name = 'COM_JOOMLEAGUE_ST_SOCCER';
                     $this->_datas['sportstype'] = $temp;
                     $temp = new stdClass();
                     $temp->name = $csv->data[$a][$jRegistry->get('cfg_dfbnet_league_name')] . ' ' . $csv->data[$a][$jRegistry->get('cfg_dfbnet_season_name')];
                     $temp->serveroffset = 0;
                     $temp->start_time = '15:30';
                     $temp->start_date = '0000-00-00';
                     $temp->sports_type_id = 1;
                     $temp->project_type = 'SIMPLE_LEAGUE';
                     $temp->staffel_id = $csv->data[$a][$jRegistry->get('cfg_dfbnet_staffel_name')];
                     $this->_datas['project'] = $temp;
                 }
                 if (empty($csv->data[$a][$jRegistry->get('cfg_dfbnet_weekday_changed')])) {
                     $valuematchday = $csv->data[$a][$jRegistry->get('cfg_dfbnet_round_name')];
                     if (isset($exportround[$valuematchday])) {
                     } else {
                         $temp = new stdClass();
                         $temp->id = $valuematchday;
                         $temp->roundcode = $valuematchday;
                         $temp->name = $valuematchday . '.Spieltag';
                         $temp->alias = $valuematchday . '.Spieltag';
                         $temp->round_date_first = '';
                         $temp->round_date_last = '';
                         $exportround[$valuematchday] = $temp;
                     }
                     // dfbnet heimmannschaft
                     $valueheim = $csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')];
                     if ($valueheim != 'Spielfrei') {
                         if (in_array($valueheim, $exportteamstemp)) {
                             // echo $valueheim." <- enthalten<br>";
                             $exportclubsstandardplayground[$valueheim] = $csv->data[$a][$jRegistry->get('cfg_dfbnet_playground_name')];
                             $exportplaygroundclubib[$csv->data[$a][$jRegistry->get('cfg_dfbnet_playground_name')]] = $valueheim;
                         } else {
                             // echo $valueheim." <- nicht enthalten<br>";
                             $exportclubsstandardplayground[$valueheim] = $csv->data[$a][$jRegistry->get('cfg_dfbnet_playground_name')];
                             $exportplaygroundclubib[$csv->data[$a][$jRegistry->get('cfg_dfbnet_playground_name')]] = $valueheim;
                             $exportteamstemp[] = $valueheim;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberteam;
                             $temp->club_id = $lfdnumberteam;
                             $temp->name = $valueheim;
                             $temp->middle_name = $valueheim;
                             $temp->short_name = $valueheim;
                             $temp->info = $csv->data[$a][$jRegistry->get('cfg_dfbnet_teamart_name')];
                             $temp->extended = '';
                             $exportteams[] = $temp;
                             $mainframe->setUserState($option . "teamart", $temp->info);
                             // der clubname muss um die mannschaftsnummer verkürzt werden
                             if (substr($valueheim, -4, 4) == ' III') {
                                 $convert = array(' III' => '');
                                 $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim);
                             }
                             if (substr($valueheim, -3, 3) == ' II') {
                                 $convert = array(' II' => '');
                                 $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim);
                             }
                             if (substr($valueheim, -2, 2) == ' I') {
                                 $convert = array(' I' => '');
                                 $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim);
                             }
                             if (substr($valueheim, -2, 2) == ' 3') {
                                 $convert = array(' 3' => '');
                                 $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim);
                             }
                             if (substr($valueheim, -2, 2) == ' 2') {
                                 $convert = array(' 2' => '');
                                 $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim);
                             }
                             $temp = new stdClass();
                             $temp->id = $lfdnumberteam;
                             $club_id = $lfdnumberteam;
                             $temp->name = $valueheim;
                             $temp->country = $country;
                             $temp->extended = '';
                             $temp->standard_playground = $lfdnumberplayground;
                             $exportclubs[] = $temp;
                             //$mainframe->enqueueMessage(JText::_('heim verein -> '.$valueheim ),'Notice');
                             $temp = new stdClass();
                             $temp->id = $lfdnumberteam;
                             $temp->team_id = $lfdnumberteam;
                             $temp->project_team_id = $lfdnumberteam;
                             $temp->is_in_score = 1;
                             $temp->division_id = 0;
                             $temp->start_points = 0;
                             $temp->points_finally = 0;
                             $temp->neg_points_finally = 0;
                             $temp->matches_finally = 0;
                             $temp->won_finally = 0;
                             $temp->draws_finally = 0;
                             $temp->lost_finally = 0;
                             $temp->homegoals_finally = 0;
                             $temp->guestgoals_finally = 0;
                             $temp->diffgoals_finally = 0;
                             $temp->standard_playground = $lfdnumberplayground;
                             $exportprojectteams[] = $temp;
                             $lfdnumberteam++;
                         }
                     }
                     // dfbnet gastmannschaft
                     $valuegast = $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')];
                     if ($valuegast != 'Spielfrei') {
                         if (in_array($valuegast, $exportteamstemp)) {
                             // echo $valuegast." <- enthalten<br>";
                         } else {
                             // echo $valuegast." <- nicht enthalten<br>";
                             $exportteamstemp[] = $valuegast;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberteam;
                             $temp->club_id = $lfdnumberteam;
                             $temp->name = $valuegast;
                             $temp->middle_name = $valuegast;
                             $temp->short_name = $valuegast;
                             $temp->info = $csv->data[$a][$jRegistry->get('cfg_dfbnet_teamart_name')];
                             $temp->extended = '';
                             $exportteams[] = $temp;
                             // der clubname muss um die mannschaftsnummer verkürzt werden
                             if (substr($valuegast, -4, 4) == ' III') {
                                 $convert = array(' III' => '');
                                 $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast);
                             }
                             if (substr($valuegast, -3, 3) == ' II') {
                                 $convert = array(' II' => '');
                                 $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast);
                             }
                             if (substr($valuegast, -2, 2) == ' I') {
                                 $convert = array(' I' => '');
                                 $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast);
                             }
                             if (substr($valuegast, -2, 2) == ' 3') {
                                 $convert = array(' 3' => '');
                                 $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast);
                             }
                             if (substr($valuegast, -2, 2) == ' 2') {
                                 $convert = array(' 2' => '');
                                 $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast);
                             }
                             $temp = new stdClass();
                             $temp->id = $lfdnumberteam;
                             $temp->name = $valuegast;
                             $temp->standard_playground = 0;
                             $temp->country = $country;
                             $temp->extended = '';
                             $exportclubs[] = $temp;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberteam;
                             $temp->team_id = $lfdnumberteam;
                             $temp->project_team_id = $lfdnumberteam;
                             $temp->is_in_score = 1;
                             $temp->division_id = 0;
                             $temp->start_points = 0;
                             $temp->points_finally = 0;
                             $temp->neg_points_finally = 0;
                             $temp->matches_finally = 0;
                             $temp->won_finally = 0;
                             $temp->draws_finally = 0;
                             $temp->lost_finally = 0;
                             $temp->homegoals_finally = 0;
                             $temp->guestgoals_finally = 0;
                             $temp->diffgoals_finally = 0;
                             $temp->standard_playground = 0;
                             $exportprojectteams[] = $temp;
                             $lfdnumberteam++;
                         }
                     }
                     // dfbnet spielstaette
                     $valueplayground = $csv->data[$a][$jRegistry->get('cfg_dfbnet_playground_name')];
                     if ($valueplayground) {
                         if (array_key_exists($valueplayground, $exportplaygroundtemp)) {
                             // echo $valueplayground." <- enthalten<br>";
                         } else {
                             // echo $valueplayground." <- nicht enthalten<br>";
                             $exportplaygroundtemp[$valueplayground] = $lfdnumberplayground;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberplayground;
                             $matchnumberplayground = $lfdnumberplayground;
                             $temp->name = $valueplayground;
                             $temp->short_name = $valueplayground;
                             $temp->country = $country;
                             $temp->max_visitors = 0;
                             $valueheimsuchen = $exportplaygroundclubib[$valueplayground];
                             foreach ($exportteamstemp as $key => $value) {
                                 if ($value == $valueheimsuchen) {
                                     $club_id = $key + 1;
                                 }
                             }
                             $temp->club_id = $club_id;
                             $exportplayground[] = $temp;
                             //$mainframe->enqueueMessage(JText::_('playground -> '.$valueplayground ),'Notice');
                             //$mainframe->enqueueMessage(JText::_('heimmannschaft suchen -> '.$valueheimsuchen ),'Notice');
                             //$mainframe->enqueueMessage(JText::_('heimmannschaft club-id -> '.$club_id ),'Notice');
                             $lfdnumberplayground++;
                         }
                     }
                     $valueperson = $csv->data[$a][$jRegistry->get('cfg_dfbnet_spielleitung_name')];
                     $valueperson1 = $csv->data[$a][$jRegistry->get('cfg_dfbnet_assistent1_name')];
                     $valueperson2 = $csv->data[$a][$jRegistry->get('cfg_dfbnet_assistent2_name')];
                     //if (in_array($valueperson, $exportpersonstemp))
                     if (array_key_exists($valueperson, $exportpersonstemp)) {
                         if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                             // nichts machen
                         } else {
                             $tempmatchreferee = new stdClass();
                             $tempmatchreferee->id = $lfdnumbermatchreferee;
                             $tempmatchreferee->match_id = $lfdnumbermatch;
                             $tempmatchreferee->project_referee_id = $exportpersonstemp[$valueperson];
                             $tempmatchreferee->project_position_id = 1000;
                             $exportmatchreferee[] = $tempmatchreferee;
                             $lfdnumbermatchreferee++;
                         }
                     } else {
                         if (strlen($valueperson) > 6 && $valueperson) {
                             // echo $valueperson." <- nicht enthalten<br>";
                             $exportpersonstemp[$valueperson] = $lfdnumberperson;
                             // nach- und vorname richtig setzen
                             $teile = explode(",", $valueperson);
                             $temp = new stdClass();
                             $temp->id = $lfdnumberperson;
                             $temp->person_id = $lfdnumberperson;
                             $temp->project_position_id = 1000;
                             $exportreferee[] = $temp;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberperson;
                             $temp->lastname = trim($teile[0]);
                             $temp->firstname = trim($teile[1]);
                             $temp->nickname = '';
                             $temp->knvbnr = '';
                             $temp->location = '';
                             $temp->birthday = '0000-00-00';
                             $temp->country = $country;
                             $temp->position_id = 1000;
                             $temp->info = 'Schiri';
                             $exportpersons[] = $temp;
                             if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                                 // nichts machen
                             } else {
                                 $tempmatchreferee = new stdClass();
                                 $tempmatchreferee->id = $lfdnumbermatchreferee;
                                 $tempmatchreferee->match_id = $lfdnumbermatch;
                                 $tempmatchreferee->project_referee_id = $lfdnumberperson;
                                 $tempmatchreferee->project_position_id = 1000;
                                 $exportmatchreferee[] = $tempmatchreferee;
                                 $lfdnumbermatchreferee++;
                             }
                             $lfdnumberperson++;
                         }
                     }
                     // 1.assistent
                     if (array_key_exists($valueperson1, $exportpersonstemp)) {
                         if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                             // nichts machen
                         } else {
                             $tempmatchreferee = new stdClass();
                             $tempmatchreferee->id = $lfdnumbermatchreferee;
                             $tempmatchreferee->match_id = $lfdnumbermatch;
                             $tempmatchreferee->project_referee_id = $exportpersonstemp[$valueperson1];
                             $tempmatchreferee->project_position_id = 1001;
                             $exportmatchreferee[] = $tempmatchreferee;
                             $lfdnumbermatchreferee++;
                         }
                     } else {
                         if (strlen($valueperson1) > 6 && $valueperson1) {
                             // echo $valueperson." <- nicht enthalten<br>";
                             $exportpersonstemp[$valueperson1] = $lfdnumberperson;
                             // nach- und vorname richtig setzen
                             $teile = explode(",", $valueperson1);
                             $temp = new stdClass();
                             $temp->id = $lfdnumberperson;
                             $temp->person_id = $lfdnumberperson;
                             $temp->project_position_id = 1001;
                             $exportreferee[] = $temp;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberperson;
                             $temp->lastname = trim($teile[0]);
                             $temp->firstname = trim($teile[1]);
                             $temp->nickname = '';
                             $temp->knvbnr = '';
                             $temp->location = '';
                             $temp->birthday = '0000-00-00';
                             $temp->country = $country;
                             $temp->position_id = 1001;
                             $temp->info = 'Schiri';
                             $exportpersons[] = $temp;
                             if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                                 // nichts machen
                             } else {
                                 $tempmatchreferee = new stdClass();
                                 $tempmatchreferee->id = $lfdnumbermatchreferee;
                                 $tempmatchreferee->match_id = $lfdnumbermatch;
                                 $tempmatchreferee->project_referee_id = $lfdnumberperson;
                                 $tempmatchreferee->project_position_id = 1001;
                                 $exportmatchreferee[] = $tempmatchreferee;
                                 $lfdnumbermatchreferee++;
                             }
                             $lfdnumberperson++;
                         }
                     }
                     // 2.assistent
                     if (array_key_exists($valueperson2, $exportpersonstemp)) {
                         if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                             // nichts machen
                         } else {
                             $tempmatchreferee = new stdClass();
                             $tempmatchreferee->id = $lfdnumbermatchreferee;
                             $tempmatchreferee->match_id = $lfdnumbermatch;
                             $tempmatchreferee->project_referee_id = $exportpersonstemp[$valueperson2];
                             $tempmatchreferee->project_position_id = 1002;
                             $exportmatchreferee[] = $tempmatchreferee;
                             $lfdnumbermatchreferee++;
                         }
                     } else {
                         if (strlen($valueperson2) > 6 && $valueperson2) {
                             // echo $valueperson." <- nicht enthalten<br>";
                             $exportpersonstemp[$valueperson2] = $lfdnumberperson;
                             // nach- und vorname richtig setzen
                             $teile = explode(",", $valueperson2);
                             $temp = new stdClass();
                             $temp->id = $lfdnumberperson;
                             $temp->person_id = $lfdnumberperson;
                             $temp->project_position_id = 1002;
                             $exportreferee[] = $temp;
                             $temp = new stdClass();
                             $temp->id = $lfdnumberperson;
                             $temp->lastname = trim($teile[0]);
                             $temp->firstname = trim($teile[1]);
                             $temp->nickname = '';
                             $temp->knvbnr = '';
                             $temp->location = '';
                             $temp->birthday = '0000-00-00';
                             $temp->country = $country;
                             $temp->position_id = 1002;
                             $temp->info = 'Schiri';
                             $exportpersons[] = $temp;
                             if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                                 // nichts machen
                             } else {
                                 $tempmatchreferee = new stdClass();
                                 $tempmatchreferee->id = $lfdnumbermatchreferee;
                                 $tempmatchreferee->match_id = $lfdnumbermatch;
                                 $tempmatchreferee->project_referee_id = $lfdnumberperson;
                                 $tempmatchreferee->project_position_id = 1002;
                                 $exportmatchreferee[] = $tempmatchreferee;
                                 $lfdnumbermatchreferee++;
                             }
                             $lfdnumberperson++;
                         }
                     }
                     //   echo 'paarung -> '.$csv->data[$a]['Heim Mannschaft']." <-> ".$csv->data[$a]['Gast Mannschaft'].'<br>';
                     if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')] == 'Spielfrei' || $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')] == 'Spielfrei') {
                         // nichts machen
                     } else {
                         $round_id = $csv->data[$a][$jRegistry->get('cfg_dfbnet_round_name')];
                         $tempmatch = new stdClass();
                         $tempmatch->id = $lfdnumbermatch;
                         $tempmatch->round_id = $round_id;
                         $datetime = strtotime($csv->data[$a][$jRegistry->get('cfg_dfbnet_date')]);
                         $tempmatch->match_date = date('Y-m-d', $datetime) . " " . $csv->data[$a][$jRegistry->get('cfg_dfbnet_time')];
                         if ($csv->data[$a][$jRegistry->get('cfg_dfbnet_date_changed')]) {
                             $datetime = strtotime($csv->data[$a][$jRegistry->get('cfg_dfbnet_date_changed')]);
                             $tempmatch->match_date_verlegt = date('Y-m-d', $datetime) . " " . $csv->data[$a][$jRegistry->get('cfg_dfbnet_time_changed')];
                         } else {
                             $tempmatch->match_date_verlegt = '';
                         }
                         // datum im spieltag setzen
                         if (!$exportround[$round_id]->round_date_first && !$exportround[$round_id]->round_date_last) {
                             $exportround[$round_id]->round_date_first = date('Y-m-d', $datetime);
                             $exportround[$round_id]->round_date_last = date('Y-m-d', $datetime);
                         }
                         if ($exportround[$round_id]->round_date_first && $exportround[$round_id]->round_date_last) {
                             $datetime_first = strtotime($exportround[$round_id]->round_date_first);
                             $datetime_last = strtotime($exportround[$round_id]->round_date_last);
                             if ($datetime_first > $datetime) {
                                 $exportround[$round_id]->round_date_first = date('Y-m-d', $datetime);
                             }
                             if ($datetime_last < $datetime) {
                                 $exportround[$round_id]->round_date_last = date('Y-m-d', $datetime);
                             }
                         }
                         //$tempmatch->match_number = $csv->data[$a]['Spielkennung'];
                         //$tempmatch->match_number = $lfdnumbermatch;
                         $tempmatch->match_number = $csv->data[$a][$jRegistry->get('cfg_dfbnet_game_id')];
                         $tempmatch->published = 1;
                         $tempmatch->count_result = 1;
                         $tempmatch->show_report = 1;
                         $tempmatch->projectteam1_id = 0;
                         $tempmatch->projectteam2_id = 0;
                         $tempmatch->projectteam1_dfbnet = $csv->data[$a][$jRegistry->get('cfg_dfbnet_home_name')];
                         $tempmatch->projectteam2_dfbnet = $csv->data[$a][$jRegistry->get('cfg_dfbnet_away_name')];
                         $tempmatch->team1_result = '';
                         $tempmatch->team2_result = '';
                         $tempmatch->summary = '';
                         if (array_key_exists($valueplayground, $exportplaygroundtemp)) {
                             $tempmatch->playground_id = $exportplaygroundtemp[$valueplayground];
                         }
                         //if ( empty($csv->data[$a]['Spalte28']) )
                         //  {
                         if (array_key_exists($tempmatch->match_number, $temp_match_number)) {
                             $exportmatch[] = $tempmatch;
                         } else {
                             $temp_match_number[$tempmatch->match_number] = $tempmatch->match_number;
                             $exportmatch[] = $tempmatch;
                         }
                         //}
                         $lfdnumbermatch++;
                         $lfdnumber++;
                     }
                 }
             }
             // ende schleife csv file
             foreach ($exportmatch as $rowmatch) {
                 foreach ($exportteams as $rowteam) {
                     if ($rowmatch->projectteam1_dfbnet == $rowteam->name) {
                         $rowmatch->projectteam1_id = $rowteam->id;
                     }
                     if ($rowmatch->projectteam2_dfbnet == $rowteam->name) {
                         $rowmatch->projectteam2_id = $rowteam->id;
                     }
                 }
             }
             if ($importcsv && sizeof($exportreferee) > 0) {
                 $temp = new stdClass();
                 $temp->id = 1;
                 $temp->name = 'Schiedsrichter';
                 $temp->alias = 'Schiedsrichter';
                 $temp->published = 1;
                 $exportparentposition[] = $temp;
                 $temp = new stdClass();
                 $temp->id = 1000;
                 $temp->name = 'Spielleitung';
                 $temp->alias = 'Spielleitung';
                 $temp->parent_id = 1;
                 $temp->published = 1;
                 $temp->persontype = 3;
                 $exportposition[] = $temp;
                 $temp = new stdClass();
                 $temp->id = 1001;
                 $temp->name = '1.Assistent';
                 $temp->alias = '1.Assistent';
                 $temp->parent_id = 1;
                 $temp->published = 1;
                 $temp->persontype = 3;
                 $exportposition[] = $temp;
                 $temp = new stdClass();
                 $temp->id = 1002;
                 $temp->name = '2.Assistent';
                 $temp->alias = '2.Assistent';
                 $temp->parent_id = 1;
                 $temp->published = 1;
                 $temp->persontype = 3;
                 $exportposition[] = $temp;
                 $temp = new stdClass();
                 $temp->id = 1000;
                 $temp->position_id = 1000;
                 $exportprojectposition[] = $temp;
                 $temp = new stdClass();
                 $temp->id = 1001;
                 $temp->position_id = 1001;
                 $exportprojectposition[] = $temp;
                 $temp = new stdClass();
                 $temp->id = 1002;
                 $temp->position_id = 1002;
                 $exportprojectposition[] = $temp;
             }
             foreach ($exportteams as $rowteam) {
                 $play_ground = $exportclubsstandardplayground[$rowteam->name];
                 $club_id = $rowteam->club_id;
                 //echo 'club_id -> '.$club_id.'<br>';
                 //echo 'play_ground -> '.$play_ground.'<br>';
                 foreach ($exportplayground as $rowground) {
                     if ($play_ground == $rowground->name) {
                         $play_ground_id = $rowground->id;
                         //echo 'play_ground_id -> '.$play_ground_id.'<br>';
                         foreach ($exportclubs as $rowclubs) {
                             if ($club_id == $rowclubs->id) {
                                 $rowclubs->standard_playground = $play_ground_id;
                             }
                         }
                     }
                 }
             }
             $this->_datas['position'] = array_merge($exportposition);
             $this->_datas['projectposition'] = array_merge($exportprojectposition);
             $this->_datas['parentposition'] = array_merge($exportparentposition);
             $this->_datas['person'] = array_merge($exportpersons);
             $this->_datas['projectreferee'] = array_merge($exportreferee);
             $this->_datas['team'] = array_merge($exportteams);
             $this->_datas['projectteam'] = array_merge($exportprojectteams);
             $this->_datas['club'] = array_merge($exportclubs);
             $this->_datas['playground'] = array_merge($exportplayground);
             // damit die spieltage in der richtigen reihenfolge angelegt werden
             ksort($exportround);
             $this->_datas['round'] = array_merge($exportround);
             $this->_datas['match'] = array_merge($exportmatch);
             $this->_datas['matchreferee'] = array_merge($exportmatchreferee);
         }
     }
     //  echo '<pre>';
     //  print_r($this->_datas);
     //  echo '</pre>';
     if ($whichfile == 'playerfile') {
         /**
          * das ganze für den standardimport aufbereiten
          */
         $output = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
         // open the project
         $output .= "<project>\n";
         // set the version of JoomLeague
         $output .= $this->_addToXml($this->_setJoomLeagueVersion());
         // set the person data
         if (isset($this->_datas['person'])) {
             $mainframe->enqueueMessage(JText::_('personen daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['person'], 'Person'));
         }
         // close the project
         $output .= '</project>';
         // mal als test
         $xmlfile = $output;
         $file = JPATH_SITE . DS . 'tmp' . DS . 'joomleague_import.jlg';
         JFile::write($file, $xmlfile);
         $this->import_version = 'NEW';
     } else {
         /**
          * das ganze für den standardimport aufbereiten
          */
         $output = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
         // open the project
         $output .= "<project>\n";
         // set the version of JoomLeague
         $output .= $this->_addToXml($this->_setJoomLeagueVersion());
         // set the project datas
         if (isset($this->_datas['project'])) {
             $mainframe->enqueueMessage(JText::_('project daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setProjectData($this->_datas['project']));
         }
         // set the rounds sportstype
         if (isset($this->_datas['sportstype'])) {
             $mainframe->enqueueMessage(JText::_('sportstype daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setSportsType($this->_datas['sportstype']));
         }
         // set league data of project
         if (isset($this->_datas['league'])) {
             $mainframe->enqueueMessage(JText::_('league daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setLeagueData($this->_datas['league']));
         }
         // set season data of project
         if (isset($this->_datas['season'])) {
             $mainframe->enqueueMessage(JText::_('season daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setSeasonData($this->_datas['season']));
         }
         // set the rounds data
         if (isset($this->_datas['round'])) {
             $mainframe->enqueueMessage(JText::_('round daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['round'], 'Round'));
         }
         // set the teams data
         if (isset($this->_datas['team'])) {
             $mainframe->enqueueMessage(JText::_('team daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['team'], 'JL_Team'));
         }
         // set the clubs data
         if (isset($this->_datas['club'])) {
             $mainframe->enqueueMessage(JText::_('club daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['club'], 'Club'));
         }
         // set the matches data
         if (isset($this->_datas['match'])) {
             $mainframe->enqueueMessage(JText::_('match daten ' . 'generiert'), '');
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['match'], 'Match'));
         }
         // set the positions data
         if (isset($this->_datas['position'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['position'], 'Position'));
         }
         // set the positions parent data
         if (isset($this->_datas['parentposition'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['parentposition'], 'ParentPosition'));
         }
         // set position data of project
         if (isset($this->_datas['projectposition'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectposition'], 'ProjectPosition'));
         }
         // set the matchreferee data
         if (isset($this->_datas['matchreferee'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['matchreferee'], 'MatchReferee'));
         }
         // set the person data
         if (isset($this->_datas['person'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['person'], 'Person'));
         }
         // set the projectreferee data
         if (isset($this->_datas['projectreferee'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectreferee'], 'ProjectReferee'));
         }
         // set the projectteam data
         if (isset($this->_datas['projectteam'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectteam'], 'ProjectTeam'));
         }
         // set playground data of project
         if (isset($this->_datas['playground'])) {
             $output .= $this->_addToXml($this->_setXMLData($this->_datas['playground'], 'Playground'));
         }
         // close the project
         $output .= '</project>';
         // mal als test
         $xmlfile = $output;
         $file = JPATH_SITE . DS . 'tmp' . DS . 'joomleague_import.jlg';
         JFile::write($file, $xmlfile);
     }
     $this->import_version = 'NEW';
     if ($this->debug_info) {
         echo $this->pane->endPane();
     }
     //$mainframe->setUserState('com_joomleague'.'_datas',$this->_datas);
     return $this->_datas;
 }
<?php

header('Content-Type: application/json');
require_once '../parsecsv-for-php/parsecsv.lib.php';
$csv = new parseCSV();
$csv->parse('../../../00_ADMIN_CSV_FOLDER/service_discounts.csv');
echo json_encode($csv->data);
} catch (PDOException $e) {
    // Print PDOException message
    echo "<h1 style='text-align:center;'>\n        Something went wrong with the database..\n        </h1>\n";
    echo $e->getMessage();
    echo '<br>';
    var_dump($e->getTraceAsString());
    die(1);
}
/*
    for debug, append the data to a csv as well
*/
// insert id in front
$vals = ['id' => $lastId] + $vals;
$csv = new parseCSV();
$csv->sort_by = 'email';
$csv->parse($csv_db_name);
$csv->data[$vals['email']] = $vals;
$csv->save();
#print_r($csv->data);
$from = '"LISA Symposium Website" <*****@*****.**>';
$replyto = $from;
$to1 = "*****@*****.**";
$to2 = "*****@*****.**";
$subj = "[LISA] registration";
$headers = 'From: ' . $from . "\r\n";
$headers .= 'Reply-To:' . $replyto . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
$headers .= 'Delivery-Date: ' . date("r") . "\r\n";
$msg = "Someone registered for the lisa conference. Here a backup dump\r\n\r\n";
<?php

header('Content-Type: application/json');
require_once '../parsecsv-for-php/parsecsv.lib.php';
$csv = new parseCSV();
$csv->parse('../../../00_ADMIN_CSV_FOLDER/bodytype_service_pricing_minutes.csv');
echo json_encode($csv->data);
예제 #20
0
 public function readCSV($inData)
 {
     $csvData = array('error' => "File Not Found");
     $noticeID = $inData['notice_id'];
     $user_file_dir = $this->session->get_user_var('file_directory');
     $basePath = "../user_files/" . $user_file_dir . "/datasources/";
     $realBasePath = realpath($basePath);
     $userPath = $basePath . $inData['subdir'] . $inData['file'];
     $realUserPath = realpath($userPath);
     if ($realUserPath === false || strpos($realUserPath, $realBasePath) !== 0) {
         //Is directory Traversal, bad!
         $this->outData['data'] = $csvData;
     } else {
         //Not directory Traversal.
         $csv = new parseCSV();
         if (filesize($realUserPath) > 0) {
             $csv->parse($realUserPath, 0, 10000);
             // At max 10000 lines.
             $csvDataRows = $csv->unparse($csv->data, $csv->titles, null, null, null, true);
         } else {
             $csvDataRows = array(array(""));
         }
         $csvData = array("csv_data" => $csvDataRows, "header_count" => count($csv->titles), "headers" => $csv->titles, "row_count" => count($csvDataRows), "csv_errors" => $csv->error_info);
         $this->outData['data'] = $csvData;
     }
     echo json_encode($csvData);
 }
예제 #21
0
function gigpress_import()
{
    // Deep breath
    global $wpdb, $gpo;
    // We've just uploaded a file to import
    check_admin_referer('gigpress-action');
    $upload = wp_upload_bits($_FILES['gp_import']['name'], null, file_get_contents($_FILES['gp_import']['tmp_name']));
    if (!$upload['error']) {
        // The file was uploaded, so let's try and parse the mofo
        require_once WP_PLUGIN_DIR . '/gigpress/lib/parsecsv.lib.php';
        // This is under MIT license, which ain't GNU, but was else is new? Don't tell on me!
        $csv = new parseCSV();
        $csv->parse($upload['file']);
        if ($csv->data) {
            // Looks like we parsed something
            $inserted = array();
            $skipped = array();
            $duplicates = array();
            foreach ($csv->data as $key => $show) {
                // Check to see if we have this artist
                $artist_exists = $wpdb->get_var("SELECT artist_id FROM " . GIGPRESS_ARTISTS . " WHERE artist_name = '" . mysql_real_escape_string($show['Artist']) . "'");
                if (!$artist_exists) {
                    // Can't find an artist with this name, so we'll have to create them
                    $new_artist = array('artist_name' => gigpress_db_in($show['Artist']));
                    $wpdb->insert(GIGPRESS_ARTISTS, $new_artist);
                    $show['artist_id'] = $wpdb->insert_id;
                } else {
                    $show['artist_id'] = $artist_exists;
                }
                if ($show['Tour']) {
                    // Check to see if we have this tour
                    $tour_exists = $wpdb->get_var("SELECT tour_id FROM " . GIGPRESS_TOURS . " WHERE tour_name = '" . mysql_real_escape_string($show['Tour']) . "' AND tour_status = 'active'");
                    if (!$tour_exists) {
                        // Can't find a tour with this name, so we'll have to create it
                        $order = $wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_TOURS . " WHERE tour_status = 'active'");
                        $order++;
                        $new_tour = array('tour_name' => gigpress_db_in($show['Tour']));
                        $wpdb->insert(GIGPRESS_TOURS, $new_tour);
                        $show['tour_id'] = $wpdb->insert_id;
                    } else {
                        $show['tour_id'] = $tour_exists;
                    }
                }
                // Check to see if we have this venue
                $venue_exists = $wpdb->get_var("SELECT venue_id FROM " . GIGPRESS_VENUES . " WHERE venue_name = '" . mysql_real_escape_string($show['Venue']) . "' AND venue_city = '" . mysql_real_escape_string($show['City']) . "' AND venue_country = '" . mysql_real_escape_string($show['Country']) . "'");
                if (!$venue_exists) {
                    // Can't find a venue with this name, so we'll have to create it
                    $new_venue = array('venue_name' => gigpress_db_in($show['Venue']), 'venue_address' => gigpress_db_in($show['Address']), 'venue_city' => gigpress_db_in($show['City']), 'venue_country' => gigpress_db_in($show['Country']), 'venue_url' => gigpress_db_in($show['Venue URL']), 'venue_phone' => gigpress_db_in($show['Venue phone']));
                    $wpdb->insert(GIGPRESS_VENUES, $new_venue);
                    $show['venue_id'] = $wpdb->insert_id;
                } else {
                    $show['venue_id'] = $venue_exists;
                }
                if ($show['Time'] == FALSE) {
                    $show['Time'] = '00:00:01';
                }
                if ($wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_SHOWS . " WHERE show_artist_id = " . $show['artist_id'] . " AND show_date = '" . $show['Date'] . "' AND show_time = '" . $show['Time'] . "' AND show_venue_id = " . $show['venue_id'] . " AND show_status != 'deleted'") > 0) {
                    // It's a duplicate, so log it and move on
                    $duplicates[] = $show;
                } else {
                    if ($show['End date'] == FALSE) {
                        $show['show_multi'] = 0;
                        $show['End date'] = $show['Date'];
                    } else {
                        $show['show_multi'] = 1;
                    }
                    $new_show = array('show_date' => $show['Date'], 'show_time' => $show['Time'], 'show_multi' => $show['show_multi'], 'show_expire' => $show['End date'], 'show_artist_id' => $show['artist_id'], 'show_venue_id' => $show['venue_id'], 'show_tour_id' => $show['tour_id'], 'show_ages' => gigpress_db_in($show['Admittance']), 'show_price' => gigpress_db_in($show['Price']), 'show_tix_url' => gigpress_db_in($show['Ticket URL']), 'show_tix_phone' => gigpress_db_in($show['Ticket phone']), 'show_notes' => gigpress_db_in($show['Notes'], FALSE), 'show_related' => '0');
                    // Are we importing related post IDs?
                    if (isset($_POST['include_related']) && ($_POST['include_related'] = 'y')) {
                        $new_show['show_related'] = $show['Related ID'];
                    }
                    $formats = array('%s', '%s', '%d', '%s', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d');
                    $import = $wpdb->insert(GIGPRESS_SHOWS, $new_show, $formats);
                    if ($import != FALSE) {
                        $inserted[] = $show;
                    } else {
                        $skipped[] = $show;
                    }
                }
            }
            // end foreach import
            if (!empty($skipped)) {
                echo '<h4 class="error">' . count($skipped) . ' ' . __("shows were skipped due to errors", "gigpress") . '.</h4>';
                echo '<ul class="ul-square">';
                foreach ($skipped as $key => $show) {
                    echo '<li>' . wptexturize($show['Artist']) . ' ' . __("in", "gigpress") . ' ' . wptexturize($show['City']) . ' ' . __("at", "gigpress") . ' ' . wptexturize($show['Venue']) . ' ' . __("on", "gigpress") . ' ' . mysql2date($gpo['date_format'], $show['Date']) . '</li>';
                }
                echo '</ul>';
            }
            if (!empty($duplicates)) {
                echo '<h4 class="error">' . count($duplicates) . ' ' . __("shows were skipped as they were deemed duplicates", "gigpress") . '.</h4>';
                echo '<ul class="ul-square">';
                foreach ($duplicates as $key => $show) {
                    echo '<li>' . wptexturize($show['Artist']) . ' ' . __("in", "gigpress") . ' ' . wptexturize($show['City']) . ' ' . __("at", "gigpress") . ' ' . wptexturize($show['Venue']) . ' ' . __("on", "gigpress") . ' ' . mysql2date($gpo['date_format'], $show['Date']) . '</li>';
                }
                echo '</ul>';
            }
            if (!empty($inserted)) {
                echo '<h4 class="updated">' . count($inserted) . ' ' . __("shows were successfully imported", "gigpress") . '.</h4>';
                echo '<ul class="ul-square">';
                foreach ($inserted as $key => $show) {
                    echo '<li>' . wptexturize($show['Artist']) . ' ' . __("in", "gigpress") . ' ' . wptexturize($show['City']) . ' ' . __("at", "gigpress") . ' ' . wptexturize($show['Venue']) . ' ' . __("on", "gigpress") . ' ' . mysql2date($gpo['date_format'], $show['Date']) . '</li>';
                }
                echo '</ul>';
            }
        } else {
            // The file uploaded, but there were no results from the parse
            echo '<div id="message" class="error fade"><p>' . __("Sorry, but there was an error parsing your file. Maybe double-check your formatting and file type?", "gigpress") . '.</p></div>';
        }
        // Bye-bye
        unlink($upload['file']);
    } else {
        // The upload failed
        echo '<div id="message" class="error fade"><p>' . __("Sorry, but there was an error uploading", "gigpress") . ' <strong>' . $_FILES['gp_import']['name'] . '</strong>: ' . $upload['error'] . '.</p></div>';
    }
}
예제 #22
0
    }
    $csv = new parseCSV();
    $csv->delimiter = ';';
    $csv->parse('dados.csv');
    $csvData = $csv->data;
    foreach ($csvData as $data_key => $data_value) {
        if ($data_value['curso'] == $curso) {
            unset($csvData[$data_key]);
        }
    }
    unset($csv);
    $csv = new File('dados.csv', 'w');
    $csv->write_file('matricula;email;nome;curso;turma' . PHP_EOL);
    unset($csv);
    $csv = new parseCSV();
    $csv->delimiter = ';';
    $csv->save('dados.csv', $csvData, true);
    unset($csv);
    $csv = new parseCSV();
    $csv->delimiter = ';';
    $csv->fields = array('matricula', 'email', 'nome', 'curso', 'turma');
    $csv->parse('dados.csv');
} elseif (isset($_POST['curso_select'])) {
    $array = [];
    foreach (Courses::return_specific_course_class($_POST['curso_select']) as $turma) {
        $array[] = $turma;
    }
    echo json_encode($array);
} else {
    header('location: index.php');
}
예제 #23
0
 /**
  * Parses an incoming CSV file and compiles it into an array
  *
  * @return array an array fo the data from the imported CSV file ready for use in the chart meta
  */
 public function ajax_import_csv()
 {
     $post = get_post(absint($_POST['post_id']));
     // Check post type
     if (!isset($post->post_type) || m_chart()->slug != $post->post_type) {
         wp_send_json_error(esc_html__('Wrong post type', 'm-chart'));
     }
     // Check the nonce
     if (!wp_verify_nonce($_POST['nonce'], m_chart()->slug . '-save-post')) {
         wp_send_json_error(esc_html__('Invalid nonce', 'm-chart'));
     }
     // Check the permissions
     if (!current_user_can('edit_post', $post->ID)) {
         wp_send_json_error(esc_html__('Wrong post type', 'm-chart'));
     }
     // Make sure there's a CSV file
     if (empty($_FILES) || !isset($_FILES['import_csv_file']['name'])) {
         wp_send_json_error(esc_html__('No file to import', 'm-chart'));
     }
     // Make sure the file is a CSV file
     $file_ext = strtolower(pathinfo($_FILES['import_csv_file']['name'], PATHINFO_EXTENSION));
     if ('csv' != $file_ext) {
         wp_send_json_error(esc_html__('Only CSV files can be imported ', 'm-chart'));
     }
     // Do some validation on the CSV file (mirroring what WP does for this sort of thing)
     $csv_file = realpath($_FILES['import_csv_file']['tmp_name']);
     if (!$csv_file) {
         wp_send_json_error(esc_html__('File path not found', 'm-chart'));
     }
     $csv_data = file_get_contents($csv_file);
     if ('' == $csv_data) {
         wp_send_json_error(esc_html__('CSV file was empty', 'm-chart'));
     }
     // Get parseCSV library so we can use it to convert the CSV to a nice array
     // Yes, PHP does this natively now but I've run into trouble with malformed CSV that parsCSV handles fine
     require_once __DIR__ . '/external/parsecsv/parsecsv.lib.php';
     $parse_csv = new parseCSV();
     // The "\n" before and after is to deal with CSV files that don't have line breaks above and below the data
     // Which then seems to confuse parseCSV occasionally
     $parse_csv->parse("\n" . trim($csv_data) . "\n");
     // This deals with Google Doc's crappy CSV exports which don't include columns at the end of a row if they are empty
     $data_array = $this->fix_csv_data_array($parse_csv->data);
     wp_send_json_success($data_array);
 }
예제 #24
0
function send_mail($to, $subject, $message)
{
    global $lang_code, $span_interfaces, $email_credentials;
    $unsubscriber_emails = array();
    $unsubscribers = new parseCSV();
    $unsubscribers->parse(realpath($_SERVER['DOCUMENT_ROOT']) . '/member/unsubscribers_list.csv');
    $unsubscribers_count = count($unsubscribers->data);
    for ($i = 0; $i < $unsubscribers_count; ++$i) {
        $unsubscriber_emails[$i] = $unsubscribers->data[$i]['email'];
    }
    sort($unsubscriber_emails);
    if (!in_array(strtolower($to), $unsubscriber_emails)) {
        $fullname = load_member_from_email($to)['fullname'];
        $boundary = uniqid('np');
        $headers = "";
        $headers .= "Organization: \"Nhip Sinh Hoc . VN\"" . PHP_EOL;
        $headers = "MIME-Version: 1.0" . PHP_EOL;
        $headers .= "X-Priority: 1 (Highest)" . PHP_EOL;
        $headers .= "Importance: High" . PHP_EOL;
        $headers .= "X-Mailer: PHP/" . phpversion() . PHP_EOL;
        $headers .= "Content-Transfer-Encoding: 8bit" . PHP_EOL;
        $headers .= "From: \"Nhip Sinh Hoc . VN\" <*****@*****.**>" . PHP_EOL;
        $headers .= "Sender: <*****@*****.**>" . PHP_EOL;
        $headers .= "Reply-To: \"Nhip Sinh Hoc . VN\" <*****@*****.**>" . PHP_EOL;
        $headers .= "Return-Path: \"Nhip Sinh Hoc . VN\" <*****@*****.**>" . PHP_EOL;
        $headers .= "List-Unsubscribe: <mailto:admin@nhipsinhhoc.vn?subject=Unsubscribe me out of Nhip Sinh Hoc . VN mailing list&body=Please unsubscribe my email&cc=tung.42@gmail.com>" . PHP_EOL;
        $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . PHP_EOL;
        //here is the content body
        $body = "This is a MIME encoded message." . PHP_EOL;
        $body .= PHP_EOL . PHP_EOL . "--" . $boundary . PHP_EOL;
        $body .= "Content-type: text/plain;charset=utf-8" . PHP_EOL . PHP_EOL;
        //Plain text body
        $body .= $message['plain'] . PHP_EOL;
        $body .= PHP_EOL . PHP_EOL . "--" . $boundary . PHP_EOL;
        $body .= "Content-type: text/html;charset=utf-8" . PHP_EOL . PHP_EOL;
        //Html body
        $body .= $message['html'] . PHP_EOL;
        $body .= PHP_EOL . PHP_EOL . "--" . $boundary . "--";
        mail("\"" . $fullname . "\" <" . strtolower($to) . ">", '=?utf-8?B?' . base64_encode($subject) . '?=', $body, $headers);
    }
}