Merge branch 'new/bug_4330' into kcmaster
[koha.git] / about.pl
1 #!/usr/bin/perl
2
3 # Copyright Pat Eyler 2003
4 # Copyright Biblibre 2006
5 # Parts Copyright Liblime 2008
6 # Parts Copyright Chris Nighswonger 2010
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 use strict;
24 use warnings;
25
26 use CGI;
27 use LWP::Simple;
28 use XML::Simple;
29 use Config;
30
31 use C4::Output;    # contains gettemplate
32 use C4::Auth;
33 use C4::Context;
34 use C4::Installer;
35
36 my $query = new CGI;
37 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38     {
39         template_name   => "about.tmpl",
40         query           => $query,
41         type            => "intranet",
42         authnotrequired => 0,
43         flagsrequired   => { catalogue => 1 },
44         debug           => 1,
45     }
46 );
47
48 my $kohaVersion   = C4::Context::KOHAVERSION;
49 my $osVersion     = `uname -a`;
50 my $perl_path = $^X;
51 if ($^O ne 'VMS') {
52     $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
53 }
54 my $perlVersion   = $];
55 my $mysqlVersion  = `mysql -V`;
56 my $apacheVersion = `httpd -v`;
57 $apacheVersion = `httpd2 -v` unless $apacheVersion;
58 $apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
59 my $zebraVersion = `zebraidx -V`;
60
61 $template->param(
62     kohaVersion   => $kohaVersion,
63     osVersion     => $osVersion,
64     perlPath      => $perl_path,
65     perlVersion   => $perlVersion,
66     perlIncPath   => [ map { perlinc => $_ }, @INC ],
67     mysqlVersion  => $mysqlVersion,
68     apacheVersion => $apacheVersion,
69     zebraVersion  => $zebraVersion,
70 );
71
72 my @components = ();
73
74 my $perl_modules = C4::Installer::PerlModules->new;
75 $perl_modules->version_info;
76
77 my @pm_types = qw(missing_pm upgrade_pm current_pm);
78
79 foreach my $pm_type(@pm_types) {
80     my $modules = $perl_modules->get_attr($pm_type);
81     foreach (@$modules) {
82         my ($module, $stats) = each %$_;
83         push(
84             @components,
85             {
86                 name    => $module,
87                 version => $stats->{'cur_ver'},
88                 missing => ($pm_type eq 'missing_pm' ? 1 : 0),
89                 upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
90                 current => ($pm_type eq 'current_pm' ? 1 : 0),
91                 require => $stats->{'required'},
92             }
93         );
94     }
95 }
96
97 @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
98
99 my $counter=0;
100 my $row = [];
101 my $table = [];
102 foreach (@components) {
103     push (@$row, $_);
104     unless (++$counter % 4) {
105         push (@$table, {row => $row});
106         $row = [];
107     }
108 }
109
110 $template->param( table => $table );
111
112 output_html_with_http_headers $query, $cookie, $template->output;