Esempio n. 1
0
 /**
  * Constructeur du groupe.
  * 
  * @param int $id
  * @param object $Fundation
  * @param string $name
  * @param int $open
  * @param int $public
  */
 public function __construct($id = 0, &$Fundation = 0, $name = 0, $open = 0, $isPublic = 0)
 {
     $this->db = Db_buckutt::getInstance();
     //Création de groupe
     if ($id == 0) {
         $this->db->query("INSERT INTO t_group_grp (grp_name, grp_open, grp_public, fun_id) VALUES('%s', '%u', '%u', '%u');", array($name, $open, $isPublic, $Fundation->getId()));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->name = $name;
             $this->open = $open;
             $this->isPublic = $isPublic;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->id = $id;
         $don = $this->db->fetchArray($this->db->query("SELECT grp_name, grp_open, grp_public FROM t_group_grp WHERE grp_id = '%u' AND grp_removed = '0';", array($this->id)));
         if ($this->db->affectedRows() == 1) {
             $this->name = $don['grp_name'];
             $this->open = $don['grp_open'];
             $this->isPublic = $don['grp_public'];
             $this->state = 1;
         } else {
             $this->state = 464;
         }
         return $this->state;
     }
 }
Esempio n. 2
0
 /**
  * Constructeur.
  * 
  * @param int $id
  * @param string $name
  * @param string $description
  * @param int $admin
  * @return int $state
  */
 public function __construct($id = 0, $name = 0, $description = 0, $admin = 0)
 {
     $this->db = Db_buckutt::getInstance();
     //Création de droit
     if ($id == 0) {
         $this->db->query("INSERT INTO ts_right_rig (rig_name, rig_description, rig_admin) VALUES('%s', '%s', '%u');", array($name, $description, $admin));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->name = $name;
             $this->description = $description;
             $this->admin = $admin;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->id = $id;
         $don = $this->db->fetchArray($this->db->query("SELECT rig_name, rig_description, rig_admin FROM ts_right_rig WHERE rig_id = '%u' AND rig_removed = '0';", array($this->id)));
         if ($this->db->affectedRows() == 1) {
             $this->name = $don['rig_name'];
             $this->description = $don['rig_description'];
             $this->admin = $don['rig_admin'];
             $this->state = 1;
         } else {
             $this->state = 453;
         }
     }
 }
Esempio n. 3
0
 /**
  * Constructeur de sale.
  * 
  * @return int $state;
  */
 public function __construct($sal_id = 0, &$Object = 0, &$Period = 0, $sal_name = '')
 {
     $this->db = Db_buckutt::getInstance();
     //Création de vente
     if ($sal_id == 0) {
         $this->db->query("INSERT INTO t_sale_sal (sal_name, per_id, obj_id) VALUES('%s', '%u', '%u');", array($sal_name, $Period->getId(), $Object->getId()));
         if ($this->db->affectedRows() == 1) {
             $this->sal_id = $this->db->insertId();
             $this->sal_name = $sal_name;
             $this->Object =& $Object;
             $this->Period =& $Period;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->sal_id = $sal_id;
         $don = $this->db->fetchArray($this->db->query("SELECT sal_name, per_id, obj_id FROM t_sale_sal WHERE sal_id = '%u' AND sal_removed = '0';", array($this->sal_id)));
         if ($this->db->affectedRows() == 1) {
             $this->sal_name = $don['sal_name'];
             $this->Object = new Object($don['obj_id']);
             $this->Period = new Period($don['per_id']);
             $this->state = 1;
         } else {
             $this->state = 466;
         }
     }
     return $this->state;
 }
Esempio n. 4
0
 /**
  * Constructeur.
  * 
  * @param int $id
  * @param int $idFundation
  * @param string $name
  * @param int $date_start
  * @param int $date_end
  * @return int $state
  */
 public function __construct($id = 0, $idFundation = 0, $name = 0, $date_start = 0, $date_end = 0)
 {
     $this->db = Db_buckutt::getInstance();
     //Création de période
     if ($id == 0) {
         $this->db->query("INSERT INTO t_period_per (fun_id, per_name, per_date_start, per_date_end) VALUES('%u', '%s', FROM_UNIXTIME(%u), FROM_UNIXTIME(%u));", array($idFundation, $name, $date_start, $date_end));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->idFundation = $idFundation;
             $this->name = $name;
             $this->date_start = $date_start;
             $this->date_end = $date_end;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->id = $id;
         $don = $this->db->fetchArray($this->db->query("SELECT fun_id, per_name, UNIX_TIMESTAMP(per_date_start) as per_date_start, UNIX_TIMESTAMP(per_date_end) as per_date_end FROM t_period_per WHERE per_id = '%u' AND per_removed = '0';", array($this->id)));
         if ($this->db->affectedRows() == 1) {
             $this->idFundation = $don['fun_id'];
             $this->name = $don['per_name'];
             $this->date_start = $don['per_date_start'];
             $this->date_end = $don['per_date_end'];
             $this->state = 1;
         } else {
             $this->state = 463;
         }
     }
 }
Esempio n. 5
0
 /**
  * Constructeur
  * 
  * @param int $img_id[optional]
  * @param string $mime[optional]
  * @param int $width[optional]
  * @param int $length[optional]
  * @param string $content[optional]
  * @return boolean $state
  */
 public function __construct($img_id = 0, $mime = 0, $width = 0, $length = 0, $content = 0)
 {
     $this->db = Db_buckutt::getInstance();
     if ($img_id == 0) {
         $this->db->query("INSERT INTO ts_image_img (img_mime, img_width, img_length, img_content) VALUES('%s','%u','%u','%s')", array($mime, $width, $length, $content));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->mime = $mime;
             $this->width = $width;
             $this->length = $length;
             $this->content = $content;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->id = $img_id;
         $don = $this->db->fetchArray($this->db->query("SELECT img_mime, img_width, img_length, img_content FROM ts_image_img WHERE img_id = '%u';", array($this->id)));
         if ($this->db->affectedRows() == 1) {
             $this->mime = $don['img_mime'];
             $this->width = $don['img_width'];
             $this->length = $don['img_length'];
             $this->content = $don['img_content'];
         } else {
             $this->state = 400;
         }
     }
     return $this->state;
 }
Esempio n. 6
0
 /**
  * Recupere une instance de DB
  * @return object $instance
  */
 public function getInstance()
 {
     global $_SQL;
     if (!isset(self::$instance)) {
         self::$instance = new Db_buckutt('mysql');
         self::$instance->connect($_SQL['host'], $_SQL['base'], $_SQL['user'], $_SQL['pass']);
     }
     return self::$instance;
 }
Esempio n. 7
0
 public function __construct(&$Buyer)
 {
     $this->db = Db_buckutt::getInstance();
     $this->Buyer =& $Buyer;
     // c'est là qu'on change si on change le directory du sherlocks
     $this->pathdebut = "/var/www/subversion/serveur/sherlocks/";
     $this->pathfile = "pathfile=/etc/sherlocks/pathfile";
     $this->path_bin_req = "/usr/bin/request";
     $this->path_bin_res = "/usr/bin/response";
     $this->logfile = "/var/log/log_sherlocks_brut.txt";
 }
Esempio n. 8
0
 /**
  * @param String $message
  * @param int $gravity
  * @param object $db
  * @return int $state
  */
 public function write($message, $gravity = 2, $db = 0)
 {
     if ($db == 0) {
         $db = Db_buckutt::getInstance();
     }
     $db->query("INSERT INTO ts_log_log (log_date, log_gravity, log_message) VALUES(NOW(), '%u', '%s');", array($gravity, $message));
     if ($db->affectedRows() == 1) {
         return 1;
     } else {
         return 0;
     }
 }
Esempio n. 9
0
 /**
  * Constructeur du groupe.
  * 
  * @param int $obj_id
  * @param string $obj_name
  * @param string $obj_type
  * @param int $obj_stock
  * @param int $fun_id
  * @param int $img_id
  * @param int $obj_single
  * @param int $pre_load
  * @param int $price
  * @return int $state;
  */
 public function __construct($obj_id = 0, $obj_name = '', $obj_type = '', $obj_stock = 0, $fun_id = 0, $img_id = 0, $obj_single = 0, $price = 0)
 {
     $this->db = Db_buckutt::getInstance();
     $this->obj_id = $obj_id;
     $this->obj_name = $obj_name;
     $this->obj_type = $obj_type;
     $this->obj_stock = $obj_stock;
     $this->obj_single = $obj_single;
     $this->img_id = $img_id;
     $this->fun_id = $fun_id;
     $this->price = $price;
     $this->state = 1;
     return $this->state;
 }
Esempio n. 10
0
 /**
  * Constructeur
  * 
  * @param string $data
  * @param int $meanOfLogin
  * @param string $pass
  * @param string $ip[optional]
  * @param int $noPass[optional] 1 si connexion sans mot de passe (badgeage simple au foyer)
  * @return int $state
  */
 public function __construct($data, $meanOfLogin, $pass, $ip = 0, $noPass = 0)
 {
     $this->db = Db_buckutt::getInstance();
     //Test si on utilise le mean of login IDCarte et si oui ba on suprime le dernier chiffre
     //On fait ça parce qu'on ne sait pas le calculer
     if ($meanOfLogin == 4) {
         $data = substr($data, 0, -1);
     }
     //Récupération de l'id buckutt
     $this->idUser = $this->db->result($this->db->query("SELECT usr_id FROM tj_usr_mol_jum WHERE jum_data='%s' AND mol_id='%u';", array($data, $meanOfLogin)), 0);
     if ($this->db->affectedRows() == 1) {
         $this->state = 1;
     } else {
         $this->state = 405;
         return $this->state;
     }
     $don = $this->db->fetchArray($this->db->query("SELECT usr_fail_auth, usr_blocked FROM ts_user_usr WHERE usr_id = '%u';", array($this->idUser)));
     if ($this->db->affectedRows() == 1) {
         $this->usr_fail_auth = $don['usr_fail_auth'];
         //si utilisateur bloqué
         if ($don['usr_blocked'] == 1) {
             $this->state = 403;
             return $this->state;
         }
     } else {
         $this->state = 405;
         return $this->state;
     }
     //si mec loggué avec mot de passe
     if ($noPass == 0) {
         //si le mot de passe est faux, on sort
         if ($this->checkPass($pass) != 1) {
             return $this->state;
         }
     }
     //si on arrive jusque là, on peut charger le mec
     $this->Ip = $ip;
     $don = $this->db->fetchArray($this->db->query("SELECT usr_firstname, usr_lastname, usr_nickname, usr_mail, usr_credit, img_id FROM ts_user_usr WHERE usr_id = '%u';", array($this->idUser)));
     $this->lastname = $don['usr_lastname'];
     $this->firstname = $don['usr_firstname'];
     $this->nickname = $don['usr_nickname'];
     $this->mail = $don['usr_mail'];
     $this->credit = $don['usr_credit'];
     $this->idPhoto = $don['img_id'];
     $this->loadRights();
 }
Esempio n. 11
0
 /**
  * Constructeur du groupe.
  * 
  * @param int $obj_id
  * @param string $obj_name
  * @param string $obj_type
  * @param int $obj_stock
  * @param int $fun_id
  * @param int $img_id
  * @param int $obj_single
  * @param int $pre_load
  * @return int $state;
  */
 public function __construct($obj_id = 0, $obj_name = '', $obj_type = '', $obj_stock = 0, $fun_id = 0, $img_id = 0, $obj_single = 0, $pre_load = 0)
 {
     $this->db = Db_buckutt::getInstance();
     //Création d'object
     if ($obj_id == 0) {
         $this->db->query("INSERT INTO t_object_obj (obj_name, obj_type, obj_stock, obj_single, img_id, fun_id) VALUES('%s', '%s', '%d', '%u', '%u', '%u');", array($obj_name, $obj_type, $obj_stock, $obj_single, $img_id, $fun_id));
         if ($this->db->affectedRows() == 1) {
             $this->obj_id = $this->db->insertId();
             $this->obj_name = $obj_name;
             $this->obj_type = $obj_type;
             $this->obj_stock = $obj_stock;
             $this->obj_single = $obj_single;
             $this->img_id = $img_id;
             $this->fun_id = $fun_id;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->obj_id = $obj_id;
         $don = $this->db->fetchArray($this->db->query("SELECT obj_name, obj_type, obj_stock, obj_single, img_id, fun_id FROM t_object_obj WHERE obj_id = '%u' AND obj_removed = '0';", array($this->obj_id)));
         if ($this->db->affectedRows() == 1) {
             $this->obj_name = $don['obj_name'];
             $this->obj_type = $don['obj_type'];
             $this->obj_stock = $don['obj_stock'];
             $this->obj_single = $don['obj_single'];
             $this->img_id = $don['img_id'];
             $this->fun_id = $don['fun_id'];
             $this->state = 1;
         } else {
             $this->state = 465;
         }
     }
     $this->loadParent();
     $this->loadChild();
     return $this->state;
 }
Esempio n. 12
0
 /**
  * Retourne un organisme existant si juste un Id envoyé en paramètre. Crée un organisme si 0 et name envoyé.
  *
  * @param int $id
  * @param string $name
  * @return int $state
  */
 public function __construct($id, $name = '')
 {
     $this->db = Db_buckutt::getInstance();
     //Création d'organisme
     if ($id == 0) {
         $this->db->query("INSERT INTO t_fundation_fun (fun_name) VALUES('%s');", array($name));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->name = $name;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         if ($this->db->numRows($name = $this->db->query("SELECT fun_name FROM t_fundation_fun WHERE fun_id = '%u';", array($id))) == 1) {
             $this->name = $this->db->result($name);
             $this->id = $id;
             $this->state = 1;
         } else {
             $this->state = 421;
         }
     }
     return $this->state;
 }
Esempio n. 13
0
 /**
  * Retourne un point existant si juste un Id envoyé en paramètre. Crée un point si 0 et name envoyé.
  *
  * @param int $id
  * @param string $name
  * @return int $state
  */
 public function __construct($id, $name = '')
 {
     $this->db = Db_buckutt::getInstance();
     //Création de point
     if ($id == 0) {
         $this->db->query("INSERT INTO t_point_poi (poi_name) VALUES('%s');", array($name));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->name = $name;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         if ($this->db->numRows($name = $this->db->query("SELECT poi_name FROM t_point_poi WHERE poi_id = '%u' AND poi_removed = '0';", array($id))) == 1) {
             $this->name = $this->db->result($name);
             $this->id = $id;
             $this->state = 1;
         } else {
             $this->state = 420;
         }
     }
     return $this->state;
 }
Esempio n. 14
0
 /**
  * Constructeur.
  */
 public function __construct()
 {
     $this->db = Db_buckutt::getInstance();
 }
Esempio n. 15
0
 /**
  * Constructeur des propositions.
  *
  * @param object $Seller
  * @param object $User
  * @param object $Point
  * @param object $ParentObject
  * @param int $step
  * @return int $state;
  */
 public function __construct(&$Seller, &$User, &$Point, &$ParentObject = 0, $step = 0)
 {
     $this->db = Db_buckutt::getInstance();
     $this->Seller = $Seller;
     if ($User) {
         $this->User = $User;
         $userid = $this->User->getId();
     } else {
         $userid = 0;
     }
     $this->Point = $Point;
     //si c'est une catégorie
     if ($ParentObject != 0 and $ParentObject->getType() == 'category') {
         $condition = vsprintf("oli.obj_id_parent = '%u' AND oli.oli_step = '0' AND ", array($ParentObject->getId()));
     } else {
         if ($ParentObject != 0 and $ParentObject->getType() == 'promotion') {
             $DetailsPromo = $this->getDetailsPromo($ParentObject->getId(), $step);
             $condition = "(";
             if ($DetailsPromo != 0) {
                 $this->promo = 0;
                 foreach ($DetailsPromo as $key => $value) {
                     if ($value == 'product') {
                         $condition .= "obj.obj_id = '" . $key . "' OR ";
                     } else {
                         if ($value == 'category') {
                             $condition .= "oli.obj_id_parent = '" . $key . "' OR ";
                         }
                     }
                 }
                 //on supprime le OR de trop
                 $condition = substr($condition, 0, -4);
                 $condition .= ") AND";
             } else {
                 //la promo est terminée
                 $condition = "oli.oli_id IS NULL AND ";
                 $ParentObject = 0;
                 $this->endPromo = 1;
             }
         } else {
             $condition = "(oli.oli_id IS NULL OR obj.obj_type = 'category') AND";
         }
     }
     //TODO gérer les produits en vente unique
     //TODO gérer le seller
     $res1 = $this->db->query("SET @SELLER_ID='%u',@BUYER_ID='%u',@POINT_ID='%u';", array($this->Seller->getId(), $userid, $this->Point->getId()));
     $req = "\nSELECT\nobj.obj_id, obj.obj_name, obj.obj_type, obj.obj_stock, obj.obj_single, obj.img_id,\nIF(obj.obj_type = 'category',0, MIN(pri.pri_credit)) AS credit\n\nFROM\nt_object_obj obj\n\n   INNER JOIN tj_obj_poi_jop jop\n         ON obj.obj_id = jop.obj_id\n\n   INNER JOIN t_sale_sal sal\n         ON (obj.obj_id = sal.obj_id AND sal.sal_removed = '0')\n               LEFT JOIN t_period_per per1\n                    ON sal.per_id = per1.per_id\n\n   LEFT OUTER JOIN t_price_pri pri\n         ON ((obj.obj_id = pri.obj_id AND obj.obj_type != 'category' AND pri.pri_removed = '0'))\n                LEFT JOIN t_period_per per2\n                         ON pri.per_id = per2.per_id";
     if ($userid != 0) {
         $req .= "\n                INNER JOIN tj_usr_grp_jug jug\n                        ON (pri.grp_id = jug.grp_id AND jug.jug_removed = '0')\n                             LEFT JOIN t_period_per per3\n                                   ON jug.per_id = per3.per_id\n";
     }
     $req .= "\n\t\tLEFT JOIN tj_object_link_oli oli\n         ON (obj.obj_id = oli.obj_id_child AND oli.oli_removed = '0')\n\n   INNER JOIN tj_usr_rig_jur jur\n         ON (obj.fun_id = jur.fun_id AND jur.jur_removed = '0' AND jur.rig_id = '11' AND jur.usr_id = @SELLER_ID AND jur.poi_id = @POINT_ID)\n                LEFT JOIN t_period_per per4\n                      ON jur.per_id = per4.per_id\n\nWHERE\n\n" . $condition . "\n\nobj.obj_removed = '0' AND\nper1.per_date_start <= NOW() AND\nper1.per_date_end >= NOW() AND\n(per2.per_date_start <= NOW() OR per2.per_date_start IS NULL) AND\n(per2.per_date_end >= NOW() OR per2.per_date_end IS NULL) AND\n";
     if ($userid != 0) {
         $req .= "\nper3.per_date_start <= NOW() AND\nper3.per_date_end >= NOW() AND\n";
     }
     $req .= "\nper4.per_date_start <= NOW() AND\nper4.per_date_end >= NOW() AND";
     if ($userid != 0) {
         $req .= " jug.usr_id = @BUYER_ID AND ";
     }
     $req .= "\njop.poi_id = @POINT_ID AND\n(obj.obj_stock > '0' OR obj.obj_stock = '-1')\n\nGROUP BY obj.obj_id, pri.pri_id\n\nORDER BY jop.jop_priority ASC, obj.obj_name ASC\n;";
     $res = $this->db->query($req);
     $ObjectList = array();
     $this->ObjectCsvLight = new ComplexData(array());
     $this->ObjectCsv = new ComplexData(array());
     if ($this->db->affectedRows() >= 1) {
         while ($don = $this->db->fetchArray($res)) {
             if ($ParentObject != 0 and $ParentObject->getType() == 'promotion') {
                 $temp_obj = new ObjectWithPrice($don['obj_id'], $don['obj_name'], $don['obj_type'], $don['obj_stock'], $don['fun_id'], $don['img_id'], 0, 0);
             } else {
                 $temp_obj = new ObjectWithPrice($don['obj_id'], $don['obj_name'], $don['obj_type'], $don['obj_stock'], $don['fun_id'], $don['img_id'], 0, $don['credit']);
             }
             $this->ObjectList[] = $temp_obj;
             $this->ObjectCsvLight->addLine($temp_obj->getDetailsLight());
             $this->ObjectCsv->addLine($temp_obj->getDetails());
         }
         $this->state = 1;
     } else {
         $this->state = 0;
     }
     return $this->state;
 }
Esempio n. 16
0
 public static function getPrice(&$User, &$Point, &$Object)
 {
     $db = Db_buckutt::getInstance();
     $result = $db->query("\nSELECT \nMIN(pri.pri_credit) AS credit \n\nFROM\nt_object_obj obj,\ntj_obj_poi_jop jop,\ntj_usr_grp_jug jug,\nt_price_pri pri,\nt_sale_sal sal,\nt_period_per per1,\nt_period_per per2,\nt_period_per per3 \n\nWHERE \nobj.obj_id = '%u' AND \nobj.obj_removed = '0' AND \njug.jug_removed = '0' AND \npri.pri_removed = '0' AND \nsal.sal_removed = '0' AND \n(obj.obj_stock > '0' OR obj.obj_stock = '-1') AND\njug.usr_id = '%u' AND \n(jug.grp_id = pri.grp_id OR pri.grp_id = '0') AND \njop.poi_id = '%u' AND \njop.obj_id = obj.obj_id AND \npri.obj_id = obj.obj_id AND \nsal.obj_id = obj.obj_id AND \nper1.per_id = jug.per_id AND \nper2.per_id = pri.per_id AND \nper3.per_id = sal.per_id AND\nper1.per_date_start <= NOW() AND \nper1.per_date_end >= NOW() AND \nper2.per_date_start <= NOW() AND \nper2.per_date_end >= NOW() AND \nper3.per_date_start <= NOW() AND \nper3.per_date_end >= NOW() \n\nGROUP BY obj.obj_id\n\t\t;", array($Object->getId(), $User->getId(), $Point->getId()));
     return $db->result($result);
 }
Esempio n. 17
0
<?php

set_include_path(dirname(_FILE_) . '/../');
require_once 'db/Db_buckutt.class.php';
require_once 'db/Mysql.class.php';
$db = Db_buckutt::getInstance();
//TABLE TS_USER_USR (buckutt_user et buckutt_user_identity)
/*
$res = $db->query("
SELECT 
u.id_user, 
u.pass, 
i.firstname, 
i.lastname, 
i.nickname, 
i.mail, 
u.credit, 
u.id_image, 
u.temporary, 
u.fail_auth, 
u.blocked 
FROM 
buckutt_user u, 
buckutt_user_identity i 
WHERE u.id_user = i.id_user 
ORDER BY u.id_user;
		",array());
		

while ($don = $db->fetchArray($res)) {
	$db->query("INSERT INTO ts_user_usr (usr_id, usr_pwd, usr_firstname, usr_lastname, usr_nickname, usr_mail, usr_credit, img_id, usr_temporary, usr_fail_auth, usr_blocked) VALUES('%u', '%s', '%s', '%s', '%s', '%s', '%u', '%u', '%u', '%u', '%u');", Array($don['id_user'], $don['pass'], $don['firstname'], $don['lastname'], $don['nickname'], $don['mail'], $don['credit'], $don['id_image'], $don['temporary'], $don['fail_auth'], $don['blocked']));