HTML CSS PHP PERL

 

Web- . Perl- , , (. 9).

Web-, , , . (. 3) :

<input type=hidden name=lang value=english> 

<input type=hidden name=lang value=russian>

.

, .

 9.   
#!/usr/local/bin/perl
############################
# SCRIPT: POSTER.CGI       #
# (c) Michael Yevdokimov   #
############################
require cgi_lib.pl;
$PathList=../mlist; #      
$PathNews=../mnews; #       
$ReturnPage=index.html #,     
$mail_prog=/usr/sbin/sendmail; #    
$Title=News List; #  
$From=maillist\@mysite.ru; #  
$Website=www.mysite.ru; #    Subject
# Method Detection and Decoding
&Parse_Data;  #     / URL
$Lang=$CGI{lang};  #   (/) 
$User=$CGI{user_name}; #  
$Email=$CGI{user_email}; # email 
$Flag=$CGI{flag}; #       
$Command=$CGI{command}; #   (send  )
if ($Lang eq english) {
	$db=userbase.eng; #    
        $nf=news.eng #   ( TXT)
} else {
        if ($Lang eq russian) {
        	$db=userbase.rus;    
		$nf=news.rus;   ( TXT)
        } else {
		&Print_Head; #  print Content-type:text/html\n\n;
		print <H3>ATTENTION! ERROR OCCURED!<H3>\n;
		print PRESS <A HREF=\$ENV{HTTP_REFERER}\>[BACK]</A> TO RETURN!\n;
		exit(0);                       
        }
}
if ($Command eq send) { #    
 	if ($db eq userbase.eng) {
		#Post English News
		&Post_News($User,$Email);
	} else {
		#Post Russian News
		&Post_News($User,$Email);
	}	
}
#   flag
if ($Flag eq eng_yes) { #   
	&Check_Email; #     email
	&Add_Record($Path,$db); #    . 
	&Print_Head; 
	print Your records were added to database

\n; print Click <a href=\/$ReturnPage\>here</a> to return...\n; exit(0); } else { if ($Flag eq rus_yes) { &Check_Email; &Add_Record; &Print_Head; print

\n; print <a href=\/$ReturnPage\></a> ...\n; exit(0); } else { } } # if ($db eq userbase.eng) { # &Print_Head; print <H2><b>News List Registration</b></H2>\n; print <PRE>\n; print <FORM METHOD=\GET\ ACTION=\/cgi-bin/poster.cgi\>\n; print <input type=hidden name=lang value=english><br>\n; print Your Name: <input type=text name=user_name size=15 value=\$User\><br>\n; print Your Email: <input type=text name=user_email size=15 value=\$Email\><br>\n; # flag, # : flag # , print <input type=hidden name=flag value=eng_yes><br>\n; print <input type=submit value=\ Correct \> ; print <input type=reset value=\ Incorrect \><br>\n; print </FORM>\n; print </PRE>\n; } else { # &Print_Head; print <H2><b> </b> </H2>\n; print <PRE>\n; print <FORM METHOD=\GET\ ACTION=\/cgi-bin/poster.cgi\>\n; print <input type=hidden name=lang value=russian><br>\n; print : <input type=text name=user_name size=15 value=\$User\><br>\n; print Email: <input type=text name=user_email size=15 value=\$Email\><br>\n; # flag (. ) print <input type=hidden name=flag value=rus_yes><br>\n; print <input type=submit value=\ \> ; print <input type=reset value=\\><br>\n; print </FORM>\n; print </PRE>\n; } sub Add_Record { # open (UB, >>$PathList/$db) || die (Error during adding a record $!); print UB join (::, $User, $Email), \n; close (UB); } sub Post_News { # # UB - open (UB, $PathList/$db) || die (Error during reading file $!); while (<UB>) { $line=$_; ($User, $Email) = split (/::/, $line); # email open (MAIL, |$mail_prog $Email); print MAIL From: $From\n; print MAIL Reply-to: $From\n; print MAIL Subject: $Title from $Website\n; print MAIL \n\n; print MAIL Dear $User,\n\n; # open (NF, $PathNews/$nf) || die (Error during reading file $!); while (<NF>) { print MAIL $_; # email } close (NF); # print MAIL \n\nThis script was created by Michael Yevdokimov\n; print MAIL Developers website: http://www.basicnet.sonnet.ru\n; print MAIL \n\n; close (MAIL); } close (UB); &Print_Head; print PRESS <A HREF=\/$ReturnPage\>[BACK]</A> TO RETURN!\n; exit(0); } sub Check_Email { # email &Err_Msg; if ($Email !~ /.+\@.+\..+/) { &Print_Head; &Err_Msg; print $ErrMsg\n; #print Location: $ENV{HTTP_REFERER}\n\n; exit(0); } #exit(0); } sub Err_Msg { # email if ($Lang eq english) { $ErrMsg=<B>ATTENTION! ERROR OCCURED!</B><P>\n <I>Email: <B>$Email</B> which you have entered is incorrect!</I><P>\n <B>PRESS [BACK] TO RETURN<B>\n; return $ErrMsg; } else { $ErrMsg=<B>! !</B><P>\n <I>Email: <B>$Email</B>, !</I><P>\n <B> [BACK] </B>\n; return $ErrMsg; } }

| |

© 2000- NIV