5 function __construct($db, $login, $password, $clientApplication, $submittedLang) {
6 global $AcceptUnknownUser;
9 $this->password
= $password;
10 $this->lang
= $submittedLang;
11 $this->client
= $clientApplication;
15 $this->user
= $this->db
->querySingle('SELECT * FROM user WHERE Login="'._e($this->login
).'"');
17 $this->uid
= $this->user
['UId'];
19 if ($AcceptUnknownUser && $this->password
) {
20 $this->db
->query('INSERT INTO user SET Login = "'._e($this->login
).'", Password = "'._e($this->password
).'", ShardId=-1, Privilege=":DEV:"');
21 $this->user
= $this->db
->querySingle('SELECT * FROM user WHERE Login="'._e($this->login
).'"');
22 $this->uid
= $this->user
['UId'];
25 $this->user
= array('Password' => 'AA');
28 $this->authenticate
= False;
29 setMsgLanguage($submittedLang);
36 echo '1:'.substr($user['Password'], 0, 2);
38 dieError(2001, '', 'askSalt');
41 function createRingInfo($ServerDomain) {
42 $domainInfo = $ServerDomain->domainInfo
;
43 $this->db
->select($domainInfo['ring_db_name']);
44 $result = $this->db
->querySingle('SELECT user_id FROM ring_users where user_id = "'._e($this->uid
).'"');
46 $this->db
->query('INSERT INTO ring_users SET user_id = "'._e($this->uid
).'", user_name = "'._e($this->login
).'", user_type="ut_pioneer"');
49 function checkAccess() {
52 function updatePrivs($privs) {
53 $this->db
->query('UPDATE user SET ExtendedPrivilege="'._e($privs).'" WHERE UId='._e($this->uid
));
54 $this->user
['ExtendedPrivilege'] = $privs;
57 function addPriv($priv) {
58 $eprivs = explode(':', $this->user
['ExtendedPrivilege']);
60 foreach ($eprivs as $p)
63 $privs[$priv] = $priv;
64 $this->updatePrivs(':'.implode(':', array_keys($privs)).':');
67 function removePriv($priv) {
68 $eprivs = explode(':', $this->user
['ExtendedPrivilege']);
70 foreach ($eprivs as $p)
74 $this->updatePrivs(':'.implode(':', array_keys($privs)).':');
78 function checkPermission($ServerDomain) {
79 $perm = $this->db
->querySingle('SELECT * FROM permission WHERE UId="'._e($this->uid
).'" AND ClientApplication="'._e($this->client
).'"');
81 $this->db
->query('INSERT INTO permission (UId, ClientApplication, ShardId, AccessPrivilege) VALUES ("'._e($this->uid
).'", "'._e($this->client
).'", "'.$ServerDomain->getShard('ShardId').'", "OPEN")');
84 function logConnection() {
87 function checkValidity($password, $ServerDomain) {
91 dieError(3009, $this->login
);
93 if ($this->user
['Password'] == $password) {
94 $this->login
= $this->user
['Login']; // Correct case
97 $this->checkPermission($ServerDomain);
98 $this->logConnection();
100 $this->priv
= $this->user
['Privilege'];