prep for js settings page

This commit is contained in:
Austin 2021-11-12 12:31:15 -05:00
parent 1e638b7688
commit a1c503a416
4 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
$userid = $user->id;
//user info
$userquery = $pdo->prepare('SELECT * FROM `users` WHERE id = :uid');
$userquery->bindParam(':uid', $userid, PDO::PARAM_INT);
$userquery->execute();
$userquery = $userquery->fetch(PDO::FETCH_OBJ);
$username = getUsername($userquery->id);
$blurb = $userquery->blurb;
$email = obfuscate_email($userquery->email);
$verified = (bool)$userquery->verified;
$joinpref = $userquery->canJoin;
$tradepref = null;
$theme = $userquery->theme;
$userInfo = array (
"userid" => $userid,
"username" => $username,
"email" => $email,
"verified" => $verified,
"blurb" => $blurb,
"twofactorenabled" => is2FAInitialized($userid),
"referralprogram" => inReferralProgram($userid),
"joinpref" => $joinpref,
"tradepref" => $tradepref,
"theme" => $theme
);
// ...
die(json_encode($userInfo));

View File

@ -0,0 +1,24 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
$userid = $user->id;
$data = json_decode(file_get_contents('php://input'));
if (!$data)
{
http_response_code(400);
}
else
{
$blurb = $data->blurb;
header('Content-Type: application/json');
echo json_encode(array("success" => setBlurb($blurb)));
}

View File

@ -0,0 +1,23 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
$data = json_decode(file_get_contents('php://input'));
if (!$data)
{
http_response_code(400);
}
else
{
$privacy = $data->preference;
header('Content-Type: application/json');
echo json_encode(array("success" => setCanJoinUser($privacy)));
}

View File

@ -0,0 +1,22 @@
<?php
/*
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
$data = json_decode(file_get_contents('php://input'));
if (!$data)
{
http_response_code(400);
}
else
{
$theme = $data->theme;
header('Content-Type: application/json');
echo json_encode(array("success" => setTheme($theme)));
}