include('nbase.php');
include('filter.php');
include('smiles.php');
function getdayrus($daynum)
{
switch ($daynum){
case '0':
$result = 'Воскресенье';
break;
case '1':
$result = 'Понедельник';
break;
case '2':
$result = 'Вторник';
break;
case '3':
$result = 'Среда';
break;
case '4':
$result = 'Четверг';
break;
case '5':
$result = 'Пятница';
break;
case '6':
$result = 'Суббота';
break;
}
return $result;
}
function tmpl($tfname)
{
$tdat = file($tfname);
$rdat = '';
for ($i = 0;$i < count(file($tfname));$i++){
$rdat = $rdat.$tdat[$i];
}
return $rdat;
}
$on_page = 10;
$log_dat = 'db/login.dat';
$base_dat = 'db/base.dat';
$ldb = nb_open($log_dat);
$glog = base64_decode(getarg(nb_get($ldb,0),1));
$gpas = base64_decode(getarg(nb_get($ldb,0),2));
$guid = md5($glog.$gpas);
$gact = strtolower($_GET['action']);
$uid = $_GET['uid'];
if ($uid == $guid){ $utxt = '&uid='.$uid; }
$tcss = tmpl('templ/style.css');
$tfrm = tmpl('templ/form.htm');
$tmsglist = tmpl('templ/messages.htm');
if ($gact == ''){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
$tdoc = tmpl('templ/main.htm');
$tdoc = str_replace('%STYLES%',$tcss,$tdoc);
$tdoc = str_replace('%FORM%',$tfrm,$tdoc);
$cdat = base64_decode($_COOKIE['netscat_guest3']);
$cname = getarg($cdat,1);
$cemail = getarg($cdat,2);
$csite = getarg($cdat,3);
$cicq = getarg($cdat,4);
if ($cemail == ' '){ $cemail = ''; }
if ($csite == ' '){ $csite = ''; }
if ($cicq == ' '){ $cicq = ''; }
$tdoc = str_replace('%NAME%',$cname,$tdoc);
$tdoc = str_replace('%EMAIL%',$cemail,$tdoc);
$tdoc = str_replace('%SITE%',$csite,$tdoc);
$tdoc = str_replace('%ICQ%',$cicq,$tdoc);
if ($uid == $guid){ $admlog = '| © NetScat Team | Выход | Сменить пароль |'; }
else { $admlog = '| © NetScat Team | Вход |'; }
$tdoc = str_replace('%LOGIN%',$admlog,$tdoc);
if ($uid == $guid){ $tdoc = str_replace('%UID%','&uid='.$uid,$tdoc); }
else { $tdoc = str_replace('%UID%','',$tdoc); }
$gdb = nb_open($base_dat);
$gcnt = count(file($base_dat));
$page = $_GET['page'];
if ($page == ''){ $page = 0; }
$ncnt = $gcnt - ($on_page * $page);
if ($ncnt - $on_page > 0){
$ost = $ncnt - $on_page;
}
else {
$ost = 0;
}
$tmsgs = '';
for ($j = $ncnt - 1;$j >= $ost;$j--){
$tmsg = tmpl('templ/message.htm');
$dbrec = nb_get($gdb,$j);
$dbname = getarg($dbrec,1);
$dbemail = getarg($dbrec,2);
$dbsite = getarg($dbrec,3);
$dbicq = getarg($dbrec,4);
$dbmsg = getarg($dbrec,5);
$dbdate = getarg($dbrec,6);
$dbanswer = getarg($dbrec,7);
$adm = '';
if ($uid == $guid){
$adm = '| Удалить | Ответить |';
}
$tmsg = str_replace('%NAME%',$dbname,$tmsg);
$tmsg = str_replace('%DATE%',$dbdate,$tmsg);
if ($dbemail != ' '){ $tmsg = str_replace('%EMAIL%','',$tmsg); }
else { $tmsg = str_replace('%EMAIL%','',$tmsg); }
if ($dbsite != ' '){ $tmsg = str_replace('%SITE%','',$tmsg); }
else { $tmsg = str_replace('%SITE%','',$tmsg); }
if ($dbicq != ' '){ $tmsg = str_replace('%ICQ%','',$tmsg); }
else { $tmsg = str_replace('%ICQ%','',$tmsg); }
if ($dbanswer != ' '){ $tmsg = str_replace('%ANSWER%','
Ответ: '.$dbanswer,$tmsg); }
else { $tmsg = str_replace('%ANSWER%','',$tmsg); }
$tmsg = str_replace('%DATE%',$dbdate,$tmsg);
$tmsg = str_replace('%MESSAGE%',$dbmsg,$tmsg);
$tmsg = str_replace('%ADMIN%',$adm,$tmsg);
$tmsgs = $tmsgs.$tmsg;
}
if ($page > 0){
$bck = $page - 1;
$nav = '';
}
$nxt = $page + 1;
$nav = ''.$nav.' '.$page.' |
';
$tmsgs = $nav.$tmsgs.$nav;
$tmsglist = str_replace('%LIST%',$tmsgs,$tmsglist);
$tdoc = str_replace('%MESSAGES%',$tmsglist,$tdoc);
echo $tdoc;
}
if ($gact == 'login'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
$tadm = tmpl('templ/login.htm');
$tadm = str_replace('%STYLES%',$tcss,$tadm);
echo $tadm;
}
if ($gact == 'check'){
$xlog = strtolower($_POST['log']);
$xpas = $_POST['pas'];
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
if (md5($xlog.$xpas) == $guid){
echo 'Вход!
';
}
else {
echo 'Вход!
';
}
}
if ($gact == 'logout'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
echo 'Выход!
';
}
if ($gact == 'change'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
if ($uid == $guid){
$tchng = tmpl('templ/change.htm');
$tchng = str_replace('%STYLES%',$tcss,$tchng);
$tchng = str_replace('%LOG%',$glog,$tchng);
$tchng = str_replace('%PAS%',$gpas,$tchng);
$tchng = str_replace('%PAGE%',$_GET['page'],$tchng);
$tchng = str_replace('%GET%','?uid='.$uid.'&page='.$_GET['page'],$tchng);
$tchng = str_replace('%UID%','&uid='.$uid,$tchng);
echo $tchng;
}
}
if ($gact == 'new'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
if ($uid == $guid){
$ldb = nb_open($log_dat);
nb_del($ldb,0);
$lrec[0] = base64_encode($_POST['log']);
$lrec[1] = base64_encode($_POST['pas']);
nb_add($ldb,$lrec);
echo 'Смена пароля!
';
}
}
if ($gact == 'add'){
$tadd = tmpl('templ/add.htm');
$tadd = str_replace('%STYLES%',$tcss,$tadd);
if ($uid == $guid){ $tadd = str_replace('%UID%','?uid='.$uid,$tadd); }
else { $tadd = str_replace('%UID%','',$tadd); }
$gdb = nb_open($base_dat);
$xname = $_POST['nick'];
$xemail = $_POST['email'];
$xsite = $_POST['site'];
$xicq = $_POST['icq'];
$xmsg = $_POST['msg'];
$xmsg = str_replace('<','<',$xmsg);
$xmsg = str_replace('>','>',$xmsg);
$xmsg = filter(replsmile(str_replace("\n",'
',$xmsg)));
$xmsg = str_replace('::',': :',$xmsg);
$xmsg = str_replace('\"','"',$xmsg);
$xmsg = str_replace('\'',"'",$xmsg);
if ($xemail == ''){$xemail = ' ';}
if ($xsite == ''){$xsite = ' ';}
if ($xicq == ''){$xicq = ' ';}
if ($xsite != ' '){ $xsite = 'http://'.str_replace('http://','',$xsite);}
$cdat = base64_encode($xname.'::'.$xemail.'::'.$xsite.'::'.$xicq.'::');
setcookie('netscat_guest3',$cdat,time()+3110400);
$dbr[0] = $xname;
$dbr[1] = $xemail;
$dbr[2] = $xsite;
$dbr[3] = $xicq;
$dbr[4] = $xmsg;
$dbr[5] = getdayrus(date("w")).date(" j.m.y G:i");
$dbr[6] = ' ';
nb_add($gdb,$dbr);
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
echo $tadd;
}
if ($gact == 'remove'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
if ($uid == $guid){
$gdb = nb_open($base_dat);
nb_del($gdb,$_GET['id']);
echo 'Выход!
';
}
}
if ($gact == 'answer'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
$tans = str_replace('%STYLES%',$tcss,tmpl('templ/answer.htm'));
if ($uid == $guid){
$tans = str_replace('%UID%','uid='.$uid.'&page='.$_GET['page'].'&id='.$_GET['id'],$tans);
echo $tans;
}
}
if ($gact == 'addanswer'){
header("Expires: Mon, 14 May 2005 15:12:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html");
if ($uid == $guid){
$id = $_GET['id'];
$amsg = $_POST['msg'];
$amsg = str_replace('<','<',$amsg);
$amsg = str_replace('>','>',$amsg);
$amsg = filter(replsmile(str_replace("\n",'
',$amsg)));
$amsg = str_replace('::',': :',$amsg);
$amsg = str_replace('\"','"',$amsg);
$amsg = str_replace('\'',"'",$amsg);
$gdb = nb_open($base_dat);
for ($j = 0;$j < 6;$j++){ $pol[$j] = getarg(nb_get($gdb,$id),$j+1); }
$pol[6] = $amsg;
if ($id < (count(file($base_dat))-1)){ nb_ins($gdb,$id+1,$pol); }
else { nb_add($gdb,$pol); }
nb_del($gdb,$id);
echo 'Ответ!
';
}
}
?>