2023-11-19 12:24:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function generate_app_id(): int
|
|
|
|
{
|
|
|
|
return mt_rand(100000000, 999999999);
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_app_id($app_id): bool
|
|
|
|
{
|
|
|
|
$app = db_execute("SELECT * FROM apps WHERE id = ? LIMIT 1", [$app_id]);
|
|
|
|
return empty($app);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
|
|
|
$app_id = generate_app_id();
|
2024-02-20 19:49:42 +00:00
|
|
|
db_execute("INSERT INTO apps (id, owner_id, title, description, type, callback) VALUES (?, ?, ?, ?, ?, ?)", [$app_id, $_POST['owner'], $_POST['title'], $_POST['description'], $_POST['type'], $_POST['callback']]);
|
2023-11-19 12:24:38 +00:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<h1>App Creator</h1>
|
|
|
|
|
|
|
|
<form method="post">
|
|
|
|
<label for="title">Title</label>
|
2024-03-02 12:41:57 +00:00
|
|
|
<input type="text" required name="title" id="title">
|
2023-11-19 12:24:38 +00:00
|
|
|
<label for="description">Description</label>
|
|
|
|
<textarea name="description" id="description" cols="30" rows="10"></textarea>
|
|
|
|
<label for="owner">App owner</label>
|
2024-03-02 12:41:57 +00:00
|
|
|
<select name="owner" required id="owner">
|
2023-11-19 12:24:38 +00:00
|
|
|
<?php
|
|
|
|
$users = db_query("SELECT * FROM accounts");
|
|
|
|
foreach ($users as $row) {
|
|
|
|
echo "<option value='".$row['id']."'>".get_display_name($row['id'])." (".$row['id'].") </option>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
2024-02-17 12:04:47 +00:00
|
|
|
<label for="type">App type</label>
|
2024-03-02 12:41:57 +00:00
|
|
|
<select name="type" required id="type">
|
2024-02-17 12:04:47 +00:00
|
|
|
<option value="null">None</option>
|
|
|
|
<option value="basic_login">Basic login</option>
|
|
|
|
</select>
|
2024-03-02 12:41:57 +00:00
|
|
|
|
|
|
|
<label for="app_icon">App icon</label>
|
|
|
|
<input type="file" id="app_icon" name="app_icon" />
|
|
|
|
|
2024-02-20 19:49:42 +00:00
|
|
|
<label for="callback">Callback</label>
|
|
|
|
<input type="url" id="callback" name="callback" />
|
|
|
|
<button type="submit" class="primary">Create app</button>
|
2023-11-19 12:24:38 +00:00
|
|
|
</form>
|