Files
coursehub/config.example.php
Harwinder Sekhon 59fab56359 Seed the vendor catalogue into SQL and add an optional AI course advisor
Course metadata: a scan now gives every course a course_meta row from the
downloader's sidecar JSON when the folder has one, else from catalog_courses
matched by the folder name the downloader would create (folderKeyFor, a port
of ine.py's sanitize_name). tools/build-catalog-seed.php turns the INE export
into seeds/ine_catalog.sql, an idempotent patch that creates its own table and
upserts by id, so it can be applied to the live server before or after the
code and re-run freely. Course pages show the blurb, difficulty, vendor and
tags; search matches tags and blurbs; Settings reports how each course got its
details. Against the live library 163 of 179 courses match.

Course advisor, off by default: api/advisor.php answers "which course should I
take to learn X / what comes before Y" with courses from the library, in
order, plus vendor courses not yet downloaded. includes/ai_client.php is a
small curl wrapper for any OpenAI-format chat endpoint (DeepSeek V4 Flash by
default, no composer); the prompt is a byte-stable catalogue of the library so
the provider's prefix cache covers it. Every course id the model returns is
validated server-side, a bad JSON reply gets one retry then a plain-text
fallback, and a per-user daily cap with token counts lives in
advisor_requests. With AI_ENABLED false the app makes no outbound requests
and the box does not appear; users can also hide it per browser.

Claude-Session: https://claude.ai/code/session_012enquL2RZdjy3D5AcKP5yx
2026-09-08 18:36:43 -04:00

55 lines
2.4 KiB
PHP

<?php
// ---- CourseHub configuration ----
// Absolute path to the directory that contains your course folders, e.g.
// /srv/media/courses/
// Course 1/Intro/Video1.mp4
// Course 2/Module 3/Advanced/lesson.mp4
define('VIDEOS_ROOT', '/srv/courses');
define('DB_HOST', '127.0.0.1');
define('DB_PORT', 3306);
define('DB_NAME', 'coursehub');
define('DB_USER', 'coursehub');
define('DB_PASS', 'change-me');
// A video counts as "completed" once the user has watched this fraction of it.
define('COMPLETE_THRESHOLD', 0.95);
// Allow new users to self-register from the login page.
define('ALLOW_REGISTRATION', true);
// How long a sign-in lasts, in seconds (30 days below). The cookie survives
// browser restarts, and idle sessions are kept at least this long. 0 = a
// browser-session cookie that also expires after php.ini's idle limit
// (session.gc_maxlifetime, 24 min by default — pausing a video over lunch
// signs you out). If other PHP apps share this server's session directory,
// give this app its own session.save_path in the vhost / FPM pool, or their
// shorter limit still wins.
define('SESSION_LIFETIME', 30 * 86400);
// Only when the app sits behind a proxy that hides the visitor's address
// (Cloudflare): the header carrying the real client IP, used by the login
// brute-force throttle. Set this ONLY if the origin cannot be reached except
// through that proxy — a directly reachable origin lets anyone spoof the
// header and dodge the per-IP limit. Leave '' to use the connection address.
// define('CLIENT_IP_HEADER', 'CF-Connecting-IP');
define('CLIENT_IP_HEADER', '');
// Return the exception type, file:line and stack trace in API error responses.
// Errors are written to the PHP error log either way — this only controls what
// the browser is told, so leave it false on anything publicly reachable.
define('DEBUG', false);
// ---- AI course advisor (optional) ----
// The advisor is off unless AI_ENABLED is true AND AI_API_KEY is set. With it
// off the app never makes an outbound request; everything else works as usual.
// Any OpenAI-format chat endpoint works — the defaults target DeepSeek
// (get a key at https://platform.deepseek.com/).
define('AI_ENABLED', false);
define('AI_API_KEY', '');
define('AI_BASE_URL', 'https://api.deepseek.com');
define('AI_MODEL', 'deepseek-v4-flash');
// Questions each user may ask per rolling 24 hours (failed calls count too).
define('AI_DAILY_LIMIT', 50);