X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcal.php;h=bdedaaacfa8afb99d1d3b3d1952728eafa3cec18;hb=9915523490e6547e9f6971884a7f502cc90d897a;hp=7796a459d0ab5795ff15d3df2a9776a740b08485;hpb=02d4b1098eaec61a801129d9c0865448e2274558;p=friendica.git diff --git a/mod/cal.php b/mod/cal.php index 7796a459d0..bdedaaacfa 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -28,52 +28,54 @@ function cal_init(App $a) DFRN::autoRedir($a, $a->argv[1]); } - if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) { - return; + if (Config::get('system', 'block_public') && !local_user() && !remote_user()) { + System::httpExit(403, ['title' => L10n::t('Access denied.')]); + } + + if ($a->argc < 2) { + System::httpExit(403, ['title' => L10n::t('Access denied.')]); } Nav::setSelected('events'); - if ($a->argc > 1) { - $nick = $a->argv[1]; - $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]); - if (!DBA::isResult($user)) { - return; - } + $nick = $a->argv[1]; + $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]); + if (!DBA::isResult($user)) { + System::httpExit(404, ['title' => L10n::t('Page not found.')]); + } - $a->data['user'] = $user; - $a->profile_uid = $user['uid']; + $a->data['user'] = $user; + $a->profile_uid = $user['uid']; - // if it's a json request abort here becaus we don't - // need the widget data - if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) { - return; - } - - $profile = Profile::getByNickname($nick, $a->profile_uid); + // if it's a json request abort here becaus we don't + // need the widget data + if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) { + return; + } - $account_type = Contact::getAccountType($profile); + $profile = Profile::getByNickname($nick, $a->profile_uid); - $tpl = get_markup_template("vcard-widget.tpl"); + $account_type = Contact::getAccountType($profile); - $vcard_widget = replace_macros($tpl, [ - '$name' => $profile['name'], - '$photo' => $profile['photo'], - '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""), - '$account_type' => $account_type, - '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""), - ]); + $tpl = get_markup_template("vcard-widget.tpl"); - $cal_widget = Widget\CalendarExport::getHTML(); + $vcard_widget = replace_macros($tpl, [ + '$name' => $profile['name'], + '$photo' => $profile['photo'], + '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""), + '$account_type' => $account_type, + '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""), + ]); - if (!x($a->page, 'aside')) { - $a->page['aside'] = ''; - } + $cal_widget = Widget\CalendarExport::getHTML(); - $a->page['aside'] .= $vcard_widget; - $a->page['aside'] .= $cal_widget; + if (!x($a->page, 'aside')) { + $a->page['aside'] = ''; } + $a->page['aside'] .= $vcard_widget; + $a->page['aside'] .= $cal_widget; + return; } @@ -100,7 +102,7 @@ function cal_content(App $a) $mode = 'view'; $y = 0; $m = 0; - $ignored = ((x($_REQUEST, 'ignored')) ? intval($_REQUEST['ignored']) : 0); + $ignored = (x($_REQUEST, 'ignored') ? intval($_REQUEST['ignored']) : 0); $format = 'ical'; if ($a->argc == 4 && $a->argv[2] == 'export') { @@ -138,7 +140,7 @@ function cal_content(App $a) $is_owner = local_user() == $a->profile['profile_uid']; - if ($a->profile['hidewall'] && (!$is_owner) && (!$remote_contact)) { + if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) { notice(L10n::t('Access to this profile has been restricted.') . EOL); return; } @@ -222,7 +224,7 @@ function cal_content(App $a) // get events by id or by date if ($event_params['event_id']) { - $r = Event::getListById($owner_uid, $event_params['event-id'], $sql_extra); + $r = Event::getListById($owner_uid, $event_params['event_id'], $sql_extra); } else { $r = Event::getListByDate($owner_uid, $event_params, $sql_extra); } @@ -293,14 +295,14 @@ function cal_content(App $a) } if ($mode == 'export') { - if (!(intval($owner_uid))) { + if (!intval($owner_uid)) { notice(L10n::t('User not found')); return; } // Test permissions // Respect the export feature setting for all other /cal pages if it's not the own profile - if (((local_user() !== intval($owner_uid))) && !Feature::isEnabled($owner_uid, "export_calendar")) { + if ((local_user() !== intval($owner_uid)) && !Feature::isEnabled($owner_uid, "export_calendar")) { notice(L10n::t('Permission denied.') . EOL); goaway('cal/' . $nick); }