#!/usr/bin/perl
##############################################################################
# Forum v 2.8
# lst mod: send mail
##############################################################################
# Define Variables
$basedir = "/home/stephm69/public_html/kayakdemer/wwwboard";
$homedir ="/home/stephm69/public_html/kayakdemer";
$filter_dir = "/home/stephm69/public_html/filter";
$mailprog = '|/usr/sbin/sendmail -t';
$docsdir = "/home/stephm69/public_html/kayakdemer/docs";
$homeurl = "http://www.kayakdemer.net";
$docsurl = "http://www.kayakdemer.net/docs";
$baseurl = "http://www.kayakdemer.net/wwwboard";
$photodir = "$baseurl/photos";
$cgi_url = "http://www.kayakdemer.net/cgi-bin2/wwwboard.pl";
$direct_wwboard_url = "http://www.kayakdemer.net/wwwboard/redirect.pl";
$cgis_url = "http://www.kayakdemer.net/cgi-bin2";
$cgis_dir = "/home/stephm69/public_html/kayakdemer/cgi-bin2";
$template = "message_t.html";
$addmailtp = "addmail.html";
$mesgdir = "messages";
$deleted_msg="deleted.html";
$mailingdir = "mailing";
# Pour ajout événements du calendrier page d'accueil
$events_dir = "calendrier";
$eventsfile = "events.txt";
$details_dir = "details";
$delais = "7";
$stats_dir = "/home/stephm69/public_html/kayakdemer/wwwboard/stats";
$stats_url = "http://www.kayakdemer.net/wwwboard/stats";
$datafile = "data.txt";
$mesgfile_all = "wwwboard_all.php";
$mesgfile = "wwwboard.html";
$mesgfile_t = "wwwboard_t.php";
$soum_file = "soum_message.php";
$faqfile = "faq.html";
$filter_activepg = "fltpg_active.php";
# Changer le message sur la page d'accueil oui=1; non=0
$chgfrontmsg = 0;
$addnouveautes = 1;
$lstmsgtmfile = "lsttime.txt";
$mxtimefile = "maxtime.txt";
$maxtimejsfl = "maxtime.js";
$reg_names = "reg_names.txt";
$nmbmsgsfile = "nombrmsgsparuser.txt";
$frmail = "forum\@kayakdemer.net";
$forumtitle = "du kayak de mer dans le nouveau monde";
$forumurl = "http://www.kayakdemer.net/wwwboard";
$background_im = "http://www.kayakdemer.net/bckgrnd.gif";
$ext = "html";
$title = "Le Kayak de Mer dans le Nouveau Monde: Forum";
$site_name = "Le Kayak de Mer dans le Nouveau Monde";
$site_url = "http://www.kayakdemer.net";
$html_help = "http://www.kayakdemer.net/html.html";
$active_period = 22;
$closed = "";
@passwords = ("tempo","loisi");
# Done
###########################################################################
# Configure Options
$show_faq = 1; # 1 - YES; 0 = NO
$allow_html = 1; # 1 = YES; 0 = NO
$quote_text = 0; # 1 = YES; 0 = NO
$subject_line = 0; # 0 = Quote Subject Editable; 1 = Quote Subject
# UnEditable; 2 = Don't Quote Subject, Editable.
$use_time = 0; # 1 = YES; 0 = NO
$show_poster_ip = 0; # 1 = Show the IP of every poster; 0 = Don't
$enforce_max_len = 0; # 2 = YES, error; 1 = YES, truncate; 0 = NO
%max_len = ('name', 50,
'email', 70,
'subject', 80,
'url', 150,
'url_title', 80,
'img', 150,
'body', 3000,
'origsubject', 80,
'origname', 50,
'origemail', 70,
'origdate', 50);
# Done
###########################################################################
# Get maxtime
&getmaxtime;
# Get the Data Number
&get_number;
# Get Form Information
&parse_form;
#$closed="09:00, 16 ocobre 06";
if($closed)
{
&error("Désolé, le forum est temporairement hors fonction. Il devrait être à nouveau en ligne vers $closed");
}
# Put items into nice variables
&get_variables;
if($fct eq "register")
{
&enregistrer;
}
if($fct eq "erase_msg")
{
&checkpsw;
&erase_msg;
&error("Le message #$msgnmbr a été effaçé...$rmvlines lignes enlevés sur la page du forum");
}
if($fct eq "voirdocs")
{
if($doc)
{
&show_doc;
}
else
{
&show_alldocs;
}
exit;
}
if($fct eq "voirdoc_dtls")
{
&showdoc_dtls;
exit;
}
if($fct eq "showlink")
{
&show_link;
exit;
}
if($addmailto)
{
&mk_page;
exit;
}
if($msgnmbr)
{
&defmsgsandadd;
&returnhtml;
exit;
}
if($star != 1)
{
&check_banned;
}
if($newsub && $registered_only eq "oui")
{
if(!$reg_usr)
{
&error("Vous devez avoir un nom enregistré pour pouvoir cocher la case Permettre seulement aux utilisateurs enregistrés de répondre à ce message");
}
else
{
®istered_only;
}
}
if($fltval && $newsub eq "oui")
{
&putfltval;
$newsub = "";
}
&write_ip;
&write_name;
# Write initial stats for message
&write_ini_stats;
# Open the new file and write information to it.
&new_file;
# Open the Main WWWBoard File to add link
&main_page;
# Now Add Thread to Individual Pages
if ($num_followups >= 1)
{
&thread_pages;
}
# Return the user HTML
&return_html;
# Increment Number
&increment_num;
if($chgfrontmsg == 1)
{
&updt_frontmsg;
}
# Put calendar coming events on front page
#&coming_events;
&check_hidden;
if($addnouveautes == 1)
{
if($fltval)
{
$typenouv = "subject";
&nouveaute;
}
else
{
&nouveaute;
}
}
if($mail_list && !$hide)
{
&sendmails;
}
&chkmailqueue;
#######################
sub chkmailqueue
{
$prestime = int(time/60)-19631284 ;
open(MAIN,"$homedir/$mailingdir/queue_check.txt") || die $!;
flock(MAIN, 2);
@queued = ;
close(MAIN);
$mailinqueue = $queued[0];
if($mailinqueue)
{
$command_string = "./subvite.pl";
system( $command_string );
}
}
############################
sub getmaxtime
{
open(NUMBER,"$basedir/$mxtimefile");
$maxtime = ;
close(NUMBER);
}
############################
# Get Data Number Subroutine
sub get_number
{
open(NUMBER,"$basedir/$datafile");
$num = ;
close(NUMBER);
if ($num == 9999999 || $num !~ /^\d+$/)
{
$num = "1";
}
else
{
$num++;
}
}
#######################
# Parse Form Subroutine
sub parse_form {
local($name,$value);
# Get the input
if($ENV{'CONTENT_LENGTH'})
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else
{
$buffer = $ENV{'QUERY_STRING'};
}
$change = $buffer;
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$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;
&place_emoticons;
if ($allow_html != 1 || $value eq 'subject') {
$value =~ s/<([^>]|\n)*>//g;
}
else {
unless ($name eq 'body') {
$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}); }
}
}
}
}
###############
sub place_emoticons
{
%emot = (' X( ','angry.gif',' :f ','flirt.gif',' :x ','dead.gif',' :( ','frown.gif',' :h ','cool.gif',' :i ','idea.gif'," \:\) ",'smile.gif',' ;) ','wink.gif',' :l ','hrmpf.gif',' :o ','redface.gif',' :00 ','look.gif',' :p ','tounge.gif',' :q ','quest.gif',' :r ','shame.gif',' :D ','biggrin.gif',' :e ','supergrin.gif',' :)) ','bigsmile.gif');
foreach $es (keys %emot)
{
$fn = $emot{$es};
$es =~ s/\)/\&clspart\;/g;
$value =~ s/\)/\&clspart\;/g;
$es =~ s/\(/\&opnpart\;/g;
$value =~ s/\(/\&opnpart\;/g;
$value =~ s/$es/\/g;
$value =~ s/\&clspart\;/\)/g;
$value =~ s/\&opnpart\;/\(/g;
}
}
###############
# Get Variables
sub get_variables
{
if ($FORM{'fct'})
{
$fct = $FORM{'fct'};
}
if ($FORM{'psw'})
{
$adminpass = "$FORM{'psw'}";
}
if($fct eq "updtocome")
{
#&coming_events;
&error("Les événements à venir ont été mis à jour");
}
if ($FORM{'doc'})
{
$doc = $FORM{'doc'};
}
if ($FORM{'dir'})
{
$dir = $FORM{'dir'};
}
if ($FORM{'rt'})
{
$rt = $FORM{'rt'};
}
if($fct eq "voirdocs" || $fct eq "voirdoc_dtls")
{
return;
}
if ($FORM{'addmailto'})
{
$addmailto = $FORM{'addmailto'};
$msgnmbr = $addmailto;
}
if ($FORM{'msgnmbr'})
{
$msgnmbr = $FORM{'msgnmbr'};
}
if ($FORM{'first_message'})
{
$first_message = $FORM{'first_message'};
}
if ($FORM{'viewnbr'})
{
$viewnbr = $FORM{'viewnbr'};
&view_all;
exit;
}
if ($FORM{'filter'})
{
$filter = $FORM{'filter'};
&filter;
&chkmailqueue;
exit;
}
if ($FORM{'followup'}) {
$followup = "1";
@followup_num = split(/,/,$FORM{'followup'});
$num_followups = @followups = @followup_num;
@lst_msgpop=@followup_num;
$last_message = pop(@lst_msgpop);
$origdate = "$FORM{'origdate'}";
$origname = "$FORM{'origname'}";
$origsubject = "$FORM{'origsubject'}";
}
else {
$followup = "0";
}
if ($FORM{'newsub'} || $followup eq "0")
{
$newsub = "oui";
}
if ($FORM{'artgfghv'})
{
$artgfghv = "$FORM{'artgfghv'}";
}
if ($FORM{'artgfgev'})
{
$artgfgev = "$FORM{'artgfgev'}";
}
if(($newsub || $FORM{'need_code'}) && ($artgfghv ne $artgfgev || !$artgfghv) && $fct ne "erase_msg" && $fct ne "showallfrom" && $fct ne "showlink" && !$addmailto && !$FORM{'mailfct'})
{
&error('
Entrez le bon code de confirmation pour valider votre message !
Le code de confirmation correspond aux quatre chiffres qui se trouvent tout juste au dessus du champ ou vous devez insérer le code
');
exit;
}
if ($FORM{'answto'})
{
$answrto = $FORM{'answto'};
}
if($FORM{'motdepasse'} && !$FORM{'nom'})
{
&error("Vous devez inscrire votre nom ou pseudonyme");
}
if($FORM{'nom'} && !$FORM{'motdepasse'})
{
&error("Vous devez inscrire votre mot de passe");
}
if($FORM{'motdepasse'})
{
$FORM{'name'} = $FORM{'nom'}."*".$FORM{'motdepasse'};
}
$nameprst = $FORM{'name'};
$nameprst =~ s/\s//g;
if ($FORM{'name'} && $nameprst)
{
if($nameprst =~/\*/)
{
$nametr = "$FORM{'name'}";
($name,$psw)= split(/\*/,$nametr);
$star=1;
}
else
{
$name = "$FORM{'name'}";
}
$name =~ s/"//g;
$name =~ s//g;
$name =~ s/>//g;
$name =~ s/\&//g;
$name =~ s/\s$//g;
$name =~ s/^\s//g;
}
elsif(!($msgnmbr) && ($fct ne "register"))
{
&error("Vous devez inscrire votre nom ou un pseudonyme");
}
if ($FORM{'registered_only'})
{
$registered_only = "$FORM{'registered_only'}";
}
if($fct eq "showallfrom")
{
&showallfrom;
exit;
}
if ($FORM{'email'} =~ /.*\@.*\..*/)
{
$email = "$FORM{'email'}";
}
if($FORM{'email'} && !($email))
{
&error("Votre adresse de courriel n\'a pas le bon format");
}
&check_registered;
if ($FORM{'addmail'} eq "on")
{
if(!($email))
{
&error("Vous devez spécifier une adresse de courriel");
}
$addmail = "on";
}
if ($FORM{'mail_list'})
{
$mail_list = $FORM{'mail_list'};
}
if ($FORM{'subject'})
{
$subject = "$FORM{'subject'}";
$subject =~ s/\&/\&\;/g;
$subject =~ s/"/\"\;/g;
}
elsif(!($msgnmbr) && ($fct ne "register")) {
&error("Vous devez spécifier un sujet");
}
if ($FORM{'fltval'})
{
$fltval = $FORM{'fltval'};
}
elsif(!($msgnmbr) && !($followup) && ($fct ne "register")) {
&error("Vous devez sélectionner la catégorie de sujet");
}
if ($FORM{'url'} =~ /.*\:.*\..*/ && $FORM{'url_title'}) {
$message_url = "$FORM{'url'}";
$message_url_title = "$FORM{'url_title'}";
}
if ($FORM{'img'} =~ /.*tp:\/\/.*\..*/) {
$message_img = "$FORM{'img'}";
}
if ($FORM{'body'})
{
$body = "$FORM{'body'}";
$body =~ s/\cM//g;
$body =~ s/\n\n/
/g;
$body =~ s/\n/ /g;
$body =~ s/<//g;
$body =~ s/"/"/g;
}
elsif(!($msgnmbr) && ($fct ne "register")) {
&error("Vous devez inscrire un message");
}
if($FORM{'photo1'} ne "none")
{
$photo1 = "$FORM{'photo1'}";
}
if($FORM{'photo2'} ne "none")
{
$photo2 = "$FORM{'photo2'}";
}
if($FORM{'photo3'} ne "none")
{
$photo3 = "$FORM{'photo3'}";
}
&insert_photos;
if ($quote_text == 1)
{
$hidden_body = "$body";
$hidden_body =~ s/</g;
$hidden_body =~ s/>/>/g;
$hidden_body =~ s/"/"/g;
}
($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","Décembre");
$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);
}
$cookies=$ENV{'HTTP_COOKIE'};
@couples=split(/\; /,$cookies);
foreach $couple (@couples)
{
($cook_name,$cook_val)=split(/=/,$couple);
$cookies{$cook_name}=$cook_val;
}
$ft=$cookies{"ft"};
if(!($ft))
{
$ft = "nul";
}
}
####################
sub checkpsw
{
foreach $ps (@passwords)
{
if($adminpass eq $ps)
{
$pass =1;
}
}
if(!$pass)
{
&error("Mauvais mot de passe");
}
}
###########
sub insert_photos
{
if($photo1)
{
if($body =~/\[photo1\]/)
{
$body =~ s/\[photo1\]/\/;
}
else
{
$body = "$body"." ";
}
}
if($photo2)
{
if($body =~/\[photo2\]/)
{
$body =~ s/\[photo2\]/\/;
}
else
{
$body = "$body"." ";
}
}
if($photo3)
{
if($body =~/\[photo3\]/)
{
$body =~ s/\[photo3\]/\/;
}
else
{
$body = "$body"." ";
}
}
}
################
sub check_banned
{
open(MAIN,"$filter_dir/banned_subject_equal.txt") || die $!;
@banned_subject_equal = ;
close(MAIN);
open(MAIN,"$filter_dir/banned_subject_contain.txt") || die $!;
@banned_subject_contain = ;
close(MAIN);
open(MAIN,"$filter_dir/banned_url_contain.txt") || die $!;
@banned_url_contain = ;
close(MAIN);
open(MAIN,"$filter_dir/block_ips.txt") || die $!;
@banned_ips = ;
close(MAIN);
open(MAIN,"$filter_dir/banned_body_contain.txt") || die $!;
@banned_body_contain = ;
close(MAIN);
open(MAIN,"$filter_dir/banned_body_equal.txt") || die $!;
@banned_body_equal = ;
close(MAIN);
open(MAIN,"$filter_dir/banned_followup_contain.txt") || die $!;
@banned_followup_contain = ;
close(MAIN);
open(MAIN,"$filter_dir/needregister_followup.txt") || die $!;
@needregister_followup = ;
close(MAIN);
$chk_followup = $FORM{'followup'};
@chk_followups = split(/\,/,$chk_followup);
$host_addr=$ENV{'REMOTE_ADDR'};
$chk_body = $body;
$chk_body =~ tr/A-Z/a-z/;
$chk_subject = $subject;
$chk_subject =~ tr/A-Z/a-z/;
$chk_message_url = $message_url;
$chk_message_url =~ tr/A-Z/a-z/;
foreach $bv (@banned_subject_equal)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
if($chk_subject eq $bv)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
foreach $bv (@banned_subject_contain)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
if($chk_subject =~ /$bv/)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
foreach $bv (@banned_url_contain)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
if($chk_message_url =~ /$bv/)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
foreach $bv (@banned_ips)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
if($host_addr =~ /$bv/)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
foreach $bv (@banned_body_contain)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
if($chk_body =~ /$bv/)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
foreach $bv (@banned_body_equal)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
$bv =~ s/<([^>]|\n)*>//g;
if($chk_body eq $bv)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
foreach $bv (@banned_followup_contain)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
foreach $cfl (@chk_followups)
{
if($cfl == $bv)
{
$banned_key=$bv;
&mail_banded;
&error("Il n\'est pas possible d\'ajouter ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
}
foreach $bv (@needregister_followup)
{
$bv =~ tr/A-Z/a-z/;
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
foreach $cfl (@chk_followups)
{
if($cfl == $bv && !($reg_usr) || ($cfl < 63773 && !($reg_usr)))
{
$banned_key=$bv;
&mail_banded;
&error("Vous devez avoir un nom enregistré pour soumettre une réponse à ce message. Contactez-nous si vous croyez qu\'il s\'agit d\'une erreur No. de référence:$banned_ref");
}
}
}
}
##############
sub check_hidden
{
open(MAIN,"$filter_dir/hide.txt") || die $!;
@hide = ;
close(MAIN);
$chk_followup = $FORM{'followup'};
@chk_followups = split(/\,/,$chk_followup);
foreach $bv (@hide)
{
$bv =~ s/\n//g;
$bv =~ s/\s\n$//g;
$bv =~ s/\r//g;
foreach $cfl (@chk_followups)
{
if($cfl == $bv)
{
$addnouveautes = 0;
$hide = 1;
}
}
}
}
################
sub write_ip
{
$host_addr=$ENV{'REMOTE_ADDR'};
open(MAIN,">>$basedir/ips.txt") || die $!;
print MAIN "$num - $host_addr\; id=$ft\n";
close(MAIN);
}
#################
sub write_name
{
open(MAIN,"$basedir/names.txt") || die $!;
@allnames=;
close(MAIN);
open(MAIN,">$basedir/names.txt") || die $!;
foreach $nml (@allnames)
{
($tx,$nms) = split(/=/,$nml);
$nms =~ s/\n//g;
if($tx == $ft)
{
if(!($nms =~ /$name/))
{
$nms = $nms.";".$name;
}
$prntnn = 1;
}
print MAIN "$tx=$nms\n";
}
if(!($prntnn))
{
print MAIN "$ft=$name\n";
}
close(MAIN);
}
#################
sub putfltval
{
open(MAIN,">>$basedir/flt_$fltval.txt") || die $!;
print MAIN "$num\n";
close(MAIN);
++$tster;
open(MAIN,">>$basedir/fltdebug.txt") || die $!;
print MAIN "$num|$fltval|$newsub|$tster\n";
close(MAIN);
}
##############
sub write_ini_stats
{
open(MAIN,">$stats_dir/$num.js") || die $!;
flock(MAIN, 2);
print MAIN "//0\n";
print MAIN "document.write(\'$nmbr\')\;";
close(MAIN);
}
############
sub mk_page
{
open(MAIN,"$basedir/$addmailtp") || die $!;
@main = ;
close(MAIN);
print "Content-type: text/html\n\n";
foreach $tl (@main)
{
if($tl =~ //)
{
print "";
}
else
{
print "$tl";
}
}
}
###########
sub enregistrer
{
$nmtoreg = $FORM{'nom'};
$nmtoreg =~ tr/A-Z/a-z/;
$nmtoreg =~ s/\s$//g;
$nmtoreg =~ s/^\s//g;
$motdepasse = $FORM{'motdepasse'};
if(!$nmtoreg)
{
&error("Vous devez entrer un nom à enregistrer !");
}
if(!($motdepasse))
{
&error("Vous devez entrer un mot de passe !");
}
open(MAIN,"$basedir/$reg_names") || die $!;
@rnms = ;
close(MAIN);
if($nmtoreg eq "liste" && $motdepasse eq "admin")
{
print "Content-type: text/html\n\n";
}
foreach $rninfs (@rnms)
{
($rname,$rpsw,$remail,$sh_email) = split(/\|/,$rninfs);
if($rname eq $nmtoreg)
{
$takennm=1;
}
++$nrnms;
if($nmtoreg eq "liste" && $motdepasse eq "admin")
{
print "$rname - $rpsw - $remail - $sh_email ";
}
}
if($takennm && $nmtoreg ne "liste")
{
&error("Le nom $nmtoreg est déjà réservé ! $nrnms noms ont déjà été reservés");
}
if($nmtoreg eq "liste" && $motdepasse eq "admin")
{
print "******** $nrnms noms enregistrés";
exit;
}
if($nmtoreg eq "nombre")
{
&error("$nrnms noms enregistrés");
}
++$nrnms;
open(MAIN,">>$basedir/$reg_names") || die $!;
flock(MAIN, 2);
print MAIN "$nmtoreg|$FORM{'motdepasse'}|$email|$FORM{'showmail'}\n";
close(MAIN);
print "Content-type: text/html\n\n";
print "
";
print "Le nom $nmtoreg a été enregistré avec succès ! ";
print "Mot de passe: $FORM{'motdepasse'} ";
print "Courriel: $email ";
if($FORM{'showmail'} eq "oui")
{
print "Votre courriel sera lié à votre nom lors d\'ajout de messages
";
}
else
{
print "Votre courriel ne sera pas lié à votre nom lors d\'ajout de messages $nrnms noms ont déjà été reservés
";
}
print "
Comment utiliser votre nom enregistré ?
Lorsque vous ajoutez un message, entrez (sans espaces !) votre nom suivit d\'une étoile (*) suivit de votre mot de passe
\n";
print "
Exemple:
Si votre nom enregistré est François et votre mot de passe est pagaie, vous devez entrer:
\n";
print "
Nom:
\n";
print "
Vous n\'avez pas à\; entrer votre courriel qui sera ajouté\; automatiquement si vous avez sé\;lectionné\; "\;Afficher votre courriel"\; lors de l\'enregistrement de votre nom.
\n";
print "
ATTENTION: Utilisez votre surnom*motdepasseUNIQUEMENT sur le forum puisque si vous l\'utilisiez ailleurs sur le site, l\'information n\'é\;tant pas traité\;, tous verraient apparaitre surnom*motdepasse à\; la place de votre nom et connaî\;traient alors votre pré\;cieux motdepasse !
\n";
exit;
}
###########
sub check_registered
{
use DBI;
$dbh = DBI->connect("DBI:mysql:stephm69_kmnmdatas:localhost","stephm69_kmnm","access") || die "Connect failed: $DBI::errstr\n";
$chckname = $name;
&removebadchar($chckname);
$chckname = $string;
$reg_gif="no_reg.gif";
$query = "SELECT * FROM users WHERE user='$chckname'";
$sth = $dbh->prepare($query);
$result = $sth->execute;
if($datas = $sth->fetchrow_hashref)
{
$remail = $datas->{email};
$rpsw = $datas->{motdepasse};
$sh_email = $datas->{showmail};
if($psw eq $rpsw)
{
if($chckname eq "stephane")
{
$registered = "$name";
$regiusr_email = $remail;
$reg_gif="reg3.gif";
}
else
{
$registered = "$name";
$regiusr_email = $remail;
$reg_gif="reg2.gif";
}
$email =$remail;
$reg_usr=1;
}
else
{
&error("Le nom $name est réservé et vous n\'avez pas soumis le bon mot de passe");
}
}
if(!($reg_usr))
{
$query = "SELECT * FROM old_users WHERE user='$chckname'";
$sth = $dbh->prepare($query);
$result = $sth->execute;
if($datas = $sth->fetchrow_hashref)
{
$remail = $datas->{email};
$rpsw = $datas->{motdepasse};
$sh_email = $datas->{showmail};
if($psw eq $rpsw)
{
if($sh_email eq "oui")
{
$registered = "$name";
$regiusr_email = $remail;
}
else
{
$registered = "$name";
}
$regiusr_email = $remail;
$reg_gif="reg.gif";
$email =$remail;
$reg_usr=1;
}
else
{
&error("Le nom $name est réservé et vous n\'avez pas soumis le bon mot de passe");
}
}
}
if(!($reg_usr) && $star)
{
&error("Le surnom $chckname et le mot de passe $psw ne sont pas enregistrés ou n\'utilisez pas le caractère * dans votre surnom");
}
}
############
sub show_alldocs
{
$prnt = 0;
$bgcolor ="eeeeee";
if($dir)
{
$fldocsdir = "$docsdir/$dir";
}
else
{
$fldocsdir = "$docsdir";
}
print "Content-type: text/html\n\n";
print "ADMIN: Tous les documents\n";
print "\n";
print <<"EOF";
EOF
print "";
print "
\n";
}
else
{
print $tl;
}
}
}
#################################
sub increment_num {
open(NUM,">$basedir/$datafile") || die $!;
flock(NUM, 2);
print NUM "$num";
close(NUM);
}
#############################
sub error {
$error = $_[0];
print "Content-type: text/html\n\n";
if ($error eq 'no_name') {
print "$title ERROR: No Name\n";
print "
ERROR: No Name
\n";
print "You forgot to fill in the 'Name' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.
\n";
print "You forgot to fill in the 'Subject' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.
\n";
print "You forgot to fill in the 'Message' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.