]>
jfr.im git - z_archive/KronOS.git/blob - dime/core/login.php
fc886539c582c6b67fa51d32136bce90779302a3
3 require_once('common.php');
5 if (empty($_POST['user']) || empty($_POST['pass'])) {
6 make_error('Username or password empty.', 1);
8 $sth = $db->prepare('SELECT uid, displayname FROM users WHERE username = ? AND password = ?');
9 $sth->bind_param('ss', $_POST['user'], sha1(PWSALT
.$_POST['pass']));
11 $sth->bind_result($uid, $dispname);
12 if (!$sth->fetch()) { // no row returned
13 make_error('Username or password incorrect.', 2);
16 // row returned, user/pw good
18 $sth = $db->prepare('INSERT INTO sessions(sid, uid, started, last, active) VALUES (NULL, ?, NOW(), NOW(), 1)');
19 $sth->bind_param('i', $uid);
21 $sid = $sth->insert_id
;
23 make_reply('Logged in!', array('uid' => $uid, 'sid' => $sid, 'name' => $dispname));