<?php
/**
* @author ByUNNAMED
* @copyright 2012
*/
ob_start();
$title='Клан';//Титул
include('../../system/include/settings.inc');//Потключаемся к базе
include('../../system/include/function.inc');//Выводим функции
head($title,$udata2);//Верх страницы
if(isset($udata['pass']) && isset($udata2['nick'])){
switch($_GET['mod'])
{
default:
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '".$udata2['clan']."'");
$clan = mysql_fetch_array($req);
echo 'Название клана: '.$clan['name'];
if($clan['emblema'] != '')
{
echo '<br />Емблема клана: <img src="../../images/clan/'.$clan['emblema'].'"/>';
}
$req = mysql_query("SELECT * FROM `chars` WHERE `clan` = '".$clan['lider']."'");
$kol = mysql_num_rows($req);
echo '<br />Количество бойцов в клане: '.$kol;
echo '<br /><a href="list.asp">Список бойцов</a>';
echo '<br />Золота на складе: '.$clan['gold'].' [<a href="put_gold.asp">Положить</a>|<a href="up_gold.asp">Забрать</a>]<br />';
if($clan['lider'] == $udata2['nick'])
{
echo '<a href="panel.asp">Панель управления</a>';
}
function smiles($string){
$dir = opendir ("../../images/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="../../images/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
echo "<br /><br /><form action=\"?mod=writes\" method=\"POST\">";
echo "<input type=\"text\" name=\"zin\" size=\"14\" maxlength=\"150\"/> <input type=\"submit\" value=\"Написать\" class=\"ibutton\"><br />";
if ($_GET[page] == "" || $_GET[page] < 0 || $_GET[page] == "0")
{
$_GET[page] = 0;
}
$next = $_GET[page] + 1;
$back = $_GET[page] - 1;
$num = $_GET[page] * 10;
if($_GET[page] == "0")
{$i = 1;}
else{$i = ($_GET[page]*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT `msg` FROM `clan_chat` WHERE `clan` = '".$udata2['clan']."'"));
$puslap = floor($viso/10);
$times = date("H:i");
$asd = mysql_query("SELECT * FROM clan_chat WHERE clan = '".$udata2['clan']."' ORDER BY id DESC LIMIT $num,10");
while($dsa = mysql_fetch_array($asd))
{
$nickas = strip_tags($dsa['usr']);
$koment = strip_tags($dsa['msg']);
$time = strip_tags($dsa['time']);
$data = strip_tags($dsa['data']);
$koment = smiles($koment);
echo '<b><a href="../../modules/character/info.asp?nick='.$nickas.'">'.$nickas.'</a> ['.$data.'/'.$time.']<br />
'.$koment;
echo'<br/>';
}
if ($_GET[page] > 0)
{
echo "<a href=\"?page=$back\">Назад</a>";
}
elseif ($_GET[page] == 0)
{
echo "Назад";
}
echo"|";
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "<a href=\"?page=$next\">Далее</a>";}
else
{echo "Далее";}
break;
case 'writes':
$msg=$_POST['zin'];
$msg=substr($msg, 0, 512);
$msg=stripslashes(htmlspecialchars($msg));
$msg=str_replace("\r\n","<br />",$msg);
$msg=str_replace("\r","<br />",$msg);
$msg=str_replace("\n","<br />",$msg);
$msg = addslashes($msg);
$msg=preg_replace ("|[\r\n]+|si","",$msg);
$a = mysql_num_rows(mysql_query("SELECT msg FROM clan_chat WHERE msg = '$msg' and clan = '".$udata2['clan']."'"));
$b = mysql_fetch_array(mysql_query("SELECT data FROM clan_chat WHERE usr = '".$udata2['nick']."' and clan = '".$udata2['clan']."' ORDER BY kada DESC LIMIT 1"));
$data_kom = strip_tags($b['kada']);
$data = date("d.m.y");
$data_dbr = date("y/m/d H:i:s");
$time = date("H:i");
if($data_dbr >= $data_kom && $msg != "")
{
mysql_query("INSERT INTO clan_chat SET usr = '".$udata2['nick']."', msg = '$msg', data = '$data', time = '$time', clan = '".$udata2['clan']."'");
$rand = rand(1000,9999);
//start
function smiles($string){
$dir = opendir ("pic/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
/////////////
$rand = rand(1000,9999);
///////////////////
echo "<a href=\"smile.php?\">Смайлы</a><br/>";
echo "<a href=\"?r=$rand\">Обновить</a>";
echo "<form action=\"?mod=writes\" method=\"POST\">";
echo "<input type=\"text\" name=\"zin\" maxlength=\"5000\"/> <input type=\"submit\" value=\"Написать\" class=\"ibutton\">";
if ($_GET[page] == "" || $_GET[page] < 0 || $_GET[page] == "0")
{
$_GET[page] = 0;
}
$next = $_GET[page] + 1;
$back = $_GET[page] - 1;
$num = $_GET[page] * 10;
if($_GET[page] == "0")
{$i = 1;}
else{$i = ($_GET[page]*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT msg FROM clan_chat WHERE clan = '".$udata2['clan']."'"));
$puslap = floor($viso/10);
$times = date("H:i");
$asd = mysql_query("SELECT * FROM clan_chat WHERE clan = '".$udata2['clan']."' ORDER BY id DESC LIMIT $num,10");
while($dsa = mysql_fetch_array($asd))
{
$nickas = strip_tags($dsa['usr']);
$koment = strip_tags($dsa['msg']);
$time = strip_tags($dsa['time']);
$koment = smiles($koment);
echo "<b>[$time]$nickas
$koment ";
echo'<br/>';
}
if ($_GET[page] > 0)
{
echo "<a href=\"?page=$back\">Назад</a>";
}
elseif ($_GET[page] == 0)
{
echo "Назад";
}
echo"|";
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "<a href=\"?page=$next\">Далее</a>";}
else
{echo "Далее";}
header('Location: ?');
//end
}
elseif($data_dbr < $data_kom)
{
$sec = $data_kom-$data_dbr;
$rand = rand(1000,9999);
echo "Защита от Флуда! Подождите $sec секунд<br/>";
echo"<a href=\"?r=$rand\">Продолжить</a>";
}
elseif($msg == "")
{
$rand = rand(1000,9999);
echo "Вы не написали сообщение!<br/>";
echo"<a href=\"?r=$rand\">Продолжить</a>";
}
else
{
$rand = rand(1000,9999);
echo "Ошибка!<br/>";
echo"<a href=\"?r=$rand\">Продолжить</a>";
}
break;
case 'ok_clan':
$req = mysql_query("SELECT * FROM `to_clan` WHERE `usr`='".$udata2['nick']."'");
$kol = mysql_num_rows($req);
$clan = mysql_fetch_array($req);
if($kol <= 0)
{
echo 'У вас нет приглашений в клан!<br />';
foot(); exit ;
}
$req = mysql_query("UPDATE `chars` SET `clan` = '".$clan['lider']."' WHERE `nick` = '".$udata2['nick']."'");
if($req == true)
{
mysql_query("DELETE FROM `to_clan` WHERE `usr` = '".$udata2['nick']."'");
echo 'Вы успешно вступили в клан ';
echo '<br /><a href="?">Продолжить</a>';
}else{
mysql_query("INSERT INTO `log_error` SET `usr` = '".$udata2['nick']."', `text` = 'Ошибка при вступлении в клан.', `file` = 'modules/clan/index.asp'");
echo 'Ошибка... Администратор извещен.';
}
break;
case 'no_clan':
$req = mysql_query("SELECT * FROM `to_clan` WHERE `usr`='".$udata2['nick']."'");
$kol = mysql_num_rows($req);
$clan = mysql_fetch_array($req);
if($kol <= 0)
{
echo 'У вас нет приглашений в клан!<br />';
foot(); exit ;
}
$req = mysql_query("DELETE FROM `to_clan` WHERE `usr` = '".$udata2['nick']."'");
if($req == true)
{
mysql_query("DELETE FROM `to_clan` WHERE `usr` = '".$udata2['nick']."'");
echo 'Вы успешно отказались вступать в клан';
}else{
mysql_query("INSERT INTO `log_error` SET `usr` = '".$udata2['nick']."', `text` = 'Ошибка при отказе вступлении в клан.', `file` = 'modules/clan/index.asp'");
echo 'Ошибка... Администратор извещен.';
}
break;
case 'exit':
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '".$udata2['nick']."'");
$clan = mysql_num_rows($req);
if($clan > 0)
{
echo 'Вы являетесь лидером клана и не можете уйти!';
foot(); exit ;
}
if($udata2['clan'] == '')
{
echo 'Вы не вклане!';
foot(); exit ;
}
$req = mysql_query("UPDATE `chars` SET `clan` = '' WHERE `nick` = '".$udata2['nick']."'");
if($req == true)
{
echo 'Вы успешно покинули клан ';
}else{
mysql_query("INSERT INTO `log_error` SET `usr` = '".$udata2['nick']."', `text` = 'Ошибка при выходе с клана.', `file` = 'modules/clan/index.asp'");
echo 'Ошибка... Администратор извещен.';
}
break;
}
}else{echo'Вы не ';
echo '<a href="../../index.asp">авторизированы</a> или не выбран персонаж';
}
foot();
?>