nonce;
?>
$_POST['nonce'],
'username' => $username,
'password' => $_POST['password'],
'admin' => 'notadmin'
];
$content['mac'] = hash_hmac('sha1', $content['nonce']."\0".$content['username']."\0".$content['password']."\0".$content['admin'], REGISTRATION_SHARED_SECRET);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SYNAPSE_URL.'/_synapse/admin/v1/register');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'content-type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($content));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_error($ch) || curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
$decoded_response = json_decode($response);
?>
Registration for "" unsuccessful. Please try again later.
Registration successful. To start using it please install a Matrix client like Element
Server: imninja.net
Username:
Matrix ID: user_id, FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?>
Password: * * * * *
For password recovery purposes it's recommended to set an email address after you successfully logged on to your new Matrix account.
Also consider using a password manager.
access_token
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
# send admin message
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SYNAPSE_URL.'/_matrix/client/v3/rooms/'.ROOM_ID.'/send/m.room.message/'.$nonce);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'body' => $decoded_response->user_id.' just registered',
'msgtype' => 'm.text'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'authorization: Bearer '.ACCESS_TOKEN,
'content-type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
}
} else {
echo 'Invalid URL';
}
?>