#! /usr/bin/perl ############################################################# ## resootime.pl (c)resoo.org '2004-2009 # ## usage: # ## - resootime.pl (/configuration utilisateur) # ## - resootime.pl?X (X -> $Seconds) # ############################################################# use strict; ## configuration utilisateur ################################# my $Language = 0; ## change to 1 for english setup my $Seconds = 0; ## 0->hh:mm / (x)->hh:mm:ss (x = reload delay) ## valeurs valides pour x :(0,2,5,10,15,20,30,60) my $Location = "toulouse"; my $Country = "(france)"; my $Signature = "resootime.pl © resoo.org '2004-2009"; my $Info = "powered by Perl / Apache / Debian - serveur de temps par CNRS/LAAS"; ## (le texte info est complete plus bas par la valeur de "refresh") ############################################################## my @Accept = (2,5,10,15,20,30,60); ## valeurs valides pour $Seconds (+0) ## recuperation du parametre eventuel my $Args = $ENV{QUERY_STRING}; $Args =~ s/%([0-9][0-9])/pack("C",oct("0x$1"))/ge; $Args =~ tr/+/ /; if ($Args) {$Seconds = $Args;} ## jour/mois mode texte et traduction my @Jours = ("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"); my @Mois = ("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"); if ($Language) { @Jours = ("sunday","monday","tuesday","wednesday","thursday","friday","saturday"); @Mois = ("january","february","march","april","may","june","july","agust","september","october","november","december"); } ## recuperation de la date my @date = localtime(time); # $date[0] secondes # $date[1] minutes # $date[2] heures # $date[3] jour du mois # $date[4] mois # $date[5] année # $date[6] jour de la semaine # $date[7] jour de l'année # $date[8] ## formatage de la date my $Today = @Jours[$date[6]]; $Today .= " "; $Today .= $date[3]; $Today .= " "; $Today .= @Mois[$date[4]]; $Today .= " "; $Today .= $date[5]+1900; ## formatage de l'heure my $TimeH = $date[2]; ## heures if ($date[2]<10) { $TimeH = "0".$TimeH;} my $TimeM = $date[1]; ## minutes if ($date[1]<10) { $TimeM = "0".$TimeM;} my $TimeS = $date[0]; ## secondes if ($date[0]<10) { $TimeS = "0".$TimeS;} ## pour n'accepter en "refresh" que les valeurs @Accept if (($Seconds) and (!grep(/^$Seconds$/, @Accept))) { $Seconds = 60; } ## reglage de la valeur "refresh" my $Reload; if ($Seconds) { $Reload = (int($date[0]/$Seconds)+1)*$Seconds-$date[0]; if ($Language) { $Info .= " - trying to reload current page every ".$Seconds."s."; } else { $Info .= " - tentative d'actualisation de l'affichage toutes les ".$Seconds."s."; } } else { $Reload = 60-$date[0]; ## secondes if ($Language) { $Info .= " - trying to reload current page every 60s."; } else { $Info .= " - tentative d'actualisation de l'affichage toutes les 60s."; } } ############################################################## ## affichage html print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "time page\n"; print "\n\n"; ### Reload / minutes print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n\n"; ### Today print "
$Today
\n\n"; if ($Seconds) { ### Time hh:mm:ss print "
$TimeH:$TimeM:$TimeS
\n\n"; ### Location / Country print "
$Location $Country
\n\n"; } else { ### Time hh:mm print "
$TimeH:$TimeM
\n\n"; ### Location / Country print "
$Location $Country
\n\n"; } ### Signature print "
$Signature
\n\n"; print "
$Info
\n\n"; print "
\n"; print "\n";