summaryrefslogtreecommitdiff
path: root/src/application/actions/lookupuser/get.php
blob: a7ed2151d94a191990a00f5b6fd0518f1b6eeb11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

use mystic\forum\orm\User;

$userHandle = $_GET["handle"] ?? call_user_func(function() {
    http_response_code(400);
    msg_error(__("Missing handle"));
    exit;
});

$user = new User();
$user->name = $userHandle;

if (!$db->fetchWhere($user, "name")) {
    http_response_code(404);
    msg_error(__("No user with name @%user_handle%", [ "user_handle" => $userHandle ]));
    exit;
}

header("Location: ./?_action=viewuser&user=" . urlencode($user->id));