summaryrefslogtreecommitdiff
path: root/extensions/tmwa/backend/libs/libladmin-db.php
blob: 2b1ba9bff6b245acadc243cddf2cf2409058bc49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/*
dbLadmin by wushin AGPL
*/

class dbLadmin {

    public function __construct() {
        $this->socket = True;
    }

    public function account_exists($username) {
        $dbr = wfGetDB(DB_SLAVE);
        $res = $dbr->select('tmw_accounts', array('USERNAME'), 'USERNAME = "'.$username.'"', __METHOD__, array());
        foreach ($res as $row) {
            return True;
        }
        return False;
    }

    public function create_account($username, $userpass, $sex, $email) {
        $dbw = wfGetDB(DB_MASTER);
        $dbw->insert('tmw_accounts', array('USERNAME' => $username, 'PASSWORD' => $userpass, 'GENDER' => $sex, 'EMAIL' => $email), __METHOD__, 'IGNORE');
        if ( $dbw->affectedRows() ) {
            return True;
        } else {
            return False;
        }
    }

    public function close() {
        return True;
    }
}