#!/usr/bin/perl
require "set.pl";
&getinput;
&printhead;
open(FILE, "config.dat"); @config = <FILE>; close FILE; chomp(@config);
if ($in{password} ne $config[1]) { &showlogin; }
if ($in{submit} eq "submit") {
if ($in{to} eq "user") {
@USER = getfile("$config[7]/$in{username}");
push(@email, $USER[9]);
}
if ($in{to} eq "all") {
opendir(DATA, "$config[7]");
@DB = readdir(DATA);
closedir (DATA);
foreach $db (@DB) {
if ($db =~ /[^a-zA-Z0-9]/) { next; }
@USER = getfile("$config[7]/$db");
push(@email, $USER[9]);
}
}
foreach $email (@email) {
&sendmail($email, $config[16], $in{subject}, $in{message});
}
print "<B>Сообщение отправлено</B>";
exit;
}
sub showlogin {
print<<d00der;
<FORM METHOD="POST">
<TABLE><TR><TD>Пароль администратора:</TD>
<TD><INPUT TYPE="PASSWORD" NAME="password"></TD></tr><TR><TD></TD>
<TD><INPUT TYPE="Submit" NAME="Submit" VALUE="Войти"></TD></tr>
</TABLE></FORM>
d00der
exit;
}
print<<d00der;
<FORM ACTION="mail.cgi" METHOD="post">
<INPUT TYPE=HIDDEN NAME="password" VALUE="$in{password}">
<CENTER><P ALIGN=CENTER><TABLE CELLPADDING="2" CELLSPACING="0" BORDER="0">
<TR><TD VALIGN=TOP><P>Кому?</TD><TD VALIGN=TOP><P>
<INPUT TYPE=RADIO NAME="to" VALUE="all">Всем <INPUT TYPE=RADIO NAME="to" VALUE="user">Пользователю
<INPUT TYPE=TEXT NAME="username" SIZE="20" MAXLENGTH="256"></TD>
</TR><TR><TD VALIGN=TOP><P>Тема</TD><TD VALIGN=TOP><P>
<INPUT TYPE=TEXT NAME="subject" SIZE="20" MAXLENGTH="256"></TD>
</TR><TR><TD VALIGN=TOP><P>Сообщение</TD><TD VALIGN=TOP><P>
<TEXTAREA NAME="message" COLS="50" ROWS="8"></TEXTAREA></TD>
</TR><TR><TD VALIGN=TOP></TD><TD VALIGN=TOP><P>
<INPUT TYPE=SUBMIT NAME="submit" VALUE="submit"></TD>
</TR></TABLE></FORM>
d00der
exit;
