#!/usr/bin/perl - w
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
##############################################################################
# Le Kayak de Mer dans le Nouveau Monde
# Destinations v 2.1
# Stéphane Maltais
# 2003
###############################
$basedir = "/home/stephm69/public_html/kayakdemer/destinations";
$baseurl = "http://www.kayakdemer.net/destinations";
$rootdir = "/home/stephm69/public_html/kayakdemer";
$rooturl = "http://www.kayakdemer.net";
$dest_dir = "destinations";
$cgi_url = "http://www.kayakdemer.net/cgi-bin2/destinations.pl";
$datas_dir = "data_files";
$html_dir = "html_files";
$destnmbrfile = "destnmbr.txt";
$mainfile = "destinations.php";
$template = "template.php";
$regions_sd = "services";
$regions_file="regions.txt";
$front_temp = "destinations_t.php";
$front_datas = "front_datas.txt";
$sug_form_templ = "sug_destination_t.php";
$sub_photos_templ = "sub_photos_t.html";
$add_form_templ = "add_infos_t.html";
$new_photos_dir = "photos/new";
$allow_html = 1;
$filter = 1;
$title = "Le Kayak de Mer dans le Nouveau Monde: Destinations";
%TITLES = ("endroit","",
"localisation","Localisation",
"region","",
"maree","Marée",
"maree_com","",
"derniere_visite","",
"acces","Points d\'accès",
"cartes","Cartes utiles",
"pourvoyeurs","Pourvoyeurs à proximité",
"faune","Faune",
"especes","Espèces observées",
"flore","Flore",
"paysages","Paysages",
"difficulte","Niveau de difficulté",
"interet","Intérêt général",
"camping","Possibilité de camping",
"camping_dtls","",
"description","Description, commentaires",
"image_url","",
"photos","Photos",
"urls","Liens à consulter",
"email","",
"name","Informations soumises par"
);
# Done
###########################################################################
use Mysql;
$connect_db = Mysql->connect('localhost', 'stephm69_kmnmdatas', 'stephm69_kmnm', 'access');
$connect_db->selectdb('stephm69_kmnmdatas');
# Get Form Information
&parse_form;
# Put items into nice variables
&get_variables;
if($fct eq "front")
{
print "Content-type: text/html\n\n";
unlink ("$basedir/$front_datas");
# open(MAINFRONT,">$basedir/$front_datas") || die $!;
# print MAINFRONT "";
# close (MAINFRONT);
opendir DATASDIR, "$basedir/$datas_dir" or die "Can't open directory $dir: $!\n";
while ($files = readdir DATASDIR)
{
$files =~ tr/A-Z/a-z/;
if($files =~ /\.txt/)
{
$files =~ s/\.txt//g;
push(@alldtfiles, $files);
}
}
foreach $fntu (@alldtfiles)
{
$code = $fntu;
#print "DEBUG - code $code
";
$lmn = "";
$img_url = "";
%NAMES = %blank;
@emails = @blank;
@last_visit = @blank;
@sub_names = @blank;
$endroit = $endroitupdt;
$endroit =~ s/\s$//g;
$endroit =~ s/\n//g;
$num = $code;
&addtofrt;
}
&upt_frtdatas;
#print "DEBUG";
&upt_frtpg;
&error("La liste des destinations a été mise à jour");
}
# block spam
#&filter_banned;
if($fct)
{
#&error($fct);
if($fct eq "sug_form")
{
&sug_form;
}
if($fct eq "sub_photos")
{
&sub_photos;
}
if($fct eq "add_photos")
{
&add_photos;
}
if($fct eq "add_infos_form")
{
&add_infos_form;
}
#&debug("locmap = $locmap & fct = $fct");
if($fct eq "addmap")
{
$updater = 1;
if($locmap ne "update" && $locmap ne "updateall")
{
$locmap =~ s/\s$//g;
$locmap =~ s/\n//g;
&add_datas;
}
if($locmap eq "updateall")
{
print "Content-type: text/html\n\n";
unlink ("$basedir/$front_datas");
# open(MAINFRONT,">$basedir/$front_datas") || die $!;
# print MAINFRONT "";
# close (MAINFRONT);
opendir DATASDIR, "$basedir/$datas_dir" or die "Can't open directory $dir: $!\n";
while ($files = readdir DATASDIR)
{
$files =~ tr/A-Z/a-z/;
if($files =~ /\.txt/)
{
$files =~ s/\.txt//g;
push(@alldtfiles, $files);
}
}
foreach $fntu (@alldtfiles)
{
$code = $fntu;
print "DEBUG3 - $code start
";
$lmn = "";
$img_url = "";
%NAMES = %blank;
@emails = @blank;
@last_visit = @blank;
@sub_names = @blank;
&html_file("$code");
$endroit = $endroitupdt;
$endroit =~ s/\s$//g;
$endroit =~ s/\n//g;
$num = $code;
&addtofrt;
if($info_ky_lk)
{
print "lk: $info_ky_lk
";
}
print "DEBUG3 - $code fin
";
}
}
else
{
&html_file("$code");
}
$submit = "";
&upt_frtdatas;
&upt_frtpg;
&error("Carte $locmap ajouté au fichier $code");
}
exit;
}
if($submit eq "add_infos")
{
&add_datas;
&html_file("$code");
$submit = "";
&upt_frtdatas;
&upt_frtpg;
&nouveaute;
&datas_added;
exit;
}
&get_filenmbr;
&data_file;
&html_file("$num");
&addtofrt;
&upt_frtdatas;
&upt_frtpg;
&nouveaute;
&submited;
#exit;
#&error("$num DONE !");
#ajout aux nouveauté sur page Accueil
#&nouveaute;
#######################
sub parse_form
{
local($name,$value);
if($ENV{'CONTENT_LENGTH'})
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else
{
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Remove any NULL characters, Server Side Includes
$value =~ s/\0//g;
$value =~ s///g;
# $value =~ s/(
)+/
/g;
if ($allow_html != 1)
{
$value =~ s/<([^>]|\n)*>//g;
}
else
{
unless($name eq 'description' || $name eq 'pourvoyeurs' || $name eq 'cartes')
{
$value =~ s/<([^>]|\n)*>//g;
}
}
$FORM{$name} = $value;
}
# Make sure that message fields do not exceed allowed value
if ($enforce_max_len)
{
foreach $name (keys %max_len)
{
if (length($FORM{$name}) > $max_len{$name})
{
if ($enforce_max_len == 2)
{
&error('field_size');
}
else
{
$FORM{$name} = sprintf("%.$max_len{$name}s",$FORM{$name});
}
}
}
}
}
###############
# FILTER
sub filter_banned
{
@banned = ('\[URL=http','meridia','online','cipro','cozaar','celebrex','augmentin','allegra','propecia','buspar');
if ($filter)
{
foreach $banned_keys (@banned)
{
foreach $field_name (keys %FORM)
{
$check_field = $FORM{$field_name};
$banned_keys =~ tr/A-Z/a-z/;
$banned_keys =~ s/\n//g;
$banned_keys =~ s/\s\n$//g;
$banned_keys =~ s/\r//g;
$check_field =~ tr/A-Z/a-z/;
$check_field =~ s/\n//g;
$check_field =~ s/\s\n$//g;
$check_field =~ s/\r//g;
if($check_field ne "http://"){$scndprev_field = $previous_field;}
if($check_field ne "http://"){$previous_field = $check_field;}
$check_field_lenght = length ($check_field);
if ($check_field ne "sug_form" && ($check_field =~ /$banned_keys/ ||((($previous_field eq $check_field) && ($scndprev_field eq $check_field)) && $check_field_lenght >1 )))
{
&error("Il n\'est pas possible d\'ajouter ces informations. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur");
}
}
}
}
}
###############
# Get Variables
sub get_variables
{
if($FORM{'map'})
{
$map = $FORM{'map'};
}
if($FORM{'zoom'})
{
$zoom = $FORM{'zoom'};
}
if($FORM{'fnum'})
{
$fnum = $FORM{'fnum'};
}
if($FORM{'carte_infokayak'} =~ /carte.kayakdemer.net/)
{
$carte_infokayak = $FORM{'carte_infokayak'};
$carte_infokayak =~ s/^\s//g;
$carte_infokayak =~ s/\s$//g;
$carte_infokayak =~ s/\n//g;
$carte_infokayak =~ s/\r//g;
}
if($map)
{
&get_map;
exit;
}
if($FORM{'code'})
{
$code = $FORM{'code'};
}
if($FORM{'locmap'})
{
$locmap = $FORM{'locmap'};
}
if($FORM{'fct'})
{
$fct = $FORM{'fct'};
return;
}
if($FORM{'submit_fct'})
{
$submit = $FORM{'submit_fct'};
}
if ($FORM{'artgfghv'})
{
$artgfghv = "$FORM{'artgfghv'}";
}
if ($FORM{'artgfgev'})
{
$artgfgev = "$FORM{'artgfgev'}";
}
$myquery = 'SELECT * FROM form_sid WHERE form_id = "'.$FORM{'form_id'}.'"';
$execute = $connect_db->query($myquery);
$hash_ref = $execute->fetchrow_hashref();
$form_sid_fr_db = $hash_ref->{form_key};
$execute = $connect_db->query("DELETE FROM form_sid WHERE form_id = '".$FORM{'form_id'}."'");
if($FORM{'form_sid'} != $form_sid_fr_db || !$form_sid_fr_db)
{
$connect_db->query("INSERT INTO dest_debug (form_id,form_sid,ghv,gev,REMOTE_ADDR,dest_no,nom) VALUES ('bad:|".$FORM{'form_id'}."|','bad:|$form_sid_fr_db vs ".$FORM{'form_sid'}."|','bad:|$artgfghv|','bad:|$artgfgev|','bad:|".$ENV{"REMOTE_ADDR"}."|','bad:|$code|','bad:|".$FORM{'name'}."|')");
&error("Un problème d'authentification est survenue. Contactez-nous si vous n'arrivez pas à soumettre de nouvelles infos\n");
exit;
}
else
{
$connect_db->query("INSERT INTO dest_debug (form_id,form_sid,ghv,gev,REMOTE_ADDR,dest_no,nom) VALUES ('ok:|".$FORM{'form_id'}."|','ok:|$form_sid_fr_db|','ok:|$artgfghv|','ok:|$artgfgev|','ok:|".$ENV{"REMOTE_ADDR"}."|','ok:|$code|','ok:|".$FORM{'name'}."|')");
}
if(!$artgfghv || ($artgfghv ne $artgfgev))
{
$connect_db->query("INSERT INTO dest_debug (form_id,form_sid,ghv,gev,REMOTE_ADDR,dest_no,nom) VALUES ('bad_code:|".$FORM{'form_id'}."|','bad_code:|$form_sid_fr_db|','bad_code:|$artgfghv|','bad_code:|$artgfgev|','bad_code:|".$ENV{"REMOTE_ADDR"}."|','bad_code:|$code|','bad_code:|".$FORM{'name'}."|')");
&error('Entrez le bon code de confirmation pour valider votre message !');
exit;
}
else
{
$connect_db->query("INSERT INTO dest_debug (form_id,form_sid,ghv,gev,REMOTE_ADDR,dest_no,nom) VALUES ('ok_code:|".$FORM{'form_id'}."|','ok_code:|$form_sid_fr_db|','ok_code:|$artgfghv|','ok_code:|$artgfgev|','ok_code:|".$ENV{"REMOTE_ADDR"}."|','ok_code:|$code|','ok_code:|".$FORM{'name'}."|')");
}
$connect_db->query("INSERT INTO dest_debug (form_id,form_sid,ghv,gev,REMOTE_ADDR,dest_no,nom) VALUES ('passed:|".$FORM{'form_id'}."|','passed:|$form_sid_fr_db|','passed:|$artgfghv|','passed:|$artgfgev|','passed:|".$ENV{"REMOTE_ADDR"}."|','passed:|$code|','passed:|".$FORM{'name'}."|')");
if ($FORM{'endroit'})
{
$endroit = "$FORM{'endroit'}";
$endroit =~ s/^\s//g;
$endroit =~ s/\s$//g;
$endroit =~ s/\n//g;
$endroit =~ s/\&/\&\;/g;
$endroit =~ s/"/\"\;/g;
}
elsif($submit != 'add_infos')
{
&error("Vous devez indiquer le nom du plan d\'eau");
}
if ($FORM{'endroit_add'})
{
$endroit_add = "$FORM{'endroit_add'}";
}
if ($FORM{'localisation'})
{
$localisation = "$FORM{'localisation'}";
$localisation =~ s/\n$//g;
$localisation =~ s/\&/\&\;/g;
$localisation =~ s/"/\"\;/g;
}
elsif($submit != 'add_infos')
{
&error("Vous devez indiquer la localisation du plan d\'eau");
}
if ($FORM{'region'})
{
$region = "$FORM{'region'}";
}
elsif($submit != 'add_infos')
{
&error("Vous devez séléctionner la région");
}
if ($FORM{'maree'})
{
$maree = "$FORM{'maree'}";
}
if ($FORM{'maree_com'})
{
$maree_com = "$FORM{'maree_com'}";
}
if ($FORM{'derniere_visite'})
{
$derniere_visite = "$FORM{'derniere_visite'}";
}
if ($FORM{'acces'})
{
$acces = "$FORM{'acces'}";
}
if ($FORM{'cartes'})
{
$cartes = "$FORM{'cartes'}";
}
if ($FORM{'pourvoyeurs'})
{
$pourvoyeurs = "$FORM{'pourvoyeurs'}";
}
if ($FORM{'faune'})
{
$faune = "$FORM{'faune'}";
}
elsif($submit != 'add_infos')
{
&error("Vous devez évaluer le niveau d\'intérêt de la faune");
}
if ($FORM{'especes'})
{
$especes = "$FORM{'especes'}";
}
if ($FORM{'flore'})
{
$flore = "$FORM{'flore'}";
}
elsif($submit != 'add_infos')
{
&error("Vous devez évaluer le niveau d\'intérêt de la flore");
}
if ($FORM{'paysages'})
{
$paysages = "$FORM{'paysages'}";
}
elsif($submit != 'add_infos')
{
&error("Vous devez évaluer le niveau d\'intérêt des paysages");
}
if ($FORM{'difficulte'})
{
$difficulte = "$FORM{'difficulte'}";
}
elsif($submit != 'add_infos')
{
&error("Vous devez évaluer le niveau de difficulté de ce plan d\'eau");
}
if ($FORM{'interet'})
{
$interet = "$FORM{'interet'}";
}
elsif($submit != 'add_infos')
{
&error("Vous devez évaluer le niveau d\'intérêt général");
}
if ($FORM{'camping'})
{
$camping = "$FORM{'camping'}";
}
if ($FORM{'camping_dtls'})
{
$camping_dtls = "$FORM{'camping_dtls'}";
$camping_dtls =~ s/\n$//g;
}
if ($FORM{'description'})
{
$description = "$FORM{'description'}";
$description =~ s/\n$//g;
$description =~ s/\n/
/g;
$description =~ s/\s$//g;
$description =~ s/\n//g;
$description =~ s/(
)+/
/g;
$description =~ s/(
)+/
/g;
$description =~ s/<//g;
$description =~ s/"/"/g;
}
if ($FORM{'image_url'} && $FORM{'image_url'} ne 'http://')
{
$image_url = "$FORM{'image_url'}";
}
if ($FORM{'url1'} && $FORM{'url1'} ne 'http://')
{
$url1 = "$FORM{'url1'}";
}
if ($FORM{'url2'} && $FORM{'url2'} ne 'http://')
{
$url2 = "$FORM{'url2'}";
}
if ($FORM{'url3'} && $FORM{'url3'} ne 'http://')
{
$url3 = "$FORM{'url3'}";
}
if ($FORM{'url4'} && $FORM{'url4'} ne 'http://')
{
$url4 = "$FORM{'url4'}";
}
if ($FORM{'url5'} && $FORM{'url5'} ne 'http://')
{
$url5 = "$FORM{'url5'}";
}
if ($FORM{'email'} =~ /.*\@.*\..*/)
{
$email = "$FORM{'email'}";
}
if ($FORM{'name'})
{
$name = "$FORM{'name'}";
$name =~ s/"//g;
$name =~ s//g;
$name =~ s/>//g;
$name =~ s/\&//g;
}
else
{
$keep_error = "yes";
&error("Vous devez inscrire votre nom ou un pseudonyme");
}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$month = ($mon + 1);
@months = ("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Decembre");
$year += 1900;
$long_date = sprintf("%02d %s %4d",$mday,$months[$mon],$year);
$year %= 100;
if ($use_time == 1)
{
$date = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec,$month,$mday,$year);
}
else
{
$date = sprintf("%02d/%02d/%02d",$mday,$month,$year);
}
}
############
sub get_filenmbr
{
open(NUMBER,"$basedir/$destnmbrfile");
$num = ;
close(NUMBER);
open(NUMBER,">$basedir/$destnmbrfile");
$inc_num = $num;
$inc_num++;
print NUMBER "$inc_num";
close(NUMBER);
}
##########
sub sug_form
{
open(MAIN,"$basedir/$sug_form_templ") || die $!;
@templatelns = ;
close(MAIN);
$code_sid = int(rand 999999);
print "Content-type: text/html\n\n";
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print "\n";
}
elsif($tl =~ //)
{
print "[ XSoumettre des photos prises à cet endroit ]\n";
}
else
{
print $tl;
}
}
}
##############
sub sub_photos
{
open(MAIN,"$basedir/$sub_photos_templ") || die $!;
@templatelns = ;
close(MAIN);
print "Content-type: text/html\n\n";
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print "\n";
}
else
{
print $tl;
}
}
}
#############
sub add_photos
{
open(MAIN,"$basedir/$sub_photos_templ") || die $!;
@templatelns = ;
close(MAIN);
print "Content-type: text/html\n\n";
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print "\n";
}
else
{
print $tl;
}
}
}
##############
sub data_file
{
# &error($carte_infokayak);
opendir PHOTOSDIR, "$basedir/$new_photos_dir" or die "Can't open directory $dir: $!\n";
while ($files = readdir PHOTOSDIR)
{
$files =~ tr/A-Z/a-z/;
if($files =~ /\.txt/)
{
$allfiles{$files}=1;
}
}
$codefile="$code\.txt";
if($allfiles{$codefile})
{
open(MAIN,"$basedir/$new_photos_dir/$code\.txt") || die $!;
@photos = ;
close(MAIN);
unlink ("$basedir/$new_photos_dir/$code\.txt");
}
mkdir "$basedir/photos/$num", 0755 || die $!;
mkdir "$basedir/photos/$num/thumbs", 0755 || die $!;
use GD;
GD::Image->trueColor(1);
if($photos[0])
{
use File::Copy;
foreach $pn (@photos)
{
$pn =~ s/\n//g;
copy("$basedir/$new_photos_dir/$pn","$basedir/photos/$num/$pn");
unlink ("$basedir/$new_photos_dir/$pn");
&resize_img;
}
}
open(NEWFILE,">$basedir/$datas_dir/$num\.txt") || die $!;
print NEWFILE "\n";
print NEWFILE "\n";
if($carte_infokayak)
{
print NEWFILE "$carte_infokayak"."&r=$code\n";
}
print NEWFILE "\n";
$endroit =~ s/\s$//g;
$endroit =~ s/\n//g;
print NEWFILE "$endroit\n";
print NEWFILE "\n";
print NEWFILE "$region\n";
print NEWFILE "\n";
print NEWFILE "$localisation\n";
print NEWFILE "\n";
if($maree)
{
print NEWFILE "$maree\n";
}
print NEWFILE "\n";
if($maree_com)
{
print NEWFILE "$maree_com\n";
}
print NEWFILE "\n";
if($acces)
{
print NEWFILE "$acces\n";
}
print NEWFILE "\n";
if($cartes)
{
print NEWFILE "$cartes\n";
}
print NEWFILE "\n";
if($pourvoyeurs)
{
print NEWFILE "$pourvoyeurs\n";
}
print NEWFILE "\n";
print NEWFILE "$faune|\n";
print NEWFILE "\n";
if($especes)
{
print NEWFILE "$especes\n";
}
print NEWFILE "\n";
print NEWFILE "$flore|\n";
print NEWFILE "\n";
print NEWFILE "$paysages|\n";
print NEWFILE "\n";
print NEWFILE "$difficulte|\n";
print NEWFILE "\n";
print NEWFILE "$interet|\n";
print NEWFILE "\n";
if($camping)
{
print NEWFILE "$camping|\n";
}
print NEWFILE "\n";
if($camping_dtls)
{
print NEWFILE "$camping_dtls\n";
}
print NEWFILE "\n";
if($description)
{
print NEWFILE "$description\n";
}
print NEWFILE "\n";
if($url1)
{
print NEWFILE "$url1\n";
}
if($url2)
{
print NEWFILE "$url2\n";
}
if($url3)
{
print NEWFILE "$url3\n";
}
if($url4)
{
print NEWFILE "$url4\n";
}
if($url5)
{
print NEWFILE "$url5\n";
}
print NEWFILE "\n";
if($image_url)
{
print NEWFILE "$image_url\n";
}
print NEWFILE "\n";
foreach $pt (@photos)
{
$pt =~ s/\n//g;
print NEWFILE "$pt\n";
}
print NEWFILE "\n";
if($derniere_visite)
{
print NEWFILE "$derniere_visite\n";
}
else
{
print NEWFILE "novisit\n";
}
print NEWFILE "\n";
print NEWFILE "$name\n";
print NEWFILE "\n";
if($email)
{
print NEWFILE "$email\n";
}
else
{
print NEWFILE "nomail\n";
}
print NEWFILE "";
close(NEWFILE);
}
###########
sub addtofrt
{
open(MAINFRONT,">>$basedir/$front_datas") || die $!;
$region_fn =~ s/\s$//g;
$region_fn =~ s/\n//g;
print MAINFRONT "$num|$endroit|$region_fn\n";
close (MAINFRONT);
}
############
sub html_file
{
$rt = 1;
$rt_aft =1;
$img_url="";
$html_num = $_[0];
$info_ky_lk = "";
open(MAIN,"$rootdir/$regions_sd/$regions_file") || die $!;
@regions = ;
close(MAIN);
foreach $rg (@regions)
{
($rg_srt,$rg_lg)=split(/\|/,$rg);
$REGION{$rg_srt}=$rg_lg;
}
open(MAIN,"$basedir/$template") || die $!;
@templatelns = ;
close(MAIN);
# &error(449);
# &debug("$basedir/$datas_dir/$html_num\.txt");
open(MAIN,"$basedir/$datas_dir/$html_num\.txt") || die $!;
@dataslns = ;
close(MAIN);
open(MAIN,">$basedir/$html_dir/$html_num\.php") || die $!;
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print MAIN "\n";
print MAIN "\n";
foreach $dl (@dataslns)
{
if($dl =~ /'))-4;
$section = substr($dl, 4, $nmbrlt);
$sect_title = $TITLES{$section};
if ($prev_sect eq "photos")
{
print MAIN "[ ajouter des photos prises à cet endroit ] \n";
}
if($prev_sect eq "email")
{
&print_names;
}
if($section eq "faune" || $section eq "flore" || $section eq "paysages" || $section eq "interet" || $section eq "difficulte")
{
$rt_aft = 0;
}
if($prev_sect eq "pourvoyeurs")
{
print MAIN "Consulter la section de services pour cette région \n";
$rt = 0;
}
if($sect_title)
{
if($rt)
{
print MAIN " ";
}
else
{
$rt = 1;
}
if ($section ne "especes")
{
print MAIN " ";
}
print MAIN "$sect_title:\n";
if($rt_aft)
{
print MAIN " ";
}
else
{
$rt_aft = 1;
}
}
if($prev_sect eq "image_url" && $img_url)
{
print MAIN " \n";
}
}
else
{
if($section eq "locmap")
{
$dl =~ s/\s$//g;
$dl =~ s/\n//g;
$lmn = $dl;
}
elsif($section eq "carte_infokayak")
{
print MAIN " \n";
$info_ky_lk = $dl;
}
elsif($section eq "endroit")
{
$endroitupdt = $dl;
if($lmn)
{
print MAIN " | | $dl \n";
}
else
{
print MAIN " | | $dl \n";
}
}
elsif($section eq "region")
{
$dl =~ s/\s$//g;
$dl =~ s/\n//g;
$region_fn = $REGION{$dl};
$region_srt = $dl;
print MAIN "$region_fn\n";
print MAIN " |
\n";
}
elsif($section eq "pourvoyeurs")
{
print MAIN "$dl
\n";
}
elsif($section eq "faune" || $section eq "flore" || $section eq "paysages" || $section eq "interet" || $section eq "difficulte")
{
$dl =~ s/\n//g;
(@numbers)=split(/\|/,$dl);
&moyenne;
print MAIN " $moyenne/5
\n";
}
elsif($section eq "camping_dtls")
{
print MAIN "$dl
\n";
}
elsif($section eq "camping")
{
$dl =~ s/\n//g;
(@answers)=split(/\|/,$dl);
&get_fnlansw;
print MAIN "$fnlansw
\n";
}
elsif($section eq "name")
{
$dl =~ s/\n//g;
push(@sub_names,$dl);
}
elsif($section eq "image_url")
{
$dl =~ s/\n//g;
$img_url = $dl;
}
elsif($section eq "photos")
{
$dl =~ s/\n//g;
print MAIN "
\n";
}
elsif($section eq "urls")
{
$dl =~ s/\n//g;
$longurl=length ($dl);
if($longurl<70)
{
$cuturl = $dl;
}
else
{
$cuturl = substr($dl, 0, 70).'...';
}
print MAIN "$cuturl
\n";
}
elsif($section eq "derniere_visite")
{
$dl =~ s/\n//g;
push(@last_visit,$dl);
}
elsif($section eq "email")
{
$dl =~ s/\n//g;
push(@emails,$dl);
}
else
{
print MAIN "$dl
\n";
}
}
}
print MAIN "\n";
}
else
{
print MAIN "$tl";
}
}
close(MAIN);
}
##########
sub print_names
{
$nn=0;
foreach $sn (@sub_names)
{
$emailx = $emails[$nn];
$lvx = $last_visit[$nn];
$lvx =~ s/\s$//g;
$lvx =~ s/\n//g;
$sn =~ s/\s$//g;
$sn =~ s/\n//g;
if(!($NAMES{"$sn"}))
{
$emailx =~ s/\s$//g;
$emailx =~ s/\n//g;
if($emailx ne "nomail")
{
print MAIN "$sn";
if($lvx ne "novisit")
{
print MAIN " (Dernière visite à cet endroit : $lvx)";
}
print MAIN "
\n";
}
else
{
print MAIN "$sn";
if($lvx ne "novisit")
{
print MAIN " (Dernière visite à cet endroit : $lvx)";
}
print MAIN "
\n";
}
}
$NAMES{"$sn"} = 1;
++$nn;
}
}
##########
sub moyenne
{
$nn = 0;
$ttl = 0;
foreach $nmb (@numbers)
{
$nmb =~ s/\s$//g;
$nmb =~ s/\n//g;
if($nmb)
{
++$nn;
$ttl = $ttl + $nmb;
}
}
if($nn > 0)
{
$moyenne = (int(($ttl/$nn)*10))/10;
}
}
##########
sub get_fnlansw
{
$camp_oui = 0;
$camp_non = 0;
$camp_dif = 0;
$answers = 0;
foreach $answ (@answers)
{
if($answ eq "Oui")
{
++$camp_oui;
}
elsif($answ eq "Non")
{
++$camp_non;
}
else
{
++$camp_dif;
}
++$answers;
}
if(($camp_oui - $answers) == 0)
{
$fnlansw = "Oui";
}
elsif(($camp_non - $answers) == 0)
{
$fnlansw = "Non";
}
elsif(($camp_dif - $answers) == 0)
{
$fnlansw = "Difficile";
}
else
{
$fnlansw = "Incertain ($camp_oui Oui\, $camp_non Non\, $camp_dif Difficile)";
}
}
###################
sub resize_img
{
$image_init = newFromJpeg GD::Image("$basedir/photos/$num/$pn");
($width,$height) = $image_init->getBounds();
$reduction = 100/$width;
$width_t = 100;
$height_t = int($height * $reduction);
if($height_t > 100)
{
$reduction = 100/$height;
$height_t = 100;
$width_t = int($width * $reduction);
}
$thumfinal = new GD::Image(100,100);
$x_dep = 0;
$y_dep = 0;
if($width_t < 100)
{
$x_dep = int((100-$width_t)/2);
}
if($height_t < 100)
{
$y_dep = int((100-$height_t)/2);
}
$thumfinal->copyResized($image_init,$x_dep,$y_dep,0,0,$width_t,$height_t,$width,$height);
open (THUMB, ">$basedir/photos/$num/thumbs/$pn") || die "cant create small file $smallfilename";
binmode THUMB;
print THUMB $thumfinal->jpeg;
close (THUMB);
}
###############
sub add_infos_form
{
open(MAIN,"$basedir/$add_form_templ") || die $!;
@templatelns = ;
close(MAIN);
open(MAIN,"$basedir/$datas_dir/$code\.txt") || die $!;
@dataslns = ;
close(MAIN);
open(MAIN,"$rootdir/$regions_sd/$regions_file") || die $!;
@regions = ;
close(MAIN);
foreach $rg (@regions)
{
($rg_srt,$rg_lg)=split(/\|/,$rg);
$REGION{$rg_srt}=$rg_lg;
}
print "Content-type: text/html\n\n";
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print "\n";
}
elsif($tl =~ //)
{
print "\n";
print "\n";
}
elsif($tl =~ //)
{
&get_datas('endroit');
print "@datas[0]
\n";
print "\n";
}
elsif($tl =~ //)
{
&get_datas('localisation');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('region');
$datas[0] =~ s/\s$//g;
$datas[0] =~ s/\n//g;
$rsn = @datas[0];
$rfn = $REGION{$rsn};
print "$rfn
\n";
}
elsif($tl =~ //)
{
&get_datas('maree');
print "@datas[0]
\n";
}
elsif($tl =~ //)
{
&get_datas('maree_com');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('acces');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('cartes');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('carte_infokayak');
$carteik_url = $datas[0];
if(!($carteik_url) || $carteik_url eq "http://")
{
print "Lien vers la carte Infokayak pour cette ré\;gion (facultatif)
\n";
print "Rendez-vous à\; la carte, dé\;placez vous et faites le zoom afin que seule cette ré\;gion apparaisse, cliquez sur Mixte (en haut et à\; droite de la carte), copiez l'adresse de la carte qui apparaît sous la lé\;gende et entrez là\; ci-dessous
\n";
print "\n";
}
}
elsif($tl =~ //)
{
&get_datas('pourvoyeurs');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('especes');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('camping_dtls');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('description');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
&get_datas('image_url');
foreach $dl (@datas)
{
print "$dl
\n";
}
}
elsif($tl =~ //)
{
use Digest::MD5 qw(md5 md5_hex md5_base64);
$sid = md5_hex(rand(9999999));
print '';
}
elsif($tl =~ //)
{
&get_datas('urls');
foreach $dl (@datas)
{
$longurl=length ($dl);
if($longurl<70)
{
$cuturl = $dl;
}
else
{
$cuturl = substr($dl, 0, 70).'...';
}
print "$cuturl
\n";
}
}
elsif($tl =~ //)
{
print "[ Soumettre des photos prises à cet endroit ]\n";
}
else
{
print $tl;
}
}
}
###########
sub upt_frtdatas
{
open(MAIN,"$rootdir/$regions_sd/$regions_file") || die $!;
@regions = ;
close(MAIN);
foreach $rg (@regions)
{
($rg_srt,$rg_lg)=split(/\|/,$rg);
$REGION{$rg_srt}=$rg_lg;
}
open(MAIN,"$basedir/$front_datas") || die $!;
@frtdats = ;
close(MAIN);
open(MAIN,">$basedir/$front_datas") || die $!;
@all_dest = sort parreg @frtdats;
foreach $pn ( @all_dest)
{
@dest_dats = split(/\|/,$pn);
$dn = @dest_dats[0];
open(DATAS,"$basedir/$datas_dir/$dn.txt") || die $!;
@dataslns = ;
close(DATAS);
&get_datas('endroit');
$datas[0] =~ s/\s$//g;
$datas[0] =~ s/\n//g;
print MAIN "$dn|$datas[0]|";
&get_datas('region');
$datas[0] =~ s/\s$//g;
$datas[0] =~ s/\n//g;
$regionx=$REGION{$datas[0]};
$regionx =~ s/\s$//g;
$regionx =~ s/\n//g;
print MAIN "$regionx|";
&get_datas('locmap');
print MAIN "$datas[0]|";
&get_datas('faune');
@numbers = split(/\|/,$datas[0]);
&moyenne;
print MAIN "$moyenne|";
&get_datas('flore');
@numbers = split(/\|/,$datas[0]);
#&moyenne;
print MAIN "$moyenne|";
&get_datas('paysages');
@numbers = split(/\|/,$datas[0]);
#&moyenne;
print MAIN "$moyenne|";
&get_datas('difficulte');
@numbers = split(/\|/,$datas[0]);
#&moyenne;
print MAIN "$moyenne|";
&get_datas('interet');
@numbers = split(/\|/,$datas[0]);
#&moyenne;
print MAIN "$moyenne|";
&get_datas('camping');
$datas[0] =~ s/\s$//g;
$datas[0] =~ s/\n//g;
@answers = split(/\|/,$datas[0]);
&get_fnlansw;
if($fnlansw eq "Oui" || $fnlansw eq "Difficile")
{
print MAIN "$fnlansw";
}
elsif($fnlansw =~ /Incertain/ )
{
print MAIN "Incertain";
}
print MAIN "\n";
}
close(MAIN);
}
#########################################
sub parreg
{
@a = split(/\|/,$a);
@b = split(/\|/,$b);
$a[2] =~ tr/A-Z/a-z/;
$a[2] =~ s/é/e/g;
$a[2] =~ s/ê/e/g;
$a[2] =~ s/É/e/g;
$a[2] =~ s/Ê/e/g;
$a[2] =~ s/Î/i/g;
$a[2] =~ s/î/i/g;
$a[2] =~ s/^l'//g;
$a[2] =~ s/ç/c/g;
$a[2] =~ s/Ç/C/g;
$a[2] =~ s/^le //g;
$a[2] =~ s/^la //g;
$a[2] =~ s/^les //g;
$b[2] =~ tr/A-Z/a-z/;
$b[2] =~ s/é/e/g;
$b[2] =~ s/ê/e/g;
$b[2] =~ s/É/e/g;
$b[2] =~ s/Ê/e/g;
$b[2] =~ s/Î/i/g;
$b[2] =~ s/î/i/g;
$b[2] =~ s/^l'//g;
$b[2] =~ s/ç/c/g;
$b[2] =~ s/Ç/C/g;
$b[2] =~ s/^le //g;
$b[2] =~ s/^la //g;
$b[2] =~ s/^les //g;
$a[1] =~ tr/A-Z/a-z/;
$a[1] =~ s/é/e/g;
$a[1] =~ s/ê/e/g;
$a[1] =~ s/É/e/g;
$a[1] =~ s/Ê/e/g;
$a[1] =~ s/Î/i/g;
$a[1] =~ s/î/i/g;
$a[1] =~ s/^l'//g;
$a[1] =~ s/ç/c/g;
$a[1] =~ s/Ç/C/g;
$a[1] =~ s/^le //g;
$a[1] =~ s/^la //g;
$a[1] =~ s/^les //g;
$b[1] =~ tr/A-Z/a-z/;
$b[1] =~ s/é/e/g;
$b[1] =~ s/ê/e/g;
$b[1] =~ s/É/e/g;
$b[1] =~ s/Ê/e/g;
$b[1] =~ s/Î/i/g;
$b[1] =~ s/î/i/g;
$b[1] =~ s/^l'//g;
$b[1] =~ s/ç/c/g;
$b[1] =~ s/Ç/C/g;
$b[1] =~ s/^le //g;
$b[1] =~ s/^la //g;
$b[1] =~ s/^les //g;
lc($a[2]) cmp lc($b[2]) || lc($a[1]) cmp lc($b[1]);
}
#########################################
sub parnom
{
@a = split(/\|/,$a);
@b = split(/\|/,$b);
$a[1] =~ tr/A-Z/a-z/;
$a[1] =~ s/é/e/g;
$a[1] =~ s/ê/e/g;
$a[1] =~ s/É/e/g;
$a[1] =~ s/Ê/e/g;
$a[1] =~ s/Î/i/g;
$a[1] =~ s/î/i/g;
$a[1] =~ s/^l'//g;
$a[1] =~ s/ç/c/g;
$a[1] =~ s/Ç/C/g;
$a[1] =~ s/^le //g;
$a[1] =~ s/^la //g;
$a[1] =~ s/^les //g;
$b[1] =~ tr/A-Z/a-z/;
$b[1] =~ s/é/e/g;
$b[1] =~ s/ê/e/g;
$b[1] =~ s/É/e/g;
$b[1] =~ s/Ê/e/g;
$b[1] =~ s/Î/i/g;
$b[1] =~ s/î/i/g;
$b[1] =~ s/^l'//g;
$b[1] =~ s/ç/c/g;
$b[1] =~ s/Ç/C/g;
$b[1] =~ s/^le //g;
$b[1] =~ s/^la //g;
$b[1] =~ s/^les //g;
lc($a[1]) cmp lc($b[1]);
}
###########
sub upt_frtpg
{
open(MAIN,"$basedir/$front_temp") || die $!;
@templatelns = ;
close(MAIN);
open(MAIN,"$basedir/$front_datas") || die $!;
@frtdats = ;
close(MAIN);
open(MAIN,">$basedir/$mainfile") || die $!;
foreach $tl (@templatelns)
{
if($tl =~ //)
{
foreach $dl (@frtdats)
{
$dl =~ s/\n//g;
(my $num,my $endroit,my $region,my $locmap,my $faune,my $flore,my $paysages,my $difficulte,my $interet,my $camping) = split(/\|/,$dl);
if($region ne $oldreg)
{
print MAIN "\n";
print MAIN "$region | ";
print MAIN "
";
print MAIN "\n";
print MAIN "Ajouter une destination | ";
print MAIN "
";
}
$oldreg = $region;
if($rc)
{
print MAIN "\n";
$rc=0;
}
else
{
print MAIN "
\n";
$rc = 1;
}
print MAIN "![](\"compas_small.gif\") | \n";
print MAIN "$endroit \n";
print MAIN "$region | \n";
print MAIN "\n";
if($locmap)
{
$locmap =~ s/\s$//g;
$locmap =~ s/\n//g;
print MAIN "![\"Localisation\"](\"getmap.gif\") | \n";
}
else
{
print MAIN " | \n";
}
if($faune >= 4)
{
print MAIN "![\"Faune](\"bird_s.gif\") | \n";
}
else
{
print MAIN " | \n";
}
if($flore >= 4)
{
print MAIN "![\"Flaure](\"plant1_s.gif\") | \n";
}
else
{
print MAIN " | \n";
}
if($paysages >= 4)
{
print MAIN "![\"Jolies](\"paysage1_s.gif\") | \n";
}
else
{
print MAIN " | \n";
}
print MAIN "![\"Niveau](\"";) | \n";
}
if($difficulte < 2.5 && $difficulte >= 1.5)
{
print MAIN "diffic2.gif\" width=\"30\" height=\"30\" border=\"0\" alt=\"Niveau de difficult\é\;: 2/5\">\n";
}
if($difficulte < 3.5 && $difficulte >= 2.5)
{
print MAIN "diffic3.gif\" width=\"30\" height=\"30\" border=\"0\" alt=\"Niveau de difficult\é\;: 3/5\">\n";
}
if($difficulte < 4.5 && $difficulte >= 3.5)
{
print MAIN "diffic4.gif\" width=\"30\" height=\"30\" border=\"0\" alt=\"Niveau de difficult\é\;: 4/5\">\n";
}
if($difficulte >= 4.5)
{
print MAIN "diffic5.gif\" width=\"30\" height=\"30\" border=\"0\" alt=\"Niveau de difficult\é\;: 5/5\">\n";
}
print MAIN "![\"Intérêt](\"";) | \n";
}
if($interet < 2.5 && $interet >= 1.5)
{
print MAIN "stars2.gif\" width=\"30\" height=\"19\" border=\"0\" alt=\"Intérêt génétal: 2/5\">\n";
}
if($interet < 3.5 && $interet >= 2.5)
{
print MAIN "stars3.gif\" width=\"30\" height=\"19\" border=\"0\" alt=\"Intérêt génétal: 3/5\">\n";
}
if($interet < 4.5 && $interet >= 3.5)
{
print MAIN "stars4.gif\" width=\"30\" height=\"19\" border=\"0\" alt=\"Intérêt génétal: 4/5\">\n";
}
if($interet >= 4.5)
{
print MAIN "stars5.gif\" width=\"30\" height=\"19\" border=\"0\" alt=\"Intérêt génétal: 5/5\">\n";
}
if($camping eq "Oui")
{
print MAIN "![\"Camping](\"tent_s.gif\") | \n";
}
elsif($camping eq "Difficile")
{
print MAIN "![\"Camping](\"tent_s_excl.gif\") | \n";
}
elsif($camping eq "Incertain")
{
print MAIN "![\"Camping](\"tent_s_quest.gif\") | \n";
}
else
{
print MAIN " | \n";
}
print MAIN "
\n";
}
}
else
{
print MAIN "$tl";
}
}
close(MAIN);
}
###########
sub get_datas
{
$field = $_[0];
@datas = @blank;
$load = 0;
foreach $dl (@dataslns)
{
$dl =~ s/\n//g;
if($dl =~ /'))-4;
$section = substr($dl, 4, $nmbrlt);
if($load)
{
$load = 0;
}
}
if($load)
{
push(@datas,$dl);
}
if($section eq $field)
{
$load = 1;
}
}
}
#############
sub add_datas
{
$datas = 0;
$pnotrt = 0;
opendir PHOTOSDIR, "$basedir/$new_photos_dir" or die "Can't open directory $dir: $!\n";
while ($files = readdir PHOTOSDIR)
{
$files =~ tr/A-Z/a-z/;
if($files =~ /\.txt/)
{
$allfiles{$files}=1;
}
}
$codefile="$code\.txt";
if($allfiles{$codefile})
{
open(MAIN,"$basedir/$new_photos_dir/$code\.txt") || die $!;
@photos = ;
close(MAIN);
unlink ("$basedir/$new_photos_dir/$code\.txt");
}
use GD;
GD::Image->trueColor(1);
if($photos[0])
{
use File::Copy;
foreach $pn (@photos)
{
$pn =~ s/\n//g;
copy("$basedir/$new_photos_dir/$pn","$basedir/photos/$code/$pn");
unlink ("$basedir/$new_photos_dir/$pn");
$num = $code;
&resize_img;
}
}
open(MAIN,"$basedir/$datas_dir/$code\.txt") || die $!;
@dataslns = ;
close(MAIN);
open(MAIN,">$basedir/$datas_dir/$code\.txt") || die $!;
foreach $dl (@dataslns)
{
if($dl =~ /'))-4;
$section = substr($dl, 4, $nmbrlt);
if($section eq "carte_infokayak")
{
$cartinfokayak_pres = 1;
}
if($section eq "endroit" && $dl =~ /\n";
$cik_url = $FORM{'carte_infokayak'};
if($cik_url)
{
if($cik_url =~ /carte.kayakdemer.net/)
{
$cik_url =~ s/\s$//g;
$cik_url =~ s/\n//g;
print MAIN "$cik_url"."&r=$code\n";
}
}
}
if(($FORM{$section} && $FORM{$section} ne "http://") || $section eq "urls" || $section eq "photos" || $section eq "email" || $section eq "derniere_visite")
{
$datas = 1;
}
else
{
$datas = 0;
}
if($pnotrt)
{
print MAIN "\n";
$pnotrt = 0;
}
print MAIN "$dl";
}
elsif($section eq "faune" || $section eq "flore" || $section eq "paysages" || $section eq "difficulte" || $section eq "interet" || $section eq "camping")
{
$dl =~ s/\s$//g;
$dl =~ s/\n//g;
print MAIN "$dl";
$pnotrt = 1;
}
else
{
print MAIN "$dl";
}
}
close(MAIN);
}
#######################################
sub submited
{
open(MAIN,"$basedir/$template") || die $!;
@templatelns = ;
close(MAIN);
print "Content-type: text/html\n\n";
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print "
\n";
print "La destination $endroit a été ajoutée !
Merci de votre contribution !!!
";
print "[ Aller à la nouvelle destination ] [ Retour aux destinations ]";
print "\n";
}
else
{
print $tl;
}
}
}
#########
sub datas_added
{
open(MAIN,"$basedir/$template") || die $!;
@templatelns = ;
close(MAIN);
print "Content-type: text/html\n\n";
foreach $tl (@templatelns)
{
if($tl =~ //)
{
print "
\n";
print "Les informations ont été ajoutées à la destination $endroit_add.
Merci de votre contribution !!!
";
print "[ Retourner à la destination ] [ Retour aux destinations ]";
print "\n";
}
else
{
print $tl;
}
}
}
############################
sub error
{
$error = $_[0];
if($submit && $keep_error ne "yes" && !$artgfghv)
{
return;
}
if($locmap eq "update")
{
$error = "La fiche $code a été mise à jour"
}
print "Content-type: text/html\n\n";
print "ERREUR\n";
print "ERREUR:
\n";
print "
$error
\n";
print "[ Retour au formulaire ]
\n";
print "";
exit;
}
############################
sub debug
{
$error = $_[0];
print "Content-type: text/html\n\n";
print "Carte Infokayak: ERREUR\n";
print "Carte Infokayak: ERREUR
\n";
print "
$error
\n";
print "[ Retour au formulaire ]
\n";
print "";
#exit;
}
############################
sub get_map
{
open(MAIN,"$basedir/$front_datas") || die $!;
@frtdats = ;
close(MAIN);
foreach $fd (@frtdats)
{
(my $num,my $endroit,my $region,my $locmap,my $faune,my $flore,my $paysages,my $difficulte,my $interet,my $camping) = split(/\|/,$fd);
$PLACES{$num} = "$endroit";
}
$destfn = $PLACES{$fnum};
print "Content-type: text/html\n\n";
print <<"EOF";
Le KMNM: Carte - $destfn
EOF
print "
\n";
print "\n";
print "
\n";
}
############################
sub nouveaute
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$month = ($mon + 1);
@months = ("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Decembre");
$year += 1900;
$date_nouv = sprintf("%02d %s %4d %02d:%02d",$mday,$months[$mon],$year,$hour,$min);
# Adapter pour chaque section
$section = "Destinations";
$url = 'http://www.kayakdemer.net/destinations/destinations.php';
$endroit_add =~ s/\s$//g;
$endroit_add =~ s/\n//g;
if($endroit_add)
{
$description="$name a ajouté de l'information à la destination $endroit_add";
}
else
{
$description="Nouvelle destination: $endroit par $name ";
}
#&debug("");
$connect_db->query("INSERT INTO nouveautes (section,sect_url,details,date) VALUES ('$section','$url','".quotemeta($description)."','$date_nouv')")or die "MySQL Error: $DBI::errstr\n";
}
############################
sub nouveaute_txt
{
$basedir_n = "/home/stephm69/public_html/kayakdemer";
$datafilen = "nouveautes.txt";
# Adapter pour chaque section
$section_n = "Destinations";
$url_n = 'http://www.kayakdemer.net/destinations/destinations.php';
$endroit_add =~ s/\s$//g;
$endroit_add =~ s/\n//g;
if($endroit_add)
{
$description_n="$name a ajouté de l\'information à la destination $endroit_add";
}
else
{
$description_n="Nouvelle destination: $endroit par $name ";
}
$mesgfile_temp = "index_tv.php";
$mesgfile = "index.php";
# Ajout à la page TEMPLATE pour ptites vites
$mesgfile_temp = "index_t.php";
$mesgfile = "index_tn.php";
&addtolist_n;
}
############################
sub addtolist_n
{
open(EVENT,"$basedir_n/$datafilen") || die $! ;
@nouveautes = ;
close (EVENT);
open(NBR,"$basedir_n/nombre_n.txt") || die $! ;
$nbr_n = ;
close (NBR);
open(EVENT,">$basedir_n/$datafilen");
print EVENT "$section_n\|$url_n\|$description_n\|$long_date\n";
$nt=1;
foreach $i (@nouveautes)
{
chomp($i);
if ($nt<$nbr_n)
{
print EVENT "$i\n";
$nt++;
}
}
close (EVENT);
}