Files
vintagecoding.net/director.php
T

43 lines
1.3 KiB
PHP

<?php
include 'functions/functions.php';
if (isset($_POST['ajax_id'])) {
switch ($_POST['ajax_id']) {
case 'todo':
handle_todo();
break;
}
} else {
$response = [
'error' => 'Malformed URI request.',
];
echo json_encode($response);
}
function handle_todo()
{
include 'functions/todo_functions.php';
$response = ['log' => []];
if (isset($_POST['todo_id']) && isset($_POST['action_id'])) {
$response['log'][] = 'Required parameters met.';
switch ($_POST['action_id']) {
case 'status':
$response['log'][] = 'Changing status on ' . $_POST['todo_id'] . ' to ' . $_POST['status'] . '.';
change_status($_POST['todo_id'], $_POST['status']);
break;
case 'create_update_todo':
if ($_POST['todo_id'] != -1) {
$response['log'][] = 'Updating todo information on ' . $_POST['todo_id'] . '.';
update_todo($_POST['todo_id'], urldecode($_POST['todo']));
} else {
$response['log'][] = 'Creating todo information on ' . $_POST['todo_id'] . '.';
create_todo(urldecode($_POST['todo']));
}
break;
}
}
echo json_encode($response);
}