. */ require_once(dirname(__DIR__) . "/helpers/auth.php"); require_once(ROOT_DIR . "/helpers/track.php"); $auth = new uAuth(); $userId = uUtils::getInt('userid'); $tracksArr = []; if ($userId) { if (uConfig::$public_tracks || ($auth->isAuthenticated() && ($auth->isAdmin() || $auth->user->id === $userId))) { $tracksArr = uTrack::getAll($userId); } } $result = []; if ($tracksArr === false) { $result = [ "error" => true ]; } else if (!empty($tracksArr)) { foreach ($tracksArr as $track) { $result[] = [ "id" => $track->id, "name" => $track->name ]; } } header("Content-type: application/json"); echo json_encode($result); ?>