Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 082263b5

Přidáno uživatelem Tomáš Pašek před téměř 4 roky(ů)

  • ID 082263b55937497c73975ffb5b4f58edd4e9ec8a
  • Rodič a4c65df6

Feature #8522 Login a bezpečnost webové aplikace
Feature #8523 Tvorba uživatele

Zobrazit rozdíly:

application/model/DB.php
65 65
        }
66 66
    }
67 67

  
68
    function getUser($username) {
69
        $this->stmt = $this->pdo->prepare('SELECT id, username, password, role FROM users WHERE username = :username');
70
        $this->stmt->bindParam(':username', $username);
71
        $this->stmt->execute();
72
        return $this->stmt->fetchAll();
73
    }
74

  
75
    function createUser($userDetails) {
76
        $this->stmt = $this->pdo->prepare('INSERT INTO users (username, password, role) VALUES (:username, :password, :role)');
77
        $password = password_hash($userDetails['username'], PASSWORD_DEFAULT);
78
        $this->stmt->bindParam(':username', $userDetails['username']);
79
        $this->stmt->bindParam(':password',$password);
80
        $this->stmt->bindParam(':role',$userDetails['role']);
81
        $this->stmt->execute();
82
        return $this->stmt->fetchAll();
83
    }
84

  
85
    function updateUserRole($userId, $role) {
86
        $this->stmt = $this->pdo->prepare("UPDATE users SET role = :role WHERE id = :userId");
87
        $this->stmt->bindParam(':role', $role);
88
        $this->stmt->bindParam(':userId',$userId);
89
        $this->stmt->execute();
90
        return $this->stmt->fetchAll();
91
    }
92

  
93
    function deleteUser($userId) {
94
        $this->stmt = $this->pdo->prepare("DELETE from users WHERE id = :userId");
95
        $this->stmt->bindParam(':userId',$userId);
96
        $this->stmt->execute();
97
        return $this->stmt->fetchAll();
98
    }
99

  
100

  
101

  
68 102
function update(){
69 103

  
70 104
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
......
297 331

  
298 332
// (D) DATABASE SETTINGS - CHANGE TO YOUR OWN!
299 333
define('DB_HOST', 'localhost');
300
define('DB_NAME', 'dalimil1');
334
define('DB_NAME', 'dalimil2');
301 335
define('DB_CHARSET', 'utf8');
302 336
define('DB_USER', 'postgres');
303 337
define('DB_PASSWORD', 'a');

Také k dispozici: Unified diff