5 * gallery.module : gallery_report.inc
6 * Bug report assistance (system info)
10 * Function _gallery_report().
12 function _gallery_report($download = FALSE
, $report = array(), $cache = FALSE
) {
13 // provide download of the cached report
14 if ($download && ($content = cache_get('gallery_report_'.
session_id()))) {
15 _gallery_report_download($content->data
);
20 $report['System']['PHP']['Version'] = phpversion();
21 $report['System']['PHP']['Memory limit'] = ini_get('memory_limit');
22 $report['System']['PHP']['Safe mode'] = ini_get('safe_mode') ?
'On' : 'Off';
23 $database = is_array($db_url) ?
$db_url : array('default' => $db_url);
24 foreach ($database as
$key => $value) {
26 $db_info = parse_url($value);
27 $report['System']['Database'][drupal_ucfirst($key)]['Type'] = urldecode(strtoupper($db_info['scheme']));
28 $report['System']['Database'][drupal_ucfirst($key)]['Version'] = db_version();
30 db_set_active('default');
33 $report['Drupal']['Version'] = VERSION
;
36 $modules = drupal_system_listing('\.module$', 'modules', 'name', 0);
37 system_get_files_database($modules, 'module');
38 foreach ($modules as
$name => $module) {
39 if (in_array($name, array('gallery', 'gallery_menu', 'gallery_content'))) {
40 $info = drupal_parse_info_file(dirname($module->filename
) .
'/'.
$module->name .
'.info');
41 $report['Module']['Version'][$info['name']] = array(
42 'Version' => isset($info['version']) ?
$info['version'] : 'unknown',
43 'Schema Version' => $module->schema_version
,
44 'Location' => dirname($module->filename
),
45 'Status' => $module->status
47 // extract detailed version info from cvsid
48 $files = file_scan_directory(dirname($module->filename
), '.*\.(inc|module)$', array('.', '..', 'CVS'), 0, FALSE
);
49 foreach ($files as
$file) {
50 if (preg_match('/\x24Id: '.
$file->basename .
',v ([^\\$]+) Exp \x24/i', file_get_contents($file->filename
), $cvsid)) {
51 $report['Module']['Version'][$info['name']]['Files'][$file->basename] = 'Rev. '.
$cvsid[1];
56 // Fetch module-related variables
57 $result = db_query('SELECT * FROM {variable} WHERE name LIKE \'gallery_%\'');
58 while ($var = db_fetch_object($result)) {
59 $report['Module']['Variables'][$var->name
] = unserialize($var->value
);
61 $status = gallery_get_status();
62 unset($status['version'], $status['gallery_valid']);
63 $report['Module']['Variables']['gallery_status'] = array($status);
66 if (variable_get('gallery_valid', 0) && _gallery_init(FALSE
, NULL
, FALSE
)) {
67 $version = gallery_version();
68 $report['Gallery 2']['Version'] = array(
69 'Core API' => $version['core']['major'] .
'.'.
$version['core']['minor'],
70 'Embed API' => $version['embed']['major'] .
'.'.
$version['embed']['minor'],
72 list($ret, $rewrite_api) = GalleryCoreApi
::newFactoryInstance('RewriteApi');
73 if (!$ret && $rewrite_api) {
74 list($ret, $rewrite_params) = $rewrite_api->fetchEmbedConfig();
75 $report['Gallery 2']['URL Rewrite'] = $rewrite_params;
77 // Get some basic information about G2 plugins
78 list($ret, $plugins) = GalleryCoreApi
::fetchPluginStatus('module');
79 foreach ($plugins as
$name => $info) {
80 $report['Gallery 2']['Active Plugins'][drupal_ucfirst($name)]['Version'] = isset($info['active']) ?
$info['version'] : 'inactive';
83 if ($GLOBALS['gallery']->_debug
== 'buffered' && !empty($GLOBALS['gallery']->_debugBuffer
)) {
84 $report['Gallery 2']['DebugBuffer'] = $GLOBALS['gallery']->_debugBuffer
;
86 else if (!empty($GLOBALS['gallery']->_debugSnippet
)) {
87 $report['Gallery 2']['DebugSnippet'] = $GLOBALS['gallery']->_debugSnippet
;
91 $report['Gallery 2'] = 'Gallery2 not available';
94 $content = theme('gallery_report', $report);
97 if ($cache_content = cache_get('gallery_report_'.
session_id())) {
98 $content .
= $cache_content->data
;
100 cache_set('gallery_report_'.
session_id(), 'cache', $content, time()+600);
103 _gallery_report_download($content);
110 * Function _gallery_report_download().
112 function _gallery_report_download($content) {
113 header("Content-Type: application/octet-stream");
114 header("Content-Disposition: attachment; filename=gallery_report.html");
115 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
116 print "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
117 print " <head>\n <title>".
t('Gallery module : Report Generator') .
"</title>\n </head>\n";
118 print " <body>\n ".
$content .
"\n</body>\n";
124 * Theme function : theme_gallery_report().
126 function theme_gallery_report($report) {
127 return ' <div><table border=1 style=\'empty-cells:hide;\'>'.
_gallery_report_walk($report) .
"\n".
' </table></div>';
131 * Function _gallery_report_walk().
133 function _gallery_report_walk($element, $level = 1, $sub = FALSE
) {
135 $element = is_object($element) ?
get_object_vars($element) : $element;
136 if (is_array($element)) {
137 foreach ($element as
$key => $value) {
138 if (is_array($value) || is_object($value)) {
139 $html .
= "\n".
' <tr>';
140 $html .
= implode('<td></td>', array_fill(0, $level, ''));
141 $html .
= '<td>'.
$key .
'</td>';
142 $html .
= _gallery_report_walk($value, $level+1, TRUE
);
145 $html .
= $sub ?
'' : "\n".
' <tr>'.
implode('<td></td>', array_fill(0, $level, ''));
146 $html .
= '<td>'.
$key .
'</td><td>'.
$value .
'</td>';