1
<?php
2
/**
3
 *   File functions:
4
 *   Monuments - the best players in various fields.
5
 *
6
 *   @name                 : monuments.php
7
 *   @copyright            : (C) 2004,2005,2006, 2007 Vallheru Team based on Gamers-Fusion ver 2.5
8
 *   @author               : thindil <thindil@users.sourceforge.net>
9
 *   @author               : eyescream <tduda@users.sourceforge.net>
10
 *   @version              : 1.4
11
 *   @since                : 17.05.2007
12
 *
13
 */
14
15
//
16
//
17
//       This program is free software; you can redistribute it and/or modify
18
//   it under the terms of the GNU General Public License as published by
19
//   the Free Software Foundation; either version 2 of the License, or
20
//   (at your option) any later version.
21
//
22
//   This program is distributed in the hope that it will be useful,
23
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
24
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
//   GNU General Public License for more details.
26
//
27
//   You should have received a copy of the GNU General Public License
28
//   along with this program; if not, write to the Free Software
29
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30
//
31
// $Id$
32
33
$title = 'PosÄ…gi';
34
require('includes/head.php');
35
36
/**
37
* Get the localization for game
38
*/
39
require('languages/'.$player -> lang.'/monuments.php');
40
41
if ($player -> location != 'Altara' && $player -> location != 'Ardulith')
42
{
43
    error (ERROR);
44
}
45
46
// Setup Smarty caching, normally this should go to includes/head.php
47
$smarty -> cache_dir = 'cache/';
48
$smarty -> caching = 2;
49
$smarty -> cache_lifetime = 3600;   // Monuments will be refreshed after 1 hour from first viewing.
50
// End of Smarty setup.
51
52
if (!$smarty -> is_cached('monuments.tpl'))
53
{
54
    // Store old fetch mode (probably ADODB_FETCH_ASSOC, defined in includes/config.php) and set new, a bit faster.
55
    $oldFetchMode = $db -> SetFetchMode(ADODB_FETCH_NUM);
56
    $arrMonuments = array(array('level', 'wins', 'credits`+`bank'),
57
                          array('strength', 'wytrz', 'inteli', 'wisdom', 'szyb', 'agility'),
58
                          array('atak', 'shoot', 'magia', 'unik', 'leadership'),
59
                          array('ability', 'fletcher', 'alchemia', 'herbalist', 'jeweller', 'breeding', 'mining', 'lumberjack', 'hutnictwo'));
60
61
    for ($i=0, $max1 = sizeof($arrMonuments), $arrResult = array(); $i<$max1; $i++)
62
    {
63
        for ($j=0, $max2 = sizeof($arrMonuments[$i]), $arrResult[$i] = array(); $j<$max2; $j++)
64
        {
65
            $arrResult[$i][$j] = $db -> GetAll('SELECT `id`, `user`, `'.$arrMonuments[$i][$j].'` FROM `players` ORDER BY `'.$arrMonuments[$i][$j].'` DESC LIMIT 5');
66
        }
67
    }
68
    // Restore old mode.
69
    $db -> SetFetchMode($oldFetchMode);
70
    // Assign by reference - less copying, less memory used.
71
    $smarty -> assign_by_ref('Groups', $arrGroups);
72
    $smarty -> assign_by_ref('Titles', $arrTitles);
73
    $smarty -> assign_by_ref('Descriptions', $arrDescriptions);
74
    $smarty -> assign_by_ref('Monuments', $arrResult);
75
    $smarty -> display ('monuments.tpl');
76
    // After this point, arrays aren't used and can be safely destroyed. Free memory!
77
    unset($arrGroups, $arrTitles, $arrDescriptions, $arrMonuments, $arrResult);
78
}
79
    else
80
{
81
    $smarty -> display ('monuments.tpl');
82
}
83
// Disable caching, to ensure that foot.php works in good, old, ineffective way.
84
$smarty -> caching = 0;
85
require('includes/foot.php');
86
?>