# Blosxom debug tool
# blosxomdebug
#
# Fletcher T. Penney
# Version 1.1 - October 6, 2003
#
# THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND.
# USE AT YOUR OWN RISK!
package blosxomdebug;
use File::stat;
my $debug = ""; # Placeholder for html content
my $permissions = "";
my %debugfilelist = ( 'Blosxom Script' => $0,
'Data Directory' => $blosxom::datadir,
'Plugin Directory' => $blosxom::plugin_dir,
'Plugin State Directory' => $blosxom::plugin_state_dir,
'Static Directory' => $blosxom::static_dir);
my $debugfile = "";
my $debugmode = "";
my $debugaction = "";
my @debugplugins = "";
sub debug {
# Here is where we run diagnostics and generate html output
add_header();
debug_files_directories();
debug_blosxom_settings();
debug_plugins();
debug_security();
$debug .= "
";
$blosxom::output = $debug . $blosxom::output;
1;
}
sub add_header {
$debug = "
| File/Directory | Path | Blosxom Variable | Permissions | Minimum Permissions | Actions to Take | |
| $_ | $debugfilelist{$_} | "; $debugfile = $debugfilelist{$_}; if (-e $debugfile) { $debugmode = sprintf("%4o",stat($debugfile)->mode); $debugmode =~ s/.*(\d\d\d)$/$1/; # Here we can verify certain permissions and color code errors if ($_ =~ /Blosxom Script/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[5|7][5|7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[5|7][5|7]/); $debug .= "N/A"; } if ($_ =~ /Data Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[5-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[5-7][5-7]/); $debug .= "\$datadir"; } if ($_ =~ /Plugin Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[5-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[5-7][5-7]/); $debug .= "\$plugin_dir"; } if ($_ =~ /Plugin State Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[7]/); $debug .= "\$plugin_state_dir"; } if ($_ =~ /Static Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[7]/); $debug .= "\$static_dir"; } # If no error, then code green $debugmode = " | $debugmode" if ( $debugmode !~ /font color/); $debugaction = "Fix the permissions on this file/folder" if ($debugmode !~ /(ff0000|00ff00)/); $debug .= " | $debugmode"; } else { $debug .= "\$static_dir" if ( $_ =~ /Static Directory/); $debug .= "\$datadir" if ( $_ =~ /Data Directory/); $debug .= "\$plugin_dir" if ( $_ =~ /Plugin Directory/); $debug .= "\$plugin_state_dir" if ( $_ =~ /Plugin State Directory/); $debug .= "N/A" if ( $_ =~ /Blosxom Script/); $debug .= "File Not Found";
$debugaction = "Create the file/folder specified in the Path column; OR Correct the variable so that it points to the correct location"; } $debug .= " | "; $debug .= "550/555" if ($_ =~ /(Blosxom Script|Data Directory|Plugin Directory)/); $debug .= "770/777" if ($_ =~ /(Plugin State Directory|Static Directory)/); $debug .= " | $debugaction |
| Article File Extension | \$file_extension | $blosxom::file_extension | Comments |
| Blosxom URL | \$url | $blosxom::url | The url to access this blog |
| Default Flavour | \$default_flavour | $blosxom::default_flavour | |
| Blog Title | \$blog_title | $blosxom::blog_title | |
| Depth | \$depth | $blosxom::depth | |
| Max. Number of Entries | \$num_entries | $blosxom::num_entries | |
| Show Future Entries? | \$show_future_entries | $blosxom::show_future_entries | |
| Generate Static Entries? | \$static_entries | $blosxom::static_entries | |
| Static Flavours | \@static_flavours | @blosxom::static_flavours |
| Server Name | $ENV{'SERVER_NAME'} | |
| Script Name | $ENV{'SCRIPT_NAME'} | The server settings: http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'} should match \$url: $blosxom::url (Sort of) |
| Server Software | $ENV{'SERVER_SOFTWARE'} | |
| Web Server Document Root | $ENV{'DOCUMENT_ROOT'} | |
| Cookies for this page | $ENV{'HTTP_COOKIE'} | |
| CGI Path Info | $ENV{'PATH_INFO'} | |
| User ID of Blosxom | $> | |
| User Name of Blosxom | " . getpwuid("$>") . " | |
| Group ID of Blosxom | $) | |
| User Name of Blosxom | " . getgrgid("$)") . " |
| Plugin | Permissions | Enabled? | Comment | |
| $plugin | "; if (-r "$blosxom::plugin_dir/$plugin") { $debugmode = sprintf("%4o",stat("$blosxom::plugin_dir/$plugin")->mode); $debugmode =~ s/.*(\d\d\d)$/$1/; $debugmode = "$debugmode" if ( $debugmode !~ /^[4-7][4-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[4-7][4-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /font color/); $debug .= $debugmode; } else { $debug .= "File not Found\?"; } $debug .= " | "; $plugin =~ s/^\d*//; if ($blosxom::plugins{$plugin} eq 1) { $debug .= "Yes | "; } else { $debug .= "No | This may be disabled on purpose... More help in future releases"; } $debug .= " |
| Folder | Path | At Risk? | Web Server Document Root | $ENV{'DOCUMENT_ROOT'} | N/A | "; foreach ( sort keys %debugfilelist) { next if ($_ =~ /(Static Directory|Blosxom Script)/); $debug .= "
| $_ | $debugfilelist{$_} | "; # If the directory being examined is within the server document root, # But not "underneath" the redirected blosxom location, # It may be accessed directly from a web browser # Unless an .htaccess file is set up if (($debugfilelist{$_} =~ /^$ENV{'DOCUMENT_ROOT'}/) && ($debugfilelist{$_} !~ /^$ENV{'DOCUMENT_ROOT'}$ENV{'SCRIPT_NAME'}/)) { $debug .= "Yes"; } else { $debug .= "No"; } $debug .= " |