WebEditor/OldFeatures/SystemInfo.pm

filter: Statementstmt 14.5% 17 / 117 Branchbran 0.0% 0 / 38 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 1 totaltotal 13.5% 22 / 163 CC 26 SCAR 54.9
CC
26
Cov
11%
system_info_as_html
372.1
__ANON__
41.9
BEGIN
1.0
CRAP 241.9
« WebEditor/OldFeatures/CustomPublish.pm ↑ Summary WE_Frontend/Publish/FTP.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: SystemInfo.pm,v 1.10 2005/01/10 08:30:43 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2004 Slaven Rezic. All rights reserved.
8 # This package is free software; you can redistribute it and/or
9 # modify it under the same terms as Perl itself.
10 #
11 # Mail: eserte@users.sourceforge.net
12 # WWW: http://www.sourceforge.net/projects/we-framework
13 #
14  
15 package WebEditor::OldFeatures::SystemInfo;
16  
17 =head1 NAME
18  
19 WebEditor::OldFeatures::SystemInfo - return system information
20  
21 =head1 SYNOPSIS
22  
23 use mixin 'WebEditor::OldFeatures::SystemInfo';
24 print $self->system_info_as_html();
25  
26 =head1 DESCRIPTION
27  
28 This module returns information about the current system.
29  
30 =head1 CAVEATS
31  
32 This module may return too much information about the system, e.g.
33 system passwords which are stored in cookies or configuration objects.
34 You should not let unauthorized users to call this feature!
35  
36 =head1 AUTHOR
37  
38 Slaven Rezic
39  
40 =cut
41  
42 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/);
45  
46 1 ▶use mixin::with 'WebEditor::OldController';
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 0 ▶sub system_info_as_html {
Subroutine system_info_as_html: not called CC=20 SCAR=59.2
Pod undocumented
49 0 my($self, %args) = @_;
50  
51 0 local $Data::Dumper::Sortkeys = 1;
52  
53 0 my $uname_a = eval { `uname -a` };
54  
55 0 my $linux_release = "";
56 0 eval {
57 0 ▶ my @release_f = glob("/etc/*-release");
Subroutine BEGIN: called CC=1 SCAR=0.2
58 0 for my $f (@release_f) {
59 0 ▶ if (open(F, $f)) {
Branch: 1 branch
BranchTrueFalseTotal
if (open F, $f) 0 0 0
60 0 local $/ = undef;
61 # Can't do this in one line (problem only apparent with
62 # perl5.8.0 and mod_perl operation, but not cgi operation)
63 0 my $add = <F>;
64 0 $linux_release .= $add;
65 0 close F;
66 }
67 }
68 };
69 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
70 0 $linux_release .= $@;
71 }
72 0 ▶ if ($linux_release ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($linux_release ne "") 0 0 0
73 0 $linux_release = <<EOF;
74 Linux distribution version (if applicable):
75 $linux_release
76 EOF
77 }
78  
79  
80 0 my $perl_version = "perl $]\n";
81 0 eval {
82 0 require Config;
83 0 $perl_version .= Config::myconfig();
84 0 $perl_version .= "\n\@INC:\n" . join(",\n", map { "\t$_" } @INC);
85 };
86 0 ▶ $perl_version .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
87  
88 0 my $apache_version = $ENV{SERVER_SOFTWARE};
89  
90 0 my $operation_mode;
91 0 ▶ if ($ENV{MOD_PERL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'MOD_PERL'}) { } 0 0 0
92 0 $operation_mode .= "Running under mod_perl ($ENV{GATEWAY_INTERFACE})\n";
93 0 ▶ if (!$self->R) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->R) 0 0 0
94 0 $operation_mode .= "Probably Apache::Registry or similar operation mode.\n";
95 }
96 } else {
97 0 $operation_mode .= "Running as cgi-bin ($ENV{GATEWAY_INTERFACE})\n";
98 }
99  
100 0 my $get_versions;
101 0 ▶ $get_versions = sub {
Subroutine __ANON__: not called CC=7 SCAR=37.3
102 0 my($module, $no_recurse, $level) = @_;
103 0 ▶ $level = 1 if !defined $level;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $level 0 0 0
104 0 ▶ return if $level >= 5; # recursion breaker
Branch: 1 branch
BranchTrueFalseTotal
if $level >= 5 0 0 0
105 0 my @versions;
106 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
107 0 ▶ if (defined ${$module . "::VERSION" }) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined ${$module . '::VERSION';}) 0 0 0
108 0 push @versions, [ $module => ${$module . "::VERSION" } ];
109 }
110 0 ▶ if (!$no_recurse) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($no_recurse) 0 0 0
111 0 for my $sym (keys %{$module . "::"}) {
112 0 ▶ if ($sym =~ /(.*)::$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sym =~ /(.*)::$/) 0 0 0
113 0 $sym = $1;
114 0 push @versions, $get_versions->($module . "::" . $sym, undef, $level+1);
115 }
116 }
117 }
118 0 @versions;
119 0 };
120  
121 0 my $perlmod_versions = "";
122 0 my @perlmod_toplevel_modules =
123 (qw(Apache CGI Template Data::JavaScript));
124 0 eval {
125 0 my @perlmod_versions;
126 0 for my $top (@perlmod_toplevel_modules) {
127 0 push @perlmod_versions, $get_versions->($top, "norecurse");
128 }
129 0 for my $v (sort { $a->[0] cmp $b->[0] } @perlmod_versions) {
130 0 my($module, $version) = @$v;
131 0 $perlmod_versions .= " $module $version\n";
132 }
133 };
134 0 ▶ $perlmod_versions .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
135  
136 0 my $we_versions = "";
137 0 my @toplevel_modules =
138 (qw(WE WebEditor WE_Content WE_Frontend
139 WE_Multisite WE_Sample WE_Singlesite));
140 0 push @toplevel_modules, "WE_" . $self->C->project->name;
141 0 eval {
142 0 my @we_versions;
143 0 for my $top (@toplevel_modules) {
144 0 push @we_versions, $get_versions->($top);
145 }
146 0 for my $v (sort { $a->[0] cmp $b->[0] } @we_versions) {
147 0 my($module, $version) = @$v;
148 0 $we_versions .= " $module $version\n";
149 }
150 };
151 0 ▶ $we_versions .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
152  
153 0 my $config_object;
154 my $current_user;
155 0 eval {
156 0 require Data::Dumper;
157 0 $config_object .= Data::Dumper::Dumper($self->C);
158 0 $current_user = "Current user is `" . $self->User . "'.\n";
159 };
160 0 ▶ $config_object .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
161  
162 0 my $database_status;
163 0 eval {
164 0 my $objdb = $self->Root->ObjDB;
165 0 my $contentdb = $self->Root->ContentDB;
166 0 $database_status = "The Object database has " . $objdb->count . " objects.\n";
167  
168 0 require WE::Util::Support;
169 0 require Data::Dumper;
170  
171 0 my $errors = $objdb->check_integrity($contentdb);
172 0 my $contentdb_errors = $contentdb->check_integrity($objdb);
173  
174 0 $database_status .= "we_fsck returned:\n" . Data::Dumper::Dumper($errors, $contentdb_errors);
175  
176 };
177 0 ▶ $database_status .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
178  
179 0 my $template_config = "";
180 0 eval {
181 0 require Data::Dumper;
182 0 $template_config .= Data::Dumper::Dumper($self->TemplateConf);
183 };
184 0 ▶ $template_config .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
185  
186 0 my $template_vars = "";
187 0 eval {
188 0 ▶ while(my($k,$v) = each %{ $self->TemplateVars }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->TemplateVars;}) 0 0 0
189 0 $template_vars .= "\t$k => $v,\n";
190 }
191 };
192 0 ▶ $template_vars .= $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
193  
194 <<EOF
195 <div class="systeminfo">
196 <div>
197 Unix system:
198 $uname_a
199 </div>
200 EOF
201 0 ▶ . ($linux_release ne "" ? <<EOF : "")
Branch: 1 branch
BranchTrueFalseTotal
$linux_release ne '' ? : 0 0 0
202 <div>
203 $linux_release
204 </div>
205 EOF
206 . <<EOF
207 <div>
208 Apache:
209 $apache_version
210 $operation_mode
211 </div>
212 <div>
213 Perl version:
214 $perl_version
215 </div>
216 <div>
217 Perl module versions:
218 $perlmod_versions
219 </div>
220 <div>
221 WE versions:
222 $we_versions
223 </div>
224 <div>
225 WebEditor config object:
226 $config_object
227 </div>
228 <div>
229 Template-Toolkit config:
230 $template_config
231 </div>
232 <div>
233 Template-Toolkit variables:
234 $template_vars
235 </div>
236 <div>
237 $current_user
238 </div>
239 <div>
240 Database status:
241 $database_status
242 </div>
243 </div>
244 <hr />
245 EOF
246 ;
247 }
248  
249 1 1;
« WebEditor/OldFeatures/CustomPublish.pm ↑ Summary WE_Frontend/Publish/FTP.pm »