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.
94 lines
2.7 KiB
PHP
94 lines
2.7 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');
|
|
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);
|
|
|
|
$options = [
|
|
'http' => [
|
|
'method' => 'POST',
|
|
'header' => 'authorization: Bearer '.ACCESS_TOKEN,
|
|
'content-type: application/json'
|
|
]
|
|
];
|
|
$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
|
|
}
|
|
|
|
$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);
|
|
$result = file_get_contents(REGISTRATION_API_URL, false, $context);
|
|
if ($result === 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>
|