2021-11-25 12:34:40 +00:00
|
|
|
<?php require_once '/src/base.php' ?>
|
|
|
|
<?php
|
|
|
|
|
2021-11-25 19:01:30 +00:00
|
|
|
$function = null;
|
2021-11-25 12:54:55 +00:00
|
|
|
$signup_method = null;
|
|
|
|
if (isset($_SERVER['REDIRECT_URL'])) {
|
2021-11-25 12:34:40 +00:00
|
|
|
|
2021-11-25 12:54:55 +00:00
|
|
|
# process URI
|
|
|
|
$path = trim($_SERVER['REDIRECT_URL'], '/');
|
|
|
|
$args = explode('/', $path);
|
|
|
|
|
|
|
|
# no args is very unlikely, but still
|
|
|
|
if (count($args) === 0) {
|
|
|
|
die('Unexpected error');
|
|
|
|
}
|
2021-11-25 12:34:40 +00:00
|
|
|
|
2021-11-25 12:54:55 +00:00
|
|
|
# get the signup method from URL
|
2021-11-25 19:01:30 +00:00
|
|
|
if (str_contains($args[1], ':')) {
|
|
|
|
$ps = explode(':', $args[1]);
|
|
|
|
$signup_method = $ps[0];
|
|
|
|
$function = $ps[1];
|
|
|
|
} else {
|
|
|
|
$signup_method = $args[1];
|
|
|
|
$function = 'view';
|
|
|
|
}
|
|
|
|
|
2021-11-25 12:54:55 +00:00
|
|
|
if (!in_array($signup_method, ['mastodon'])) {
|
2021-11-25 19:01:30 +00:00
|
|
|
die('The given signup method does not exist');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array($function, ['view', 'oauth'])) {
|
|
|
|
die('The given function is not correct');
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$function = 'view';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($function === 'oauth') {
|
|
|
|
$ID = $_GET['id'] ?? '';
|
|
|
|
$code = $_GET['code'] ?? '';
|
|
|
|
if (empty($code) || empty($ID)) {
|
|
|
|
header('Location: /signup'); die;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($signup_method) {
|
|
|
|
case 'mastodon':
|
|
|
|
require '/src/action/oauth/mastodon.php';
|
|
|
|
break;
|
2021-11-25 12:54:55 +00:00
|
|
|
}
|
2021-11-25 12:34:40 +00:00
|
|
|
}
|
|
|
|
|
2021-11-25 12:54:55 +00:00
|
|
|
?>
|
|
|
|
<?php require '/src/views/head.php' ?>
|
|
|
|
<?php require '/src/views/public/head.php' ?>
|
2021-11-25 19:01:30 +00:00
|
|
|
|
2021-11-25 12:54:55 +00:00
|
|
|
<main>
|
|
|
|
SIGNUP: <?php echo $signup_method ?>
|
2021-11-25 19:01:30 +00:00
|
|
|
<br>
|
|
|
|
FUNCTION: <?php echo $function ?>
|
2021-11-25 12:54:55 +00:00
|
|
|
</main>
|
2021-11-25 19:01:30 +00:00
|
|
|
|
|
|
|
<?php require '/src/js/api.php' ?>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
window.onload = function(e) {
|
|
|
|
<?php if ($function === 'view'): ?>
|
|
|
|
|
|
|
|
console.log('view');
|
|
|
|
|
|
|
|
<?php elseif ($function === 'oauth'): ?>
|
|
|
|
|
|
|
|
console.log('oauth');
|
|
|
|
|
|
|
|
<?php endif ?>
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
2021-11-25 12:54:55 +00:00
|
|
|
<?php require '/src/views/public/foot.php' ?>
|
|
|
|
<?php require '/src/views/foot.php' ?>
|