[vhffs-dev] [1943] backend might be down for public area too |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1943
Author: gradator
Date: 2012-01-25 22:53:06 +0100 (Wed, 25 Jan 2012)
Log Message:
-----------
backend might be down for public area too
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Main.pm
trunk/vhffs-api/src/Vhffs/Panel/Public.pm
trunk/vhffs-public/templates/misc/closed.tt
Modified: trunk/vhffs-api/src/Vhffs/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Main.pm 2012-01-25 09:40:18 UTC (rev 1942)
+++ trunk/vhffs-api/src/Vhffs/Main.pm 2012-01-25 21:53:06 UTC (rev 1943)
@@ -114,8 +114,8 @@
my $port = ( $config->{'db_port'} or '5432' );
my $host = ( $config->{'db_host'} or 'localhost' );
- my $dbh = DBI->connect('DBI:Pg:dbname='.$config->{'db_name'}.';host='.$host.';port='.$port, $config->{'db_username'}, $config->{'db_password'}, {pg_enable_utf8 => 1} )
- or ( warn 'X10X Unable to open database connection: '.$DBI::errstr."\n" and return undef );
+ my $dbh = DBI->connect('DBI:Pg:dbname='.$config->{'db_name'}.';host='.$host.';port='.$port, $config->{'db_username'}, $config->{'db_password'}, {pg_enable_utf8 => 1} );
+ return undef unless defined $dbh;
$dbh->do( 'SET CLIENT_ENCODING TO \'UTF8\'' );
$self->{'db'} = $dbh;
return $dbh;
Modified: trunk/vhffs-api/src/Vhffs/Panel/Public.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Public.pm 2012-01-25 09:40:18 UTC (rev 1942)
+++ trunk/vhffs-api/src/Vhffs/Panel/Public.pm 2012-01-25 21:53:06 UTC (rev 1943)
@@ -58,6 +58,7 @@
sub new {
my $class = shift;
my $panel = $class->SUPER::new(@_);
+ return undef unless defined $panel;
unless( $panel->check_public() ) {
$panel->render('misc/closed.tt', undef);
return undef;
@@ -67,7 +68,8 @@
sub render {
my ($self, $file, $vars) = @_;
- my $conf = $self->{vhffs}->get_config;
+ my $vhffs = $self->{vhffs};
+ my $conf = $vhffs->get_config;
$vars = {} unless(defined $vars);
@@ -79,9 +81,11 @@
$vars->{groups_avatar} = Vhffs::Functions::strtobool( $conf->get_panel->{'groups_avatars'} );
# Handling ajax stuff
- unless($self->{is_ajax_request}) {
- $vars->{popular_tags} = Vhffs::Tag::get_most_popular_tags($self->{vhffs});
- $vars->{random_tags} = Vhffs::Tag::get_random_tags($self->{vhffs});
+ if( $vhffs->is_valid ) {
+ unless($self->{is_ajax_request}) {
+ $vars->{popular_tags} = Vhffs::Tag::get_most_popular_tags($self->{vhffs});
+ $vars->{random_tags} = Vhffs::Tag::get_random_tags($self->{vhffs});
+ }
}
$self->SUPER::render($file, $vars, 'public.tt', 'public');
Modified: trunk/vhffs-public/templates/misc/closed.tt
===================================================================
--- trunk/vhffs-public/templates/misc/closed.tt 2012-01-25 09:40:18 UTC (rev 1942)
+++ trunk/vhffs-public/templates/misc/closed.tt 2012-01-25 21:53:06 UTC (rev 1943)
@@ -1,2 +1,2 @@
-<h1>[% 'Public area disabled' | i18n | html %]</h1>
-<p class="error">[% 'Public area is disabled on this hosting platform.' | i18n | html %]</p>
+<h1>[% 'Public area temporary closed' | i18n | html %]</h1>
+<p class="error">[% 'Public area is temporary closed. Administrators are performing some maintenances tasks or system encountered database error. Please come back in a few minutes.' | i18n | html %]</p>