Друзья

meydan

Старейшина
Репутация
0 / 95
Мод друзья:

Код:
CREATE TABLE `friend` (
  `id` int(4) NOT NULL auto_increment,
  `login` varchar(30) default NULL,
  `friend` varchar(30) default NULL,
  PRIMARY KEY  (`id`),
  KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;


Код:
function getalign($align)
{
    switch ($align)
    {
        case 1:    return("Братство Палачей"); break;
        case 2:    return("Вампиры");break;
        case 3: return("Орден Равновесия");break;
        case 4: return("Орден Света");break;
        case 5: return("Тюремный заключеный");break;
        case 6: return("Истинный Мрак");break;
    }
    return("");
}
function drwfl($name, $id, $level, $dealer,  $align, $klan, $klanid)
{
    $s="";
    if ($align>0) $s.="<img src='img/orden/".$align.".gif'  alt=\"".getalign($align)."\" border='0' /></a> ";
    if ($dealer>0)$s.="<img src='img/orden/dealer.gif' border=0 alt=\"Дилер игры\">";
    if ($klan) $s.="<a href='clan_inf.php?clan=".$klan."' target='_blank'><img src='img/clan/".$klan.".gif'  alt='Клан ".$klanid."' border='0' /></A>";
    $s.="[b]".$name."[/b]";
    if ($level!=-1) $s.=" [".$level."]";
    if ($id!=-1) $s.="<a href='info.php?log=".$name."' target='_blank'><img src='img/index/h.gif' alt='Инф. о ".$name."' border='0' /></a>";
    return ($s);
}

friend.php


Код:
<?include('key.php');
$login=$_SESSION["login"];
$act=$_GET['act'];
$added=$_GET['added'];
$deleted=$_GET['deleted'];

include "conf.php";
include "align.php";
include "functions.php";

$chas = date("H");
$server_date=date("d.m.Y", mktime($chas-$GSM));
$server_time=date("H:i:s", mktime($chas-$GSM));

$data = mysql_connect($base_name, $base_user, $base_pass);
if(!mysql_select_db($db_name,$data))
{
    echo mysql_error();
    die();
}

//-----------------------------------------------------------------------------------------------       
    if ($act=="add")
    { 
        if (isset($_POST['target']))
        {       
            $target=trim($_POST['target']);
            $result = mysql_query("SELECT * FROM `users` WHERE login='".$target."'");
            $CHECK = mysql_fetch_array($result);
            if(!$CHECK)
            {
                print "<font color=#ff0000>Персонаж [b]$target[/b] не найден в базе данных. </font>";
            }
            else
            {   
                $search=mysql_query("SELECT * FROM `friend` WHERE login = '".$login."' and friend='".$target."'");
                $CHECKFRIEND = mysql_fetch_array($search);
               
                if(!$CHECKFRIEND)
                {   
                    $add=mysql_query("INSERT INTO friend(login,friend) VALUES('$login','".$CHECK['login']."')");
                }
                else
                {
                    echo "<font color=#ff0000>Персонаж [b]$target[/b] уже в списке. </font>";
                }
            }   
        }
    }
//-----------------------------------------------------------------------------------------------   
    if ($act=="delete")
    { 
        if (isset($_POST['target']))
        {   
            $target=trim($_POST['target']);
            $search=mysql_query("SELECT * FROM `friend` WHERE login='".$_SESSION['login']."' and friend = '".$target."'");
            if($sec = mysql_fetch_array($search))
            {
                $delete_friend=mysql_query("DELETE FROM `friend` WHERE login='".$_SESSION['login']."' and friend = '".$target."'");
            }
            else
            {
                print "<font color=#ff0000>Персонаж [B]".$target."[/B] не в списке.</font>";
            }
        }
    }
//-----------------------------------------------------------------------------------------------   
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta http-equiv="Content-Language" content="ru">
<LINK REL=StyleSheet HREF='main.css' TYPE='text/css'>
<body bgcolor=#dddddd onLoad='top.cf.action=1;' onUnload='top.cf.action=0;'>
<script LANGUAGE="javascript" SRC="scripts/magic-main.js"></SCRIPT>   
<div id=hint4></div>   
<div align=right><input type=button value='Вернуться' class='new' style='cursor:hand' onClick="java script:location.href='main.php?act=none'"></div>


<table border="0" cellspacing="0" style="border-collapse: collapse" width="80%" align="center">
    <tr>
    <td width="100%">
        <table cellpadding=3 width=100% cellspacing=1 border=0>
        <tr>
        <td bgcolor=#eaeaea width=100% align=center colspan=4><b style="color:green">Список ваших Друзей[/b]</td></tr>
        <tr>
            <td bgcolor=#FCFAF3 width=50% align=center>[b]Ник[/b]</td>
            <td bgcolor=#FCFAF3 width=30% align=center>[b]Комната[/b]</td>
            <td bgcolor=#FCFAF3 width=20% align=center>[b]Статус[/b]</td>
        </tr>
        </table>
    </td>
    </tr>
</table>
<table border=0 cellspacing=0 style='border-collapse: collapse' width=80% align=center>
  <tr>
    <td width=100%>       
<?
    $result = mysql_query("select users.login as login,users.id as id,level,dealer,orden,clan_short,clan,room,(select count(*) FROM online where online.login=users.login)as online FROM users, (SELECT * FROM `friend` WHERE login='".$_SESSION["login"]."') as dbfr WHERE users.login=dbfr.friend");
    while($DAT = mysql_fetch_array($result))
    {
        $room=$DAT['room'];
        include('otaqlar.php');
        if ($DAT['online']<1) $online="<font color='#666666'>[i][b]Нет в клубе[/b][/i]</font>";
        else $online="<font color='green'>[b]OnLine[/b]</font>";
        ?>
        <table cellpadding=3 width=100% cellspacing=1 border=0>
        <tr>
        <?
        echo "<td bgcolor=#FCFAF3 width=50% align='left'>";
        echo "[url="'java"]<img border=0 src=img/arrow3.gif alt=\"Приватное сообщение\" >[/url] ";
        echo drwfl($DAT['login'], $DAT['id'], $DAT['level'], $DAT['dealer'], $DAT['orden'], $DAT['clan_short'], $DAT['clan']);
        echo "</td>";
        echo "<td bgcolor=#FCFAF3 width=30% align='center'>";
        echo $mesto;
        echo "</td>";
        echo "<td bgcolor=#FCFAF3 width=20% align='center'>";
        echo $online;
        echo "</td>";           
        ?>
        </tr>
        </table>
<?}?>
</td>
  </tr>
</table>


<center>
<INPUT type='button' style='width: 100px' value='Добавить' onclick='findlogin("Добавить в список", "?act=add", "target", "",5)'>
  
<INPUT type='button' style='width: 100px' value='Удалить' onclick='findlogin("Удалить из списка", "?act=delete", "target", "", 5)'></TD>
 
Последнее редактирование модератором:
Сверху