[vhffs-dev] [841] Bye bye robots_logging, robots_logfile, use_locking, robot_lockfile useless accessors

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 841
Author:   gradator
Date:     2007-08-30 22:13:46 +0000 (Thu, 30 Aug 2007)

Log Message:
-----------
Bye bye robots_logging, robots_logfile, use_locking, robot_lockfile useless accessors

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Conf.pm
    trunk/vhffs-api/src/Vhffs/Robots.pm


Modified: trunk/vhffs-api/src/Vhffs/Conf.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Conf.pm	2007-08-30 21:50:11 UTC (rev 840)
+++ trunk/vhffs-api/src/Vhffs/Conf.pm	2007-08-30 22:13:46 UTC (rev 841)
@@ -118,7 +118,12 @@
 	return $Config{'listengine'};
 }
 
+sub get_robots
+{
+	return $Config{'robots'};
+}
 
+
 # get a service configuration
 # if a parameter is given, the configuration of the service will be returned
 # if not, it returns the whole configuration for all services
@@ -331,48 +336,6 @@
 }
 
 
-sub robots_logging
-{
-	if( $Config{"robots"}{"use_logging"} )
-	{
-		if( $Config{"robots"}{"use_logging"} eq "yes" )
-		{
-			return 1;
-		}
-	}
-	return 0;
-}
-
-sub robots_logfile
-{
-	if( defined $Config{"robots"}{"logfile"} )
-	{
-		return( $Config{"robots"}{"logfile"} );
-	}
-	return undef;
-}
-
-sub use_locking
-{
-	if( $Config{"robots"}{"use_lock"} )
-	{
-		if( $Config{"robots"}{"use_lock"} eq "yes" )
-		{
-			return 1;
-		}
-	}
-	return 0;
-}
-
-sub robot_lockfile
-{
-	if( defined $Config{"robots"}{"lockfile"} )
-	{
-		return( $Config{"robots"}{"lockfile"} );
-	}
-	return undef;
-}
-
 sub get_moderation
 {
 	if( ( defined $Config{"global"}{"moderation"} ) && ( $Config{"global"}{"moderation"} eq 'yes' ) )

Modified: trunk/vhffs-api/src/Vhffs/Robots.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots.pm	2007-08-30 21:50:11 UTC (rev 840)
+++ trunk/vhffs-api/src/Vhffs/Robots.pm	2007-08-30 22:13:46 UTC (rev 841)
@@ -53,10 +53,12 @@
 	my $vhffs = shift;
 	my $name = shift;
 	return 1 unless defined $vhffs;
-	return 1 if( $vhffs->get_config->use_locking != 1 );
 
+	my $robotconf = $vhffs->get_config->get_robots;
+	return 0 if( $robotconf->{'use_lock'} ne 'yes' );
+
 	my $lockfile = LOCKFILE.'.'.$name;
-	$lockfile = $vhffs->get_config->robot_lockfile.'.'.$name if( $vhffs->get_config->robot_lockfile );
+	$lockfile = $robotconf->{'lockfile'}.'.'.$name if( $robotconf->{'lockfile'} );
 
 	LockFile::Simple::lock( $lockfile ) or exit( 1 );
 	return 0;
@@ -68,10 +70,12 @@
 	my $vhffs = shift;
 	my $name = shift;
 	return 1 unless defined $vhffs;
-	return 1 if( $vhffs->get_config->use_locking != 1 );
 
+	my $robotconf = $vhffs->get_config->get_robots;
+	return 0 if( $robotconf->{'use_lock'} ne 'yes' );
+
 	my $lockfile = LOCKFILE.'.'.$name;
-	$lockfile = $vhffs->get_config->robot_lockfile.'.'.$name if( $vhffs->get_config->robot_lockfile );
+	$lockfile = $robotconf->{'lockfile'}.'.'.$name if( $robotconf->{'lockfile'} );
 
 	LockFile::Simple::unlock( $lockfile );
 	return 0;
@@ -82,20 +86,20 @@
 	my $sent = shift;
 	my $vhffs = shift;
 	my $logfile;
-	if( defined $vhffs )
-	{
-		if( $vhffs->get_config->robots_logging == 1 )
-		{
-			my ($seconds,$minutes,$hours,$day,$month,$year) = localtime(time);
-			my $timestamp = sprintf ('[ %.4u/%.2u/%.2u %.2u:%.2u:%.2u ]',$year+1900,$month + 1,$day,$hours,$minutes,$seconds);
+	return 1 unless defined $vhffs;
 
-			$logfile = $vhffs->get_config->robots_logfile;
-			$logfile = LOGFILE if( ! ( defined $logfile ) );
-			open( FILE , ">>$logfile" ) or return -1;
-			print FILE $timestamp." - ".$sent."\n";
-			close FILE ;
-	        }
-	}
+	my $robotconf = $vhffs->get_config->get_robots;
+	return 0 if( $robotconf->{'use_logging'} ne 'yes' );
+
+	my ($seconds,$minutes,$hours,$day,$month,$year) = localtime(time);
+	my $timestamp = sprintf ('[ %.4u/%.2u/%.2u %.2u:%.2u:%.2u ]',$year+1900,$month + 1,$day,$hours,$minutes,$seconds);
+
+	$logfile = $robotconf->{'logfile'};
+	$logfile = LOGFILE unless defined $logfile;
+	open( FILE , ">>$logfile" ) or return -1;
+	print FILE $timestamp." - ".$sent."\n";
+	close FILE ;
+
 	return 0;
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/