📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
otogaleriscripti.demodesign.com.tr
/
includes
/
models
📝
User.php
← Geri Dön
<? Class UserTypes{ public static $BAYI=0; public static $MUSTERI=1; public static $ONAYSIZ=2; } Class Users{ public function getAll() { global $dbh; $sth = $dbh->prepare("select * from users order by id desc"); $sth->execute( ); $users = $sth->fetchAll(PDO::FETCH_ASSOC); $r=[]; foreach ($users as $user) { $User = new User( $user["uname"], $user["pw"], $user["fullname"],$user["email"],$user["phone"],$user["type"]); $User->id = $user["id"]; $r[] = $User; } return $r; } } class User{ public $id,$uname,$pw,$email,$fullname,$phone,$type,$shopname; public function __construct($uname="",$pw="",$fullname="",$email="",$phone="",$type=0,$shopname=""){ $this->set($uname,$pw,$fullname,$email,$phone,$type,$shopname); } public function setType($t) { $this->type=$t; } public function insert(){ /** @var PDO $dbh */ global $dbh; $sth = $dbh->prepare("insert into users set fullname=:fullname ,email=:email ,uname=:uname , pw=:pw , phone=:phone, type=:type,shopname=:shopname "); $sth->execute(array( "shopname"=>$this->shopname, "fullname"=>$this->fullname, "uname"=>$this->uname, "email"=>$this->email, "pw"=>$this->pw, "phone"=>$this->phone, "type"=>$this->type, )); $error=$sth->errorInfo(); if(!isset($error[1])){ $this->id = $dbh->lastInsertId(); return $this; }else{ //print_r($error); return false; } } public function delete(){ global $dbh; $sth = $dbh->prepare("delete from users where id=:id "); $sth->execute(array( "id"=>$this->id )); $this->set("","","","","",""); return $this; } public function update(){ global $dbh; $pwparam=""; $guncarray=array( "id"=>$this->id, "shopname"=>$this->shopname, "fullname"=>$this->fullname, "uname"=>$this->uname, "email"=>$this->email, "phone"=>$this->phone, "type"=>$this->type ); if($this->pw!=""){ $pwparam="pw=:pw,"; $guncarray["pw"]=$this->pw; } $sth = $dbh->prepare("update users set fullname=:fullname ,shopname=:shopname ,email=:email ,uname=:uname ,$pwparam phone=:phone, type=:type where id=:id"); $sth->execute($guncarray); return $this; } public function get($id){ global $dbh; $sth = $dbh->prepare("select * from users where id=:id"); $sth->execute(array("id"=>$id)); $user = $sth->fetch(PDO::FETCH_ASSOC); if(isset($user["id"])){ $this->set( $user["uname"], "", $user["fullname"],$user["email"],$user["phone"],$user["type"],$user["shopname"]); $this->pw=$user["pw"]; $this->id = $user["id"]; return $this; }else{ return false; } } public function login($uname,$pw,$yetki="") { global $dbh; $sth = $dbh->prepare("select * from users where email=:email and pw=:pw"); $this->setPw($pw); $sth->execute(array( "email" => $uname, "pw" => $this->pw )); $user = $sth->fetch(PDO::FETCH_ASSOC); $error=$sth->errorInfo(); if(isset($user["id"])){ $this->get($user["id"]); return $this; }else{ return false; } } public function IsLoggedIn(){ return $this->id!=""?true:false; } public function set($uname,$pw,$fullname,$email,$phone,$type,$shopname=""){ $this->id=""; $this->uname = $uname; $pw!=""?$this->setPw($pw):""; $this->fullname = $fullname; $this->email = $email; $this->phone = $phone; $this->type = $type; $this->shopname = $shopname; return $this; } public function setPw($pw){ $this->pw = md5($pw); return $this; } } ?>
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula