Fix typo
Use dirname(__FILE__) instead of APPROOT and ensure proper start cwd
Create templates_c/ automatically if needed, with proper permissions
Make index.php a real front controller, move login.php and logout.php to includes/
Move front controller to includes/main.inc.php, shorten index.php to a minimum
Avoid "index.php" part in links and redirects