forked from H3Gi/tatar-wars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
friends.php
119 lines (84 loc) · 2.62 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
118
119
<?php
require( '.' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'boot.php' );
require_once( MODEL_PATH . 'friends.php' );
class GPage extends SecureGamePage {
var $friends = array();
var $pageSize = 20;
var $pageIndex = null;
var $pageCount = null;
function GPage() {
parent::securegamepage();
$this->viewFile = 'friends.phtml';
$this->contentCssClass = 'player';
}
function load() {
parent::load();
$this->pageIndex = (( isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ) ? intval( $_GET['p'] ) : 0);
$m = new FriendsModel();
$rowsCount = $m->getFriendsCount( $this->player->playerId );
$this->pageCount = (0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1);
if (( isset( $_GET['DFid'] ) && !empty( $_GET['DFid'] ) )) {
$FriendID = mysql_real_escape_string( trim( $_GET['DFid'] ) );
if ($FriendID != '') {
$m->DeleteFriend( $FriendID, $this->player->playerId );
$m->dispose();
$this->redirect( 'friends.php' );
return null;
}
}
if (( isset( $_GET['CFid'] ) && !empty( $_GET['CFid'] ) )) {
$ConfirmID = mysql_real_escape_string( trim( $_GET['CFid'] ) );
if ($ConfirmID != '') {
$m->ConfirmInvitation( $ConfirmID, $this->player->playerId );
$m->dispose();
$this->redirect( 'friends.php' );
return null;
}
}
if ($this->isPost()) {
$post = array();
$post['playerId1'] = $this->player->playerId;
$post['myname'] = $this->data['name'];
$post['playerName'] = (( isset( $_POST['playerName'] ) && $_POST['playerName'] != '' ) ? trim( $_POST['playerName'] ) : trim( $_POST['playerName'] ));
if ($post['playerName'] != '') {
$m->SendInvitation( $post );
}
else {
echo '<pre> Error : Wrong name';
}
$m->dispose();
}
$this->friends = $m->GetFriends( $this->player->playerId, $this->pageIndex, $this->pageSize );
$m->dispose();
}
function getNextLink() {
$text = text_nextpage_lang . ' »';
if ($this->pageIndex + 1 == $this->pageCount) {
return $text;
}
$link = 'p=' . ( $this->pageIndex + 1 );
$link = 'friends.php?' . $link;
return '<a href="' . $link . '">' . $text . '</a>';
}
function getPreviousLink() {
$text = '« ' . text_prevpage_lang;
if ($this->pageIndex == 0) {
return $text;
}
$link = '';
if (0 < $this->pageIndex) {
if ($link != '') {
$link .= '&';
}
$link .= 'p=' . ( $this->pageIndex - 1 );
}
if ($link != '') {
$link = '?' . $link;
}
$link = 'friends.php' . $link;
return '<a href="' . $link . '">' . $text . '</a>';
}
}
$p = new GPage();
$p->run();
?>