[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/annu/ -> export_csv.php (source)

   1  <?php
   2  
   3  
   4     /**
   5     
   6     * Export un csv des comptes existants
   7     * @Version $Id: export_csv.php 8600 2015-03-16 20:12:30Z plouf $ 
   8     
   9     * @Projet LCS / SambaEdu 
  10     
  11     * @auteurs jLCF jean-luc.chretien@tice.ac-caen.fr
  12     * @auteurs oluve olivier.le_monnier@crdp.ac-caen.fr
  13     * @auteurs wawa  olivier.lecluse@crdp.ac-caen.fr
  14     * @auteurs Equipe Tice academie de Caen
  15  
  16     * @Licence Distribue selon les termes de la licence GPL
  17     
  18     * @note 
  19     */
  20  
  21     /**
  22  
  23     * @Repertoire: annu
  24     * file: export_csv.php
  25     */
  26  
  27  
  28  
  29  include  "ldap.inc.php";
  30  include  "ihm.inc.php";
  31  
  32  require_once  ("lang.inc.php");
  33  bindtextdomain('se3-annu',"/var/www/se3/locale");
  34  textdomain ('se3-annu');
  35  
  36  // HTMLPurifier
  37  require_once  ("traitement_data.inc.php");
  38  
  39  
  40  $testaction=$_GET['download'];
  41  
  42  
  43  if (!$testaction) {
  44      include  "entete.inc.php";
  45  
  46      // Aide
  47      $_SESSION["pageaide"]="Annuaire";
  48  
  49      echo "<h1>".gettext("Annuaire")."</h1>";
  50      
  51      $filter="Classe_*";
  52        $group=search_groups ("(cn=".$filter.")");
  53        $uids = search_uids ("(cn=".$filter.")");
  54        $people = search_people_groups ($uids,"(sn=*)","group");
  55  
  56          for ($loop=0; $loop < count($people); $loop++) {
  57                preg_match("/([0-9]{8})/",$people[$loop]["gecos"],$naiss);
  58          $ligne_eleve=$ligne_eleve.$people[$loop]["group"].";".$people[$loop]["fullname"].";".$people[$loop]["uid"].";".$naiss[0]."\r\n";
  59          }
  60      $content_dir = '/tmp/';
  61      $file_temp='export_eleves.csv';
  62      $get= fopen("/tmp/export_eleves.csv", "w+");
  63      fputs($get,$ligne_eleve);
  64      fclose($get);
  65  
  66        $filter="Profs";
  67        $group=search_groups ("(cn=".$filter.")");
  68        $uids = search_uids ("(cn=".$filter.")");
  69        $people = search_people_groups ($uids,"(sn=*)","group");
  70  
  71          for ($loop=0; $loop < count($people); $loop++) {
  72                preg_match("/([0-9]{8})/",$people[$loop]["gecos"],$naiss);
  73          $ligne_prof=$ligne_prof.$people[$loop]["fullname"].";".$people[$loop]["uid"].";".$naiss[0]."\r\n";
  74          }
  75      $content_dir = '/tmp/';
  76      $file_temp='export_profs.csv';
  77      $get= fopen("/tmp/export_profs.csv", "w+");
  78      fputs($get,$ligne_prof);
  79      fclose($get);
  80  
  81      echo gettext("Les fichiers export_eleves.csv et export_profs.csv ont &#233;t&#233; g&#233;n&#233;r&#233;s")."<br><br>";
  82      echo "<a href=\"export_csv.php?download=export_eleves\">".gettext("T&#233;l&#233;charger le fichier &#233;l&#232;ves")."</a><br>";
  83      echo "<a href=\"export_csv.php?download=export_profs\">".gettext("T&#233;l&#233;charger le fichier profs")."</a>";
  84      
  85      include ("pdp.inc.php");
  86  
  87  
  88  } elseif ($testaction=="export_eleves") {
  89      require ("config.inc.php");
  90      include "functions.inc.php";
  91      $login=isauth();
  92      if ($login == "") header("Location:$urlauth");
  93      if (is_admin("se3_is_admin",$login)=="Y") {
  94  
  95          header("Content-Type: octet-stream");
  96          header("Content-Length: ".filesize ("/tmp/export_eleves.csv") );
  97          header("Content-Disposition: attachment; filename=\"/tmp/export_eleves.csv\"");
  98          include ("/tmp/export_eleves.csv");
  99      }
 100  
 101  
 102  } elseif ($testaction=="export_profs") {
 103      require ("config.inc.php");
 104      include "functions.inc.php";
 105      $login=isauth();
 106      if ($login == "") header("Location:$urlauth");
 107      if (is_admin("se3_is_admin",$login)=="Y") {
 108  
 109          header("Content-Type: octet-stream");
 110          header("Content-Length: ".filesize ("/tmp/export_profs.csv") );
 111          header("Content-Disposition: attachment; filename=\"/tmp/export_profs.csv\"");
 112          include ("/tmp/export_profs.csv");
 113  
 114      }
 115  }
 116  ?>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1