| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Logout with rest for players without houses |
| 5 |
* |
| 6 |
* @name : poorhouse.php |
| 7 |
* @copyright : (C) 2004,2005,2006,2007 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : Tril <tril@faerun.com.pl> |
| 9 |
* @version : 1.0 |
| 10 |
* @since : 19.09.2007 |
| 11 |
* |
| 12 |
*/ |
| 13 |
|
| 14 |
// Published under GNU GPL 2 or later. See /install/README file for details. |
| 15 |
// $Id$ |
| 16 |
$title = 'Schronisko'; |
| 17 |
/** |
| 18 |
* Logout with rest |
| 19 |
*/ |
| 20 |
if(isset($_GET['did']) && preg_match('/[1-9][0-9]*/', $_GET['did'])) { |
| 21 |
|
| 22 |
require_once 'includes/sessions.php'; |
| 23 |
require_once 'includes/config.php'; |
| 24 |
|
| 25 |
// End session |
| 26 |
if(empty($_SESSION['email'])) |
| 27 |
{ |
| 28 |
date_default_timezone_set('Europe/Warsaw'); |
| 29 |
/** |
| 30 |
* Check avaible languages |
| 31 |
*/ |
| 32 |
$dir = opendir('languages/'); |
| 33 |
$arrLanguage = array(); |
| 34 |
$i = 0; |
| 35 |
while ($file = readdir($dir)) |
| 36 |
{ |
| 37 |
if (!preg_match("/.htm*$/i", $file) && !preg_match("/\.$/i", $file)) |
| 38 |
{ |
| 39 |
$arrLanguage[$i] = $file; |
| 40 |
++$i; |
| 41 |
} |
| 42 |
} |
| 43 |
closedir($dir); |
| 44 |
/** |
| 45 |
* Get the localization for game |
| 46 |
*/ |
| 47 |
$strLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
| 48 |
foreach ($arrLanguage as $strTrans) |
| 49 |
{ |
| 50 |
if (preg_match('/^'.$strTrans.'/i', $strLanguage)) |
| 51 |
{ |
| 52 |
$strTranslation = $strTrans; |
| 53 |
break; |
| 54 |
} |
| 55 |
} |
| 56 |
if (!isset($strTranslation)) |
| 57 |
{ |
| 58 |
$strTranslation = 'pl'; |
| 59 |
} |
| 60 |
require_once("languages/".$strTranslation."/poorhouse.php"); |
| 61 |
require_once('libs/Smarty.class.php'); |
| 62 |
$smarty = new Smarty; |
| 63 |
$smarty -> compile_check = true; |
| 64 |
$smarty -> assign ("Error", E_SESSIONS); |
| 65 |
$smarty -> display ('error.tpl'); |
| 66 |
exit; |
| 67 |
} |
| 68 |
|
| 69 |
$stat = $db -> GetRow("SELECT `id`, `level`, `credits`, `lang` FROM `players` WHERE `email`='".$_SESSION['email']."'"); |
| 70 |
// Id's don't match |
| 71 |
if ($stat['id'] != $_GET['did']) |
| 72 |
{ |
| 73 |
require_once 'includes/head.php'; |
| 74 |
require_once 'languages/'.$player -> lang.'/poorhouse.php'; |
| 75 |
error(ERROR); |
| 76 |
} |
| 77 |
// Player hasn't enough cash |
| 78 |
if ($stat['credits'] < $stat['level']*50) |
| 79 |
{ |
| 80 |
require_once 'includes/head.php'; |
| 81 |
require_once 'languages/'.$player -> lang.'/poorhouse.php'; |
| 82 |
error(NO_CASH); |
| 83 |
} |
| 84 |
// All ok, destroy session, set rest, display logout.tpl |
| 85 |
$db -> Execute('UPDATE `players` SET `rest`=\'Y\', `lpv`=`lpv`-180, `credits`=`credits`-'.(50*$stat['level']).' WHERE `id`='.$stat['id']); |
| 86 |
session_unset(); |
| 87 |
session_destroy(); |
| 88 |
date_default_timezone_set('Europe/Warsaw'); |
| 89 |
require_once "languages/".$stat['lang']."/logout.php"; |
| 90 |
require_once('libs/Smarty.class.php'); |
| 91 |
$smarty = new Smarty; |
| 92 |
$smarty -> compile_check = true; |
| 93 |
$smarty -> assign("Gamename", $gamename); |
| 94 |
$smarty -> display ('logout.tpl'); |
| 95 |
} |
| 96 |
/** |
| 97 |
* View main page |
| 98 |
*/ |
| 99 |
else |
| 100 |
{ |
| 101 |
require_once 'includes/head.php'; |
| 102 |
require_once 'languages/'.$player -> lang.'/poorhouse.php'; |
| 103 |
$smarty -> display('poorhouse.tpl'); |
| 104 |
require_once 'includes/foot.php'; |
| 105 |
} |
| 106 |
?> |