realfan/public/user/index.php

37 lines
842 B
PHP

<?php require_once '/src/base.php' ?>
<?php
if (!isset($_SERVER['REDIRECT_URL'])) {
header('Location: /'); die;
}
# process URI
$path = trim($_SERVER['REDIRECT_URL'], '/');
$args = explode('/', $path);
# no args is very unlikely, but still
if (count($args) === 0) {
die('Unexpected error');
}
# support path if /user/@* instead of /@*
if (strtolower($args[0]) === 'user') {
$args = array_splice($args, 1);
}
# first arg => Fediverse ID
$fediverse_id = $args[0];
if (!preg_match('/^@[a-zA-Z0-9_]+@[a-z0-9\-\.]+$/', $fediverse_id)) {
die('The given arguments are not correct');
}
$args = array_splice($args, 1);
?>
<?php require '/src/views/head.php' ?>
<?php require '/src/views/public/head.php' ?>
<main>
USER: <?php echo $fediverse_id ?>
</main>
<?php require '/src/views/public/foot.php' ?>
<?php require '/src/views/foot.php' ?>