Correction de la requete SQL de suppression de sondage et correction lors de l'utilisation de la fonction error_log
This commit is contained in:
parent
0eab474e38
commit
d434e6e28d
@ -74,7 +74,7 @@ echo '<form action="index.php" method="POST">'."\n";
|
|||||||
// Test et affichage du bouton de confirmation en cas de suppression de sondage
|
// Test et affichage du bouton de confirmation en cas de suppression de sondage
|
||||||
$i=0;
|
$i=0;
|
||||||
while($dsondage = $sondage->FetchNextObject(false)) {
|
while($dsondage = $sondage->FetchNextObject(false)) {
|
||||||
if ($_POST["supprimersondage$i"]) {
|
if (issetAndNoEmpty('supprimersondage'.$i) === true) {
|
||||||
echo '<table>'."\n";
|
echo '<table>'."\n";
|
||||||
echo '<tr><td bgcolor="#EE0000" colspan="11">'. _("Confirm removal of the poll ") .'"'.$dsondage->id_sondage.'" : <input type="submit" name="confirmesuppression'.$i.'" value="'. _("Remove this poll!") .'">'."\n";
|
echo '<tr><td bgcolor="#EE0000" colspan="11">'. _("Confirm removal of the poll ") .'"'.$dsondage->id_sondage.'" : <input type="submit" name="confirmesuppression'.$i.'" value="'. _("Remove this poll!") .'">'."\n";
|
||||||
echo '<input type="submit" name="annullesuppression" value="'. _("Keep this poll!") .'"></td></tr>'."\n";
|
echo '<input type="submit" name="annullesuppression" value="'. _("Keep this poll!") .'"></td></tr>'."\n";
|
||||||
@ -83,17 +83,25 @@ while($dsondage = $sondage->FetchNextObject(false)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Traitement de la confirmation de suppression
|
// Traitement de la confirmation de suppression
|
||||||
if ($_POST["confirmesuppression$i"]) {
|
if (issetAndNoEmpty('confirmesuppression'.$i) === true) {
|
||||||
|
// On inclut la routine de suppression
|
||||||
$date=date('H:i:s d/m/Y');
|
$date=date('H:i:s d/m/Y');
|
||||||
|
|
||||||
// requetes SQL qui font le ménage dans la base
|
$req = 'DELETE s, su, u, c
|
||||||
$connect->Execute('DELETE FROM sondage LEFT INNER JOIN sujet_studs ON sujet_studs.id_sondage = sondage.id_sondage '.
|
FROM
|
||||||
'LEFT INNER JOIN user_studs ON user_studs.id_sondage = sondage.id_sondage ' .
|
sondage s LEFT JOIN sujet_studs su
|
||||||
'LEFT INNER JOIN comments ON comments.id_sondage = sondage.id_sondage ' .
|
ON su.id_sondage = s.id_sondage
|
||||||
"WHERE id_sondage = '$dsondage->id_sondage' ");
|
LEFT JOIN user_studs u
|
||||||
|
ON u.id_sondage = s.id_sondage
|
||||||
|
LEFT JOIN comments c
|
||||||
|
ON c.id_sondage = s.id_sondage
|
||||||
|
WHERE s.id_sondage = '.$connect->Param('id_sondage');
|
||||||
|
|
||||||
|
$sql = $connect->Prepare($req);
|
||||||
|
$connect->Execute($sql, array($dsondage->id_sondage));
|
||||||
|
|
||||||
// ecriture des traces dans le fichier de logs
|
// ecriture des traces dans le fichier de logs
|
||||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\t$nbuser\t$dsujets->sujet\n", 'logs_studs.txt');
|
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'logs_studs.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -143,5 +151,5 @@ echo '</body>'."\n";
|
|||||||
echo '</html>'."\n";
|
echo '</html>'."\n";
|
||||||
|
|
||||||
// si on annule la suppression, rafraichissement de la page
|
// si on annule la suppression, rafraichissement de la page
|
||||||
if ($_POST["annulesuppression"]) {
|
if (issetAndNoEmpty('annulesuppression') === true) {
|
||||||
}
|
}
|
@ -50,13 +50,20 @@ while ($dsondage=$sondage->FetchNextObject(false)) {
|
|||||||
if ($date_courante > strtotime($dsondage->date_fin)) {
|
if ($date_courante > strtotime($dsondage->date_fin)) {
|
||||||
//destruction des données dans la base
|
//destruction des données dans la base
|
||||||
|
|
||||||
$req = 'DELETE FROM sondage LEFT INNER JOIN sujet_studs ON sujet_studs.id_sondage = sondage.id_sondage '.
|
$req = 'DELETE s, su, u, c
|
||||||
'LEFT INNER JOIN user_studs ON user_studs.id_sondage = sondage.id_sondage ' .
|
FROM
|
||||||
'LEFT INNER JOIN comments ON comments.id_sondage = sondage.id_sondage ' .
|
sondage s LEFT JOIN sujet_studs su
|
||||||
"WHERE id_sondage = '$dsondage->id_sondage'; ";
|
ON su.id_sondage = s.id_sondage
|
||||||
echo $req;
|
LEFT JOIN user_studs u
|
||||||
$connect->Execute($req);
|
ON u.id_sondage = s.id_sondage
|
||||||
|
LEFT JOIN comments c
|
||||||
|
ON c.id_sondage = s.id_sondage
|
||||||
|
WHERE s.id_sondage = '.$connect->Param('id_sondage');
|
||||||
|
|
||||||
|
$sql = $connect->Prepare($req);
|
||||||
|
$connect->Execute($sql, array($dsondage->id_sondage));
|
||||||
|
|
||||||
// ecriture des traces dans le fichier de logs
|
// ecriture des traces dans le fichier de logs
|
||||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", '../admin/logs_studs.txt');
|
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, '../admin/logs_studs.txt');
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user