This commit is contained in:
grandeljay 2022-06-14 14:52:19 +02:00
parent e2ffff94b9
commit 3c14a927f4
5 changed files with 26 additions and 19 deletions

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* index.php * wishthis - Make a wish
* *
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @author Jay Trees <github.jay@grandel.anonaddy.me>
*/ */

View file

@ -2,6 +2,8 @@
/** /**
* Blog * Blog
*
* @category API
*/ */
namespace wishthis; namespace wishthis;

View file

@ -3,7 +3,7 @@
/** /**
* Various statistics * Various statistics
* *
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @category API
*/ */
namespace wishthis; namespace wishthis;
@ -37,8 +37,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
} }
} else { } else {
$count = $database $count = $database
->query('SELECT COUNT(`id`) AS "count" ->query(
FROM `' . $_GET['table'] . '`;') 'SELECT COUNT(`id`) AS "count"
FROM `' . $_GET['table'] . '`;'
)
->fetch(); ->fetch();
$response['data'] = $count; $response['data'] = $count;

View file

@ -1,9 +1,9 @@
<?php <?php
/** /**
* url.php * URL
* *
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @category API
*/ */
namespace wishthis; namespace wishthis;

View file

@ -1,9 +1,9 @@
<?php <?php
/** /**
* wishes.php * Wishes
* *
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @category API
*/ */
namespace wishthis; namespace wishthis;
@ -175,20 +175,22 @@ switch ($_SERVER['REQUEST_METHOD']) {
$status = time(); $status = time();
} }
$database->query('UPDATE `wishes` $database->query(
'UPDATE `wishes`
SET `status` = "' . $status . '" SET `status` = "' . $status . '"
WHERE `id` = ' . $_PUT['wish_id'] . ' WHERE `id` = ' . $_PUT['wish_id'] . ';'
;'); );
$response['success'] = true; $response['success'] = true;
} elseif (isset($_PUT['wish_url_current'], $_PUT['wish_url_proposed'])) { } elseif (isset($_PUT['wish_url_current'], $_PUT['wish_url_proposed'])) {
/** /**
* Update Wish URL * Update Wish URL
*/ */
$database->query('UPDATE `wishes` $database->query(
'UPDATE `wishes`
SET `url` = "' . $_PUT['wish_url_proposed'] . '" SET `url` = "' . $_PUT['wish_url_proposed'] . '"
WHERE `url` = "' . $_PUT['wish_url_current'] . '" WHERE `url` = "' . $_PUT['wish_url_current'] . '";'
;'); );
$response['success'] = true; $response['success'] = true;
} }
@ -198,9 +200,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
parse_str(file_get_contents("php://input"), $_DELETE); parse_str(file_get_contents("php://input"), $_DELETE);
if (isset($_DELETE['wish_id'])) { if (isset($_DELETE['wish_id'])) {
$database->query('DELETE FROM `wishes` $database->query(
WHERE `id` = ' . $_DELETE['wish_id'] . ' 'DELETE FROM `wishes`
;'); WHERE `id` = ' . $_DELETE['wish_id'] . ';'
);
} }
$response['success'] = true; $response['success'] = true;