#!/usr/bin/perl BEGIN { unshift(@INC, '/web/www/Mercatino/'); } package main; use SelfLoader; use CGI qw(:all); require('mercatino.pl'); $baseDir = '/web/Mercatino/annunci'; $oldDir = '/web/Mercatino/annunci.old'; $noCata = '___'; $intro = $INTRODUZIONE; $intro = $intro; $fileSuffix = '.html'; $filePrefix0 = '00'; $filePrefixZ = 'zz'; $time = time; $IERI = 2 * 86400; $DEATH = 30 * 86400; # delta = espresso in secondi # giorni x ( secondi/giorno ) $DEATH = $time - $DEATH; $IERI = $time - $IERI; @lt = localtime(time); # 1 (stato iniziale) un solo frame con lista cataloghi # 3 due frame , LL con messaggi UL con banner (fisso) # R con elenco soggetti messaggi ############# START ############### $catalog = sanitize(param('c')); $from = sanitize(param('f')); $crontab = sanitize(param('nocgi')); $url = url; $url = 'http://www.doit.it/Mercatino/classified.cgi' if(defined $crontab); if(defined $from) { if (($from == 1) && (isCatalog($catalog)) ) { # proviene da 1, deve cambiare da 1 a 3 MsgEleMsg(); } elsif (($from == 2) and ($catalog eq $noCata)) { CatalogsIndex(2, 'Elenco'); } elsif (($from == 2) and (isCatalog($catalog)) ) { # output a 2 'subj_idx' SubjectsIndex($catalog, $from, 'Messaggio' ); } else { # ingresso deve passare a 1 # MsgEleMsg($intro); CatalogsIndex(1); } } else { # ingresso deve passare a 1 CatalogsIndex(1); #MsgEleMsg($intro); } exit; ############# END ############### sub sanitize { my $str = shift; return if(not defined $str); $str =~ s/^\s*(.*?)\s*$/$1/; $str =~ tr/ / /s; return undef if ($str =~/^$/); return $str; } #__DATA__ sub MsgEleMsg { my ($introduz) = @_; print header() if(not defined $crontab); print< $TITLE <BODY BGCOLOR="#FFFFFF"> <P ALIGN=center> <A HREF="/Mercatino/" TARGET="_top"><IMG SRC="/img/banner/mercato2.gif" WIDTH=300 HEIGTH=75 ALT="Mercatino" BORDER=0></A> <P> <BR> <HR NOSHADE> EOT ; $catalog = $noCata unless($catalog); show_msg($catalog, 0 , '_top'); print " \n"; print " \n"; #print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; if (not defined $introduz) { print " \n"; } else { print " \n"; } print " \n"; print " \n"; print " \n"; print "\n"; } ############## sub CatalogsIndex { my ($n_from, $n_target) = @_; my ($sth, @res, $flag); $n_target = '_top' if (not defined $n_target); $n_target = 'Messaggio' if ($n_from == 2); print header() if(not defined $crontab); print start_html( '-title' => $TITLE, -author => $AUTHOR, -BGCOLOR => $BGCOLOR); hd_merc() if ($n_from == 1); print< COUNTER ; voceInserzioni($baseDir, $n_from, $n_target); ft_merc() if ( $n_from == 1);; print end_html(); } ################################### sub SubjectsIndex { my ($catalogo, $n_from, $n_target) = @_; #print header(-target => $n_target ); print header() if(not defined $crontab); print start_html( '-title' => $TITLE, -author => $AUTHOR, -BGCOLOR => $BGCOLOR); show_msg($catalogo, $n_from, $n_target); print end_html(); } ################################### sub isCatalog { my $cata = shift; return unless defined $map{$cata}; return 1; } ################################### ## errAbort - messaggio d' errore # ## sub errAbort { my $msg = shift; print start_html(); print "
\n\
\n\

$msg

\n\
\n"; print end_html(); exit 1; } ################################### sub action { my ($dir,$sbj) = @_; my ($path, $k, $cnt, @list); unless (opendir(DIR, $dir)) { warn "Can't open $dir\n"; closedir(DIR); return; } @list = readdir(DIR); closedir(DIR); $cnt=0; $ieri=0; $LDEATH = $DEATH; $LDEATH = ($DEATH - (5 * 86400)) if( $dir eq 'mep'); foreach $k (@list) { next if (($k eq '.') || ($k eq '..') || ($k eq 'OLD') || ($k eq 'counter')); $_ = $k; next if ((/^$filePrefixZ/) || (/^$filePrefix0/)); $path = "$dir/$k"; next if (-d $path); # a directory $_ = $path; if ( (-f $_) and (/$fileSuffix$/) ){ @mystat = stat($_); $cnt++ if ($mystat[9] >= $LDEATH) ; $ieri++ if ($mystat[9] >= $IERI) ; } } return ($cnt,$ieri); } ################################### sub show_msg { my ($sbj,$n_from, $n_target ) = @_; my ($path, $dire, $k, $cnt, @list); $dire = $baseDir.'/'.$sbj; unless (opendir(DIR, $dire)) { warn "Can't open $dire\n"; closedir(DIR); return; } @list = readdir(DIR); closedir(DIR); $cnt=0; $ieri=0; $LDEATH = $DEATH; $LDEATH = ($DEATH - ( 5 * 86400)) if ($sbj eq 'mep'); foreach $k (@list) { next if (($k eq '.') || ($k eq '..') || ($k eq 'counter')); $_ = $k; next if ((/^$filePrefixZ/) || (/^$filePrefix0/)); $path = "$dire/$k"; next if (-d $path); # a directory $_ = $path; if ( (-f $_) and (/$fileSuffix$/) ){ @mystat = stat($_); $nome{$mystat[9]} = $_ if ($mystat[9] >= $LDEATH); } } print<

$map{$sbj}

[ Mercatino - contatore - 2]

DO it

EOT ; if($sbj eq 'mep'){ print< $EXPLICIT

| Mercatino | DOit Home Page |


EOT } elsif (($sbj eq 'jor') or ($sbj eq 'joo') or ($sbj eq 'job')){ print< $CAREER

EOT } print<


EOT ; foreach $key ( sort { $b <=> $a } (keys %nome) ){ open(MSGG,"<$nome{$key}") or next; while (){ print $_; } close(MSGG); } if($n_from == 0) { print<
[Mecatino] $DISCLAIMER [home]

webmaster\@doit.it

EOT ; } } ################################## sub voceInserzioni { my ($dir, $num_from, $n_target) = @_; my ($key,$value, $path, $dire, $k, $dre,$effe); unless (opendir(DIR, $dir)) { warn "Can't open $dir\n"; closedir(DIR); return; } @lista = readdir(DIR); closedir(DIR); foreach $k (@lista) { next if (($k eq '.') || ($k eq '..') || ($k eq 'job.old')); $path = "$dir/$k"; $_ = $k; next if (-f $_); # a plain file if (-d $path) { # a directory $dre = $_; ($nelem{$dre},$ultimi{$dre}) = action($path, $_); } } if($num_from == 2) { print< EOT ; link2form($n_target, $NUOVA_INSERZIONE, $MODIFICA_INSERZIONE); } else { print< EOT ; } print<ultimo aggiornamento - ore $lt[2]:$lt[1] EOT ; while(($key,$value) = each %map){ $newmap{$value} = $key; } foreach $key ( sort(keys %newmap) ){ if( $nelem{$newmap{$key}} > 0 ){ print "\n"; #print "\n"; print "\n"; print "\n"; if ($ultimi{$newmap{$key}} > 0) { print "\n"; } else { print "\n"; } print "\n"; } else { print< EOT ; } } if($num_from == 2) { link2form($n_target, $NUOVA_INSERZIONE, $MODIFICA_INSERZIONE); print "
DO it ultimi
30
giorni
ultime
48
ore
nª messaggi
presenti
$key$key"; print "
(per Adulti)" if($newmap{$key} eq 'mep'); print "
$nelem{$newmap{$key}}$ultimi{$newmap{$key}}-
$key 0 0
\n"; } else { print< EOT ; } } ############## sub link2form { my ($targ, $ins, $mod) = @_; print<
Inserzione
 
Aggiornamento
  --> EOT ; } ############## sub ft_merc{ print<

Gli Altri Mercatini
On Line



[Mecatino] $DISCLAIMER [home]

webmaster\@doit.it

EOT ; } ####################################### sub hd_merc{ print< [ Mercatino ]


Inserzioni Gratuite su DOit

Le inserzioni sono divise per argomenti e sono in rigoroso ordine cronologico di inserimento o conferma; per ogni argomento è indicato il numero di messaggi presenti in bacheca (totali e recenti).

Le inserzioni sono consultabili per 30 giorni dalla data dell'inserimento; successivamente vengono rimosse a meno che l'utente che ha inserito l'annuncio non lo rinnovi attraverso l'apposito form.

Le Società Commerciali sono invitate ad indicare esclusivamente il messaggio e il contatto non la ragione sociale.

Non sono ammessi messaggi pubblicitari da parte di organizzazioni commerciali.

Ogni messaggio è classificato per argomento e per tipologia (Annuncio, Offerta, Ricerca).

A ogni messaggio viene sempre associata una "password" e un codice di riferimento: password e codice sono richiesti dal sistema per ogni azione di aggiornamento.

La rubrica Messaggi Personali è riservata esclusivamente al lettore adulto.

Inserzione [ Inserzioni ] Aggiornamento [ Inserzioni ] Altri Mercatini

EOT ; }