Update api/next.php
This commit is contained in:
+15
-13
@@ -1,30 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../includes/config.php';
|
require_once __DIR__ . '/../includes/config.php';
|
||||||
require_once '../includes/functions.php';
|
require_once __DIR__ . '/../includes/functions.php';
|
||||||
require_once '../includes/jsondb.php';
|
require_once __DIR__ . '/../includes/jsondb.php';
|
||||||
require_once '../includes/srs.php';
|
require_once __DIR__ . '/../includes/srs_queue.php';
|
||||||
require_once '../includes/srs_queue.php';
|
require_once __DIR__ . '/../includes/auth.php';
|
||||||
require_once '../includes/auth.php';
|
|
||||||
|
|
||||||
requireLogin();
|
requireLogin();
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
$user = $_SESSION['user'];
|
$user = $_SESSION['user'];
|
||||||
|
|
||||||
$lang = $_GET['lang'];
|
$lang = $_GET['lang'] ?? '';
|
||||||
$list = $_GET['list'];
|
$list = $_GET['list'] ?? '';
|
||||||
|
|
||||||
$file = listPath($user, $lang, $list);
|
$file = listPath($user, $lang, $list);
|
||||||
$data = JsonDB::read($file);
|
$data = JsonDB::read($file);
|
||||||
|
|
||||||
if (!isset($data['words'])) {
|
if (!isset($data['words']) || !is_array($data['words'])) {
|
||||||
echo json_encode(['error' => 'no_list']);
|
echo json_encode(['error' => 'list_not_found']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$words = sortDueWords($data['words']);
|
$words = $data['words'];
|
||||||
|
|
||||||
$today = date('Y-m-d');
|
$today = date('Y-m-d');
|
||||||
|
|
||||||
@@ -36,7 +35,10 @@ if (count($due) === 0) {
|
|||||||
$due = $words;
|
$due = $words;
|
||||||
}
|
}
|
||||||
|
|
||||||
$word = array_values($due)[0];
|
// pak altijd eerste uit gesorteerde set (stabiel gedrag)
|
||||||
|
$due = array_values($due);
|
||||||
|
|
||||||
|
$word = $due[0];
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'word' => $word
|
'word' => $word
|
||||||
|
|||||||
Reference in New Issue
Block a user