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