| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* File functions:
|
| 4 |
* Jail
|
| 5 |
*
|
| 6 |
* @name : jail.php
|
| 7 |
* @copyright : (C) 2004,2005,2006 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.3
|
| 11 |
* @since : 23.11.2006
|
| 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: jail.php 880 2007-02-07 19:14:14Z thindil $
|
| 32 |
|
| 33 |
$title = "Lochy";
|
| 34 |
require_once("includes/head.php");
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Get the localization for game
|
| 38 |
*/
|
| 39 |
require_once("languages/".$player -> lang."/jail.php");
|
| 40 |
|
| 41 |
if ($player -> location != 'Altara' && $player -> location != 'Lochy' && $player -> location != 'Ardulith')
|
| 42 |
{
|
| 43 |
error (ERROR);
|
| 44 |
}
|
| 45 |
|
| 46 |
$smarty -> assign("Prisoner", '');
|
| 47 |
|
| 48 |
/**
|
| 49 |
* If player is in city - show prisoners
|
| 50 |
*/
|
| 51 |
if ($player -> location == 'Altara' || $player -> location == 'Ardulith')
|
| 52 |
{
|
| 53 |
$smarty -> display ('jail.tpl');
|
| 54 |
$jail = $db -> Execute("SELECT * FROM `jail` ORDER BY `id` ASC");
|
| 55 |
$number = $jail -> RecordCount();
|
| 56 |
$smarty -> assign ("Number", $number);
|
| 57 |
if ($number > 0)
|
| 58 |
{
|
| 59 |
$arrid = array();
|
| 60 |
$arrname = array();
|
| 61 |
$arrdate = array();
|
| 62 |
$arrverdict = array();
|
| 63 |
$arrduration = array();
|
| 64 |
$arrjailid = array();
|
| 65 |
$arrcost = array();
|
| 66 |
$arrDurationr = array();
|
| 67 |
$i = 0;
|
| 68 |
while (!$jail -> EOF)
|
| 69 |
{
|
| 70 |
$pname = $db -> Execute("SELECT `user` FROM `players` WHERE `id`=".$jail -> fields['prisoner']);
|
| 71 |
$arrid[$i] = $jail -> fields['prisoner'];
|
| 72 |
$arrname[$i] = $pname -> fields['user'];
|
| 73 |
$arrdate[$i] = $jail -> fields['data'];
|
| 74 |
$arrverdict[$i] = $jail -> fields['verdict'];
|
| 75 |
$arrduration[$i] = ceil($jail -> fields['duration'] / 9);
|
| 76 |
$arrDurationr[$i] = $jail -> fields['duration'];
|
| 77 |
/**
|
| 78 |
* Easter egg - delete if you want
|
| 79 |
*/
|
| 80 |
if ($arrid[$i] == 331)
|
| 81 |
{
|
| 82 |
$arrduration[$i] = 'Dożywocie';
|
| 83 |
$arrDurationr[$i] = 'X';
|
| 84 |
}
|
| 85 |
$arrjailid[$i] = $jail -> fields['id'];
|
| 86 |
$arrcost[$i] = $jail -> fields['cost'];
|
| 87 |
$jail -> MoveNext();
|
| 88 |
$i = $i + 1;
|
| 89 |
}
|
| 90 |
$smarty -> assign(array("Id" => $arrid,
|
| 91 |
"Name" => $arrname,
|
| 92 |
"Date" => $arrdate,
|
| 93 |
"Verdict" => $arrverdict,
|
| 94 |
"Duration" => $arrduration,
|
| 95 |
"Jailid" => $arrjailid,
|
| 96 |
"Cost" => $arrcost,
|
| 97 |
"Duration2" => $arrDurationr,
|
| 98 |
"Pname" => P_NAME,
|
| 99 |
"Pid" => P_ID,
|
| 100 |
"Pdate" => P_DATE,
|
| 101 |
"Preason" => P_REASON,
|
| 102 |
"Pduration" => P_DURATION,
|
| 103 |
"Pduration2" => P_DURATION_R,
|
| 104 |
"Pcost" => P_COST,
|
| 105 |
"Goldcoins" => GOLD_COINS,
|
| 106 |
"Jailinfo" => JAIL_INFO));
|
| 107 |
}
|
| 108 |
else
|
| 109 |
{
|
| 110 |
$smarty -> assign(array("Noprisoners" => NO_PRISONERS,
|
| 111 |
"Jailinfo" => JAIL_INFO));
|
| 112 |
}
|
| 113 |
$jail -> Close();
|
| 114 |
}
|
| 115 |
|
| 116 |
/**
|
| 117 |
* If player is in jail - show info about it
|
| 118 |
*/
|
| 119 |
if ($player -> location == 'Lochy')
|
| 120 |
{
|
| 121 |
$prisoner = $db -> Execute("SELECT * FROM `jail` WHERE `prisoner`=".$player -> id);
|
| 122 |
$intTime = ceil($prisoner -> fields['duration'] / 9);
|
| 123 |
/**
|
| 124 |
* Easter egg - delete if you want
|
| 125 |
*/
|
| 126 |
if ($player -> id == 331)
|
| 127 |
{
|
| 128 |
$intTime = 'Dożywocie';
|
| 129 |
$arrDurationr[$i] = 'X';
|
| 130 |
}
|
| 131 |
$smarty -> assign(array("Date" => $prisoner -> fields['data'],
|
| 132 |
"Verdict" => $prisoner -> fields['verdict'],
|
| 133 |
"Duration" => $intTime,
|
| 134 |
"Cost" => $prisoner -> fields['cost'],
|
| 135 |
"Duration2" => $prisoner -> fields['duration'],
|
| 136 |
"Youare" => YOU_ARE,
|
| 137 |
"Pdate" => P_DATE,
|
| 138 |
"Pduration" => P_DURATION,
|
| 139 |
"Pduration2" => P_DURATION_R,
|
| 140 |
"Preason" => P_REASON,
|
| 141 |
"Pcost" => P_COST));
|
| 142 |
$prisoner -> Close();
|
| 143 |
}
|
| 144 |
|
| 145 |
/**
|
| 146 |
* Pay for free prisoner
|
| 147 |
*/
|
| 148 |
if (isset($_GET['prisoner']))
|
| 149 |
{
|
| 150 |
if (!ereg("^[1-9][0-9]*$", $_GET['prisoner']))
|
| 151 |
{
|
| 152 |
error (ERROR);
|
| 153 |
}
|
| 154 |
$prisoner = $db -> Execute("SELECT * FROM `jail` WHERE `id`=".$_GET['prisoner']);
|
| 155 |
if (!$prisoner -> fields['id'])
|
| 156 |
{
|
| 157 |
error (NO_PRISONER);
|
| 158 |
}
|
| 159 |
if ($prisoner -> fields['cost'] > $player -> credits)
|
| 160 |
{
|
| 161 |
error (NO_MONEY);
|
| 162 |
}
|
| 163 |
if ($player -> id == $prisoner -> fields['prisoner'])
|
| 164 |
{
|
| 165 |
error (NO_PERM);
|
| 166 |
}
|
| 167 |
$pname = $db -> Execute("SELECT `user` FROM `players` WHERE `id`=".$prisoner -> fields['prisoner']);
|
| 168 |
if (!isset($_GET['step']))
|
| 169 |
{
|
| 170 |
$_GET['step'] = '';
|
| 171 |
$smarty -> assign(array("Youwant" => YOU_WANT,
|
| 172 |
"Ayes" => YES,
|
| 173 |
"Prisonername" => $pname -> fields['user'],
|
| 174 |
"Aback" => A_BACK));
|
| 175 |
}
|
| 176 |
if (isset($_GET['step']) && $_GET['step'] == 'confirm')
|
| 177 |
{
|
| 178 |
$db -> Execute("UPDATE `players` SET `miejsce`='Altara' WHERE `id`=".$prisoner -> fields['prisoner']);
|
| 179 |
$db -> Execute("DELETE FROM `jail` WHERE `id`=".$prisoner -> fields['id']);
|
| 180 |
$db -> Execute("UPDATE `players` SET `credits`=`credits`-".$prisoner -> fields['cost']." WHERE `id`=".$player -> id);
|
| 181 |
$strDate = $db -> DBDate($newdate);
|
| 182 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$prisoner -> fields['prisoner'].",'".L_PLAYER.'<a href="view.php?view='.$player -> id.'">'.$player -> user.'</a>'.L_ID.'<b>'.$player -> id.'</b>'.PAY_FOR."', ".$strDate.")");
|
| 183 |
error (YOU_PAY.$prisoner -> fields['cost'].GOLD_FOR.$pname -> fields['user'].L_ID.$prisoner -> fields['prisoner']);
|
| 184 |
}
|
| 185 |
$smarty -> assign("Step", $_GET['step']);
|
| 186 |
}
|
| 187 |
else
|
| 188 |
{
|
| 189 |
$_GET['prisoner'] = '';
|
| 190 |
}
|
| 191 |
|
| 192 |
/**
|
| 193 |
* Assign variables to template and display page
|
| 194 |
*/
|
| 195 |
$smarty -> assign(array("Location" => $player -> location,
|
| 196 |
"Prisoner" => $_GET['prisoner']));
|
| 197 |
$smarty -> display ('jail.tpl');
|
| 198 |
|
| 199 |
require_once("includes/foot.php");
|
| 200 |
?>
|