186 lines
6.2 KiB
PHP
186 lines
6.2 KiB
PHP
<?php
|
|
/*************************************************************************************/
|
|
/* */
|
|
/* Thelia */
|
|
/* */
|
|
/* Copyright (c) Octolys Development */
|
|
/* email : thelia@octolys.fr */
|
|
/* web : http://www.octolys.fr */
|
|
/* */
|
|
/* This program is free software; you can redistribute it and/or modify */
|
|
/* it under the terms of the GNU General Public License as published by */
|
|
/* the Free Software Foundation; either version 2 of the License, or */
|
|
/* (at your option) any later version. */
|
|
/* */
|
|
/* This program 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 General Public License for more details. */
|
|
/* */
|
|
/* You should have received a copy of the GNU General Public License */
|
|
/* along with this program; if not, write to the Free Software */
|
|
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
/* */
|
|
/*************************************************************************************/
|
|
?>
|
|
<?php
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Client.class.php");
|
|
|
|
class Comparateur extends PluginsClassiques{
|
|
|
|
var $id;
|
|
var $client;
|
|
var $comparateur;
|
|
var $date;
|
|
|
|
var $table="sauvcomp";
|
|
var $bddvars = array("id", "client", "comparateur", "date");
|
|
|
|
function Comparateur(){
|
|
$this->PluginsClassiques();
|
|
}
|
|
|
|
function init(){
|
|
$cnx = new Cnx();
|
|
$query_sauvcomp = "CREATE TABLE `sauvcomp` (
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
|
`client` INT NOT NULL ,
|
|
`comparateur` TEXT NOT NULL,
|
|
`date` datetime NOT NULL default '0000-00-00 00:00:00'
|
|
) ;";
|
|
$resul_sauvcomp = mysql_query($query_sauvcomp, $cnx->link);
|
|
}
|
|
|
|
function charger($client){
|
|
return $this->getVars("select * from $this->table where client=\"$client\"");
|
|
}
|
|
|
|
function demarrage(){
|
|
if($_REQUEST['action'] == "connexion") {
|
|
|
|
$client = new Client();
|
|
if($client->charger($_REQUEST['email'], $_REQUEST['motdepasse'])){
|
|
|
|
$recsauv = new Comparateur();
|
|
if(! $recsauv->charger($client->id)){
|
|
$recsauv->client = $client->id;
|
|
$recsauv->comparateur = addslashes(serialize($_SESSION['navig']->comparateur));
|
|
$recsauv->date = date("Y-m-d H:i:s");
|
|
$recsauv->add();
|
|
return;
|
|
}
|
|
|
|
if(! $_SESSION['navig']->comparateur->nbart){
|
|
$_SESSION['navig']->comparateur = new Panier();
|
|
$_SESSION['navig']->comparateur = unserialize(stripcslashes($recsauv->comparateur));
|
|
}
|
|
else {
|
|
$recsauv->comparateur = addslashes(serialize($_SESSION['navig']->comparateur));
|
|
$this->date = date("Y-m-d H:i:s");
|
|
$recsauv->maj();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function pre(){
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/config.php");
|
|
|
|
if(! isset($_SESSION['navig']->comparateur))
|
|
$_SESSION['navig']->comparateur = new Comparateur_panier();
|
|
|
|
if(isset($_REQUEST['action']) && $_REQUEST['action'] == "ajouter_comparateur" && isset($_REQUEST['ref']) && $_SESSION['navig']->comparateur->nbart<$max)
|
|
$_SESSION['navig']->comparateur->ajouter($_REQUEST['ref']);
|
|
|
|
else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "ajouter_comparateur" && isset($_REQUEST['ref']) && $_SESSION['navig']->comparateur->nbart>=$max){
|
|
?>
|
|
<script type="text/javascript">
|
|
alert("Votre comparateur est plein");
|
|
</script>
|
|
<?php
|
|
|
|
}
|
|
|
|
else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "supprimer_comparateur" && isset($_REQUEST['article']))
|
|
{
|
|
$_SESSION['navig']->comparateur->supprimer($_REQUEST['article']);
|
|
}
|
|
|
|
}
|
|
|
|
function post(){
|
|
if(($_REQUEST['action'] == "ajouter_comparateur" || $_REQUEST['action'] == "supprimer_comparateur") && $_SESSION['navig']->client->id){
|
|
|
|
$tempsauv = new Comparateur();
|
|
|
|
if($tempsauv->charger($_SESSION['navig']->client->id)){
|
|
$this->charger($_SESSION['navig']->client->id);
|
|
$this->comparateur = addslashes(serialize($_SESSION['navig']->comparateur));
|
|
$this->date = date("Y-m-d H:i:s");
|
|
$this->maj();
|
|
}
|
|
else {
|
|
$this->client = $_SESSION['navig']->client->id;
|
|
$this->comparateur = addslashes(serialize($_SESSION['navig']->comparateur));
|
|
$this->date = date("Y-m-d H:i:s");
|
|
$this->add();
|
|
}
|
|
}
|
|
|
|
if($_REQUEST['action'] == "sauver_comparateur" && ! $_SESSION['navig']->client->id){
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
alert("Vous devez vous identifier afin de pouvoir sauvegarder votre comparateur");
|
|
location = "?fond=connexion";
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function action(){
|
|
|
|
global $res;
|
|
|
|
$res = str_replace("#COMPARATEUR_NBART", $_SESSION['navig']->comparateur->nbart, $res);
|
|
|
|
}
|
|
|
|
function boucle($texte, $args){
|
|
|
|
$dernier = lireTag($args, "dernier");
|
|
|
|
if(!$deb) $deb=0;
|
|
|
|
if($dernier == 1)
|
|
$deb = $_SESSION['navig']->comparateur->nbart - 1;
|
|
|
|
$res="";
|
|
|
|
if(! $_SESSION['navig']->comparateur->nbart) return;
|
|
|
|
for($i=$deb; $i<$_SESSION['navig']->comparateur->nbart; $i++){
|
|
|
|
$temp = str_replace("#REF", $_SESSION['navig']->comparateur->tabarticle[$i], $texte);
|
|
$temp = str_replace("#ARTICLE", $i, $temp);
|
|
$res .= $temp;
|
|
}
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
function destroy(){
|
|
|
|
}
|
|
}
|
|
|
|
|
|
?>
|