2011-05-15 01:32:47 +02:00
|
|
|
<?php
|
2014-09-04 17:52:18 +02:00
|
|
|
/**
|
|
|
|
* This software is governed by the CeCILL-B license. If a copy of this license
|
|
|
|
* is not distributed with this file, you can obtain one at
|
|
|
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
|
|
|
*
|
|
|
|
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
|
|
|
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
|
|
|
|
*
|
2014-07-04 11:21:31 +02:00
|
|
|
* =============================
|
2014-09-04 17:52:18 +02:00
|
|
|
*
|
|
|
|
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
|
|
|
|
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
|
|
|
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
|
|
|
*
|
2014-07-04 11:21:31 +02:00
|
|
|
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
2014-09-04 17:52:18 +02:00
|
|
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
2014-07-04 11:21:31 +02:00
|
|
|
*/
|
2014-09-04 17:52:18 +02:00
|
|
|
namespace Framadate;
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
include_once __DIR__ . '/app/inc/init.php';
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2011-05-15 03:56:54 +02:00
|
|
|
if(!isset($_GET['numsondage']) || ! preg_match(";^[\w\d]{16}$;i", $_GET['numsondage'])) {
|
2014-09-04 17:52:18 +02:00
|
|
|
header('Location: studs.php');
|
2011-05-15 03:56:54 +02:00
|
|
|
}
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2014-07-04 11:21:31 +02:00
|
|
|
$sql = 'SELECT * FROM user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
|
|
|
|
$sql = $connect->Prepare($sql);
|
|
|
|
$user_studs = $connect->Execute($sql, array($_GET['numsondage']));
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
$dsondage = Utils::get_sondage_from_id($_GET['numsondage']);
|
2011-05-15 01:32:47 +02:00
|
|
|
$nbcolonnes=substr_count($dsondage->sujet,',')+1;
|
|
|
|
|
|
|
|
$toutsujet=explode(",",$dsondage->sujet);
|
|
|
|
|
|
|
|
//affichage des sujets du sondage
|
2014-07-04 11:21:31 +02:00
|
|
|
$input =";";
|
|
|
|
foreach ($toutsujet as $value) {
|
2014-09-04 17:52:18 +02:00
|
|
|
if ($dsondage->format=="D"||$dsondage->format=="D+") {
|
|
|
|
if (strpos($dsondage->sujet,'@') !== false) {
|
|
|
|
$days=explode("@",$value);
|
|
|
|
$input.= date("j/n/Y",$days[0]).';';
|
|
|
|
} else {
|
|
|
|
$input.= date("j/n/Y",$values).';';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$input.= $value.';';
|
|
|
|
}
|
2011-05-15 01:32:47 +02:00
|
|
|
}
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2011-05-15 01:32:47 +02:00
|
|
|
$input.="\r\n";
|
|
|
|
|
2011-05-15 03:56:54 +02:00
|
|
|
if (strpos($dsondage->sujet,'@') !== false) {
|
2014-09-04 17:52:18 +02:00
|
|
|
$input.=";";
|
|
|
|
foreach ($toutsujet as $value) {
|
|
|
|
$heures=explode("@",$value);
|
|
|
|
$input.= $heures[1].';';
|
|
|
|
}
|
|
|
|
|
|
|
|
$input.="\r\n";
|
2011-05-15 01:32:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
while ( $data=$user_studs->FetchNextObject(false)) {
|
2014-09-04 17:52:18 +02:00
|
|
|
// Le nom de l'utilisateur
|
|
|
|
$nombase=html_entity_decode(str_replace("°","'",$data->nom));
|
|
|
|
$input.=$nombase.';';
|
|
|
|
//affichage des resultats
|
|
|
|
$ensemblereponses=$data->reponses;
|
|
|
|
for ($k=0;$k<$nbcolonnes;$k++) {
|
|
|
|
$car=substr($ensemblereponses,$k,1);
|
|
|
|
switch ($car) {
|
|
|
|
case "1": $input .= _('Yes').';'; $somme[$k]++; break;
|
|
|
|
case "2": $input .= _('Ifneedbe').';'; break;
|
|
|
|
default: $input .= _('No').';'; break;
|
|
|
|
}
|
2011-05-15 03:56:54 +02:00
|
|
|
}
|
2014-09-04 17:52:18 +02:00
|
|
|
|
|
|
|
$input.="\r\n";
|
2011-05-15 01:32:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$filesize = strlen( $input );
|
|
|
|
$filename=$_GET["numsondage"].".csv";
|
|
|
|
|
2011-05-15 03:56:54 +02:00
|
|
|
header( 'Content-Type: text/csv; charset=utf-8' );
|
|
|
|
header( 'Content-Length: '.$filesize );
|
|
|
|
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
|
|
|
|
header( 'Cache-Control: max-age=10' );
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2011-05-15 01:32:47 +02:00
|
|
|
echo $input;
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-07-04 11:21:31 +02:00
|
|
|
die();
|