forked from H3Gi/tatar-wars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbadwords.php
120 lines (84 loc) · 2.37 KB
/
badwords.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
120
<?php
require( '.' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'boot.php' );
require_once( MODEL_PATH . 'badwords.php' );
require_once( MODEL_PATH . 'wordsfilter.php' );
class GPage extends SecureGamePage {
var $isAdmin = FALSE;
var $BadWords = array();
var $pageSize = 20;
var $pageIndex = null;
var $pageCount = null;
function GPage() {
parent::securegamepage();
$this->viewFile = 'badwords.phtml';
$this->contentCssClass = 'player';
}
function load() {
parent::load();
$this->pageIndex = (( isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ) ? intval( $_GET['p'] ) : 0);
$this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
if (!$this->isAdmin) {
exit( 0 );
return null;
}
$m = new BadWordsModel();
$rowsCount = $m->getBadWordsCount();
$this->pageCount = (0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1);
if (( isset( $_GET['Dword'] ) && !empty( $_GET['Dword'] ) )) {
$wordID = mysql_real_escape_string( trim( $_GET['Dword'] ) );
if ($wordID != '') {
$m->DeleteBadWords( $wordID );
$m->dispose();
$this->redirect( 'badwords.php' );
return null;
}
}
if ($this->isPost()) {
$i = 0;
while ($i < count( $_POST['words'] )) {
$words = mysql_real_escape_string( trim( $_POST['words'][$i] ) );
if ($words == '') {
continue;
}
$this->BadWords[] = $words;
++$i;
}
$m->addBadWords( $this->BadWords );
$m->dispose();
$this->redirect( 'badwords.php' );
return null;
}
$this->BadWords = $m->GetBadWords( $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 = 'badwords.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 = 'badwords.php' . $link;
return '<a href="' . $link . '">' . $text . '</a>';
}
}
$p = new GPage();
$p->run();
?>