#!/usr/bin/perl ############################################################################## # Definizione delle variabili globali ############################################################################## # Libera il buffer subito # $| = 1; print "Content-type: text/html\n\n"; ############################################################################## # Carica le librerie necessarie # &require_supporting_libraries (__FILE__, __LINE__, "./library/misc.pl", "./library/cgi-lib.pl"); # Controlla i contenuti del Form &ReadParse(*FORM); #Legge il file di configurazione dopo i cambiamenti if ($FORM{'setup_file'} ne "") { $setup_file = "$FORM{'setup_file'}.setup.cgi"; } else { $setup_file = "default.setup.cgi"; $FORM{'setup_file'} = "default"; } if ($session_file eq "") { $session_file = $FORM{'session_file'}; } if ($FORM{'lingua'} eq "") { $FORM{'lingua'} = "ita"; } if ($FORM{'body'} eq "") { $FORM{'body'} = ""; } if ($FORM{'active'} eq "") { $FORM{'active'} = "find"; } if ($FORM{'n_step'} eq "") { $FORM{'n_step'} = 0; } if ($FORM{'user'} eq "admin") { $FORM{'window'} = "body"; $FORM{'body'} = "admin"; } # Carica il file di setup opportuno &require_supporting_libraries (__FILE__, __LINE__, "./setup/$setup_file"); &get_date; &load_label; if ($FORM{'auth_rif_USR'} eq "") { $FORM{'auth_rif_USR'} ="$yy$mm$mday$hh$min$ss"; } &my_postmessage; if ($FORM{'window'} eq "body") { if ($FORM{'body'} eq "scambio") { # Disegna pagina principale &require_supporting_libraries (__FILE__, __LINE__, "./library/notizie.pl"); &form_scambio; } elsif ($FORM{'body'} eq "find") { &require_supporting_libraries (__FILE__, __LINE__, "./library/pubblica.pl"); &pubblica_ricerca; } elsif ($FORM{'body'} eq "new") { } elsif ($FORM{'body'} eq "edit") { } elsif ($FORM{'body'} eq "delete") { } elsif ($FORM{'body'} eq "scheda") { } elsif ($FORM{'body'} eq "password") { &require_supporting_libraries (__FILE__, __LINE__, "./library/gs_pwd.pl"); &wnd_password; } elsif ($FORM{'body'} eq "dettagli") { # Disegna pagina principale &require_supporting_libraries (__FILE__, __LINE__, "./library/pubblica.pl"); &pubblica_dettagli; } elsif ($FORM{'body'} eq "admin") { &require_supporting_libraries (__FILE__, __LINE__, "./library/notizie.pl", "./library/misc.pl", "./library/mail-lib.pl", "./library/auth-lib.pl"); ($session_file, $session_username, $session_group,$session_first_name, $session_last_name, $session_listino, $session_email) = &GetSessionInfo($session_file, $this_script_url, *FORM); &gestione_notizie; } else { # Disegna pagina principale &require_supporting_libraries (__FILE__, __LINE__, "./library/pubblica.pl"); &pubblica_notizie; } } else { # Disegna pagina principale &require_supporting_libraries (__FILE__, __LINE__, "./library/flash.pl"); &news_flash; } exit; ########################################################################### # sub my_postmessage { if ($FORM{'msgTarget'} eq "notizia") { &require_supporting_libraries (__FILE__, __LINE__, "./library/notizie.pl"); if ($FORM{'rif_NOTIZIA'} eq "") { $FORM{'rif_NOTIZIA'} = "$yy$mm$mday$hh$min$ss"; } if ($FORM{'msgID'} eq "insert") { &insert_notizia; $FORM{'rif_NOTIZIA'} = ""; } elsif ($FORM{'msgID'} eq "find") { if ($FORM{'find'} eq "") { $FORM{'body'} eq "pubblica"; }; } elsif ($FORM{'msgID'} eq "delete") { &delete_notizia; $FORM{'rif_NOTIZIA'} = ""; } elsif ($FORM{'msgID'} eq "scambia") { &scambia_notizia; $FORM{'rif_NOTIZIA'} = ""; } elsif ($FORM{'msgID'} eq "sposta") { &sposta_notizia; $FORM{'rif_NOTIZIA'} = ""; } elsif ($FORM{'msgID'} eq "edit") { &delete_notizia; ($FORM{'rif_NOTIZIA'},$FORM{'data_news'},$FORM{'titolo'},$FORM{'anteprima'},$FORM{'descrizione'},$FORM{'firma'}, $FORM{'foto'}) = split (/\|/,$FORM{'safe_value'}); } elsif ($FORM{'msgID'} eq "upload") { &upload_notizia; $FORM{'rif_NOTIZIA'} = ""; } } elsif ($FORM{'msgTarget'} eq "password") { &require_supporting_libraries (__FILE__, __LINE__, "./library/gs_pwd.pl"); if ($FORM{'msgID'} eq "delete") { &elimina_password; } } elsif ($FORM{'msgTarget'} eq "lista") { &require_supporting_libraries (__FILE__, __LINE__, "./library/lista.pl"); if ($FORM{'msgID'} eq "ordina") { &ordina_elenco($FORM{'ordinamento'}); } } # Annullo il messaggio per prevenire ricorsioni anche se non processato $FORM{'msgTarget'} = ""; $FORM{'msgID'} = ""; } sub get_date { @days = ('Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato','Domenica'); @months = ('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'); ($ss,$min,$hh,$mday,$mm,$yy,$wday,$yday,$isdst) = localtime(time); $hh += $offset_time;# differenza time + o - (+=) (-=) if ($hh > 23) { $hh -= 24; $mday+=1; $wday+=1; } if ($hh < 0 ) { $hh += 24; $gg-=1;} if ($hh < 10) { $hh = "0$hh"; } if ($min < 10) { $min = "0$min"; } if ($ss < 10) { $ss = "0$ss"; } # Per utilizzare il mese in ID è necessario aumentarlo 'array zero based' $mm++; if ($yy > 99) { $yyyy = 1900 + $yy; $yy = substr($yyyy,2,2); } else { $yyyy = "20$yy"; } $gg = $mday; if ($mm < 10) { $mm = "0$mm"; } if ($mday < 10) { $mday = "0$mday"; } $giorno = $days[$wday]; $mese = $months[$mm -1]; $date = "$giorno, $gg $mese $yyyy ore $hh\:$min\:$ss"; $short_date = "$giorno, $gg $mese $yyyy"; } ############################################################################## # Apre in sola lettura un file per riempire un buffer temporaneo # sub FO_400 { my ($nomefile)=@_; open (TEMP,"$database_directory_path/$nomefile") || &file_open_error("$database_directory_path/$nomefile", "FO_400", __FILE__, __LINE__); @LINES=; close (TEMP); $SIZE=@LINES; } ####################################################################### # Caricamento delle librerie di supporto. # # Uso: &require_supporting_libraries (__FILE__, __LINE__, "file1", "file2", "file3"...); # sub require_supporting_libraries { local ($file, $line, @require_files) = @_; local ($require_file); # (-e) flag per la verifica dell'esistenza del file # (-r) flag per la verifica della leggibilità del file foreach $require_file (@require_files) { if (-e "$require_file" && -r "$require_file") { require "$require_file"; } else { print "Spiacente, ma non è stato trovato il file richiesto $require_file alla linea $line in $file. Cortesemente verifica che il percorso sia corretto e che i permessi siano corretti. Grazie."; exit; } } } ####################################################################### # file_open_error Subroutine # # &file_open_error("file.name", "ROUTINE", __FILE__, __LINE__); # sub file_open_error { local ($bad_file, $script_section, $this_file, $line_number) = @_; &CgiDie ("Spiacente, ma non è stato possibile accedere a $bad_file nella routine $script_section di $this_file alla linea numero $line_number. Cortesemente verifica che il percorso indicato in dummie.setup sia corretto e che i permessi siano corretti.") } ####################################################################### # get_file_lock # # Uso: &get_file_lock("file.name"); # sub get_file_lock { local ($lock_file) = @_; local ($endtime); $endtime = 20; $endtime = time + $endtime; while (-e $lock_file && time < $endtime) { sleep(1); } flock(LOCK_FILE, 2); # 2 exclusively locks the file } ####################################################################### # release_file_lock # # Uso: &release_file_lock("file.name"); # sub release_file_lock { local ($lock_file) = @_; flock(LOCK_FILE, 8); # 8 unlocks the file } sub noparams { $cmdline = "$this_script_url?lingua=$FORM{'lingua'}&setup_file=$FORM{'setup_file'}&session_file=$session_file&user=$FORM{'user'}"; print " Pratiche Online \n"; print "\n"; print " \n"; print " \n"; print " \n"; print " <body>\n"; print " <p>La pagina corrente utilizza i frame. Questa caratteristica non è supportata dal browser in uso.</p>\n"; print " </body>\n"; print " \n"; print "\n"; print "\n"; } sub load_label { open (LFILE,"./language/label.$FORM{'lingua'}") || &file_open_error("$language_directory_path/label.$FORM{'lingua'}", "Caricamento etichette in lingua", __FILE__, __LINE__); chop(@LABELS = ); close (LFILE); $NLABELS = @LABELS; } sub get_lb { my($nlb)=@_; $nlb = substr($LABELS[$nlb],5); } 1;