$myPassword = trim(exec(dirname(__FILE__).'/../bin/nicepass.py'));
if (empty($myPassword)) exit('bad Password');
-$Login = new Login($myUsername);
+$Login = new Login(getUsernameID($myUsername));
if (!$Login->exists() && !empty($myUsername)) {
addUser(array('Name'=>$myName,'Username'=>$myUsername,'Email'=>$myEmail));
- $Login->refresh();
+ $Login = new Login(getUsernameID($myUsername));
}
if ($Login->canSignup()) {
$User = new User($Login->getUserId());
require_once('batch.inc.php');
-$Login = new Login($i_u);
+$Login = new Login(getUsernameID($i_u));
// Previously "-1" -- verify consistency
if (!$Login->canLogin()) die('1');
/*$LoginSSL = sess('LoginSSL');
if (!is_a($LoginSSL, 'Login')) { $LoginSSL = new Login($SSLUsername); }*/
- $LoginSSL = new Login($SSLUsername);
+ $LoginSSL = new Login(getUsernameID($SSLUsername));
$LoginSSL->update($SSLCred['Name'],$SSLCred['Email']);
if (!isLoggedIn() && !$LoginSSL->exists()) {
if (!empty($SSLName))
addUser($SSLCred);
- $LoginSSL->refresh();
+ $LoginSSL = new Login(getUsernameID($SSLUsername));
}
} else {
unset($_SESSION['LoginSSL']);
if (empty($u)) return;
$this->u = $u;
$this->p = $p;
- if ((string)intval($u)===(string)$u) {
+ if (is_null($p)) {
$this->id = $u;
- $opt = sprintf(" Username = '%s' OR UserId = '%s'", mysql_escape_string($u), mysql_escape_string($u));
+ $opt = sprintf(" UserId = '%s'", mysql_escape_string($u));
} else {
$opt = sprintf(" Username = '%s'", mysql_escape_string($u));
$opt .= (is_null($p)?'':sprintf(" AND Password='%s'", mysql_escape_string(base64_encode($p))));
function expire() {
$this->info = null;
}
- function refresh() {
- if (!empty($this->id)) {
- $this->Login($this->id);
- } else {
- $this->Login($this->u,$this->p);
- }
- }
function update($name=null,$email=null) {
if (!$this->exists()) return;
$arr = array();
}
}
+function getUsernameID($username) {
+ $sql = sprintf("SELECT UserId FROM User USE INDEX (UsernameID) WHERE Username = '%s'", mysql_escape_string($username));
+ $r = fetchRows(DBSelect($sql), 'UserId');
+ $r = array_shift($r);
+ return count($r)?$r['UserId']:null;
+}
+
## 302 REDIRECTS
function redirect($target=null,$secure=null) {
require_once('mitsql.cfg.php');
require_once('mitsql.lib.php');
-include 'tpl/head.php';
+//include 'tpl/head.php';
function getManagedDBs($owner=null) {
$databases = array_keys(fetchRows(DBSelect('SELECT Name FROM DB WHERE bEnabled=1'),'Name'));
printErrors(array('this is a test error: test 0'));
printErrors(array('this is a test error: test 1', 'this is a test error: test 2'));
-include 'tpl/foot.php';
+print_r(getUsernameID('presbrey'));
+
+//include 'tpl/foot.php';
?>