Subversion Repositories Sites.tela-botanica.org

Rev

Rev 4 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: spip_cookie.php,v 1.1 2004/07/20 10:01:22 alex Exp $
23
/**
24
* Envoie de cookie pour SPIP à partir d'une inscription
25
*
26
* Envoie de cookie pour SPIP à partir d'une inscription
27
*
28
*@package inscription
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.1 $ $Date: 2004/07/20 10:01:22 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
 
39
// Ce fichier doit être placé à la racine de SPIP
40
// Il doit être appellé dans chaque squelette
41
// après l'ouverture d'une session, si on ouvre une session
42
 
43
// Il faut récupérer une valeur userid, c'est à dire
44
// loggué l'utilisateur par exemple avec PEAR
45
 
46
set_include_path (".:/usr/local/lib/php:/home/telabotap/www/actu/:") ;
47
define ("SPIP_CHEMIN", "actu/") ;
48
 
49
//
50
// Ajouter une session pour l'auteur specifie
51
// Modifié pour éviter un Warning
52
 
53
if (!defined ('CHEMIN_SPIP')) {
54
    define ('CHEMIN_SPIP', '') ;
55
}
56
 
57
function ajouter_session_($auteur, $id_session, $id_auteur, $alea) {
58
        $fichier_session = CHEMIN_SPIP.'actu/ecrire/data/session_'.$id_auteur.'_'.md5($id_session.' '.$alea).'.php3';
59
        $vars = array('id_auteur', 'nom', 'login', 'email', 'statut', 'lang' /*, 'ip_change'*/, 'hash_env' );
60
        $auteur['hash_env'] = hash_env_() ;
61
        $texte = "<"."?php\n";
62
        reset($vars);
63
        while (list(, $var) = each($vars)) {
64
                $texte .= "\$GLOBALS['auteur_session']['$var'] = '".addslashes($auteur[$var])."';\n";
65
        }
66
        $texte .= "?".">\n";
67
 
68
        if ($f = fopen($fichier_session, "wb")) {
69
                fputs($f, $texte);
70
                fclose($f);
71
        }
72
}
73
 
74
function hash_env_() {
75
        global $HTTP_SERVER_VARS;
76
        return md5($HTTP_SERVER_VARS['REMOTE_ADDR'] . $HTTP_SERVER_VARS['HTTP_USER_AGENT']);
77
}
78
 
79
 
80
//
81
// Supprimer une session
82
//
83
function supprimer_session_($id_session, $id_auteur) {
84
 
85
    // recherche de l'alea éphémère dans spip_meta
86
    $requete_meta = 'select nom,valeur from spip_meta' ;
87
    $resultat_meta = mysql_query ($requete_meta) or die ('echec') ;
88
    while ($ligne_meta = mysql_fetch_object ($resultat_meta) ) {
89
        if ($ligne_meta->nom == 'alea_ephemere') {
90
            $alea = $ligne_meta->valeur ;
91
        }
92
    }
93
 
94
	$fichier_session = CHEMIN_SPIP.'actu/ecrire/data/session_'.$id_auteur.'_'.md5($id_session.' '.$alea).'.php3';
95
	if (@file_exists($fichier_session)) {
96
		@unlink($fichier_session);
97
	}
98
    unset ($_COOKIE['spip_session']) ;
99
    unset ($_COOKIE['spip_admin']) ;
100
}
101
 
102
// On recherche userid
103
supprimer_session_($HTTP_COOKIE_VARS["spip_session"], $id_logout) ;
104
 
105
 
106
?>