%PDF- %PDF-
| Direktori : /www/varak.net/losik.varak.net/app/ |
| Current File : //www/varak.net/losik.varak.net/app/session-csv.php |
<?php
/**
* Created by IntelliJ IDEA.
* User: mvarak
* Date: 2/22/19
* Time: 3:11 PM
*/
function normalizeString ($str = '')
{
$str = strip_tags($str);
$str = preg_replace('/[\r\n\t ]+/', ' ', $str);
$str = preg_replace('/[\"\*\/\:\<\>\?\'\|]+/', ' ', $str);
$str = strtolower($str);
$str = html_entity_decode( $str, ENT_QUOTES, "utf-8" );
$str = htmlentities($str, ENT_QUOTES, "utf-8");
$str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
$str = str_replace(' ', '-', $str);
$str = rawurlencode($str);
$str = str_replace('%', '-', $str);
return $str;
}
$result = dibi::query("SELECT [data] FROM [registration] WHERE [guid]=%s", $id)->fetchSingle();
$match = json_decode($result, true);
//header("Content-type: text/plain");
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"zavodnici-" . normalizeString($match['name']) . ".csv\"");
echo "Last Name,First Name,Division,Email,Member,Power factor,Squad\n";
foreach ($match['shooters'] as $shooter)
{
$squad = $shooter['squad'] == 999 ? $match['squads'] : $shooter['squad'];
echo $shooter['lastName'] . "," . $shooter['firstName'] . "," . $shooter['division'] . "," . $shooter['email'] . ",,MINOR," . $squad . "\n";
}
die;