DboorZ /statistics.php

Language PHP Lines 374
MD5 Hash b952ac3a3fb42e61bba8fc5127bd0edc
Repository https://github.com/minea94/DboorZ.git View Raw File
  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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/
require( ".".DIRECTORY_SEPARATOR."app".DIRECTORY_SEPARATOR."boot.php" );
require_once( MODEL_PATH."statistics.php" );
class GPage extends securegamepage
{

    public $selectedTabIndex = NULL;
    public $selectedRank = NULL;
    public $dataList = NULL;
    public $pageSize = 20;
    public $pageCount = NULL;
    public $pageIndex = NULL;
    public $generalData = NULL;
    public $top10Result = NULL;
    public $isAdmin = FALSE;
    public $adminActionMessage = "";
    public $_tb = NULL;
    public $tatarRaised = NULL;

    public function GPage( )
    {
        parent::securegamepage( );
        $this->viewFile = "statistics.phtml";
        $this->contentCssClass = "statistics";
    }

    public function load( )
    {
        parent::load( );
        $this->selectedTabIndex = isset( $_GET['t'] ) && is_numeric( $_GET['t'] ) && 0 <= intval( $_GET['t'] ) && intval( $_GET['t'] ) <= 11 ? intval( $_GET['t'] ) : 0;
        $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
        $this->_tb = isset( $_GET['tb'] ) ? intval( $_GET['tb'] ) : 0;
        $m = new StatisticsModel( );
        $this->tatarRaised = $m->tatarRaised( );
        if ( $this->selectedTabIndex == 11 && !$this->tatarRaised )
        {
            $this->selectedTabIndex = 0;
        }
        $this->selectedRank = 0;
        if ( $this->selectedTabIndex == 0 )
        {
            if ( $this->isPost( ) && isset( $_POST['rank'] ) && isset( $_POST['name'] ) )
            {
                if ( trim( $_POST['name'] ) != "" )
                {
                    $this->selectedRank = intval( $m->getPlayerRankByName( trim( $_POST['name'] ), $this->_tb ) );
                }
                else if ( 0 < intval( $_POST['rank'] ) )
                {
                    $this->selectedRank = intval( $_POST['rank'] );
                }
            }
            else if ( !isset( $_GET['p'] ) )
            {
                $this->selectedRank = 0 < $this->_tb && $this->data['tribe_id'] != $this->_tb ? 1 : intval( $m->getPlayerRankById( $this->player->playerId, $this->_tb ) );
            }
            if ( $this->isAdmin && !$this->isPost( ) )
            {
                if ( isset( $_GET['_cs'] ) && 0 < intval( $_GET['_cs'] ) )
                {
                    $m->togglePlayerStatus( intval( $_GET['_cs'] ) );
                    $this->adminActionMessage = statistics_p_playerstatusch;
                }
                else if ( isset( $_GET['_dp'] ) && 0 < intval( $_GET['_dp'] ) )
                {
                    if ( $m->getPlayerType( intval( $_GET['_dp'] ) ) == PLAYERTYPE_NORMAL )
                    {
                        $qm = new QueueJobModel( );
                        $qm->deletePlayer( intval( $_GET['_dp'] ) );
                        $this->adminActionMessage = statistics_p_playerdeleted;
                    }
                }
                else if ( isset( $_GET['_gd'] ) && 0 < intval( $_GET['_gd'] ) && isset( $_GET['_g'] ) && 0 <= intval( $_GET['_g'] ) )
                {
                    $m->setPlayerGold( intval( $_GET['_gd'] ), intval( $_GET['_g'] ) );
                    $this->adminActionMessage = statistics_p_goldwaschanged;
                }
            }
        }
        else if ( $this->selectedTabIndex == 1 )
        {
            if ( $this->isPost( ) && isset( $_POST['rank'] ) && isset( $_POST['name'] ) )
            {
                if ( trim( $_POST['name'] ) != "" )
                {
                    $this->selectedRank = intval( $m->getAllianceRankByName( trim( $_POST['name'] ) ) );
                }
                else if ( 0 < intval( $_POST['rank'] ) )
                {
                    $this->selectedRank = intval( $_POST['rank'] );
                }
            }
            else if ( !isset( $_GET['p'] ) )
            {
                $this->selectedRank = intval( $m->getAllianceRankById( intval( $this->data['alliance_id'] ) ) );
            }
        }
        else if ( $this->selectedTabIndex == 2 )
        {
            if ( $this->isPost( ) && isset( $_POST['rank'] ) && isset( $_POST['name'] ) )
            {
                if ( trim( $_POST['name'] ) != "" )
                {
                    $this->selectedRank = intval( $m->getVillageRankByName( trim( $_POST['name'] ) ) );
                }
                else if ( 0 < intval( $_POST['rank'] ) )
                {
                    $this->selectedRank = intval( $_POST['rank'] );
                }
            }
            else if ( !isset( $_GET['p'] ) )
            {
                $this->selectedRank = intval( $m->getVillageRankById( $this->data['selected_village_id'] ) );
            }
        }
        else if ( $this->selectedTabIndex == 3 )
        {
            if ( $this->isPost( ) && isset( $_POST['rank'] ) && isset( $_POST['name'] ) )
            {
                if ( trim( $_POST['name'] ) != "" )
                {
                    $this->selectedRank = intval( $m->getHeroRankByName( trim( $_POST['name'] ) ) );
                }
                else if ( 0 < intval( $_POST['rank'] ) )
                {
                    $this->selectedRank = intval( $_POST['rank'] );
                }
            }
            else if ( !isset( $_GET['p'] ) )
            {
                $this->selectedRank = intval( $m->getHeroRankById( $this->player->playerId ) );
            }
        }
        else if ( $this->selectedTabIndex == 6 || $this->selectedTabIndex == 7 )
        {
            if ( $this->isPost( ) && isset( $_POST['rank'] ) && isset( $_POST['name'] ) )
            {
                if ( trim( $_POST['name'] ) != "" )
                {
                    $this->selectedRank = intval( $m->getPlayersPointsByName( trim( $_POST['name'] ), $this->selectedTabIndex == 6 ) );
                }
                else if ( 0 < intval( $_POST['rank'] ) )
                {
                    $this->selectedRank = intval( $_POST['rank'] );
                }
            }
            else if ( !isset( $_GET['p'] ) )
            {
                $this->selectedRank = intval( $m->getPlayersPointsById( $this->player->playerId, $this->selectedTabIndex == 6 ) );
            }
        }
        else if ( $this->selectedTabIndex == 9 || $this->selectedTabIndex == 10 )
        {
            if ( $this->isPost( ) && isset( $_POST['rank'] ) && isset( $_POST['name'] ) )
            {
                if ( trim( $_POST['name'] ) != "" )
                {
                    $this->selectedRank = intval( $m->getAlliancePointsRankByName( trim( $_POST['name'] ), $this->selectedTabIndex == 9 ) );
                }
                else if ( 0 < intval( $_POST['rank'] ) )
                {
                    $this->selectedRank = intval( $_POST['rank'] );
                }
            }
            else if ( !isset( $_GET['p'] ) )
            {
                $this->selectedRank = intval( $m->getAlliancePointsRankById( intval( $this->data['alliance_id'] ), $this->selectedTabIndex == 9 ) );
            }
        }
        if ( $this->selectedTabIndex == 0 )
        {
            $rowsCount = $m->getPlayerListCount( $this->_tb );
            $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
            $this->pageIndex = 0 < $this->selectedRank ? floor( ( $this->selectedRank - 1 ) / $this->pageSize ) : isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
            if ( $this->pageCount <= $this->pageIndex )
            {
                $this->pageIndex = $this->pageCount - 1;
                $this->selectedRank = 0 - 1;
            }
            $this->dataList = $m->getPlayerList( $this->pageIndex, $this->pageSize, $this->_tb );
        }
        else if ( $this->selectedTabIndex == 1 )
        {
            $rowsCount = $m->getAllianceListCount( );
            $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
            $this->pageIndex = 0 < $this->selectedRank ? floor( ( $this->selectedRank - 1 ) / $this->pageSize ) : isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
            if ( $this->pageCount <= $this->pageIndex )
            {
                $this->pageIndex = $this->pageCount - 1;
                $this->selectedRank = 0 - 1;
            }
            $this->dataList = $m->getAlliancesList( $this->pageIndex, $this->pageSize );
        }
        else if ( $this->selectedTabIndex == 2 )
        {
            $rowsCount = $m->getVillageListCount( );
            $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
            $this->pageIndex = 0 < $this->selectedRank ? floor( ( $this->selectedRank - 1 ) / $this->pageSize ) : isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
            if ( $this->pageCount <= $this->pageIndex )
            {
                $this->pageIndex = $this->pageCount - 1;
                $this->selectedRank = 0 - 1;
            }
            $this->dataList = $m->getVillagesList( $this->pageIndex, $this->pageSize );
        }
        else if ( $this->selectedTabIndex == 3 )
        {
            $rowsCount = $m->getHeroListCount( );
            $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
            $this->pageIndex = 0 < $this->selectedRank ? floor( ( $this->selectedRank - 1 ) / $this->pageSize ) : isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
            if ( $this->pageCount <= $this->pageIndex )
            {
                $this->pageIndex = $this->pageCount - 1;
                $this->selectedRank = 0 - 1;
            }
            $this->dataList = $m->getHerosList( $this->pageIndex, $this->pageSize );
        }
        else if ( $this->selectedTabIndex == 4 )
        {
            $this->generalData = $m->getGeneralSummary( );
        }
        else if ( $this->selectedTabIndex == 6 || $this->selectedTabIndex == 7 )
        {
            $rowsCount = $m->getPlayersPointsListCount( );
            $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
            $this->pageIndex = 0 < $this->selectedRank ? floor( ( $this->selectedRank - 1 ) / $this->pageSize ) : isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
            if ( $this->pageCount <= $this->pageIndex )
            {
                $this->pageIndex = $this->pageCount - 1;
                $this->selectedRank = 0 - 1;
            }
            $this->dataList = $m->getPlayersPointsList( $this->pageIndex, $this->pageSize, $this->selectedTabIndex == 6 );
        }
        else if ( $this->selectedTabIndex == 9 || $this->selectedTabIndex == 10 )
        {
            $rowsCount = $m->getAlliancePointsListCount( );
            $this->pageCount = 0 < $rowsCount ? ceil( $rowsCount / $this->pageSize ) : 1;
            $this->pageIndex = 0 < $this->selectedRank ? floor( ( $this->selectedRank - 1 ) / $this->pageSize ) : isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) ? intval( $_GET['p'] ) : 0;
            if ( $this->pageCount <= $this->pageIndex )
            {
                $this->pageIndex = $this->pageCount - 1;
                $this->selectedRank = 0 - 1;
            }
            $this->dataList = $m->getAlliancePointsList( $this->pageIndex, $this->pageSize, $this->selectedTabIndex == 9 );
        }
        else if ( $this->selectedTabIndex == 5 || $this->selectedTabIndex == 8 )
        {
            if ( $this->selectedTabIndex == 5 )
            {
            }
            $this->top10Result = array(
                "URL" => $this->selectedTabIndex == 5 ? "profile.php?uid=" : "alliance.php?id=",
                "TARGETNAME" => $this->selectedTabIndex == 5 ? $this->data['name'] : $this->data['alliance_name'],
                "TARGETID" => $this->selectedTabIndex == 5 ? $this->player->playerId : intval( $this->data['alliance_id'] ),
                "TARGEPOINT_ATTACK" => $this->selectedTabIndex == 5 ? $this->data['week_attack_points'] : $m->getAlliancePoint( intval( $this->data['alliance_id'] ), "week_attack_points" ),
                "TARGEPOINT_DEFENSE" => $this->selectedTabIndex == 5 ? $this->data['week_defense_points'] : $m->getAlliancePoint( intval( $this->data['alliance_id'] ), "week_defense_points" ),
                "TARGEPOINT_DEV" => $this->selectedTabIndex == 5 ? $this->data['week_dev_points'] : $m->getAlliancePoint( intval( $this->data['alliance_id'] ), "week_dev_points" ),
                "TARGEPOINT_THIEF" => $m->getAlliancePoint( intval( $this->data['alliance_id'] ), "week_thief_points" ),
                "ATTACK" => $m->getTop10( $this->selectedTabIndex == 5, "week_attack_points" ),
                "DEFENSE" => $m->getTop10( $this->selectedTabIndex == 5, "week_defense_points" ),
                "DEV" => $m->getTop10( $this->selectedTabIndex == 5, "week_dev_points" ),
                "THIEF" => $m->getTop10( $this->selectedTabIndex == 5, "week_thief_points" )
            );
        }
        else if ( $this->selectedTabIndex == 11 )
        {
            $this->dataList = $m->getTatarVillagesList( );
        }
        $m->dispose( );
    }

    public function preRender( )
    {
        parent::prerender( );
        if ( 0 <= $this->selectedTabIndex )
        {
            $this->villagesLinkPostfix .= "&t=".$this->selectedTabIndex;
        }
    }

    public function getNextLink( )
    {
        $text = text_nextpage_lang." »";
        if ( $this->pageIndex + 1 == $this->pageCount )
        {
            return $text;
        }
        $link = "";
        if ( 0 < $this->selectedTabIndex )
        {
            $link .= "t=".$this->selectedTabIndex;
        }
        if ( $link != "" )
        {
            $link .= "&";
        }
        $link .= "p=".( $this->pageIndex + 1 );
        if ( 0 < $this->_tb )
        {
            $link .= "&tb=".$this->_tb;
        }
        $link = "statistics.php?".$link;
        return "<a href=\"".$link."\">".$text."</a>";
    }

    public function getPreviousLink( )
    {
        $text = "« ".text_prevpage_lang;
        if ( $this->pageIndex == 0 )
        {
            return $text;
        }
        $link = "";
        if ( 0 < $this->selectedTabIndex )
        {
            $link .= "t=".$this->selectedTabIndex;
        }
        if ( 0 < $this->pageIndex )
        {
            if ( $link != "" )
            {
                $link .= "&";
            }
            $link .= "p=".( $this->pageIndex - 1 );
        }
        if ( 0 < $this->_tb )
        {
            if ( $link != "" )
            {
                $link .= "&";
            }
            $link .= "tb=".$this->_tb;
        }
        if ( $link != "" )
        {
            $link = "?".$link;
        }
        $link = "statistics.php".$link;
        return "<a href=\"".$link."\">".$text."</a>";
    }

    public function getWonderLandLevel( $builds )
    {
        $b_arr = explode( ",", $builds );
        $indx = 0;
        foreach ( $b_arr as $b_str )
        {
            ++$indx;
            $b2 = explode( " ", $b_str );
            $itemId = $b2[0];
            $level = $b2[1];
            if ( !( $itemId == 40 ) )
            {
                continue;
            }
            return $level;
        }
        return 0;
    }

}


$p = new GPage( );
$p->run( );
?>
Back to Top