#!/usr/bin/perl
#############################################################
##            ExchangeVisits    Version  3.00              ##
##            February 2003  Ust-Nera  Russia              ##
##            All rights  ScriptZaWM&RuScript              ##
##            Web  http://www.script.zawm.biz              ##
##            Support scripts script@zawm.biz              ##
#############################################################
require "config.pl";
require "allhtml.pl";
print "Content-Type: text/html\n\n";
my $locks_dir = './tmp/';
if($ENV{'REQUEST_METHOD'} eq 'GET'){$query=$ENV{'QUERY_STRING'}}
elsif($ENV{'REQUEST_METHOD'} eq 'POST'){sysread(STDIN,$query,$ENV{'CONTENT_LENGTH'})}
@formfields=split(/&/,$query);
sub urldecode{local($val)=@_;
$val=~s/\+/ /g;$val=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $val;}
foreach (@formfields){chomp($_);
($f_n,$f_v)=split(/=/,$_);
$f_n=&urldecode($f_n);
$f_v=&urldecode($f_v);
if($f_n=~/^d/ && $f_v ne '1'){$f_v = 0}
if($f_n eq 'move'){push(@td,$f_v)}else{$in{$f_n}=$f_v}}
@month = ("01", "02", "03", "04", "05", "06", "07","08", "09", "10", "11", "12");
($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek,
$DayOfYear, $IsDST) = localtime(time);
$Year = $ShortYear + 1900;$Year=~s/^..//;
$Date = "$DayInMonth.$month[$Month].$Year<time>$Hours:$Minutes:$Seconds";
$today = "$DayInMonth.$month[$Month].$Year";
# Проверка на наличие IP в базе блокированных пользователей
open (IPusers, "ipusers.txt");
@banlist = <IPusers>;
close(IPusers);
($this1,$this2,$this3,$this4) = split(/\./,$ENV{REMOTE_ADDR});
foreach $banlist (@banlist) {
($ip1,$ip2,$ip3,$ip4,$chop) = split(/\./,$banlist);
if ($this1 == $ip1) {
if ($this2 == $ip2) {
if ($this3 == $ip3) {
if ($this4 == $ip4) {
print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;URL=$htmlurl/ban.htm\">\n\n";
}}}
}}
# Конец проверки
&html_start;
print qq~~;
open(PWD,"userdat.pl");
if ($flock eq "1")
{flock(PWD, 2);}
@users = <PWD>;
close(PWD);chomp(@users);
foreach (@users){($login,$pwd,$id,$status,$dr,$dc) = split(/\|/,$_);
if($in{'user'} eq $login){$userid=$id;$password{$login}=$pwd;$exist='da';$ST=$status;}
if($in{'to'} eq $login){$to = '1';$toid = $id}}
$u = $in{'user'};
$error="<br><br><p align=center><font size=4>Пользователя $in{'user'} не существует.<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p></font></p>";
if($exist eq 'da'){$error = '<br><p align=center><font size=4>Неправильный пароль.<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br></font></p>'}
if($ST eq 'B'){$error = '<br><p align=center><font size=4>Вами нарушены правила работы в системе.<br>Ваш аккаунт заблокирован администратором.<br>
</font>Для разблокировки Вашего аккаунта свяжитесь с администратором.<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
<p>&nbsp;</p><p>&nbsp;</p><br></p>'}
if($password{$u} eq $in{'pwd'} && $exist eq 'da' && $ST eq 'A'){
if($in{'action'} eq 'stat'){
#### Запись в статистику ####
open(TSTAT,"./system/today.stat");
if ($flock eq "1")
{flock(TSTAT, 2);}
@tstat = <TSTAT>;
close(TSTAT);chomp(@tstat);
open(TSTAT,">./system/today.stat");
if ($flock eq "1")
{flock(TSTAT, 2);}
foreach (@tstat){
($login,$id,$dc) = split(/\|/,$_);
if($in{'user'} eq $login){print TSTAT "$login|$userid|$Date\n"}else{print TSTAT "$_\n";}}
close(TSTAT);
# Конец
open(STAT,"./users/$userid/stat.user");
if ($flock eq "1")
{flock(STAT, 2);}
@stat = <STAT>;
close(STAT);chomp(@stat);
open(WMUSER,"./users/$userid/wm.user");
if ($flock eq "1")
{flock(WMUSER, 2);}
@wmuser = <WMUSER>;
close(WMUSER);chomp(@wmuser);
if ($wmuser[0] eq ""){$wmuser[0]="0";}
($d8,$n8)=split(/\|/,$stat[8]);
if($today eq $d8){$stat[8]=$n8}else{$stat[8]=0}
($d9,$n9)=split(/\|/,$stat[9]);
if($today eq $d9){$stat[9]=$n9}else{$stat[9]=0}
($d10,$n10)=split(/\|/,$stat[10]);
if($today eq $d10){$stat[10]=$n10}else{$stat[10]=0}
$refsumm=$stat[13]+$stat[15]+$stat[17];
$refearn=$stat[14]+$stat[16]+$stat[18];
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bgcolor="#F0F0F0" bordercolorlight="#CCCCFF">
<tr><td width="100%" align="center"><b><font size="2">С т а т и с т и к а
&nbsp;&nbsp;п о л ь з о в а т е л я&nbsp;&nbsp;<font color="#000080">$in{'user'}
</font></font></b></td></tr></table><br><div align="center"><center>
<table border="1" width="95%" cellpadding="0" cellspacing="0" bordercolordark="#808080" bordercolorlight="#CCCCFF">
<tr><td width="100%" colspan="2" align="center" bgcolor="#D8D8D8"><b>
<font face="Arial" size="2">Ваша статистика</font></b></td></tr><tr><td width="80%">
&nbsp;Ваш баланс WM</td><td width="20%"><font color="#000080">&nbsp; $wmuser[0]</font></td>
</tr><tr><td width="80%">&nbsp;Кредитов у вас на основном счету</td><td width="20%">
<font color="#000080">&nbsp; $stat[1]</font></td></tr><tr><td width="80%">
<font color="#000080">&nbsp;</font>Кредитов на банковском счету</td><td width="20%">
<font color="#000080">&nbsp; $stat[25]</font></td></tr><tr><td width="80%">&nbsp;Кредитов
продаваемых на бирже</td><td width="20%">
<font color="#000080">&nbsp; $stat[22]</font></td></tr><tr><td width="80%">
&nbsp;Вами заработано кредитов</td><td width="20%"><font color="#000080">
&nbsp; $stat[2]</font></td></tr><tr><td width="80%">
&nbsp;Вами куплено кредитов</td><td width="20%"><font color="#000080">&nbsp;
$stat[23]</font></td></tr><tr><td width="80%">&nbsp;Вами потрачено кредитов</td>
<td width="20%"><font color="#000080">&nbsp; $stat[5]</font></td></tr><tr><td width="80%">
&nbsp;Вами продано кредитов</td>
<td width="20%"><font color="#000080">&nbsp; $stat[20]</font></td></tr><tr><td width="80%">
&nbsp;Получено за чтение писем&nbsp;</td><td width="20%"><font color="#000080">
&nbsp; $stat[21]</font></td></tr><tr><td width="80%">&nbsp;У вас вcего в системе рефералов
&nbsp;</td><td width="20%"><font color="#000080">&nbsp; $refsumm</font></td>
</tr><tr><td width="80%">&nbsp;- рефералов 1 уровня</td><td width="20%">
<font color="#000080">&nbsp; $stat[13]</font></td></tr><tr><td width="80%">
&nbsp;- рефералов 2 уровня</td><td width="20%"><font color="#000080">&nbsp;
$stat[15]</font></td></tr><tr><td width="80%">&nbsp;- рефералов 3 уровня</td>
<td width="20%"><font color="#000080">&nbsp; $stat[17]</font></td></tr><tr>
<td width="80%">&nbsp;Рефералами заработано кредитов</td><td width="20%">
<font color="#000080">&nbsp; $refearn</font></td></tr><tr>
<td width="80%">&nbsp;Вами получено кредитов</td><td width="20%">
<font color="#000080">&nbsp; $stat[12]</font></td></tr><tr><td width="80%">
&nbsp;Вами переведено кредитов</td><td width="20%"><font color="#000080">&nbsp;
$stat[11]</font></td></tr><tr><td width="80%">
&nbsp;Конвертировано кредитов в WM</td><td width="20%"><font color="#000080">&nbsp;
$stat[24]</font></td></tr><tr><td width="100%" colspan="2" bgcolor="#F0F0F0" align="center">
<b><font face="Arial" size="2">Ссылка для привлечения рефералов</font></b></td></tr>
<tr><td width="100%" colspan="2" align="center"><a href="$cgiurl/reg.cgi?refid=$in{'user'}" target="_blank">
<font color="#000080" size="2" face="Arial">$cgiurl/reg.cgi?refid=$in{'user'}</font>
</a></td></tr></table></center></div>
~;
}elsif($in{'action'} eq 'urls'){
if($in{'new'} eq'url'){
open(URLID,"./urls/urlid.txt");
if ($flock eq "1")
{flock(URLID, 2);}
$urlid = <URLID>;
close(URLID);chomp($urlid);
$urlid++;
open(URLID,">./urls/urlid.txt");
if ($flock eq "1")
{flock(URLID, 2);}
print URLID $urlid;
close(URLID);
if($in{'status'} ne '1'){$in{'status'} = '0'}
if($in{'serf'} ne '1'){$in{'serf'} = '0'}
if($in{'autoserf'} ne '1'){$in{'autoserf'} = '0'}
if($in{'maxday'} eq ''){$in{'maxday'} = '0'}
if($in{'ipday'} eq ''){$in{'ipday'} = '0'}
open (LOCK, "./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
@lock = <LOCK>;
close (LOCK);
chomp(@lock);
if ($lock[0]=='1') {
open (LOCK, ">./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "0";
close (LOCK);
open(URLS,">>./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
print URLS "$userid\_$urlid|$in{'status'}|$in{'http'}|$in{'serf'}|$in{'autoserf'}|$in{'maxday'}|$in{'ipday'}|$in{'cat'}|\n";
close(URLS);
# Записываем сайт в файл пользователя
open(URLS,">>./urls/$userid.urls");
if ($flock eq "1")
{flock(URLS, 2);}
print URLS "$userid\_$urlid|$in{'title'}|";
print URLS "$in{'d1_0'}x$in{'d1_1'}x$in{'d1_2'}x$in{'d1_3'}x$in{'d1_4'}x$in{'d1_5'}x$in{'d1_6'}x$in{'d1_7'}x$in{'d1_8'}x$in{'d1_9'}x$in{'d1_10'}x$in{'d1_11'}x$in{'d1_12'}x$in{'d1_13'}x$in{'d1_14'}x$in{'d1_15'}x$in{'d1_16'}x$in{'d1_17'}x$in{'d1_18'}x$in{'d1_19'}x$in{'d1_20'}x$in{'d1_21'}x$in{'d1_22'}x$in{'d1_23'}"; # targeting
print URLS "x$in{'d2_0'}x$in{'d2_1'}x$in{'d2_2'}x$in{'d2_3'}x$in{'d2_4'}x$in{'d2_5'}x$in{'d2_6'}x$in{'d2_7'}x$in{'d2_8'}x$in{'d2_9'}x$in{'d2_10'}x$in{'d2_11'}x$in{'d2_12'}x$in{'d2_13'}x$in{'d2_14'}x$in{'d2_15'}x$in{'d2_16'}x$in{'d2_17'}x$in{'d2_18'}x$in{'d2_19'}x$in{'d2_20'}x$in{'d2_21'}x$in{'d2_22'}x$in{'d2_23'}"; # targeting
print URLS "x$in{'d3_0'}x$in{'d3_1'}x$in{'d3_2'}x$in{'d3_3'}x$in{'d3_4'}x$in{'d3_5'}x$in{'d3_6'}x$in{'d3_7'}x$in{'d3_8'}x$in{'d3_9'}x$in{'d3_10'}x$in{'d3_11'}x$in{'d3_12'}x$in{'d3_13'}x$in{'d3_14'}x$in{'d3_15'}x$in{'d3_16'}x$in{'d3_17'}x$in{'d3_18'}x$in{'d3_19'}x$in{'d3_20'}x$in{'d3_21'}x$in{'d3_22'}x$in{'d3_23'}"; # targeting
print URLS "x$in{'d4_0'}x$in{'d4_1'}x$in{'d4_2'}x$in{'d4_3'}x$in{'d4_4'}x$in{'d4_5'}x$in{'d4_6'}x$in{'d4_7'}x$in{'d4_8'}x$in{'d4_9'}x$in{'d4_10'}x$in{'d4_11'}x$in{'d4_12'}x$in{'d4_13'}x$in{'d4_14'}x$in{'d4_15'}x$in{'d4_16'}x$in{'d4_17'}x$in{'d4_18'}x$in{'d4_19'}x$in{'d4_20'}x$in{'d4_21'}x$in{'d4_22'}x$in{'d4_23'}"; # targeting
print URLS "x$in{'d5_0'}x$in{'d5_1'}x$in{'d5_2'}x$in{'d5_3'}x$in{'d5_4'}x$in{'d5_5'}x$in{'d5_6'}x$in{'d5_7'}x$in{'d5_8'}x$in{'d5_9'}x$in{'d5_10'}x$in{'d5_11'}x$in{'d5_12'}x$in{'d5_13'}x$in{'d5_14'}x$in{'d5_15'}x$in{'d5_16'}x$in{'d5_17'}x$in{'d5_18'}x$in{'d5_19'}x$in{'d5_20'}x$in{'d5_21'}x$in{'d5_22'}x$in{'d5_23'}"; # targeting
print URLS "x$in{'d6_0'}x$in{'d6_1'}x$in{'d6_2'}x$in{'d6_3'}x$in{'d6_4'}x$in{'d6_5'}x$in{'d6_6'}x$in{'d6_7'}x$in{'d6_8'}x$in{'d6_9'}x$in{'d6_10'}x$in{'d6_11'}x$in{'d6_12'}x$in{'d6_13'}x$in{'d6_14'}x$in{'d6_15'}x$in{'d6_16'}x$in{'d6_17'}x$in{'d6_18'}x$in{'d6_19'}x$in{'d6_20'}x$in{'d6_21'}x$in{'d6_22'}x$in{'d6_23'}"; # targeting
print URLS "x$in{'d0_0'}x$in{'d0_1'}x$in{'d0_2'}x$in{'d0_3'}x$in{'d0_4'}x$in{'d0_5'}x$in{'d0_6'}x$in{'d0_7'}x$in{'d0_8'}x$in{'d0_9'}x$in{'d0_10'}x$in{'d0_11'}x$in{'d0_12'}x$in{'d0_13'}x$in{'d0_14'}x$in{'d0_15'}x$in{'d0_16'}x$in{'d0_17'}x$in{'d0_18'}x$in{'d0_19'}x$in{'d0_20'}x$in{'d0_21'}x$in{'d0_22'}x$in{'d0_23'}|0|0|0|\n"; # targeting
close(URLS);}}
open (LOCK, ">./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "1";
close (LOCK);
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#CCCCFF">
<tr><td width="100%" bgcolor="#F0F0F0" align="center"><font size="2"><b>В а ш
и&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; с а й т ы</b></font></td>
</tr></table><font size="2"><a href="javascript:document.forms.addsites.submit();">&nbsp;[
д о б а в и т ь ]</a></font>
<form method="POST" name="addsites">
<input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}">
<input type="hidden" name="urls" value="addsites">
</form>
~;
# Читаем из общей базы
open(URLS,"./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
@sites = <URLS>;
close(URLS);
chomp(@sites);
foreach (@sites){
($ids_urls,$status,$http,$serf,$auto,$maxday,$ipday,$cat) = split(/\|/,$_);
($Uids,$URLids) = split(/_/,$ids_urls);
if($userid eq $Uids){
if($status eq '1'){$statustxt = 'включен'}else{$statustxt = 'выключен'}
if($serf eq '1'){$advers = 'серфинге<br>'}
if($auto eq '1'){$advers = "$advers &nbsp;автосерфинге"}
if($serf ne '1' && $auto ne '1'){$advers = 'не рекламируется'}
# Читаем из базы пользователя
open(SITES,"./urls/$userid.urls");
if ($flock eq "1")
{flock(SITES, 2);}
@urls = <SITES>;
close(SITES);
chomp(@urls);
foreach (@urls){
($id_url,$title,$targ,$showed,$inserf,$inauto,$log) = split(/\|/,$_);
($Uid,$URLid) = split(/_/,$id_url);
if($URLids eq $URLid){
print qq~
<div align="center"><center><table border="1" cellspacing="0" cellpadding="0" width="95%" bordercolorlight="#CCCCFF"><tr><td width="100%" colspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td width="100%" bgcolor="#D8D8D8"><font size="2">&nbsp;$statustxt&nbsp;
I&nbsp; </font><font size="2" color="#800000">$title</font></td>
</tr></table></td></tr><center><tr><td width="31%">&nbsp;Адрес сайта</td>
<td width="69%"><font color="#000080">&nbsp;</font><a href="$http" target=_blank><font color="#000080">$http</font></a></td>
</tr><tr><td width="31%">&nbsp;Показан всего</td>
<td width="69%"> &nbsp;$showed </td></tr><tr><td width="31%">&nbsp;- в серфинге</td><td width="69%">&nbsp;$inserf </td></tr>
<tr><td width="31%">&nbsp;- в автосерфинге&nbsp;&nbsp;</td><td width="69%"> &nbsp;$inauto </td></tr><tr><td width="31%">&nbsp;Рекламируется&nbsp; </td>
<td width="69%">&nbsp;$advers</td></tr><tr><td width="31%">&nbsp;Лимит показов&nbsp;</td><td width="69%"> &nbsp;$maxday </td></tr><tr><td width="100%" colspan="2" align="center" bgcolor="#F0F0F0">
<font size="2"><a href="javascript:document.forms.rem$URLid.submit();">[ У д
а л и т ь ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:document.forms.conf$URLid.submit();">
[ Н а с т р о и т ь ]</a></font></td></tr></table></center></div>
<form name="rem$URLid" method="POST">
<input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}">
<input type="hidden" name="action" value="conf">
<input type="hidden" name="conf" value="del">
<input type="hidden" name="url" value="$URLid">
</form><form method="POST" name="conf$URLid">
<input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}">
<input type="hidden" name="action" value="conf">
<input type="hidden" name="url" value="$URLid">
</form>
~;
}}}
$advers = '';}}
if($in{'urls'} eq 'addsites'){
print qq~
<tr><td width="100%" align="center"></center>
<form method="POST"><div align="center"><center>
<table border="1" width="99%" cellspacing="0" cellpadding="0" bordercolorlight="#CCCCFF">
<tr><td colspan="2" height="15" align="center" bgcolor="#F0F0F0"><font size="2">
<b>Д о б а в л е н и е&nbsp;&nbsp;&nbsp; н о в о г о&nbsp;&nbsp;&nbsp; с а й т а</b></font></td></tr>
<tr><td colspan="2" height="15">&nbsp;<input type="checkbox" name="status" value="1" checked>сайт включен</td></tr>
<tr align="left" valign="middle"><td> &nbsp;Адрес сайта</td><td><input name="http" value="http://"></td></tr>
<tr align="left" valign="middle"><td> &nbsp;Название сайта</td><td><input name="title" value="Сайт"></td></tr>
<tr><td><p> &nbsp;Разрешить рекламировать сайт </td><td><p><input type=checkbox name="serf" value="1" checked>
в серфинге<br><input type=checkbox name="autoserf" value="1" checked>в автосерфинге</p></td></tr>
<tr><td> &nbsp;Делать в день не более </td><td><input name="maxday" value="1000"> 
показов </td><tr><td> &nbsp;Одному IP в день не более </td><td><input name="ipday" value="1">
показов </td>
<tr><td colspan="2" align="center" bgcolor="#F0F0F0"><font size="2">Таргетинг по времени&nbsp;</font></td></tr><tr align="center" valign="top">
<td colspan="2" bgcolor="#F0F0F0"><table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td><font size="2">Дни/Часы</font></td><td align="center"><font size="2">0</font></td>
<td align="center"><font size="2">1</font></td><td align="center"><font size="2">2</font></td>
<td align="center"><font size="2">3</font></td><td align="center"><font size="2">4</font></td>
<td align="center"><font size="2">5</font></td><td align="center"><font size="2">6</font></td>
<td align="center"><font size="2">7</font></td><td align="center"><font size="2">8</font></td>
<td align="center"><font size="2">9</font></td><td align="center"><font size="2">10</font></td>
<td align="center"><font size="2">11</font></td><td align="center"><font size="2">12</font></td>
<td align="center"><font size="2">13</font></td><td align="center"><font size="2">14</font></td>
<td align="center"><font size="2">15</font></td><td align="center"><font size="2">16</font></td>
<td align="center"><font size="2">17</font></td><td align="center"><font size="2">18</font></td>
<td align="center"><font size="2">19</font></td><td align="center"><font size="2">20</font></td>
<td align="center"><font size="2">21</font></td><td align="center"><font size="2">22</font></td>
<td align="center"><font size="2">23</font></td></tr><tr><td><font size="2">Понедельник</font></td>
<td><font size="2"><input type=checkbox name="d1_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d1_23" value="1" checked></font></td>
</tr><tr><td><font size="2">Вторник</font></td>
<td><font size="2"><input type=checkbox name="d2_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d2_23" value="1" checked></font></td>                    </tr>
<tr><td><font size="2">Среда</font></td>
<td><font size="2"><input type=checkbox name="d3_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d3_23" value="1" checked></font></td>                    </tr>
<tr><td><font size="2">Четверг</font></td>
<td><font size="2"><input type=checkbox name="d4_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d4_23" value="1" checked></font></td>                    </tr>
<tr><td><font size="2">Пятница</font></td>
<td><font size="2"><input type=checkbox name="d5_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d5_23" value="1" checked></font></td>                    </tr>
<tr><td><font size="2">Суббота</font></td>
<td><font size="2"><input type=checkbox name="d6_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d6_23" value="1" checked></font></td>                    </tr>
<tr><td><font size="2">Воскресенье</font></td>
<td><font size="2"><input type=checkbox name="d0_0" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_1" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_2" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_3" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_4" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_5" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_6" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_7" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_8" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_9" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_10" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_11" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_12" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_13" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_14" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_15" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_16" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_17" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_18" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_19" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_20" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_21" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_22" value="1" checked></font></td>
<td><font size="2"><input type=checkbox name="d0_23" value="1" checked></font></td>   
</tr></table><p align="center">
<input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}">
<input type="hidden" name="action" value="urls">
<input type="hidden" name="new" value="url"><INPUT alt="Добавить" style="cursor: hand; font-size: 10pt; list-style-type: font-family" type=submit value="Добавить сайт">
<br><font size="1"><br></font></p></td></tr></table></center></div></td>
</table>
~;
# Выводим низ страницы дабавления сайта
print qq~
</td></tr></table></center></div></td></tr></table></div><center>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr bgcolor="#f0f0f0"><td><hr width=100% color=000000 size=1 noshadow>
</td></tr><tr><td><div align="center"><center></center></div></td></tr>
<tr bgcolor="#f0f0f0"><td><center class=small><hr width=100% color=000000 size=1 noshadow>
<div align="center"><center>
<table width=740 border=0 cellpadding=0 cellspacing=0><tr>
<td width="148" align="center">$schet1</td>
<td width="148" align="center">$schet2</td>
<td width="148" align="center">$schet3</td>
<td align=center width="148">$schet4</td><td align=center width="148">$schet5</td>
</tr></table></center></div></center><hr width=100% color=000000 size=1 noshadow>
</table><p align="right"><i><a href="http://www.ruscript.com" target="_blank"><font size="2" color="#808080">Development
and designed by RuScript.Com</font></a></i></p>
</html>
~;
exit;
}
elsif($in{'action'} eq 'conf'){
if($in{'conf'} eq 'change'){
if($in{'status'} ne '1'){$in{'status'} = '0'}
if($in{'serf'} ne '1'){$in{'serf'} = '0'}
if($in{'autoserf'} ne '1'){$in{'autoserf'} = '0'}
if($in{'maxday'} eq ''){$in{'maxday'} = '0'}
if($in{'ipday'} eq ''){$in{'ipday'} = '0'}
open(URLS,"./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
@sitesconf = <URLS>;
close(URLS);
chomp(@sitesconf);
$nu = "$userid\_$in{'url'}";
open(SITES,"./urls/$userid.urls");
if ($flock eq "1")
{flock(SITES, 2);}
@urls = <SITES>;
close(SITES);
chomp(@urls);
$ru = "$userid\_$in{'url'}";
open (LOCK, "./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
@lock = <LOCK>;
close (LOCK);
chomp(@lock);
if ($lock[0]=='1') {
open (LOCK, ">./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "0";
close (LOCK);
open(URLS,">./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
foreach (@sitesconf){
($id_url,$status,$http,$serf,$auto,$maxday,$ipday,$cat) = split(/\|/,$_);
if($id_url eq $nu){
# Изменяем в базе
print URLS "$nu|$in{'status'}|$in{'http'}|$in{'serf'}|$in{'autoserf'}|$in{'maxday'}|$in{'ipday'}|$in{'cat'}|\n";
}else{print URLS "$_\n"}}
#flock (URLS, 8);
close(URLS);
# Изменяем в файле пользователя
open(SITES,">./urls/$userid.urls");
if ($flock eq "1")
{flock(SITES, 2);}
foreach (@urls){
($id_url,$title,$Targ,$showed,$inserf,$inauto,$log) = split(/\|/,$_);
($id_url,$title,) = split(/\|/,$_);
if($id_url eq $ru){
print SITES "$nu|$in{'title'}|";
print SITES "$in{'d1_0'}x$in{'d1_1'}x$in{'d1_2'}x$in{'d1_3'}x$in{'d1_4'}x$in{'d1_5'}x$in{'d1_6'}x$in{'d1_7'}x$in{'d1_8'}x$in{'d1_9'}x$in{'d1_10'}x$in{'d1_11'}x$in{'d1_12'}x$in{'d1_13'}x$in{'d1_14'}x$in{'d1_15'}x$in{'d1_16'}x$in{'d1_17'}x$in{'d1_18'}x$in{'d1_19'}x$in{'d1_20'}x$in{'d1_21'}x$in{'d1_22'}x$in{'d1_23'}"; # targeting
print SITES "x$in{'d2_0'}x$in{'d2_1'}x$in{'d2_2'}x$in{'d2_3'}x$in{'d2_4'}x$in{'d2_5'}x$in{'d2_6'}x$in{'d2_7'}x$in{'d2_8'}x$in{'d2_9'}x$in{'d2_10'}x$in{'d2_11'}x$in{'d2_12'}x$in{'d2_13'}x$in{'d2_14'}x$in{'d2_15'}x$in{'d2_16'}x$in{'d2_17'}x$in{'d2_18'}x$in{'d2_19'}x$in{'d2_20'}x$in{'d2_21'}x$in{'d2_22'}x$in{'d2_23'}"; # targeting
print SITES "x$in{'d3_0'}x$in{'d3_1'}x$in{'d3_2'}x$in{'d3_3'}x$in{'d3_4'}x$in{'d3_5'}x$in{'d3_6'}x$in{'d3_7'}x$in{'d3_8'}x$in{'d3_9'}x$in{'d3_10'}x$in{'d3_11'}x$in{'d3_12'}x$in{'d3_13'}x$in{'d3_14'}x$in{'d3_15'}x$in{'d3_16'}x$in{'d3_17'}x$in{'d3_18'}x$in{'d3_19'}x$in{'d3_20'}x$in{'d3_21'}x$in{'d3_22'}x$in{'d3_23'}"; # targeting
print SITES "x$in{'d4_0'}x$in{'d4_1'}x$in{'d4_2'}x$in{'d4_3'}x$in{'d4_4'}x$in{'d4_5'}x$in{'d4_6'}x$in{'d4_7'}x$in{'d4_8'}x$in{'d4_9'}x$in{'d4_10'}x$in{'d4_11'}x$in{'d4_12'}x$in{'d4_13'}x$in{'d4_14'}x$in{'d4_15'}x$in{'d4_16'}x$in{'d4_17'}x$in{'d4_18'}x$in{'d4_19'}x$in{'d4_20'}x$in{'d4_21'}x$in{'d4_22'}x$in{'d4_23'}"; # targeting
print SITES "x$in{'d5_0'}x$in{'d5_1'}x$in{'d5_2'}x$in{'d5_3'}x$in{'d5_4'}x$in{'d5_5'}x$in{'d5_6'}x$in{'d5_7'}x$in{'d5_8'}x$in{'d5_9'}x$in{'d5_10'}x$in{'d5_11'}x$in{'d5_12'}x$in{'d5_13'}x$in{'d5_14'}x$in{'d5_15'}x$in{'d5_16'}x$in{'d5_17'}x$in{'d5_18'}x$in{'d5_19'}x$in{'d5_20'}x$in{'d5_21'}x$in{'d5_22'}x$in{'d5_23'}"; # targeting
print SITES "x$in{'d6_0'}x$in{'d6_1'}x$in{'d6_2'}x$in{'d6_3'}x$in{'d6_4'}x$in{'d6_5'}x$in{'d6_6'}x$in{'d6_7'}x$in{'d6_8'}x$in{'d6_9'}x$in{'d6_10'}x$in{'d6_11'}x$in{'d6_12'}x$in{'d6_13'}x$in{'d6_14'}x$in{'d6_15'}x$in{'d6_16'}x$in{'d6_17'}x$in{'d6_18'}x$in{'d6_19'}x$in{'d6_20'}x$in{'d6_21'}x$in{'d6_22'}x$in{'d6_23'}"; # targeting
print SITES "x$in{'d0_0'}x$in{'d0_1'}x$in{'d0_2'}x$in{'d0_3'}x$in{'d0_4'}x$in{'d0_5'}x$in{'d0_6'}x$in{'d0_7'}x$in{'d0_8'}x$in{'d0_9'}x$in{'d0_10'}x$in{'d0_11'}x$in{'d0_12'}x$in{'d0_13'}x$in{'d0_14'}x$in{'d0_15'}x$in{'d0_16'}x$in{'d0_17'}x$in{'d0_18'}x$in{'d0_19'}x$in{'d0_20'}x$in{'d0_21'}x$in{'d0_22'}x$in{'d0_23'}|"; # targeting
print SITES "$showed|$inserf|$inauto|$log\n";
}else{print SITES "$_\n"}}
}
open (LOCK, ">./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "1";
close (LOCK);
}
elsif($in{'conf'} eq 'del'){
open(URLS,"./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
@sitesconf = <URLS>;
close(URLS);
chomp(@sitesconf);
$nu = "$userid\_$in{'url'}";
open(SITES,"./urls/$userid.urls");
if ($flock eq "1")
{flock(SITES, 2);}
@urls = <SITES>;
close(SITES);
chomp(@urls);
$nu = "$userid\_$in{'url'}";
open (LOCK, "./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
@lock = <LOCK>;
close (LOCK);
chomp(@lock);
if ($lock[0]=='1') {
open (LOCK, ">./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "0";
close (LOCK);
open(URLS,">./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
foreach (@sitesconf){
($id_url,$status,$http,$serf,$auto,$maxday,$ipday) = split(/\|/,$_);
if($id_url ne $nu){
print URLS "$_\n"}}
close(URLS);
# Удаляем из файла пользователя
open(SITES,">./urls/$userid.urls");
if ($flock eq "1")
{flock(SITES, 2);}
foreach (@urls){
($id_url,$title,$log,$showed,$inserf,$inauto) = split(/\|/,$_);
if($id_url ne $nu){
print SITES "$_\n"}}
close(SITES);
}
open (LOCK, ">./urls/urls.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "1";
close (LOCK);
print "<br><br><br><h2 align=center><font size=3>Сайт удален</font></h2><p><br><br><br><br>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>";
}
####
open(SITES,"./urls/$userid.urls");
if ($flock eq "1")
{flock(SITES, 2);}
@urls = <SITES>;
close(SITES);
chomp(@urls);
foreach (@urls){
($id_url,$titles,$Targs,$showeds,$inserfs,$inautos) = split(/\|/,$_);
$mysite = "$userid\_$in{'url'}";
if($id_url eq $mysite){$title=$titles;$Targ=$Targs;$showed=$showeds;$inserf=$inserfs;$inauto=$inautos}}
open(URLS,"./urls/urls.pl");
if ($flock eq "1")
{flock(URLS, 2);}
@sites = <URLS>;
close(URLS);
chomp(@sites);
foreach (@sites){
($id_url,$status,$http,$serf,$auto,$maxday,$ipday,$cat) = split(/\|/,$_);
$mysite = "$userid\_$in{'url'}";
if($id_url eq $mysite){
$be = '1';
if($status eq '1'){$ch1 = 'checked'}
if($serf eq '1'){$ch2 = 'checked'}
if($auto eq '1'){$ch3 = 'checked'}
${$cat} = 'selected';
print qq~
<form name="conf" method="POST">
<div align="center"><center>
<tr><table border="1" cellpadding="0" cellspacing="0" width="99%" bordercolorlight="#CCCCFF">
<tr><td colspan="2" bgcolor="#F0F0F0" align="center"><font size="2"><b>Н а с т р о й к а
&nbsp;&nbsp;&nbsp; с а й т а</b></font></td></tr><tr>
<td colspan="2"><input type="checkbox" name="status" value="1" $ch1> сайт включен</td>
</tr><tr><td>&nbsp;Адрес</td><td> <input name="http" value="$http"> </td></tr><tr>
<td>&nbsp;Название </td><td> <input name="title" value="$title"> </td></tr><tr>
<td>&nbsp;Рекламируется </td><td> <input type="checkbox" name="serf" value="1" $ch2>
в серфинге <br><input type="checkbox" name="autoserf" value="1" $ch3> в автосерфинге </td>
</tr><tr><td>&nbsp;Делать в день не более </td><td> <input name="maxday" value="$maxday">
показов</td></tr><tr><td>&nbsp;Одному IP в день не более </td><td> <input name="ipday" value="$ipday"> показов</td>
~;
@targ = split(/x/,$Targ);
print qq~
</tr><tr><td colspan="2" align="center" bgcolor="#F0F0F0"> <font size="2">Таргетинг по времени
</font></td></tr><tr>
~;
print qq~
<td colspan="2" bgcolor="#F0F0F0"><table border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td><font size="2">Дни/Часы</font></td><td align="center"><font size="2">0</font></td><td align="center"><font size="2">1</font></td>
<td align="center"><font size="2">2</font></td><td align="center"><font size="2">3</font></td><td align="center"><font size="2">4</font></td>
<td align="center"><font size="2">5</font></td><td align="center"><font size="2">6</font></td><td align="center"><font size="2">7</font></td>
<td align="center"><font size="2">8</font></td><td align="center"><font size="2">9</font></td><td align="center"><font size="2">10</font></td>
<td align="center"><font size="2">11</font></td><td align="center"><font size="2">12</font></td><td align="center"><font size="2">13</font></td>
<td align="center"><font size="2">14</font></td><td align="center"><font size="2">15</font></td><td align="center"><font size="2">16</font></td>
<td align="center"><font size="2">17</font></td><td align="center"><font size="2">18</font></td><td align="center"><font size="2">19</font></td>
<td align="center"><font size="2">20</font></td><td align="center"><font size="2">21</font></td><td align="center"><font size="2">22</font></td>
<td align="center"><font size="2">23</font></td><tr><td><font size=2>Понедельник</font></td>
~;
for($d=0;$d<=23;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d1_$d" value="1" $ok></td>
~;}
print qq~
<tr><td><font size=2>Вторник</font></td>
~;
$h=0;
for($d=24;$d<=47;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d2_$h" value="1" $ok></td>
~;$h++}
print "<tr><td><font size=2>Среда</font></td>";
$h=0;
for($d=48;$d<=71;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d3_$h" value="1" $ok></td>
~;$h++}
print qq~
<tr><td><font size=2>Четверг</font></td>
~;
$h=0;
for($d=72;$d<=95;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d4_$h" value="1" $ok></td>
~;$h++}
print qq~
<tr><td><font size=2>Пятница</font></td>
~;
$h=0;
for($d=96;$d<=119;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d5_$h" value="1" $ok></td>
~;$h++}
print qq~
<tr><td><font size=2>Суббота</font></td>
~;
$h=0;
for($d=120;$d<=143;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d6_$h" value="1" $ok></td>
~;$h++}
print qq~
<tr><td><font size=2>Воскресенье</font></td>
~;
$h=0;
for($d=144;$d<=167;$d++){if($targ[$d] eq '1'){$ok='checked'}else{$ok=''};
print qq~
<td><input type=checkbox name="d0_$h" value="1" $ok></td>
~;$h++}
print qq~
</td></tr>
~;}}
if($be eq '1'){
print qq~
</tr></table>
<input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}">
<input type="hidden" name="action" value="conf">
<input type="hidden" name="conf" value="change">
<input type="hidden" name="url" value="$in{'url'}">
<a href="javascript:document.forms.conf.submit();"><p align="center">Сохранить изменения</a></form>
~;

print qq~
<form name="rem" method="POST">
<input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}">
<input type="hidden" name="action" value="conf">
<input type="hidden" name="conf" value="del">
<input type="hidden" name="url" value="$in{'url'}">
<a href="javascript:document.forms.rem.submit();">Удалить</a></form>
</table></table>
~;
# Выводим низ страницы настройки сайта
print qq~
</td></tr></table></center></div></td></tr></table></div><center>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr bgcolor="#f0f0f0"><td><hr width=100% color=000000 size=1 noshadow>
</td></tr><tr><td><div align="center"><center></center></div></td></tr>
<tr bgcolor="#f0f0f0"><td><center class=small><hr width=100% color=000000 size=1 noshadow>
<div align="center"><center>
<table width=740 border=0 cellpadding=0 cellspacing=0><tr>
<td width="148" align="center">$schet1</td>
<td width="148" align="center">$schet2</td>
<td width="148" align="center">$schet3</td>
<td align=center width="148">$schet4</td><td align=center width="148">$schet5</td>
</tr></table></center></div></center><hr width=100% color=000000 size=1 noshadow>
</table><p align="right"><i><a href="http://www.ruscript.com" target="_blank"><font size="2" color="#808080">Development
and designed by RuScript.Com</font></a></i></p>
</html>
~;
exit;
}
}elsif($in{'action'} eq 'info'){
if($in{'info'} eq 'save'){
open(INFO,">./users/$userid/info.user");
if ($flock eq "1")
{flock(INFO, 2);}
print INFO "$in{'name'}\n";
print INFO "$in{'mail'}\n";
print INFO "$in{'wmid'}\n";
print INFO "$in{'wmz'}\n";
close(INFO);}
open(INFO,"./users/$userid/info.user");
if ($flock eq "1")
{flock(INFO, 2);}
@info = <INFO>;
close(INFO);chomp(@info);
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#CCCCFF" bgcolor="#F0F0F0">
<tr><td width="100%" align="center"><b><font size="2">И н ф о р м а ц и я&nbsp;&nbsp;
п о л ь з о в а т е л я</font></b></td></tr></table><p></p><div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="95%" bordercolorlight="#CCCCFF">
<tr><td width="100%" align="center" bgcolor="#F0F0F0"><font color="#008080">&nbsp;В целях
безопасности, изменение информации  возможно только по письменному обращению
к администрации.</font></td></tr><tr><td width="100%" align="center" bgcolor="#FFFFFF">
<p align=center><font color="#000080"><b><font size="1"><br></font></b>
<h2 align="center"><font face="Arial" size="2"><b>Информация
пользователя <font color="#000080">$in{'user'}</font></b></font></h2>&nbsp;
<div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="50%">
<tr><td>Ваш пароль</td><td>$in{'pwd'}</td></tr><tr><td>E-mail</td><td>$info[1]</td>
</tr><tr><td>WM-ID</td><td>$info[2]</td></tr><tr><td>Z-кошелек</td><td>$info[3]</td>
</tr></table></center></div></font><p><b><font color="#008080" size="1"><br></font></b></p>
</td></tr><tr><td width="100%" align="center" bgcolor="#E0E0E0">
<font color="#008080">Если Вы хотите изменить регистрационную информацию, Вам
необходимо направить письмо </font><a href="mailto:$adminmail?Subject=Изменение информации&Body=
Прошу изменить мою регистрационную информацию. Мои данные: Логин - $in{'user'}, пароль - $in{'pwd'},
e-mail - $info[1], WMID - $info[2], WMZ - $info[3] прошу изменить на"><b>
<font color="#008080">администрации</font></b></a><font color="#008080">
с Вашего e-mail $info[1] с указанием причин изменения данных.</font></td>
</tr></table></center></div>
~;
##### Страница серфинга #####
}elsif($in{'action'} eq 'promo'){
open(ROT,"./system/config.pl");
if ($flock eq "1")
{flock(ROT, 2);}
@rotation = <ROT>;
close(ROT);chomp(@rotation);
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bgcolor="#F0F0F0" bordercolorlight="#CCCCFF">
<tr><td width="100%" align="center"><b><font size="2">В ы б о р&nbsp;&nbsp;&nbsp;
р е ж и м а&nbsp;&nbsp; с е р ф и н г а</font></b></td></tr></table></center>
</div><p align="center"><b>Ручной серфинг<br><br></b><div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="95%" bordercolorlight="#CCCCFF">
<tr><td width="100%" bgcolor="#E0E0E0"><div align="center"><center>
<table border="0" cellpadding="0" cellspacing="0" width="98%"><tr>
<td width="100%" align="center">За просмотр в этом режиме серфинга Вы будете получать
$rotation[1] кредит. Время просмотра одной страницы 30 секунд.</td></tr></table>
</center></div></td></tr><tr><td width="100%"><p align="center">
<a href="javascript:document.forms.rserf.submit();"><b><font color="#8E7CCD">Просмотр
в ручном режиме</font></b></a><br></p></td></tr></table></center></div>
<FORM action=promo.cgi method=post name=rserf TARGET=startpage>
<input type="hidden" name="user" value="$in{'user'}"></form>
<p align="center"><b>&nbsp;Автоматический серфинг</b></p><div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="95%" bordercolorlight="#CCCCFF">
<tr><td width="100%" bgcolor="#E0E0E0"><div align="center"><center>
<table border="0" cellpadding="0" cellspacing="0" width="98%"><tr>
<td width="100%" align="center">За просмотр в этом режиме серфинга Вы будете получать
$rotation[2] кредита. Время просмотра одной страницы 30 секунд. Страницы
показываются автоматически.</td></tr></table></center></div></td></tr><tr><td width="100%">
<p align="center"><b><a href="javascript:document.forms.aserf.submit();">
<font color="#8E7CCD">Просмотр в автоматическом режиме</font></a></b>&nbsp;
</td></tr></table><FORM action=autopromo.cgi method=post name=aserf TARGET=startpage>
<input type="hidden" name="user" value="$in{'user'}"></form></center></div>
<p align="center"><b><i><font color="#000080">Удачного серфинга!</font></i></b><p>&nbsp;</p>
~;
#################### КОНЕЦ
}elsif($in{'action'} eq 'credit'){
open(STAT,"./users/$userid/stat.user");
if ($flock eq "1")
{flock(STAT, 2);}
@stat = <STAT>;
close(STAT);chomp(@stat);
open(ROT,"./system/config.pl");
if ($flock eq "1")
{flock(ROT, 2);}
@rotation = <ROT>;
close(ROT);chomp(@rotation);
if($in{'crd'} eq 'start'){
print qq~~;
}elsif($in{'crd'} eq 'next'){
$error = '0';
$errortxt = '';
$com = ($in{'much'}/100) * $rotation[6];
$summ=$in{'much'}+$com;
if($in{'to'} eq 'admin'){$to = '1'}
if($stat[1] < $summ){$error = 1;$errortxt = "<p align=center><b>С учетом комиссии  ($rotation[6]%)  для перевода вам необходимо $summ кредитов!</b> <br>"}
if($stat[1] < $rotation[9]){$error = 1;$errortxt = "<p align=center><b>У Вас на счету должно быть не менее $rotation[9] кредитов!</b> <br>"}
if($to ne '1'){$error = '1';$errortxt = "$errortxt Пользователя $in{'to'} не существует<br>"}
if($in{'much'} eq ''){$error = '1';$errortxt = ""}
if($in{'much'}=~/\D/g){$error = '1';$errortxt = "$errortxt <b><p align=center>Поле <i>- 'Число кредитов'</i> должно содержать число!<br></b>"}
if($error ne '0'){
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#CCCCFF" bgcolor="#F0F0F0">
<tr><td width="100%" align="center"><b><font size="2">П е р е в о д&nbsp;&nbsp;&nbsp;
к р е д и т о в&nbsp;</font></b></td></tr></table><p align="center"><font size="-1" color="red">
$errortxt</font></p><form method="POST"><input type="hidden" name="user" value="$in{'user'}">
<input type="hidden" name="pwd" value="$in{'pwd'}"><input type="hidden" name="action" value="credit">
<input type="hidden" name="crd" value="next"><div align="center"><center>
<table cellpadding="0" cellspacing="0" width="95%" bordercolorlight="#CCCCFF" border="1">
<tr><td colspan="2" align="center" bgcolor="#D8D8D8"><font size="2">Перевод
кредитов другим пользователям</font></td></tr><tr><td colspan="2">&nbsp;</td>
</tr><tr><td>&nbsp;У вас на счету</td><td><b><font color="#800000">&nbsp;
</font></b><font color="#000080">$stat[1] кредитов</font></td>
</tr><tr><td>&nbsp;Кому перевести&nbsp;&nbsp;</td><td>&nbsp;<input name="to" size="12"> 
<font size="-1">[ логин ]</font></td></tr><tr><td>&nbsp;Число кредитов</td><td>
&nbsp;<input name="much" size="12"><font size="-1">&nbsp;[количество]</font></td>
</tr><tr><td colspan="2"><p align="center"><br><input type="submit" value="Перевести кредиты"><br>
&nbsp;</p></td></tr><tr><td colspan="2" bgcolor="#F0F0F0"><div align="center">
<center><table border="0" cellpadding="0" cellspacing="1" width="99%"><tr>
<td width="100%"><font size="2">Для перевода кредитов другому пользователю Вам надо иметь
на счету не менее $rotation[9] кредитов. При переводе с вас будет удержана
комиссия в размере $rotation[6] %. При переводе администрации системы
комиссия не взимается.</font></td></tr></table></center></div></td>
</tr></table></center></div></form>&nbsp;</form><center><table border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="top"><font color="#008080"><b>Вы перевели<br></b>
</font><table border="1" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#008080"><tbody><tr><td align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Дата&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="center">&nbsp;&nbsp;
&nbsp;&nbsp;Кому&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="center">&nbsp;&nbsp;Кол-во&nbsp;&nbsp;</td></tr>
</tr>
~;
open PWD, "userdat.pl";
if ($flock eq "1")
{flock(PWD, 2);}
@users = <PWD>;
close(PWD);chomp(@users);
foreach (@users){
($login,$userpass,$id,$status,$dr,$dc) = split(/\|/,$_);
if($user eq $login){$userid=$id}}
#Выводим лог кому перевели
open H,"./users/$userid/outtr.dat";
while(defined($line=<H>))
{chomp($line);
($date,$users,$kolvo,$ipuser) = split(/\|/,$line);
($dmy,$hms) = split(/<time>/,$date);
print "<td>&nbsp;&nbsp;$dmy&nbsp;&nbsp;<td>&nbsp;$users&nbsp;<td>&nbsp;$kolvo&nbsp;</td></tr>";
}
close(H);
print qq~
</tbody></table></center></td><td align=center width=30></td><td align=center valign=top>
<font color=#008080><b>Вами получено<br></b></font><center>
<table border=1 cellspacing=0 cellpadding=0 bordercolorlight=#FFFFFF bordercolordark=#008080>
<tbody><tr><td align=center>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Дата&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td><td align=center>&nbsp;&nbsp;От кого&nbsp;&nbsp;</td>
<td align=center>&nbsp;&nbsp;Кол-во&nbsp;&nbsp;</td></tr><tr>
~;
# Вводим лог кто перевел
open H,"./users/$userid/intr.dat";
while(defined($line=<H>))
{chomp($line);
($date2,$users2,$kolvo2,$ipuser2) = split(/\|/,$line);
($dmy2,$hms2) = split(/<time>/,$date2);
print "<td>&nbsp;&nbsp;$dmy2&nbsp;&nbsp;<td>&nbsp;$users2<td>&nbsp;$kolvo2</td></tr>";
}
close(H);
print "</table></center></td></tr></table></center>";
}else{
if($in{'to'} eq 'admin'){
$stat[1] = $stat[1] - $in{'much'};
$stat[11] = $stat[11] + $in{'much'};
open(STAT,">./users/$userid/stat.user");
if ($flock eq "1")
{flock(STAT, 2);}
foreach (@stat){
print STAT "$_\n"}
close(STAT);
$summcom=$summcom+0;
open(SYS,"./system/sysstat.pl");
if ($flock eq "1")
{flock(SYS, 2);}
@system = <SYS>;
close(SYS);chomp(@system);
$system[0] = $system[0] - $in{'much'};
$system[1] = $system[1] + $in{'much'};
$system[4] = $system[4] + $in{'much'};
($dearn6,$earn6) = split(/\|/,$system[6]);
if($today eq $dearn6){$earn6 = $earn6 + $in{'much'};$system[6] = "$dearn6|$earn6"}else{$system[6] = "$today|$in{'much'}"}
($dearn9,$earn9) = split(/\|/,$system[9]);
if($today eq $dearn9){$earn9 = $earn9 + $in{'much'};$system[9] = "$dearn9|$earn9"}else{$system[9] = "$today|$in{'much'}"}
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#CCCCFF" bgcolor="#F0F0F0">
<tr><td width="100%" align="center"><b><font size="2">П е р е в о д&nbsp;&nbsp;&nbsp;
к р е д и т о в&nbsp;</font></b></td></tr></table><p></p><div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="95%" bordercolorlight="#CCCCFF">
<tr><td width="100%" align="center" bgcolor="#F0F0F0">
<p align=center><font color="#000080"><b><font size="1"><br>
</font></b>Перевод успешно завершен!</font></p><p align=center>Администрации системы
переведено <font color=#000080>$in{'much'} кредитов.<br>
<font color=#008080>С Вас удержано комиссии  $summcom </font></font><font color="#008080">кредитов<font color=#000080>.<br>
</font></font><b><font color="#008080" size="1"><br></font></b></p></td></tr></table></center>
</div>
~;
open (LOCK, "./system/sysstat.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
@lock = <LOCK>;
close (LOCK);
chomp(@lock);
if ($lock[0]=='1') {
open (LOCK, ">./system/sysstat.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "0";
close (LOCK);
open(SYS,">./system/sysstat.pl");
if ($flock eq "1")
{flock(SYS, 2);}
foreach (@system){
print SYS "$_\n"}
close(SYS);}
open (LOCK, ">./system/sysstat.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "1";
close (LOCK);
}else{
$much = $in{'much'} + $com;
$stat[1] = $stat[1] - $much;
$stat[11] = $stat[11] + $in{'much'};
open(STAT,">./users/$userid/stat.user");
if ($flock eq "1")
{flock(STAT, 2);}
foreach (@stat){
print STAT "$_\n"}
close(STAT);
#### Записываем лог переводов ###
# Кому переводим
open(OUTTR,">>./users/$userid/outtr.dat");
print OUTTR "$Date|$in{'to'}|$in{'much'}|$ENV{'REMOTE_ADDR'}\n";
close(OUTTR);
# Кто перевел
open(INTR,">>./users/$toid/intr.dat");
print INTR "$Date|$in{'user'}|$in{'much'}|$ENV{'REMOTE_ADDR'}\n";
close(INTR);
open(TO,"./users/$toid/stat.user");
if ($flock eq "1")
{flock(TO, 2);}
@tostat = <TO>;
close(TO);chomp(@tostat);
$tostat[1] = $tostat[1] + $in{'much'};
$tostat[12] = $tostat[12] + $in{'much'};
open(TO,">./users/$toid/stat.user");
if ($flock eq "1")
{flock(TO, 2);}
foreach (@tostat){print TO "$_\n"}
close(TO);
open(SYS,"./system/sysstat.pl");
if ($flock eq "1")
{flock(SYS, 2);}
@system = <SYS>;
close(SYS);chomp(@system);
$system[0] = $system[0] - $com;
$system[1] = $system[1] + $com;
$system[4] = $system[4] + $com;
($dearn6,$earn6) = split(/\|/,$system[6]);
if($today eq $dearn6){$earn6 = $earn6 + $com;$system[6] = "$dearn|$earn6"}else{$system[6] = "$today|$com"}
($dearn,$earn) = split(/\|/,$system[9]);
if($today eq $dearn){$earn = $earn + $com;$system[9] = "$dearn|$earn"}else{$system[9] = "$today|$com"}
open (LOCK, "./system/sysstat.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
@lock = <LOCK>;
close (LOCK);
chomp(@lock);
if ($lock[0]=='1') {
open (LOCK, ">./system/sysstat.lock");
if ($flock eq "1")
{flock(LOCK, 2);}
print LOCK "0";
close (LOCK);
open(SYS,">./system/sysstat.pl");
if ($flock eq "1")
{flock(SYS, 2);}
foreach (@system){
print SYS "$_\n"}
close(SYS);}
open (LOCK, ">./system/sysstat.lock");
if ($flock eq "1")
{flock(SYS, 2);}
print LOCK "1";
close (LOCK);
$summcom=($in{'much'}/100)*$rotation[6]+0;
print qq~
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#CCCCFF" bgcolor="#F0F0F0">
<tr><td width="100%" align="center"><b><font size="2">П е р е в о д&nbsp;&nbsp;&nbsp;
к р е д и т о в&nbsp;</font></b></td></tr></table><p></p><div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="95%" bordercolorlight="#CCCCFF">
<tr><td width="100%" align="center" bgcolor="#F0F0F0"><p align=center><font color="#000080">
<b><font size="1"><br></font></b>Перевод успешно завершен!</font></p><p align=center>
Пользователю $in{'to'} переведено <font color=#000080>$in{'much'} кредитов.<br>
<font color=#008080>С Вас удержано комиссии  $summcom </font></font><font color="#008080">кредитов<font color=#000080>.<br>
</font></font><b><font color="#008080" size="1"><br></font></b></p></td></tr></table></center></div>
~;
}}}}
}else{
print qq~<center>$error<br></center></b>~;
if($exist ne 'da'){print "<center>$exist</center></b>"}
}
&html_end;
# Подпрограмма неразрешающая доступ к файлу одновременно
sub check_lock {
$lock_file = $_[0];
$can_work = 0;
$time = 5; # ждем 5 секундных циклов
for ($i = 1;$i <= $time; $i++) {
if (-e "$lock_file") {
sleep 1;
}
else {
open(LOCK,">$lock_file");
print LOCK "0";
close(LOCK);
$can_work = 1;
last;
}
}
return($can_work);
}
