<?
/*
GB(v1.0) by Viktor
icq:357332321
site: http://yarap.ru
http://xwab.ru/forum/profile656
[index.php]
*/
include('incl/head.php');
$template->set_filenames(array(
'body' => 'index.tpl'));
if($_SESSION['adm']==1)
$template->assign_block_vars("admin", array("ADMIN"=>$admin, "ADM"=>$l[6], "EXIT"=>$l[23]));
if($_GET['code']==1)
$template->assign_block_vars("code", array());
if($_GET['mail']==1)
$template->assign_block_vars("mail", array());
$max=sql("SELECT * FROM ".$pref."config WHERE c='max_name'");
$max_name=$max['o'];
$max=sql("SELECT * FROM ".$pref."config WHERE c='min_name'");
$min_name=$max['o'];
$max=sql("SELECT * FROM ".$pref."config WHERE c='max_text'");
$max_text=$max['o'];
$max=sql("SELECT * FROM ".$pref."config WHERE c='min_text'");
$min_text=$max['o'];
$max=sql("SELECT * FROM ".$pref."config WHERE c='pagin'");
$pagin=$max['o'];
if($_GET['mintext']==1)
$template->assign_block_vars("mintext", array("M"=>$min_text));
if($_GET['maxtext']==1)
$template->assign_block_vars("maxtext", array("M"=>$max_text));
if($_GET['minname']==1)
$template->assign_block_vars("minname", array("M"=>$min_name));
if($_GET['maxname']==1)
$template->assign_block_vars("maxname", array("M"=>$max_name));
$start1 = intval($_GET['start']);
if ( !empty($start1) )
{
$start1 = abs(intval($_GET['start']));
$start = $start1;// * $pagin;
}
else
{
$start = ( isset($_GET['start']) ) ? intval($_GET['start']) : 0;
$start = ($start < 0) ? 0 : $start;
}
$i=0;
$id=intval(abs($_GET['id']));
if($row=sql("SELECT * FROM ".$pref."mes WHERE id=$id"))
{
if(!($row['mail']))$mail='';
elseif(!($row['email']) || $_SESSION['adm']==1)$mail='<a href="mailto:'.$row['mail'].'">'.$row['mail'].'</a>';
else $mail='';
if($row['admin'])$adm='(<font color="#FF0000">'.$l[39].'</font>)';else $adm='';
if((sql("SELECT * FROM ".$pref."config WHERE o='1' AND c='http'") || $_SESSION['adm']==1) && $row['site'])
$site='[<a href="'.$row['site'].'">'.((strlen($row['site'])>15) ? (substr($row['site'], 0, 15).'...') : $row['site']).'</a>]';
else
$site='';
$data=data($row['data']);
$ban=(!(sql("SELECT * FROM ".$pref."bans WHERE ip='".$row['ip']."'")) && $row['ip']<>user_ip()) ? "|<a href=\"$admin?m=ban&id=".$row['id']."\">".$l[86]."</a>" : "";
if($_SESSION['adm']==1)$ud='[<a href="ok.php?m=del&id='.$row['id'].'">'.$l[12].'</a>'.((sql("SELECT * FROM ".$pref."mes WHERE id=-".$row['id'])) ? "" : '|<a href="'.$admin.'?m=otv&id='.$row['id'].'">'.$l[52].'</a>').$ban.']';
$like=sql("SELECT COUNT(*) AS l FROM ".$pref."like WHERE id=".$row['id']);
$template->assign_block_vars("mes", array(
"LIKE"=>(sql("SELECT * FROM ".$pref."like WHERE ip='".user_ip()."' AND id=".$row['id'])) ? $l[84].' (<b>'.$like['l'].'</b>)' : '<a href="ok.php?m=like&id='.$row['id'].'">'.$l[84].'</a> (<b>'.$like['l'].'</b>)',
"UD"=>$ud,
"DATA"=>$data,
"SITE"=>$site,
"ADM"=>$adm,
"MAIL"=>$mail,
"NAME"=>$row['name'],
"TEXT"=>$row['text'],
"ID"=>$row['id']));
if($admin_otvet=sql("SELECT * FROM ".$pref."mes WHERE id=".(-$row['id'])))
$template->assign_block_vars("mes.otv", array(
"UD"=>($_SESSION['adm']==1) ? '[<a href="ok.php?m=del&id='.$admin_otvet['id'].'">'.$l[12].'</a>]' : '',
"ID"=>$admin_otvet['id'],
"TEXT"=>$admin_otvet['text'],
"DATA"=>data($admin_otvet['data']),
"NAME"=>(($admin_otvet['name']) ? $admin_otvet['name'] : "Admin")));
}
else
{
$res=query("SELECT * FROM ".$pref."mes WHERE id>0 ORDER BY id DESC LIMIT ".abs($start).", $pagin");
while ($row=row($res))
{
if(!($row['mail']))$mail='';
elseif(!($row['email']) || $_SESSION['adm']==1)$mail='<a href="mailto:'.$row['mail'].'">'.$row['mail'].'</a>';
else $mail='';
if($row['admin'])$adm='(<font color="#FF0000">'.$l[39].'</font>)';else $adm='';
if((sql("SELECT * FROM ".$pref."config WHERE o='1' AND c='http'") || $_SESSION['adm']==1) && $row['site'])
$site='[<a href="'.$row['site'].'">'.((strlen($row['site'])>15) ? (substr($row['site'], 0, 15).'...') : $row['site']).'</a>]';
else
$site='';
$data=data($row['data']);
$ban=(!(sql("SELECT * FROM ".$pref."bans WHERE ip='".$row['ip']."'")) && $row['ip']<>user_ip()) ? "|<a href=\"$admin?m=ban&id=".$row['id']."\">".$l[86]."</a>" : "";
if($_SESSION['adm']==1)$ud='[<a href="ok.php?m=del&id='.$row['id'].'">'.$l[12].'</a>'.((sql("SELECT * FROM ".$pref."mes WHERE id=-".$row['id'])) ? "" : '|<a href="'.$admin.'?m=otv&id='.$row['id'].'">'.$l[52].'</a>').$ban.']';
$like=sql("SELECT COUNT(*) AS l FROM ".$pref."like WHERE id=".$row['id']);
$template->assign_block_vars("mes", array(
"LIKE"=>(sql("SELECT * FROM ".$pref."like WHERE ip='".user_ip()."' AND id=".$row['id'])) ? $l[84].' (<b>'.$like['l'].'</b>)' : '<a href="ok.php?m=like&id='.$row['id'].'">'.$l[84].'</a> (<b>'.$like['l'].'</b>)',
"UD"=>$ud,
"DATA"=>$data,
"SITE"=>$site,
"ADM"=>$adm,
"MAIL"=>$mail,
"NAME"=>$row['name'],
"TEXT"=>$row['text'],
"ID"=>$row['id']));
if($admin_otvet=sql("SELECT * FROM ".$pref."mes WHERE id=".(-$row['id'])))
$template->assign_block_vars("mes.otv", array(
"UD"=>($_SESSION['adm']==1) ? '[<a href="ok.php?m=del&id='.$admin_otvet['id'].'">'.$l[12].'</a>]' : '',
"ID"=>$admin_otvet['id'],
"TEXT"=>$admin_otvet['text'],
"DATA"=>data($admin_otvet['data']),
"NAME"=>(($admin_otvet['name']) ? $admin_otvet['name'] : "Admin")));
$id=$row['id'];
$i++;
}
if($i==0)$template->assign_block_vars("null", array("NULL"=>$l[105]));
if($id<>0)
{
$t=sql("SELECT COUNT(*) AS t FROM ".$pref."mes WHERE id>0");
$total=$t['t'];
if($total>$pagin)
{
$pagin=pagin("index.php?pag=1", $total, $pagin, $start);
$template->assign_block_vars("pagin", array());
}
}
}
if(sql("SELECT * FROM ".$pref."config WHERE o='0' AND c='close'") || $_SESSION['adm']==1)
{
$template->assign_block_vars("close", array());
if(sql("SELECT * FROM ".$pref."config WHERE o='1' AND c='code'") && $_SESSION['adm']<>1)$template->assign_block_vars("close.code1", array());
}
else
$template->assign_block_vars("closes", array("CLOSE"=>$l[106]));
$http=sql("SELECT * FROM ".$pref."config WHERE c='site'");
$template->assign_vars(array(
"INDEX"=>$l[103],
"HTTP"=>$http['o'],
"PAGIN"=>$pagin,
"ERRORMAIL"=>$l[36],
"ERRORCODE"=>$l[35],
"MINTEXT"=>$l[32],
"MINNAME"=>$l[34],
"MAXTEXT"=>$l[31],
"MAXNAME"=>$l[33],
"SNAME"=>$_SESSION[$pref.'name'],
"SMAIL"=>$_SESSION[$pref.'mail'],
"STEXT"=>$_SESSION[$pref.'text'],
"SSITE"=>($_SESSION[$pref.'site']<>'' && $_SESSION[$pref.'site']<>'http://') ? $_SESSION[$pref.'site'] : 'http://',
"EMAIL"=>$_SESSION[$pref.'email'],
"ADD_COM"=>$l[28],
"ADD"=>$l[10],
"NAME"=>$l[25],
"POK"=>$l[29],
"MES"=>$l[27],
"SITE"=>$l[26]));
$template->pparse('body');
include('incl/foot.php');
?>