Файл: titwar.ru/clans.php
Строк: 108
<?
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
switch($_GET['action']) {
default:
$title = 'Clans rating';
include './system/h.php';
?>
<div class='line'></div>
<div class='menu'>
<?
$max = 10;
$count = mysql_result(mysql_query('SELECT COUNT(*) FROM `clans`'),0);
$pages = ceil($count/$max);
$page = _string(_num($_GET['page']));
if($page > $pages) {
$page = $pages;
}
if($page < 1) {
$page = 1;
}
$start = $page * $max - $max;
if($page == 1) {
$i = $page - 1;
}
elseif($page == 2) {
$i = ($page + 9);
}
else
{
$i = ($page * 10) - 9;
}
if($count > 0) {
$q = mysql_query('SELECT * FROM `clans` ORDER BY `level` DESC,`exp` DESC LIMIT '.$start.', '.$max.'');
while($row = mysql_fetch_array($q)) {
$i++;
if($i < 4) {
?>
<div class='content'>
<?=$i?> place<br/><br/>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/images/icon/clan/gerb/<?=$row['gerb']?>.png' alt='*'/></td><td valign='top' style='padding-left: 5px;'><img src='/images/icon/clan/<?=$row['r']?>.png' alt=''*/> <a href='/clan.php?id=<?=$row['id']?>'><?=$row['name']?></a><br/>
<img src='/images/icon/level.png'/> Level: <b><?=$row['level']?></b><br/>
<img src='/images/icon/exp.png' alt='*'/> Experience: <?=n_f($row['exp'])?></td>
</tr></table>
</div><div class='line'></div>
<?
}
else
{
?>
<li><img src='/images/icon/clan/<?=$row['r']?>.png' alt=''*/> <a href='/clan.php?id=<?=$row['id']?>'><?=$row['name']?></a>, <img src='/images/icon/level.png'/> <?=$row['level']?></li>
<?
}
}
?>
<li><?=pages('?')?></li>
<?
}
else
{
?>
<?
}
?>
<li class='no_b'><a href='/clans/create/'><img src='/images/icon/clan.png' alt='*'/> Create clan</a></li>
</div>
<?
include './system/f.php';
break;
case 'create':
$title = 'Create clan';
include './system/h.php';
$cost = 2000;
?>
<?
if($clan) {
?>
<div class='content'><font color='#999'>If you want to create your own clan you have to leave the current</font></div>
<?
}
else
{
$name = _string($_POST['name']);
$name = strToLower($name);
if($name && $user['g'] >= $cost) {
$clans = mysql_query('SELECT * FROM `clans` WHERE `name` = "'.$name.'"');
$clans = mysql_fetch_array($clans);
if(!$clans) {
mysql_query('UPDATE `users` SET `g` = "'.($user['g'] - $cost).'" WHERE `id` = "'.$user['id'].'"');
mysql_query('INSERT INTO `clans` (`name`,`r`) VALUES ("'.$name.'", "'.$user['r'].'")');
$clan_id = mysql_insert_id();
mysql_query('INSERT INTO `clan_memb` (`clan`,`user`,`rank`, `time`,`last_update`) VALUES ("'.$clan_id.'", "'.$user['id'].'", "4", "'.time().'","'.(time() + ((60 * 60) * 24)).'")');
header('location: /clan.php');
}
}
?>
<div class='content' align='center'>
<form action='' method='post'>
Clan name:<br/>
<input name='name'/><br/>
<input type='submit' value='Create clan'/><br/>
<font color='#999'>Cost: <img src='/images/icon/gold.png' alt='*'/> <?=$cost?> gold</font>
</form>
</div>
<?
}
include './system/f.php';
break;
}
?>