コード例 #1
0
ファイル: db.php プロジェクト: inscriptionweb/Envoi
 static function insert_autoinc($req, $params = array())
 {
     $sth = DB::request($req, $params);
     return DB::$dbh->lastInsertId();
 }
コード例 #2
0
ファイル: rendu.php プロジェクト: inscriptionweb/Envoi
                 $notifmail->Subject = "Livraison {$code} : {$tousParticipants}";
                 $notifmail->Body = "Livraison du travail : " . $obj->titre . "\n\nÉtudiants : " . $tousParticipants . "\n\nCommentaire :\n" . $commentaire;
                 $notifmail->AddAddress($notification, $notification);
                 $notifmail->Send();
                 echo " --> OK.</p>\n";
             } catch (Exception $ex) {
                 echo " --> Echec. <span style='color:red;'>Veuillez lui signaler.</span></p>\n";
             }
         }
         $afficheFormulaire = false;
     }
 }
 if ($afficheFormulaire) {
     // Fichiers à fournir
     $zoneFichiers = "";
     $res = DB::request("SELECT nom, idFichier, optionnel FROM fichier WHERE idRendu=?", array($idRendu));
     while ($obj = $res->fetch()) {
         $nom = $obj->nom;
         $idFichier = $obj->idFichier;
         //$fname = isset($_FILES["fichier$idFichier"]) ? "value=\"" . $_FILES["fichier" . $idFichier]["name"] . "\" " : "";
         $zoneFichiers .= "<li>{$nom}" . ($obj->optionnel ? " (optionnel) " : "") . "&nbsp;: <input name=\"fichier{$idFichier}\" type=\"file\" id=\"fichier{$idFichier}\" /></li>\n";
     }
     $fnom1 = isset($_POST["nom1"]) ? 'value="' . htmlspecialchars($_POST["nom1"]) . '" ' : "";
     $fprenom1 = isset($_POST["prenom1"]) ? 'value="' . htmlspecialchars($_POST["prenom1"]) . '" ' : "";
     $femail1 = isset($_POST["email1"]) ? 'value="' . htmlspecialchars($_POST["email1"]) . '" ' : "";
     if (!isset($_POST["nom1"]) && !isset($_POST["prenom1"]) && !isset($_POST["email1"])) {
         $fnom1 = "value=\"" . $_SESSION["nom"] . "\" ";
         $fprenom1 = "value=\"" . $_SESSION["prenom"] . "\" ";
         $femail1 = "value=\"" . $_SESSION["mail"] . "\" ";
     }
     $fnom2 = isset($_POST["nom2"]) ? 'value="' . htmlspecialchars($_POST["nom2"]) . '" ' : "";
コード例 #3
0
ファイル: rss.php プロジェクト: inscriptionweb/Envoi
<?php

/*

SELECT code, titre, GROUP_CONCAT(CONCAT(prenom, " ", nom) SEPARATOR ', ') noms, renduDonne.date, idEnseignant FROM renduDonne JOIN rendu JOIN participant ON renduDonne.idRendu=rendu.idRendu AND renduDonne.idRenduDonne=participant.idRenduDonne WHERE renduDonne.date >= '2012-07-23' GROUP BY renduDonne.idRenduDonne ORDER BY rendu.idRendu
*/
if (!isset($_GET["id"])) {
    echo "Id enseignant manquant.";
    exit;
}
$id = $_GET["id"];
$res = DB::request("SELECT code, titre, GROUP_CONCAT(CONCAT(prenom, ' ', nom) SEPARATOR ', ') noms, renduDonne.date FROM renduDonne JOIN rendu JOIN participant ON renduDonne.idRendu=rendu.idRendu AND renduDonne.idRenduDonne=participant.idRenduDonne WHERE idEnseignant=? GROUP BY renduDonne.idRenduDonne ORDER BY renduDonne.date DESC LIMIT 0,50", array($id));
date_default_timezone_set("Europe/Berlin");
header("Content-Type: application/xml; charset=UTF-8");
echo <<<END
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
<title>Livraisons pour {$id}</title>
END;
while ($obj = $res->fetch()) {
    $date = date(DATE_RFC822, strtotime($obj->date));
    echo <<<END
<item>
<title>{$obj->code} - {$obj->titre}</title>
<description>{$obj->date} : livraison par {$obj->noms}</description>
<pubDate>{$date}</pubDate>
</item>
END;
}
コード例 #4
0
ファイル: extractfiles.php プロジェクト: inscriptionweb/Envoi
/*
   This file is part of Envoi.

   Envoi is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   Envoi is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Envoi.  If not, see <http://www.gnu.org/licenses/>.

   (c) Christophe Jacquet, 2009-2011.
*/
require "tools.php";
$res = DB::request("SELECT idFichierDonne, contenu FROM fichierDonne");
while ($row = $res->fetch()) {
    fileIdToPath($row->idFichierDonne, $path, $name);
    createFilePath($path);
    echo "{$path} {$name}: ";
    if (file_put_contents($path . $name, $row->contenu) === FALSE) {
        echo "FAILED!\n";
        break;
    } else {
        echo "OK\n";
    }
}
コード例 #5
0
ファイル: ziprendu.php プロジェクト: inscriptionweb/Envoi
 }
 $eleves .= "\nDate de livraison : {$row->date}\n\nCommentaire :\n{$row->commentaire}\n";
 if (isset($multiCount[$login])) {
     $multiCount[$login]++;
     $suffixe = "_" . $multiCount[$login];
 } else {
     $multiCount[$login] = 0;
     $suffixe = "";
 }
 $path = "Livraison_{$row->code}/{$login}{$suffixe}";
 $code = $row->code;
 $ascii_title = preg_replace("/[^A-Za-z0-9]/", "_", iconv('UTF-8', 'ASCII//TRANSLIT', $row->titre));
 $zip->addFromString("{$path}/LisezMoi.txt", $eleves);
 // liste des fichiers
 $req = "SELECT idFichierDonne, nom FROM fichierDonne WHERE idRenduDonne=?";
 $res2 = DB::request($req, array($idRenduDonne));
 while ($r = $res2->fetch()) {
     fileIdToPath($r->idFichierDonne, $fspath, $fsname);
     if (is_file($fspath . $fsname)) {
         $zip->addFile($fspath . $fsname, "{$path}/{$r->nom}");
         /*
                         echo "addFile $fspath $fsname: ";
                         echo "  ==> ";
                         echo filesize($tmpname);
                         echo "\n";
         * 
         */
     } else {
         $zip->addFromString("{$path}/{$r->nom}", "File ID {$r->idFichierDonne} missing; this is probably a bug.");
     }
 }
コード例 #6
0
ファイル: tools.php プロジェクト: inscriptionweb/Envoi
function supprimeLivraison($idRendu, $code = FALSE)
{
    echo "<p>Suppression de la livraison #" . $idRendu . "</p>";
    if ($code) {
        $res = DB::request("DELETE FROM rendu WHERE idRendu=? AND idEnseignant=? AND code=?", array($idRendu, $_SESSION["login"], $_POST['code']));
    } else {
        $res = DB::request("DELETE FROM rendu WHERE idRendu=? AND idEnseignant=?", array($idRendu, $_SESSION["login"]));
    }
    if ($res->rowCount() < 1) {
        die(<<<END
<p>{$idRendu} : livraison inexistante, ou n'appartenant pas à l'utilisateur {$_SESSION["login"]}, ou mauvais code.</p>
<p><a href="voirrendu.php?id={$idRendu}">Retour au rendu</a></p>
END
);
    } else {
        echo "<p>Supprimé la spécification de livraison.</p>";
    }
    # fichiers sur le disque
    $res = DB::request("SELECT idFichierDonne FROM fichierDonne NATURAL JOIN renduDonne WHERE renduDonne.idRendu = ?", array($idRendu));
    $supprCount = 0;
    $supprCountDB = 0;
    while ($row = $res->fetch()) {
        fileIdToPath($row->idFichierDonne, $p, $n);
        $fn = $p . $n;
        $r = unlink($fn);
        #echo "<p>DEBUG: deleted $fn</p>";
        if ($r) {
            $supprCount++;
        } else {
            echo "<p>ATTENTION : échec de la suppression du fichier {$fn}. Veuillez contacter le mainteneur.</p>";
        }
        # fichierDonne
        $r = DB::request("DELETE FROM fichierDonne WHERE idFichierDonne = ?", array($row->idFichierDonne));
        if ($r->rowCount() === 1) {
            $supprCountDB++;
        } else {
            echo "<p>ATTENTION : échec de la suppression du fichier {$row->idFichierDonne} dans la base. Veuillez contacter le mainteneur.</p>";
        }
    }
    echo "<p>Supprimé {$supprCount} sur disque et {$supprCountDB} dans la base</p>";
    # participant
    $res = DB::request("DELETE FROM participant WHERE idRenduDonne IN (SELECT idRenduDonne FROM renduDonne WHERE idRendu=?)", array($idRendu));
    echo "<p>Supprimé " . $res->rowCount() . " participants</p>";
    # renduDonne
    $res = DB::request("DELETE FROM renduDonne WHERE idRendu=?", array($idRendu));
    echo "<p>Supprimé " . $res->rowCount() . " livraisons</p>";
    # fichier
    $res = DB::request("DELETE FROM fichier WHERE idRendu=?", array($idRendu));
    echo "<p>Supprimé " . $res->rowCount() . " spécifications de fichiers";
}
コード例 #7
0
ファイル: ajoutrendu.php プロジェクト: inscriptionweb/Envoi
    DB::request("UPDATE rendu SET code=? WHERE idRendu=?", array($code, $idRendu));
    echo "<p>Le code pour la livraison « " . htmlspecialchars($_POST["titre"]) . " » est <strong>{$code}</strong>.</p>\n";
    if ($_POST["clone"] != "no") {
        $idParent = $_POST["clone"];
        echo "<p>Clonage de la livraison #" . $idParent . "...</p>\n";
        $res = DB::request("SELECT script, nom, optionnel FROM fichier WHERE idRendu=?", array($idParent));
        while ($obj = $res->fetch()) {
            DB::request("INSERT INTO fichier (idRendu, script, nom, optionnel) VALUES (?, ?, ?, ?)", array($idRendu, $obj->script, $obj->nom, $obj->optionnel));
            echo "<p>Ajout par clonage du fichier '{$obj->script}', '{$obj->nom}', '{$obj->optionnel}'</p>";
        }
    } else {
        echo "<p>Vous voudez probablement ajouter un fichier à <a href=\"voirrendu.php?id={$idRendu}\">cette livraison...</p>\n";
    }
    echo "<p><a href=\"index.php\">Retour à l'accueil</a>.</p>\n";
} else {
    $res = DB::request("SELECT titre, idRendu FROM rendu WHERE idEnseignant=? ORDER BY date DESC", array($_SESSION['login']));
    $opt = "";
    while ($obj = $res->fetch()) {
        $opt .= "<option value='{$obj->idRendu}'>{$obj->titre}</a>\n";
    }
    echo <<<EOF

<form action="ajoutrendu.php" method="post">
Titre&nbsp;: <input name="titre" /><br />
Clonage&nbsp;: <select name="clone">
    <option value="no">Non</option>
    {$opt}
    </select><br />
<input type="submit" value="Créer" />
</form>
コード例 #8
0
ファイル: voirrendu.php プロジェクト: inscriptionweb/Envoi
 $res = DB::request("SELECT date, commentaire, login, idRenduDonne FROM renduDonne WHERE idRendu=? ORDER BY date", array($idRendu));
 echo "<table>\n";
 echo "<tr><th>Élèves</th><th>Date</th><th>Commentaire</th><th>Fichiers</th></tr>\n";
 $idCount = 0;
 while ($row = $res->fetch()) {
     $idRenduDonne = $row->idRenduDonne;
     echo "<tr><td>";
     // liste des élèves
     $res2 = DB::request("SELECT nom, prenom, email FROM participant WHERE idRenduDonne=?", array($idRenduDonne));
     while ($r = $res2->fetch()) {
         echo "<a href=\"mailto:" . $r->email . "\">" . htmlspecialchars($r->prenom) . " " . htmlspecialchars($r->nom) . "</a><br />";
     }
     echo "(" . $row->login . ")";
     echo "</td><td>" . $row->date . "</td><td>" . str_replace("\n", "<br>", htmlspecialchars($row->commentaire)) . "</td><td>";
     // liste des fichiers
     $res2 = DB::request("SELECT idFichierDonne, nom FROM fichierDonne WHERE idRenduDonne=?", array($idRenduDonne));
     while ($r = $res2->fetch()) {
         echo "<a href=\"fichier.php?id=" . $r->idFichierDonne . "\">" . htmlspecialchars($r->nom) . "</a>";
         if ($files = list_zip_files($r->idFichierDonne)) {
             $htmlid = "zip" + $idCount;
             $idCount++;
             echo " <a href='#' onclick='\$(\"#{$htmlid}\").toggle(); return false;'>▶</a> <span id='{$htmlid}' class='closedsection'>(";
             foreach ($files as $id => $filename) {
                 echo "<a href=\"zipfichier.php?zipId=" . $r->idFichierDonne . "&fileId={$id}\">{$filename}</a> | ";
             }
             echo ")</span> ";
         }
         echo "<br />";
     }
     echo "</td></tr>";
 }
コード例 #9
0
            continue;
        }
        if (is_dir($path . $f)) {
            buildfilelist($prefix . $f . "/");
        } else {
            $filelist[$path . $prefix . $f] = TRUE;
        }
    }
}
buildfilelist("");
echo "Checking whether the filesystem is consistent with the database...\n";
$delete = isset($argv[1]) && $argv[1] === "delete_orphans";
if ($delete) {
    echo "Will be deleting orphans.\n";
}
$res = DB::request("SELECT idFichierDonne, idFichier, idRenduDonne, idRendu FROM fichierDonne NATURAL JOIN renduDonne");
#var_dump($filelist);
$countOk = 0;
$countMissing = 0;
$countOrphaned = 0;
while ($row = $res->fetch()) {
    fileIdToPath($row->idFichierDonne, $p, $n);
    $fn = $p . $n;
    if (isset($filelist[$fn])) {
        unset($filelist[$fn]);
        $countOk++;
    } else {
        echo "Missing file: " . $fn . "   idRendu=" . $row->idRendu . ", idFichier=" . $row->idFichier . ", idRenduDonne=" . $row->idRenduDonne . " \n";
        $countMissing++;
    }
}