Listing active Drupal modules and themes


<?php
// Module to list active modules and themes
// (Assumes Drupal 5 type layout with sites/all/modules, sites/all/themes, etc)
// V1.1, A S Hardie, 2007-09-20
// V1.2, A S Hardie, 2008-04-04: simplified version
//
$core_mod_tab = '<ul>';
$added_mod_tab = '<ul>';
//
$result1 = db_query("SELECT * FROM {system} WHERE status = 1 AND type = 'module' ORDER BY name");
while ($item_info = db_fetch_object($result1)) {
preg_match('@^([^/]+)/([^/]+)@i', $item_info->filename, $matches);
if ("$matches[1]" == 'modules') {
$core_mod_tab .= '<li>' . $item_info->name . '</li>';
}
elseif ("$matches[1]" == 'sites') {
$added_mod_tab .= '<li>' . $item_info->name . '</li>';
}
else {
$added_mod_tab .= '<ul>UNKNOWN ' . $item_info->filename . '</ul>';
}
}
$core_mod_tab .= '</ul>';
$added_mod_tab .= '</ul>';
print '<h5>Active Core Modules</h5>' . $core_mod_tab;
print '<h5>Active Added Modules</h5>' . $added_mod_tab;
//
$core_theme_tab = '<ul>';
$added_theme_tab = '<ul>';
$result2 = db_query("SELECT * FROM {system} WHERE status = 1 AND type = 'theme' ORDER BY name");
while ($item_info = db_fetch_object($result2)) {
preg_match('@^([^/]+)/([^/]+)@i', $item_info->filename, $matches);
if ("$matches[1]" == 'themes') {
$core_theme_tab .= '<li>' . $item_info->name . '</li>';
}
elseif ("$matches[1]" == 'sites') {
$added_theme_tab .= '<li>' . $item_info->name . '</li>';
}
else {
$added_theme_tab .= '<li>UNKNOWN ' . $item_info->filename . '</li>';
}
}
$core_theme_tab .= '</ul>';
$added_theme_tab .= '</ul>';
print '<h5>Active Core Themes</h5>' . $core_theme_tab;
print '<h5>Active Added Themes</h5>' . $added_theme_tab;
?>