'network' => $item['author-network'], 'url' => $item['author-link']];
// Only create a redirection to a magic link when logged in
- if (!empty($item['plink']) && (local_user() || remote_user())) {
+ if (!empty($item['plink']) && Session::isAuthenticated()) {
$item['plink'] = Contact::magicLinkByContact($author, $item['plink']);
}
}
{
$uid = 0;
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return;
}
function cal_init(App $a)
{
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
}
{
$o = '';
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
notice(L10n::t('Public access denied.') . EOL);
return;
}
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
$hidewall = false;
if (($dfrn_id === '') && empty($_POST['dfrn_id'])) {
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Group;
exit();
} else {
// Normal web request. Display our user's introduction form.
- if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
if (!Config::get('system', 'local_block')) {
notice(L10n::t('Public access denied.') . EOL);
return;
Objects::rawContent();
}
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
function display_content(App $a, $update = false, $update_uid = 0)
{
- if (Config::get('system','block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system','block_public') && !Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException(L10n::t('Public access denied.'));
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
function hcard_init(App $a)
{
- $blocked = Config::get('system', 'block_public') && !local_user() && !remote_user();
+ $blocked = Config::get('system', 'block_public') && !Session::isAuthenticated();
if ($a->argc > 1) {
$which = $a->argv[1];
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Attach;
require_once 'include/items.php';
function item_post(App $a) {
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return 0;
}
function item_content(App $a)
{
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return;
}
function photos_init(App $a) {
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
$albums = Photo::getAlbums($a->data['user']['uid']);
- $albums_visible = ((intval($a->data['user']['hidewall']) && !local_user() && !remote_user()) ? false : true);
+ $albums_visible = ((intval($a->data['user']['hidewall']) && !Session::isAuthenticated()) ? false : true);
// add various encodings to the array so we can just loop through and pick them out in a template
$ret = ['success' => false];
// photos/name/image/xxxxx/edit
// photos/name/image/xxxxx/drop
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
notice(L10n::t('Public access denied.') . EOL);
return;
}
$contact_url = $contact['url'];
- if ((!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
+ if (!Session::isAuthenticated() // Visitors (not logged in or not remotes) can't authenticate.
|| (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
{
$a->redirect(defaults($url, $contact_url));
}
}
- // When the remote page does support OWA, then we enforce the use of it
- $basepath = Contact::getBasepath($contact_url);
- if (Strings::compareLink($basepath, System::baseUrl())) {
- $use_magic = true;
- } else {
- $serverret = Network::curl($basepath . '/magic');
- $use_magic = $serverret->isSuccess();
- }
-
// Doing remote auth with dfrn.
- if (local_user() && !$use_magic && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
+ if (local_user() && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
$dfrn_id = $orig_id = (($contact['issued-id']) ? $contact['issued-id'] : $contact['dfrn-id']);
if ($contact['duplex'] && $contact['issued-id']) {
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
+use Friendica\Core\Session;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Model\Item;
}
function search_content(App $a) {
- if (Config::get('system','block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system','block_public') && !Session::isAuthenticated()) {
notice(L10n::t('Public access denied.') . EOL);
return;
}
- if (Config::get('system','local_search') && !local_user() && !remote_user()) {
+ if (Config::get('system','local_search') && !Session::isAuthenticated()) {
$e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a search."));
$e->httpdesc = L10n::t("Public access denied.");
throw $e;
}
- if (Config::get('system','permit_crawling') && !local_user() && !remote_user()) {
+ if (Config::get('system','permit_crawling') && !Session::isAuthenticated()) {
// Default values:
// 10 requests are "free", after the 11th only a call per minute is allowed
function subthread_content(App $a) {
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return;
}
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Item;
function tagger_content(App $a) {
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return;
}
function videos_init(App $a)
{
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
// videos/name/video/xxxxx/edit
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
notice(L10n::t('Public access denied.') . EOL);
return;
}
$nav['usermenu'] = [];
$userinfo = null;
- if (local_user() || remote_user()) {
+ if (Session::isAuthenticated()) {
$nav['logout'] = ['logout', L10n::t('Logout'), '', L10n::t('End this session')];
} else {
$nav['login'] = ['login', L10n::t('Login'), ($a->module == 'login' ? 'selected' : ''), L10n::t('Sign in')];
$nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')];
}
- if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !local_user() && !remote_user()) {
+ if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !Session::isAuthenticated()) {
$nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')];
}
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
+use Friendica\Core\Session;
use Friendica\Util\Network;
/**
*/
public static function contactAutocomplete($search, $mode, int $page = 1)
{
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
return [];
}
/**
* Retrieves a key from the session super global or the defaults if the key is missing or the value is falsy.
- *
+ *
* Handle the case where session_start() hasn't been called and the super global isn't available.
*
* @param string $name
}
DBA::close($remote_contacts);
}
+
+ /**
+ * Returns if the current visitor is authenticated
+ *
+ * @return boolean "true" when visitor is either a local or remote user
+ */
+ public static function isAuthenticated()
+ {
+ if (empty($_SESSION['authenticated'])) {
+ return false;
+ }
+
+ return $_SESSION['authenticated'];
+ }
}
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Network\Probe;
*/
public static function magicLink($contact_url, $url = '')
{
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
}
{
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
- if ((!local_user() && !remote_user()) || ($contact['network'] != Protocol::DFRN)) {
+ if (!Session::isAuthenticated() || ($contact['network'] != Protocol::DFRN)) {
return $destination;
}
*/
public static function performLike($item_id, $verb)
{
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return false;
}
}
// Update the cached values if there is no "zrl=..." on the links.
- $update = (!local_user() && !remote_user() && ($item["uid"] == 0));
+ $update = (!Session::isAuthenticated() && ($item["uid"] == 0));
// Or update it if the current viewer is the intented viewer.
if (($item["uid"] == local_user()) && ($item["uid"] != 0)) {
);
}
- $block = ((Config::get('system', 'block_public') && !local_user() && !remote_user()) ? true : false);
+ $block = ((Config::get('system', 'block_public') && !Session::isAuthenticated()) ? true : false);
/**
* @todo
$about = !empty($profile['about']) ? L10n::t('About:') : false;
$xmpp = !empty($profile['xmpp']) ? L10n::t('XMPP:') : false;
- if ((!empty($profile['hidewall']) || $block) && !local_user() && !remote_user()) {
+ if ((!empty($profile['hidewall']) || $block) && !Session::isAuthenticated()) {
$location = $gender = $marital = $homepage = $about = false;
}
use Friendica\Content\Widget;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
+use Friendica\Core\Session;
use Friendica\Core\Renderer;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
$app = self::getApp();
$config = $app->getConfig();
- if (($config->get('system', 'block_public') && !local_user() && !remote_user()) ||
- ($config->get('system', 'block_local_dir') && !local_user() && !remote_user())) {
+ if (($config->get('system', 'block_public') && !Session::isAuthenticated()) ||
+ ($config->get('system', 'block_local_dir') && !Session::isAuthenticated())) {
throw new HTTPException\ForbiddenException(L10n::t('Public access denied.'));
}
use Friendica\BaseModule;
use Friendica\Model\Item;
+use Friendica\Core\Session;
use Friendica\Network\HTTPException;
use Friendica\Util\Strings;
{
public static function rawContent()
{
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
throw new HTTPException\ForbiddenException();
}
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
{
public static function content()
{
- if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
+ if (Config::get('system', 'block_public') && !Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('User not found.'));
}
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
- if (local_user() || remote_user()) {
+ if (Session::isAuthenticated()) {
$profile_link = Contact::magicLinkByContact($author);
} else {
$profile_link = $item['author-link'];
{
static $verified = 0;
- if (!local_user() && !remote_user()) {
+ if (!Session::isAuthenticated()) {
return false;
}