diff --git a/theme/index.php b/theme/index.php
index b8cf52c2e3f..54ecababdcb 100644
--- a/theme/index.php
+++ b/theme/index.php
@@ -72,7 +72,12 @@
echo "
";
echo "
";
foreach ($themes as $theme) {
- include ("$theme/config.php");
+
+ if (!file_exists("$CFG->dirroot/theme/$theme/config.php")) { // bad folder
+ continue;
+ }
+ include ("$CFG->dirroot/theme/$theme/config.php");
+
echo "";
if ($CFG->theme == $theme) {
echo "| body\">$theme | ";