| 1 |
<?php
|
| 2 |
// $Id: gallery_report.inc,v 1.1.2.9 2007/09/10 18:04:08 profix898 Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* gallery.module : gallery_report.inc
|
| 6 |
* Bug report assistance (system info)
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Function _gallery_report().
|
| 11 |
*/
|
| 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);
|
| 16 |
}
|
| 17 |
|
| 18 |
//System
|
| 19 |
global $db_url;
|
| 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) {
|
| 25 |
db_set_active($key);
|
| 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();
|
| 29 |
}
|
| 30 |
db_set_active('default');
|
| 31 |
|
| 32 |
//Drupal
|
| 33 |
$report['Drupal']['Version'] = VERSION;
|
| 34 |
|
| 35 |
// Module
|
| 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
|
| 46 |
);
|
| 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];
|
| 52 |
}
|
| 53 |
}
|
| 54 |
}
|
| 55 |
}
|
| 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);
|
| 60 |
}
|
| 61 |
$status = gallery_get_status();
|
| 62 |
unset($status['version'], $status['gallery_valid']);
|
| 63 |
$report['Module']['Variables']['gallery_status'] = array($status);
|
| 64 |
|
| 65 |
// Gallery
|
| 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'],
|
| 71 |
);
|
| 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;
|
| 76 |
}
|
| 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';
|
| 81 |
}
|
| 82 |
// Debug Logs
|
| 83 |
if ($GLOBALS['gallery']->_debug == 'buffered' && !empty($GLOBALS['gallery']->_debugBuffer)) {
|
| 84 |
$report['Gallery 2']['DebugBuffer'] = $GLOBALS['gallery']->_debugBuffer;
|
| 85 |
}
|
| 86 |
else if (!empty($GLOBALS['gallery']->_debugSnippet)) {
|
| 87 |
$report['Gallery 2']['DebugSnippet'] = $GLOBALS['gallery']->_debugSnippet;
|
| 88 |
}
|
| 89 |
}
|
| 90 |
else {
|
| 91 |
$report['Gallery 2'] = 'Gallery2 not available';
|
| 92 |
}
|
| 93 |
|
| 94 |
$content = theme('gallery_report', $report);
|
| 95 |
|
| 96 |
if ($cache) {
|
| 97 |
if ($cache_content = cache_get('gallery_report_'. session_id())) {
|
| 98 |
$content .= $cache_content->data;
|
| 99 |
}
|
| 100 |
cache_set('gallery_report_'. session_id(), 'cache', $content, time()+600);
|
| 101 |
}
|
| 102 |
if ($download) {
|
| 103 |
_gallery_report_download($content);
|
| 104 |
}
|
| 105 |
|
| 106 |
return $content;
|
| 107 |
}
|
| 108 |
|
| 109 |
/**
|
| 110 |
* Function _gallery_report_download().
|
| 111 |
*/
|
| 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";
|
| 119 |
print "</html>";
|
| 120 |
exit();
|
| 121 |
}
|
| 122 |
|
| 123 |
/**
|
| 124 |
* Theme function : theme_gallery_report().
|
| 125 |
*/
|
| 126 |
function theme_gallery_report($report) {
|
| 127 |
return ' <div><table border=1 style=\'empty-cells:hide;\'>'. _gallery_report_walk($report) ."\n".' </table></div>';
|
| 128 |
}
|
| 129 |
|
| 130 |
/**
|
| 131 |
* Function _gallery_report_walk().
|
| 132 |
*/
|
| 133 |
function _gallery_report_walk($element, $level = 1, $sub = FALSE) {
|
| 134 |
$html = '';
|
| 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);
|
| 143 |
}
|
| 144 |
else {
|
| 145 |
$html .= $sub ? '' : "\n".' <tr>'. implode('<td></td>', array_fill(0, $level, ''));
|
| 146 |
$html .= '<td>'. $key .'</td><td>'. $value .'</td>';
|
| 147 |
$html .= '</tr>';
|
| 148 |
$sub = FALSE;
|
| 149 |
}
|
| 150 |
}
|
| 151 |
}
|
| 152 |
|
| 153 |
return $html;
|
| 154 |
}
|