public function log_in($idMember)
 {
     $this->idMember = $idMember;
     $this->get_data_member();
     $this->verif_sessions();
     $bdd = new Bdd();
     $bdd->query('UPDATE ' . TABLE_MEMBERS . ' SET membre_last_up = ? WHERE membre_id = ?', array(time(), $this->getId()));
 }
Example #2
0
 public static function getInstance()
 {
     if (self::$instance === false) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public function __construct($infos = false)
 {
     $displayErrors = false;
     if (!self::$pdoS) {
         if (empty($infos)) {
             require ROOT . 'config/bdd.php';
             $infos = $BDD['mysql'];
         }
         $displayErrors = @$infos['displayErrors'];
         try {
             self::$pdoS = new PDO('mysql:host=' . $infos['host'] . ';dbname=' . $infos['database'] . '', $infos['login'], $infos['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
             self::$pdoS->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             $this->wake_up();
             return true;
         } catch (PDOException $erreur) {
             $error = new error();
             if ($displayErrors) {
                 $error->addError('Error : ' . $erreur->getMessage(), ERROR_PAGE);
             } else {
                 $error->addError('We can\'t display the page you asked for.', ERROR_PAGE);
             }
             return false;
         }
     }
     $this->wake_up();
 }
Example #4
0
 public function install()
 {
     $bdd = Bdd::getInstance();
     $filename = DATA_DIR . "/data.json";
     Cli::pinfo("Import {$filename} in database");
     $data = json_decode(file_get_contents($filename));
     $bdd->import($data);
 }
 public static function MettreAJourMembre($post)
 {
     $bdd = Bdd::Connect();
     $updateMembre = $bdd->prepare('UPDATE membre SET pseudo= :1, email= :2, mdp= :3, nom= :4, prenom= :5, 
                                                         adress= :6, cp= :7, ville= :8, tel= :9, tel_port= :10 
                                                          WHERE id_membre= :11');
     var_dump($updateMembre->execute(array(':1' => $post['pseudo'], ':2' => $post['confirmemail'], ':3' => $post['confirmNewMdp'], ':4' => $post['nom'], ':5' => $post['prenom'], ':6' => $post['adresse'], ':7' => $post['cp'], ':8' => $post['ville'], ':9' => $post['telfixe'], ':10' => $post['telport'], ':11' => $_SESSION['membre']->get_id())));
     $membre = array('id_membre' => $_SESSION['membre']->get_id(), 'pseudo' => $post['pseudo'], 'email' => $post['confirmemail'], 'mdp' => $post['confirmNewMdp'], 'nom' => $post['nom'], 'prenom' => $post['prenom'], 'adress' => $post['adresse'], 'cp' => $post['cp'], 'ville' => $post['ville'], 'tel' => $post['telfixe'], 'tel_port' => $post['telport'], 'admin' => $_SESSION['membre']->get_admin());
     var_dump($membre);
     return new Membre($membre);
 }
    public static function CreerArchive($info)
    {
        $bdd = Bdd::Connect();
        $panier = $_SESSION['panier']->getCart();
        foreach ($panier as $key => $pan) {
            $creatPanier = $bdd->prepare('INSERT INTO historique (id_membre,nom_produits,quantite_produits,prix_produits,prix_total)
				VALUES 
					( ?, ?, ?, ?, ?)
					
				');
            var_dump($creatPanier->execute(array($_SESSION['membre']->get_id(), $pan['nom'], $pan['qte'], $pan['prix'], $_SESSION['panier']->getPrixTotal())));
        }
    }
Example #7
0
 public function persist()
 {
     try {
         $bdd = Bdd::getInstance()->getConnexion();
         for ($i = 0; $i < sizeof($this->products); $i++) {
             $req = $bdd->prepare("INSERT INTO product SET name=:name, \n                                                    description=:description, \n                                                    image=:image, \n                                                    keyword=:keyword, \n                                                    height=:height,\n                                                    width=:width, \n                                                    nb_pakage=:nb_package, \n                                                    category=:category, \n                                                    weight=:weight");
             $data = array('name' => $this->products[$i]->getName(), 'description' => $this->products[$i]->getDescription(), 'image' => $this->products[$i]->getImage(), 'keyword' => $this->products[$i]->getKeyword(), 'height' => $this->products[$i]->getHeight(), 'width' => $this->products[$i]->getWidth(), 'nb_package' => $this->products[$i]->getNbPackage(), 'category' => $this->products[$i]->getCategory(), 'weight' => $this->products[$i]->getWeight());
             $req->execute($data);
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
 public static function insertA($_url, $_meta_desc, $_meta_title)
 {
     $bdd = Bdd::connect();
     if (!empty($_url)) {
         $url_canonique = $_url;
     }
     if (!empty($_meta_desc)) {
         $haut_meta_desc = $_meta_desc;
     }
     if (!empty($_meta_title)) {
         $haut_meta_title = $_meta_title;
     }
     include '../lib/php/perso/head.php';
 }
Example #9
0
function loggin()
{
    $_SESSION['username'] = getPost("pseudo");
    $pass = getPost("password");
    $datas = Bdd::sql_fetch_array_assoc("SELECT *\n                                            FROM LOL_user\n                                            WHERE pseudo=?", array($this->get_pseudo()));
    if ($data[0] == 0) {
        return false;
    }
    $_SESSION['id_user'] = $datas[1]['id'];
    $_SESSION['nom'] = $datas[1]['nom'];
    $_SESSION['prenom'] = $datas[1]['prenom'];
    $_SESSION['pseudo'] = $datas[1]['pseudo'];
    $_SESSION['mail'] = $datas[1]['mail'];
    $_SESSION['pass'] = $datas[1]['password'];
    return true;
}
Example #10
0
 public function dologin($login, $password)
 {
     $bdd = Bdd::getInstance();
     $user = $this->simpleSelect(array($bdd->quoteIdent(self::USERNAME) . "=:login"), array("login" => $login));
     if ($user->isEmpty()) {
         Logger::debug("User {$login} not found");
         return false;
     }
     $hash = $user->get(self::PASSWORD);
     $pwd = new Password();
     if (!$pwd->check($password, $hash)) {
         Logger::debug("Invalid password for {$login}");
         return false;
     }
     Logger::debug("User {$login} authenticated");
     return $user->getId();
 }
Example #11
0
 public function install()
 {
     Cli::pinfo(" * Create database structure");
     $bdd = Bdd::getInstance();
     if (is_dir(self::MODEL_DIR)) {
         if ($dh = opendir(self::MODEL_DIR)) {
             while (($file = readdir($dh)) !== false) {
                 if (substr($file, -15) == "Model.class.php" && substr($file, 0, 4) != "Base") {
                     $class = __NAMESPACE__ . "\\" . substr($file, 0, -10);
                     $model = new $class();
                     $bdd->dropTable($model->getTableName());
                     $model->createTable();
                 }
             }
             closedir($dh);
         }
     }
 }
 public static function verifDispoMail($email)
 {
     $email = htmlspecialchars($email, ENT_QUOTES);
     $bdd = Bdd::connect();
     $recupVerifEmail = $bdd->prepare('SELECT id_membre FROM membre WHERE email = ?');
     $recupVerifEmail->execute(array($email));
     $verifEmail = $recupVerifEmail->fetch();
     if (!empty($email)) {
         if (!empty($verifEmail['id'])) {
             return false;
         } else {
             return true;
         }
     } else {
         return true;
     }
     //$erreur[] = 4;
 }
Example #13
0
 public static function exist($db_name)
 {
     $tmp_req = Bdd::sql_get_global_bdd()->pdo();
     //      $tmp_req->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
     $tmp_req = $tmp_req->query("SELECT count(*) FROM {$db_name}");
     $tmp_req = gettype($tmp_req);
     return !is_bool($tmp_req);
 }
Example #14
0
print $_SERVER['REQUEST_METHOD'];
var_dump($_POST);
/**************   REGISTER     *****************/
if (isset($_POST['register'])) {
    print 'aa';
    $pseudo = getPost("pseudo", true);
    //$mail = getPost("mail",true);
    $pass = getPost("password", true);
    $passconf = getPost("password_confirmation", true);
    $region = 'euw';
    if ($passconf == $pass) {
        //$pass = password_hash( $pass, PASSWORD_DEFAULT);
        $salt = mcrypt_create_iv(22, MCRYPT_DEV_URANDOM);
        $salt = base64_encode($salt);
        $salt = str_replace('+', '.', $salt);
        $pass = crypt($pass, '$2y$10$' . $salt . '$');
        if (!$pass) {
            $str .= '<p class="bg-danger">Erreur lors du hashage de votre mot de passe.</p>';
        } else {
            $req = "INSERT INTO `user` (user_name, user_mdpsecret, user_region, sel ) VALUES ( ?,?,?,? )";
            $vals = array(post2bdd($pseudo), post2bdd($pass), post2bdd($region), $salt);
            if (Bdd::sql_insert($req, $vals)) {
                $str .= '<p class="bg-success">Votre compte a été crée avec succés !</p>';
            } else {
                $str .= '<p class="bg-danger">Erreur.</p>';
            }
        }
    } else {
        $str .= '<p class="bg-danger">Erreur, vos mot de passe ne correspondent pas.</p>';
    }
}
Example #15
0
<?php

header('Access-Control-Allow-Origin: *');
header('Content-type: application/json');
require_once "config.php";
require_once "class.bdd.php";
$bdd = new Bdd();
$post = $bdd->escape($_POST);
extract($post);
if (isset($latitude) && isset($longitude) && isset($status)) {
    $req = $bdd->query("INSERT INTO flag VALUES (DEFAULT, '{$latitude}', '{$longitude}', '{$status}')");
    if ($req === false) {
        die(json_encode(array("status" => "ERR", "error" => "Il manque des variables")));
    }
    die(json_encode(array("status" => "OK")));
} else {
    die(json_encode(array("status" => "ERR", "error" => "Il manque des variables")));
}
Example #16
0
 public static function getAll()
 {
     $table_user = User::$table_user;
     $membres = Bdd::sql_fetch_array_assoc("\n\t\tSELECT " . $table_user . ".pseudo, " . $table_user . ".id as IDD, count(MBL_fiche_lecture.id_user) as NBR_LECTURE,\n( SELECT count(MBL_biblio.id_user) FROM " . $table_user . " JOIN MBL_biblio ON " . $table_user . ".id=MBL_biblio.id_user  WHERE " . $table_user . ".id =IDD) as NBR_LIVRE\nFROM `" . $table_user . "` \nLEFT OUTER JOIN MBL_fiche_lecture ON " . $table_user . ".id=MBL_fiche_lecture.id_user\nGROUP BY " . $table_user . ".id, MBL_fiche_lecture.id_user");
     return $membres;
 }
Example #17
0
 public static function insertA($script_perso, $jquery = false)
 {
     $bdd = Bdd::connect();
     include '../lib/php/perso/foot.php';
 }
Example #18
0
 public function whereEq($name, $value)
 {
     $bdd = Bdd::getInstance();
     if (is_string($value)) {
         $this->where[] = $name . "=" . $bdd->quote($value);
     } elseif ($value === null) {
         $this->where[] = $name . " IS NULL";
     } elseif ($value === true) {
         $this->where[] = $name . "=1";
     } elseif ($value === false) {
         $this->where[] = $name . "=0";
     } else {
         $this->where[] = $name . "=" . $value;
     }
     return $this;
 }
 private function _rebuild_cache_templates_infos()
 {
     $bdd = new Bdd();
     $query = $bdd->query('SELECT * FROM ' . TABLE_CONFIG . ' WHERE config_name = "header" OR config_name = "footer"');
     $linesFile = array('<?php', '$templates_infos = array();');
     while ($fetch = $bdd->fetch($query)) {
         $infosPart = unserialize($fetch['config_value']);
         foreach ($infosPart as $k => $info) {
             $linesFile[] = '$templates_infos[\'' . $fetch['config_lang'] . '\'][\'' . $k . '\'] = \'' . $info . '\';';
         }
     }
     $linesFile[] = 'return $templates_infos;' . "\n" . '?>';
     file_put_contents(DIR_CACHE . 'templates_infos' . CACHE_LOAD, implode("\n", $linesFile));
     chmod(DIR_CACHE . 'templates_infos' . CACHE_LOAD, 0777);
     return $this->get_cache('templates_infos', CACHE_LOAD, true, true);
 }
Example #20
0
include 'lib/php/autoload/autoload.php';
session_start();
if (!isset($_SESSION['panier'])) {
    $_SESSION['panier'] = new Cart();
}
//session_destroy();
//var_dump($_SESSION['panier']);
if (isset($_GET['action'])) {
    $action = htmlspecialchars($_GET['action']);
} else {
    header('Location:Home');
    die;
}
if (file_exists('lib/php/config/config.' . $action . '.php')) {
    include 'lib/php/config/config.' . $action . '.php';
}
$bdd = Bdd::connect();
if (file_exists('ctr/ctr.' . $action . '.php')) {
    include 'ctr/ctr.' . $action . '.php';
}
if (file_exists('mod/mod.' . $action . '.php')) {
    include 'mod/mod.' . $action . '.php';
}
Head::insert($design, $description, $title);
if (file_exists('vue/vue.' . $action . '.php')) {
    include 'vue/vue.' . $action . '.php';
} else {
    echo 'vue introuvable';
}
Foot::insert($script, $jquery);
Example #21
0
 public function loggin()
 {
     $_SESSION['username'] = getPost("pseudo");
     $pass = getPost("password");
     $datas = Bdd::sql_fetch_array_assoc("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM MBL_user \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE pseudo=?", array($this->get_pseudo()));
     $_SESSION['id_user'] = $datas[1]['id'];
     $_SESSION['nom'] = $datas[1]['nom'];
     $_SESSION['prenom'] = $datas[1]['prenom'];
     $_SESSION['pseudo'] = $datas[1]['pseudo'];
     $_SESSION['mail'] = $datas[1]['mail'];
     $_SESSION['pass'] = $datas[1]['password'];
 }
Example #22
0
 public static function init($newLink = false, $clientFlags = false)
 {
     self::$data = array('serveur' => 'localhost', 'utilisateur' => 'geekland_Site', 'motPasse' => 'jU95unj5dhJr', 'bdd' => 'geek-land_membres', 'link' => false, 'bdd_link' => false, 'queryNbr' => 0);
     unset($bdd);
     //$this->driver->connect()
     if (!(self::$data['link'] = mysql_connect(self::$data['serveur'], self::$data['utilisateur'], self::$data['motPasse'], $newLink, $clientFlags))) {
         var_dump(self::$data['link']);
         //$this->driver->error()
         throw new Bdd_Exception(mysql_error(), E_USER_ERROR);
         return false;
     }
     //$this->driver->select_db()
     if (!(self::$data['bdd_link'] = mysql_select_db(self::$data['bdd'], self::$data['link']))) {
         //$this->driver->error()
         throw new Bdd_Exception(mysql_error(), E_USER_ERROR);
         //$this->driver->close() || .................. || $this->driver->error()
         mysql_close(self::$data['link']) or trigger_error(mysql_error(), E_USER_ERROR);
         return false;
     }
     //$this->driver->set_charset()
     mysql_set_charset('utf8', self::$data['link']);
     //On définit l'encodage des valeurs d'échange PHP <=> SQL
 }
Example #23
0
 /**
  * SupprimerCompte
  *
  * Fonction qui desactive le compte
  *
  * @return none
  */
 public function supprimerCompte()
 {
     $table = "`user`";
     $infos['`activate`'] = 0;
     $placeholder[] = $_SESSION['rss']['id_user'];
     $condition = " WHERE `id_user` = ?";
     parent::modifier($table, $infos, $placeholder, $condition);
     $session = new Session();
     $session->destroy();
     header('Location: ../view/index.php');
 }
Example #24
0
File: Post.php Project: milkae/Php
 public function __construct()
 {
     parent::__construct();
     $this->db = ORM::for_table($this->table);
 }
Example #25
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $object = __CLASS__;
         self::$instance = new $object();
     }
     return self::$instance;
 }