Mise en route du suivi.
[aidenligne_francais_universite.git] / plugins / forms_1_9_1 / valide_form.html
CommitLineData
c495c100
P
1#CACHE{0}
2[(#HTTP_HEADER{Content-Type: image/gif})]
3<?php
4/*
5 * forms
6 * version plug-in de spip_form
7 *
8 * Auteur :
9 * Antoine Pitrou
10 * adaptation en 182e puis plugin par cedric.morin@yterium.com
11 * © 2005,2006 - Distribue sous licence GNU/GPL
12 *
13 */
14
15include_spip("inc/forms");
16include_spip("inc/admin");
17include_spip("inc/session");
18
19function valide_sondage()
20{
21 $verif_cookie = _request('verif_cookie');
22 $id_reponse = intval(_request('id_reponse'));
23 $hash = _request('hash');
24 $mel_confirm = _request('mel_confirm');
25
26 $renvoyer_image = false;
27
28 if ($verif_cookie == 'oui' AND ($id_reponse = intval($id_reponse))) {
29 $query = "SELECT * FROM spip_reponses WHERE id_reponse=$id_reponse AND statut='attente'";
30 $result = spip_query($query);
31 if ($row = spip_fetch_array($result)) {
32 $id_form = $row['id_form'];
33 $cookie = $row['cookie'];
34 $nom_cookie = Forms_nom_cookie_form($id_form);
35 // D'abord verifier que l'URL est legitime, donc que la demande a bien
36 // ete generee par SPIP
37 if ($cookie && $cookie == $_COOKIE[$nom_cookie]
38 && verifier_action_auteur("forms valide reponse sondage $id_reponse", $hash)) {
39 // Ensuite verifier que le cookie n'a pas deja ete utilise pour le meme formulaire
40 $query = "SELECT id_reponse FROM spip_reponses ".
41 "WHERE id_form=$id_form AND id_reponse!=$id_reponse AND cookie='".addslashes($cookie)."'";
42 if (!spip_num_rows(spip_query($query))) {
43 $query = "UPDATE spip_reponses SET statut='valide' WHERE id_reponse=$id_reponse";
44 spip_query($query);
45 }
46 }
47 }
48 $renvoyer_image = true;
49 }
50 else if ($mel_confirm == 'oui' AND ($id_reponse = intval($id_reponse))) {
51 $query = "SELECT * FROM spip_reponses WHERE id_reponse=$id_reponse";
52 $result = spip_query($query);
53 if ($row = spip_fetch_array($result)) {
54 $id_form = $row['id_form'];
55 // D'abord verifier que l'URL est legitime, donc que la demande a bien
56 // ete generee par SPIP
57 if (verifier_action_auteur("forms confirme reponse $id_reponse", $hash)) {
58 $env = unserialize('[(#ENV*|texte_script)]');
59 Forms_generer_mail_reponse_formulaire($id_form, $id_reponse, $env);
60 }
61 }
62 $renvoyer_image = true;
63 }
64
65 if ($renvoyer_image) {
66 $image = "47494638396118001800800000ffffff00000021f90401000000002c0000000018001800000216848fa9cbed0fa39cb4da8bb3debcfb0f86e248965301003b";
67 $image = pack("H*", $image);
68 $size = strlen($image);
69
70 //Header("Content-Type: image/gif");
71 Header("Content-Length: ".$size);
72 Header("Cache-Control: no-cache,no-store");
73 Header("Pragma: no-cache");
74 Header("Connection: close");
75
76 echo $image;
77 }
78
79}
80
81valide_sondage();
82?>