if (isset($_COOKIE["Friendica"])) {
$data = json_decode($_COOKIE["Friendica"]);
if (isset($data->uid)) {
- $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
- FROM `user` WHERE `uid` = %d AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified` LIMIT 1",
- intval($data->uid)
+
+ $user = dba::select('user',
+ [],
+ [
+ 'uid' => intval($data->uid),
+ 'blocked' => 0,
+ 'account_expired' => 0,
+ 'account_removed' => 0,
+ 'verified' => 1,
+ ],
+ ['limit' => 1]
);
- if ($r) {
- if ($data->hash != cookie_hash($r[0])) {
+ if (DBM::is_result($user)) {
+ if ($data->hash != cookie_hash($user)) {
logger("Hash for user " . $data->uid . " doesn't fit.");
nuke_session();
goaway(System::baseUrl());
// Expires after 7 days by default,
// can be set via system.auth_cookie_lifetime
$authcookiedays = Config::get('system', 'auth_cookie_lifetime', 7);
- new_cookie($authcookiedays * 24 * 60 * 60, $r[0]);
+ new_cookie($authcookiedays * 24 * 60 * 60, $user);
// Do the authentification if not done by now
if (!isset($_SESSION) || !isset($_SESSION['authenticated'])) {
- authenticate_success($r[0]);
+ authenticate_success($user);
if (Config::get('system', 'paranoia')) {
$_SESSION['addr'] = $data->ip;
goaway(System::baseUrl());
}
- $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
- FROM `user` WHERE `uid` = %d AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified` LIMIT 1",
- intval($_SESSION['uid'])
+ $user = dba::select('user',
+ [],
+ [
+ 'uid' => intval($_SESSION['uid']),
+ 'blocked' => 0,
+ 'account_expired' => 0,
+ 'account_removed' => 0,
+ 'verified' => 1,
+ ],
+ ['limit' => 1]
);
-
- if (!DBM::is_result($r)) {
+ if (!DBM::is_result($user)) {
nuke_session();
goaway(System::baseUrl());
}
$_SESSION['last_login_date'] = datetime_convert('UTC', 'UTC');
$login_refresh = true;
}
- authenticate_success($r[0], false, false, $login_refresh);
+ authenticate_success($user, false, false, $login_refresh);
}
} else {
session_unset();
*/
function cookie_hash($user) {
return(hash("sha256", Config::get("system", "site_prvkey").
- $user["uprvkey"].
+ $user["prvkey"].
$user["password"]));
}
// mod/settings.php in 8367cad so it might have left mixed
// records in the user table
//
- $r = q("SELECT *, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey` FROM `user`
+ $r = q("SELECT *
+ FROM `user`
WHERE ( `openid` = '%s' OR `openid` = '%s' )
AND `blocked` = 0 AND `account_expired` = 0
AND `account_removed` = 0 AND `verified` = 1
}
// check the email is valid
if (!valid_email($email)) {
- $err .= t(' Not valid email.');
+ $err .= t('Invalid email.');
}
// ensure new email is not the admin mail
//if ((x($a->config, 'admin_email')) && (strcasecmp($email, $a->config['admin_email']) == 0)) {
if (x($a->config, 'admin_email')) {
$adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
if (in_array(strtolower($email), $adminlist)) {
- $err .= t(' Cannot change to that email.');
+ $err .= t('Cannot change to that email.');
$email = $a->user['email'];
}
}
logger('Removing user: ' . $uid);
- $r = dba::select('user', array(), array('uid' => $uid), array("limit" => 1));
+ $user = dba::select('user', [], ['uid' => $uid], ['limit' => 1]);
- call_hooks('remove_user', $r);
+ call_hooks('remove_user', $user);
// save username (actually the nickname as it is guaranteed
// unique), so it cannot be re-registered in the future.
-
- dba::insert('userd', array('username' => $r['nickname']));
+ dba::insert('userd', ['username' => $user['nickname']]);
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
- q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
+ dba::update('user', ['account_removed' => 1, 'account_expires_on' => datetime_convert()], ['uid' => intval($uid)]);
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory
- Worker::add(PRIORITY_LOW, "Directory", $r['url']);
+ Worker::add(PRIORITY_LOW, "Directory", $user['url']);
if ($uid == local_user()) {
unset($_SESSION['authenticated']);
}
}
- $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
+ $r = q("SELECT `contact`.*, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`page-flags`, `user`.`account-type`, `user`.`prvnets`
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
$recipients[] = $suggest[0]['cid'];
$item = $suggest[0];
} elseif ($cmd === 'removeme') {
- $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
+ $r = q("SELECT `contact`.*, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`page-flags`, `user`.`prvnets`, `user`.`account-type`, `user`.`guid`
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
}
- $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
+ $r = q("SELECT `contact`.*, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`page-flags`, `user`.`prvnets`, `user`.`account-type`
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
$q_item = $r[0];
- $c = q(
- "SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($q_item['cid'])
- );
-
- if (!DBM::is_result($c)) {
+ $contact = dba::select('contact', [], ['id' => intval($q_item['cid'])], ['limit' => 1]);
+ if (!DBM::is_result($contact)) {
remove_queue_item($q_item['id']);
return;
}
- $dead = Cache::get($cachekey_deadguy . $c[0]['notify']);
+ $dead = Cache::get($cachekey_deadguy . $contact['notify']);
if (!is_null($dead) && $dead) {
- logger('queue: skipping known dead url: ' . $c[0]['notify']);
+ logger('queue: skipping known dead url: ' . $contact['notify']);
update_queue_time($q_item['id']);
return;
}
- $server = PortableContact::detectServer($c[0]['url']);
+ $server = PortableContact::detectServer($contact['url']);
if ($server != "") {
$vital = Cache::get($cachekey_server . $server);
if (is_null($vital)) {
- logger("Check server " . $server . " (" . $c[0]["network"] . ")");
+ logger("Check server " . $server . " (" . $contact["network"] . ")");
- $vital = PortableContact::checkServer($server, $c[0]["network"], true);
+ $vital = PortableContact::checkServer($server, $contact["network"], true);
Cache::set($cachekey_server . $server, $vital, CACHE_QUARTER_HOUR);
}
}
}
- $u = q(
- "SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
- FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($c[0]['uid'])
- );
- if (!DBM::is_result($u)) {
+ $user = dba::select('user', [], ['uid' => intval($contact['uid'])], ['limit' => 1]);
+ if (!DBM::is_result($user)) {
remove_queue_item($q_item['id']);
return;
}