#!/usr/bin/perl

require "set.pl";
$in{referer} = "rudean";
&getinput;
&printhead;

open(FILE, "config.dat"); $a = @config = <FILE>; close FILE; for ($i=0; $i<$a; $i++) { chomp($config[$i]); }

if (($in{password} eq "") || ($in{username} eq "")) {
&showlogin;
}
if (-e "$config[7]/$in{username}") {
@USER = getfile("$config[7]/$in{username}");
open(FILE, "$config[7]/$in{username}.list") or dienice("Couldnt open $filename: $!");
@URLz = <FILE>;
close FILE;
}
else { &showlogin; }
if ($in{password} ne $USER[1]) {
&showlogin;
}
if ($in{a} eq "edit") {
@user = ($in{username}, $in{pword}, "-", $USER[3], $USER[4], $USER[5], $USER[6], $USER[7], $USER[8], $in{email}, $USER[10], $USER[11], $USER[12], $USER[13], $USER[14], $USER[15], $USER[16], $USER[17], $in{pause});
writefile("$config[7]/$in{username}", @user);
writefile("$config[7]/$in{username}.list", $in{urlz});
if ($in{password} ne $in{pword}) {
$in{referer} = $in{username};
$text=<<d00der;
<b><p align="center">&nbsp;</p></b>
<p align="center"><b><font size="3">Пароль изменен!</font></b></p><b>
<p align="center"><font color="#000000">Войдите в систему</font> <a HREF=member.cgi>заново.</a>
&nbsp;</p><p align="center"><br></p>

d00der
reptem($text);
}
}
if ($USER[18] eq "yes") {
$pausetext = '<INPUT TYPE=RADIO NAME="pause" VALUE="yes" CHECKED>да<BR><INPUT TYPE=RADIO NAME="pause" VALUE="no">нет';
}
else {
$pausetext = '<INPUT TYPE=RADIO NAME="pause" VALUE="yes">да<BR><INPUT TYPE=RADIO NAME="pause" VALUE="no" CHECKED>нет';
}        
$left = $USER[3] - $USER[4];
$text=<<d00der;
<H1 align="center"><font size="3">Информация
пользователя <font color="#0000FF">$in{username}</font></font></H1>
<FORM METHOD="POST"><div align="center"><center>
<TABLE width="516"><TR><TD width="238">Логин</TD>
<TD width="264">$in{username}</TD></TR><TR><TD width="238">Пароль</TD>
<TD width="264"><INPUT NAME="pword" VALUE="$in{password}" size="20"></TD></TR>
<TR><TD width="238">E-mail</TD>
<TD width="264"><INPUT NAME="email" VALUE="$USER[9]" size="20"></TD></TR>
<tr><TD width="238">Приостановить показ<br>вашего сайта?</TD>
<TD width="264">$pausetext</TD></TR>
<TR><TD width="238">Ваши сайты (по одному в строчку) через http://</TD>
<TD width="264"><TEXTAREA NAME="urlz" COLS="35" ROWS="4">@URLz</TEXTAREA></TD></TR>
<TR><TD colspan="2" align="center" width="508"><INPUT TYPE=HIDDEN NAME="a" VALUE="edit">
<INPUT TYPE=HIDDEN NAME="password" VALUE="$in{password}">
<INPUT TYPE=HIDDEN NAME="username" VALUE="$in{username}"><INPUT TYPE="Submit" NAME="Submit" VALUE="Р е д а к т и р о в а т ь"></TD>
</TR></TABLE></center></div></FORM>
<FORM METHOD=POST ACTION=member.cgi>
<p align="center"><INPUT TYPE=HIDDEN NAME="password" VALUE="$in{password}">
<INPUT TYPE=HIDDEN NAME="username" VALUE="$in{username}">
<INPUT TYPE="Submit" NAME="Submit" VALUE="Главное меню"></FORM>

d00der
reptem($text);

sub showlogin {
$text=<<d00der;

<h1 align="center"><font size="3">Вход в систему</font></h1>
<form METHOD="POST" ACTION="member.cgi"><div align="center">
<center><table><tr><td>Логин</td><td><input TYPE="TEXT" NAME="username" size="20"></td>
</tr><tr><td>Пароль</td><td><input TYPE="PASSWORD" NAME="password" size="20"></td>
</tr><tr><td></td><td><input TYPE="Submit" NAME="Submit" VALUE="В о й т и"></td>
</tr></table></center></div>
<h6 align="center"><font size="3">Забыли&nbsp; пароль? Нажмите</font>
<a HREF="forgot.cgi"><font size="3">здесь</font></a></h6>
</form>

d00der
reptem($text);
}
sub reptem {
my($text) = @_;
open(TEMP, "html.txt");
@TE = <TEMP>;
close TEMP;
$temp = join('',@TE);
$temp =~ s/%PLACE%/$text/;
print "$temp";
exit;
}
