Subversion Repositories Sites.tela-botanica.org

Compare Revisions

Ignore whitespace Rev 3 → Rev 4

/trunk/actu/spip_efface_session.php
New file
0,0 → 1,106
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library 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 |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: spip_cookie.php,v 1.1 2004/07/20 10:01:22 alex Exp $
/**
* Envoie de cookie pour SPIP à partir d'une inscription
*
* Envoie de cookie pour SPIP à partir d'une inscription
*
*@package inscription
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1 $ $Date: 2004/07/20 10:01:22 $
// +------------------------------------------------------------------------------------------------------+
*/
 
 
// Ce fichier doit être placé à la racine de SPIP
// Il doit être appellé dans chaque squelette
// après l'ouverture d'une session, si on ouvre une session
 
// Il faut récupérer une valeur userid, c'est à dire
// loggué l'utilisateur par exemple avec PEAR
 
set_include_path (".:/usr/local/lib/php:/home/telabotap/www/actu/:") ;
define ("SPIP_CHEMIN", "actu/") ;
 
//
// Ajouter une session pour l'auteur specifie
// Modifié pour éviter un Warning
 
if (!defined ('CHEMIN_SPIP')) {
define ('CHEMIN_SPIP', '') ;
}
 
function ajouter_session_($auteur, $id_session, $id_auteur, $alea) {
$fichier_session = CHEMIN_SPIP.'actu/ecrire/data/session_'.$id_auteur.'_'.md5($id_session.' '.$alea).'.php3';
$vars = array('id_auteur', 'nom', 'login', 'email', 'statut', 'lang' /*, 'ip_change'*/, 'hash_env' );
$auteur['hash_env'] = hash_env_() ;
$texte = "<"."?php\n";
reset($vars);
while (list(, $var) = each($vars)) {
$texte .= "\$GLOBALS['auteur_session']['$var'] = '".addslashes($auteur[$var])."';\n";
}
$texte .= "?".">\n";
if ($f = fopen($fichier_session, "wb")) {
fputs($f, $texte);
fclose($f);
}
}
 
function hash_env_() {
global $HTTP_SERVER_VARS;
return md5($HTTP_SERVER_VARS['REMOTE_ADDR'] . $HTTP_SERVER_VARS['HTTP_USER_AGENT']);
}
 
 
//
// Supprimer une session
//
function supprimer_session_($id_session, $id_auteur) {
 
// recherche de l'alea éphémère dans spip_meta
$requete_meta = 'select nom,valeur from spip_meta' ;
$resultat_meta = mysql_query ($requete_meta) or die ('echec') ;
while ($ligne_meta = mysql_fetch_object ($resultat_meta) ) {
if ($ligne_meta->nom == 'alea_ephemere') {
$alea = $ligne_meta->valeur ;
}
}
 
$fichier_session = CHEMIN_SPIP.'actu/ecrire/data/session_'.$id_auteur.'_'.md5($id_session.' '.$alea).'.php3';
if (@file_exists($fichier_session)) {
@unlink($fichier_session);
}
unset ($_COOKIE['spip_session']) ;
unset ($_COOKIE['spip_admin']) ;
}
 
// On recherche userid
supprimer_session_($HTTP_COOKIE_VARS["spip_session"], $id_logout) ;
 
 
?>