<?php
use Friendica\App;
+use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Group;
/**
* @brief Calculate the hash that is needed for the "Friendica" cookie
* @param int $time
* @param array $user Record from "user" table
*/
-function new_cookie($time, $user = array())
+function new_cookie($time, $user = [])
{
if ($time != 0) {
$time = $time + time();
}
if ($user) {
- $value = json_encode(array("uid" => $user["uid"],
+ $value = json_encode(["uid" => $user["uid"],
"hash" => cookie_hash($user),
- "ip" => $_SERVER['REMOTE_ADDR']));
+ "ip" => $_SERVER['REMOTE_ADDR']]);
} else {
$value = "";
}
}
}
- $r = dba::select('user', array('uid', 'username', 'nickname'),
- array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false));
+ $r = dba::select('user', ['uid', 'username', 'nickname'],
+ ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
if (DBM::is_result($r)) {
$a->identities = dba::inArray($r);
} else {
- $a->identities = array();
+ $a->identities = [];
}
$r = dba::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
if ($login_initial || $login_refresh) {
- dba::update('user', array('login_date' => datetime_convert()), array('uid' => $_SESSION['uid']));
+ dba::update('user', ['login_date' => datetime_convert()], ['uid' => $_SESSION['uid']]);
// Set the login date for all identities of the user
- dba::update('user', array('login_date' => datetime_convert()),
- array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false));
+ dba::update('user', ['login_date' => datetime_convert()],
+ ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
}
if ($login_initial) {
}
if ($login_initial) {
- call_hooks('logged_in', $a->user);
+ Addon::callHooks('logged_in', $a->user);
if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
}
}
-function can_write_wall(App $a, $owner)
+function can_write_wall($owner)
{
static $verified = 0;
}
$uid = local_user();
-
- if (($uid) && ($uid == $owner)) {
+ if ($uid == $owner) {
return true;
}
);
if (DBM::is_result($r)) {
$remote_verified = true;
- $groups = init_groups_visitor($remote_user);
+ $groups = Group::getIdsByContactId($remote_user);
}
}
);
if (DBM::is_result($r)) {
$remote_verified = true;
- $groups = init_groups_visitor($remote_user);
+ $groups = Group::getIdsByContactId($remote_user);
}
}
if ($remote_verified) {
}
}
-// Returns an array of group id's this contact is a member of.
-// This array will only contain group id's related to the uid of this
-// DFRN contact. They are *not* neccessarily unique across the entire site.
-
-
-if (! function_exists('init_groups_visitor')) {
-function init_groups_visitor($contact_id) {
- $groups = array();
- $r = q("SELECT `gid` FROM `group_member`
- WHERE `contact-id` = %d ",
- intval($contact_id)
- );
- if (DBM::is_result($r)) {
- foreach ($r as $rr)
- $groups[] = $rr['gid'];
- }
- return $groups;
-}}
+/**
+ * @brief Kills the "Friendica" cookie and all session data
+ */
+function nuke_session()
+{
+ new_cookie(-3600); // make sure cookie is deleted on browser close, as a security measure
+ session_unset();
+ session_destroy();
+}