259 lines
3.4 KiB
PHP
259 lines
3.4 KiB
PHP
<?php
|
|
|
|
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Variable.class.php");
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Client.class.php");
|
|
|
|
|
|
|
|
class Connexionauto extends PluginsClassiques{
|
|
|
|
|
|
|
|
function Connexionauto()
|
|
|
|
{
|
|
|
|
$this->PluginsClassiques();
|
|
|
|
}
|
|
|
|
|
|
|
|
function init()
|
|
|
|
{
|
|
|
|
$variable = new Variable();
|
|
|
|
if(! $variable->charger("connexionautoID")) {
|
|
|
|
$variable->nom = "connexionautoID";
|
|
|
|
$variable->valeur = "thelia".gencode(5);
|
|
|
|
$variable->protege = 1;
|
|
|
|
$variable->cache = 1;
|
|
|
|
$variable->add();
|
|
|
|
} else {
|
|
|
|
$variable->valeur = "thelia".gencode(5);
|
|
|
|
$variable->maj();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function destroy()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function demarrage()
|
|
|
|
{
|
|
|
|
$variable = new Variable();
|
|
|
|
$variable->charger('connexionautoID');
|
|
|
|
|
|
|
|
if(isset($_COOKIE[$variable->valeur]) && !empty($_COOKIE[$variable->valeur]))
|
|
|
|
{
|
|
|
|
$str = unserialize(urldecode($_COOKIE[$variable->valeur]));
|
|
|
|
|
|
|
|
if (!$_SESSION['navig']->connecte)
|
|
|
|
{
|
|
|
|
if ($str['type'] == "login")
|
|
|
|
{
|
|
|
|
$client = New Client();
|
|
|
|
$rec = $client->charger_mail($str['login']);
|
|
|
|
if($rec && md5($client->motdepasse) == $str['password'])
|
|
|
|
{
|
|
|
|
$_SESSION['navig']->client = $client;
|
|
|
|
$_SESSION['navig']->connecte = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function action()
|
|
|
|
{
|
|
|
|
$variable = new Variable();
|
|
|
|
$variable->charger("connexionautoID");
|
|
|
|
|
|
|
|
if (isset($_COOKIE[$variable->valeur]) && !empty($_COOKIE[$variable->valeur]))
|
|
|
|
{
|
|
|
|
if (function_exists('lireParam'))
|
|
|
|
$get = lireParam('action', 'string', 'GET');
|
|
|
|
else
|
|
|
|
$get = isset($_GET['action'])?$_GET['action']:'';
|
|
|
|
|
|
|
|
if ($get && $get == "deconnexion")
|
|
|
|
{
|
|
|
|
$cook = unserialize(urldecode($_COOKIE[$variable->valeur]));
|
|
|
|
$cook['type'] = "email";
|
|
|
|
$cook = urlencode(serialize($cook));
|
|
|
|
setcookie($variable->valeur, $cook, time() + "36000000");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function apresconnexion()
|
|
|
|
{
|
|
|
|
$variable = new Variable();
|
|
|
|
$variable->charger("connexionautoID");
|
|
|
|
|
|
|
|
if (function_exists('lireParam'))
|
|
|
|
$post = lireParam('connexionauto', 'string', 'POST');
|
|
|
|
else
|
|
|
|
$post = isset($_POST['connexionauto'])?$_POST['connexionauto']:'';
|
|
|
|
|
|
|
|
$user['type'] = $post;
|
|
|
|
$user['login'] = $_SESSION['navig']->client->email;
|
|
|
|
|
|
|
|
if ($post)
|
|
|
|
{
|
|
|
|
if ($post == "login")
|
|
|
|
$user['password'] = md5($_SESSION['navig']->client->motdepasse);
|
|
|
|
//AJOUT TYPE "NONE"
|
|
|
|
if (in_array($post, array("email", "login")) || ($post == "none" && isset($_COOKIE[$variable->valeur]) && !empty($_COOKIE[$variable->valeur])))
|
|
|
|
{
|
|
|
|
$cook = urlencode(serialize($user));
|
|
|
|
setcookie($variable->valeur, $cook, time() + "36000000");
|
|
|
|
}
|
|
|
|
//AJOUT TYPE "SUPPR"
|
|
|
|
if (isset($_COOKIE[$variable->valeur]) && $post == "suppr")
|
|
|
|
{
|
|
|
|
setcookie($variable->valeur, false, 0);
|
|
|
|
unset($_COOKIE[$variable->valeur]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function post()
|
|
|
|
{
|
|
|
|
global $res;
|
|
|
|
|
|
|
|
$variable = new Variable();
|
|
|
|
$variable->charger("connexionautoID");
|
|
|
|
|
|
|
|
if(isset($_COOKIE[$variable->valeur]) && !empty($_COOKIE[$variable->valeur]))
|
|
|
|
{
|
|
|
|
$str = unserialize(urldecode($_COOKIE[$variable->valeur]));
|
|
|
|
if ($str['type'] == "email")
|
|
|
|
$res = str_replace("#CX_EMAIL", $str['login'], $res);
|
|
|
|
}
|
|
|
|
$res = str_replace("#CX_EMAIL", "", $res);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|