1
<?php
2
/**
3
 *   File functions:
4
 *   Logout from game
5
 *
6
 *   @name                 : logout.php                            
7
 *   @copyright            : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5
8
 *   @author               : thindil <thindil@users.sourceforge.net>
9
 *   @version              : 1.2
10
 *   @since                : 29.07.2006
11
 *
12
 */
13
14
//
15
//
16
//       This program is free software; you can redistribute it and/or modify
17
//   it under the terms of the GNU General Public License as published by
18
//   the Free Software Foundation; either version 2 of the License, or
19
//   (at your option) any later version.
20
//
21
//   This program is distributed in the hope that it will be useful,
22
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
23
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
//   GNU General Public License for more details.
25
//
26
//   You should have received a copy of the GNU General Public License
27
//   along with this program; if not, write to the Free Software
28
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
//
30
// $Id: logout.php 546 2006-07-29 10:42:45Z thindil $
31
32
require_once('includes/sessions.php'); 
33
require_once('libs/Smarty.class.php');
34
require_once ('includes/config.php');
35
36
$smarty = new Smarty;
37
38
$smarty -> compile_check = true;
39
40
/**
41
* Check avaible languages
42
*/    
43
$path = 'languages/';
44
$dir = opendir($path);
45
$arrLanguage = array();
46
$i = 0;
47
while ($file = readdir($dir))
48
{
49
    if (!ereg(".htm*$", $file))
50
    {
51
        if (!ereg("\.$", $file))
52
        {
53
            $arrLanguage[$i] = $file;
54
            $i = $i + 1;
55
        }
56
    }
57
}
58
closedir($dir);
59
60
/**
61
* Get the localization for game
62
*/
63
$strLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
64
foreach ($arrLanguage as $strTrans)
65
{
66
    $strSearch = "^".$strTrans;
67
    if (eregi($strSearch, $strLanguage))
68
    {
69
        $strTranslation = $strTrans;
70
        break;
71
    }
72
}
73
if (!isset($strTranslation))
74
{
75
    $strTranslation = 'pl';
76
}
77
require_once("languages/".$strTranslation."/logout.php");
78
79
if (!ereg("^[1-9][0-9]*$", $_GET['did'])) 
80
{
81
    $smarty -> assign ("Error", ERROR);
82
    $smarty -> display ('error.tpl');
83
    exit;
84
}
85
86
$pass = MD5($_SESSION['pass']);
87
$stat = $db -> Execute("SELECT id FROM players WHERE email='".$_SESSION['email']."'");
88
if ($stat -> fields['id'] != $_GET['did']) 
89
{
90
    $smarty -> assign ("Error", ERROR);
91
    $smarty -> display ('error.tpl');
92
    exit;
93
}
94
95
$stat -> Close();
96
if (isset($_GET['rest']) && $_GET['rest'] == 'Y') 
97
{
98
    $test = $db -> Execute("SELECT id FROM houses WHERE owner=".$_GET['did']);
99
    $test1 = $db -> Execute("SELECT id FROM houses WHERE locator=".$_GET['did']);
100
    if (!$test -> fields['id'] && !$test1 -> fields['id']) 
101
    {
102
        $smarty -> assign ("Error", NOT_SLEEP);
103
        $smarty -> display ('error.tpl');
104
        exit;
105
    }
106
    $test -> Close();
107
    $test1 -> Close();    
108
    $db -> Execute("UPDATE players SET rest='Y' WHERE id=".$_GET['did']);
109
}
110
$db -> Execute("UPDATE players SET lpv=lpv-180 WHERE id=".$_GET['did']);
111
session_unset();
112
session_destroy();
113
$smarty -> assign(array("Gamename" => $gamename,
114
    "Youare" => YOU_ARE,
115
    "Ahere" => A_HERE,
116
    "Charset" => CHARSET));
117
$smarty -> display ('logout.tpl');
118
119
?>