-
Notifications
You must be signed in to change notification settings - Fork 0
/
friends.php
117 lines (113 loc) · 5.64 KB
/
friends.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* ----------------------------------------------
* Flame Web-site (PHP/MySQL)
* Copyright (c) Maksim <<Klym>> Klimenko
* URL: http://clan-flame.ru
* ----------------------------------------------
*/
session_start();
require("blocks/autoload.php");
require("blocks/db.php");
require("blocks/user.php");
if (!isset($_SESSION['email'])) {
die("<html><head>
<meta http-equiv='refresh' content='3; url=/'>
Для просмотра этой страници войдите или зарегистрируйтесь
</head></html>");
}
if (isset($_GET['id'])) {$id = $_GET['id'];} else {$id = '';}
if (isset($_GET['position'])) {$position = $_GET['position'];} else {$position = '';}
$page = "friends";
// Внимание! Дублирование кода. Блок кода приведенный ниже продублирован в leftUserBlock.php
$self = new Friends($user->id,$db);
$selfFriendsIds = $self->getConfirmedFriends();
$selfNotConfFriends = $self->getNotConfirmedFriends();
$selfFriendsRequests = $self->getFriendsRequests();
$friendsCount = count($selfFriendsIds);
$requestsCount = count($selfFriendsRequests);
if ($id != $user->id && !empty($id)) {
try {
$user1 = new User();
$user1->db = $db;
$user1->getUserInfo($id);
} catch( DataException $e ) {
die(require("blocks/errorTemplate.php"));
}
}
else {
$user1 = $user;
}
$friend = new Friends($user1->id,$db);
if ($position == "requests" && empty($id)) {
$friendsIds = $selfFriendsRequests;
}
else {
$friendsIds = $friend->getConfirmedFriends();
$friendsCount = count($friendsIds);
}
for($i = 0; $i < count($friendsIds); $i++) {
$friend->getFriendInfo($friendsIds[$i]);
}
$friends = Friends::$friend;
$endings = array('г','га','зей');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<? require("blocks/scripts.php"); ?>
<title>Официальный сайт клана Пламя - Друзья пользователя <? echo $user1->login; ?></title>
</head>
<body>
<div id="wrapper">
<? require("blocks/header.php"); ?>
<div id="body">
<? require("blocks/left.php"); ?>
<? require("blocks/right.php"); ?>
<div id="content">
<? require("blocks/menu.php"); ?>
<div id="contentText">
<div class="user">
<div class="beginUserBlock"></div>
<div class="userBlockInformation">
<div class="userBlockOpacity"></div>
<div class="userInformation">
<? require("blocks/leftUserBlock.php"); ?>
<div class="rightUserBlock">
<div class="userLogin"><? if ($id == $user->id || empty($id)) { ?> <a <? if ($position != "requests") {echo "class='active'";} ?> href="friends.php">Мои Друзья<? if($position != "requests") echo " (<span id='firendsCount'>".$friendsCount."</span>)"; ?></a><? if ($requestsCount > 0) {if($position == "requests") {$class = "class='active'";} else {$class = '';} echo "<a ".$class." href='friends.php?position=requests'>Заявки в друзья (+<span id='count'>".$requestsCount."</span>)</a>";} ?> <? } else {echo "У пользователя <span class='fpLogin'>".$user1->login."</span> ".$friendsCount." дру".$endings[Category::declension($friendsCount)];} ?></div>
<div>
<div id="userPol" style="display:none;"><? echo $user1->pol; ?></div>
<?
for($i = 0; $i < count($friends); $i++) { ?>
<div class="friend">
<div class="friendAvatar"><img src="avatars/<? echo $friends[$i]->avatar; ?>" width="75px" height="75px"></div>
<div class="friendLogin"><a href="page.php?id=<? echo $friends[$i]->friendId; ?>"><? echo $friends[$i]->login; ?></a></div>
<div class="friendAccess"><p><? echo $friends[$i]->access; ?></p></div>
<div class="friendOperations">
<? if($position == "requests") { ?>
<a href='#' class='addFriend' name='<? echo $friends[$i]->friendId; ?>'>Принять</a>
<a class='delFriend' href='#' name='<? echo $friends[$i]->friendId; ?>'>Отклонить</a>
<? } else if(empty($id) || $user->id == $id) { ?>
<a class='delFriend' href='#' name='<? echo $friends[$i]->friendId; ?>'>Убрать из друзей</a>
<? } ?>
</div>
<div class="sendMessage"><a href="im.php">ЛС</a></div>
</div>
<? } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="rightBorder"></div>
</div>
</div>
<? require("blocks/footer.php"); ?>
</div>
</body>
</html>