You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.8 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<title>I M NINJA | Registration</title>
<?php
define('ACCESS_TOKEN', 'at_bsef');
define('REGISTRATION_PASSWORD', 'asef');
define('REGISTRATION_API_URL', 'http://synapse:8008/_synapse/admin/v1/register');
define('EVENT_API_URL', 'http://synapse:8008/_matrix/client/v3/rooms/{roomId}/send/{eventType}/{txnId}')
if ($_GET['secret'] === REGISTRATION_PASSWORD) {
?>
<form action="" method="post">
<input type="hidden" name="secret" value="<?php echo REGISTRATION_PASSWORD ?>">
<input type="hiddeN" name="nonce" value="<?php echo filter_var(file_get_contents(REGISTRATION_API_URL), FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?>">
Username:<br>
<input type="text" name="username"><br>
<br>
Password:<br>
<input type="password" name="password"><br>
<br>
<input type="submit" value="Register">
</form>
<?php
} elseif ($_POST['secret'] === REGISTRATION_PASSWORD) {
$username = filter_var($_POST['username'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
var_dump($_POST);
$content = [
nonce => $_POST['nonce'],
username => $_POST['username'],
password => $_POST['password']
admin = false
];
$content->mac = hash_hmac('sha1', $content->nonce."\s".$content->username."\s".$content->password."\s".$content->admin
$options = [
'http' => [
'method' => 'POST',
'header' => 'authorization: Bearer '.ACCESS_TOKEN,
'content-type: application/json',
'content' => json_encode($content);
]
];
$context = stream_context_create($options);
$registration = file_get_contents($url, false, $context);
if ($registration === false) {
?>
Registration for "<?php echo $username ?>"unsuccessful. Please try again later.
<?php
} else {
?>
Registration successful. To start using it please install a Matrix client like <a href="https://element.io/download">Element</a><br>
<br>
Server: <strong>imninja.net</strong><br>
Username: <strong><?php echo $username ?></strong><br>
Password: <strong>* * * * *</strong><br>
<br>
For password recovery purposes it's recommended to set an email address after you successfully logged on to your new Matrix account.<br>
<br>
Also consider using a password manager.<br>
<?php
}
$options = [
'http' => [
'method' => 'POST',
'header' => 'authorization: Bearer '.ACCESS_TOKEN,
'content-type: application/json',
'content' => json_encode($content);
]
];
$context = stream_context_create($options);
$message = file_get_contents(EVENT_API_URL, false, $context);
if ($message === FALSE) {
# something with errors
} else {
# success
}
} else {
echo 'Invalid URL';
}
?>
<!--
<br>
<br>
<sub>This is an <a href="https://imninja.net">imninja.net</a> service.</sub>