View file users.php

File size: 1.95Kb
<?php
include 'inc/db.php';
include 'inc/1.php';
function hc($in){
return htmlspecialchars($in);
}
if ($_GET['name']){
echo "<div class='t2'>Поиск</div>";
$name=mysql_escape_string(htmlspecialchars(trim($_GET['name'])));
if (!$_GET['p'])$_GET['p']=1;
$p=intval($_GET['p']);
$start=($p*15-15);
$q=mysql_query("SELECT * FROM `user` WHERE `name` = '$name' LIMIT $start, 15");
$i=1;
mysql_query("INSERT INTO `log` (`user`, `text`, `time`) values ('$user[id]', 'Поиск пользователя', '".time()."')");
if (mysql_num_rows($q)==0)echo "Не найдено";
while ($f=mysql_fetch_assoc($q)){
echo "<div class='p".($i%2)."'>".im($f['id'])." <a href='ank.php?id=$f[id]'>".hc($f['name'])."</a>".on($f['id'])."</div>";
$i++;
}
if ($p>1)echo "<a href='?name=$name&p=".($p-1)."'>Назад</a> ";
if (mysql_num_rows(mysql_query("SELECT * FROM `user` WHERE `name` = '$name' ORDER BY `id` ASC"))>($start+15)) echo "<a href='?name=$name&p=".($p+1)."'>Далее</a>";
include_once 'inc/foot.php';
exit;
}
echo "<div class='t2'>Пользователи</div>";
echo "<div class='input'><form action='?' method='GET'>Ник:<br><input type='text' name='name'><br><input type='submit' value='Поиск'></form></div>";
if (!$_GET['p'])$_GET['p']=1;
$p=intval($_GET['p']);
$start=($p*15-15);
$q1=(mysql_num_rows(mysql_query("SELECT `id` FROM `user`"))/15);
$q2=round(mysql_num_rows(mysql_query("SELECT `id` FROM `user`"))/15);
if ($q1>$q2)$pages=($q2+1);
else
$pages=$q2;
$q=mysql_query("SELECT * FROM `user` ORDER BY `id` ASC LIMIT $start, 15");
$i=1;
while ($f=mysql_fetch_assoc($q)){
echo "<div class='p".($i%2)."'>".im($f['id'])." <a href='ank.php?id=$f[id]'>".hc($f['name'])."</a>".on($f['id'])."</div>";
$i++;
}
/*if ($p>1)echo "<a href='?p=".($p-1)."'>Назад</a> ";
if (mysql_num_rows(mysql_query("SELECT * FROM `user`"))>($start+15)) echo "<a href='?p=".($p+1)."'>Далее</a>";*/
pages($pages, $p, "?p");
include_once 'inc/foot.php';
?>