| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Player log - events |
| 5 |
* |
| 6 |
* @name : log.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.3 |
| 10 |
* @since : 16.10.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: log.php 725 2006-10-16 15:47:57Z thindil $ |
| 31 |
|
| 32 |
$title = "Dziennik"; |
| 33 |
require_once("includes/head.php"); |
| 34 |
|
| 35 |
/** |
| 36 |
* Get the localization for game |
| 37 |
*/ |
| 38 |
require_once("languages/".$player -> lang."/log.php"); |
| 39 |
|
| 40 |
$db -> Execute("UPDATE log SET unread='T' WHERE unread='F' AND owner=".$player -> id); |
| 41 |
|
| 42 |
if (!isset($_GET['limit'])) |
| 43 |
{ |
| 44 |
$_GET['limit'] = 0; |
| 45 |
} |
| 46 |
|
| 47 |
if (!ereg("^[0-9]*$", $_GET['limit'])) |
| 48 |
{ |
| 49 |
error(ERROR); |
| 50 |
} |
| 51 |
|
| 52 |
$objTest = $db -> Execute("SELECT count(*) FROM `log` WHERE `owner`=".$player -> id." ORDER BY `id` DESC"); |
| 53 |
$intAmount = $objTest -> fields['count(*)']; |
| 54 |
$objTest -> Close(); |
| 55 |
if ($intAmount < $_GET['limit']) |
| 56 |
{ |
| 57 |
error(ERROR); |
| 58 |
} |
| 59 |
|
| 60 |
$smarty -> assign(array("Previous" => '', |
| 61 |
"Next" => '')); |
| 62 |
|
| 63 |
$log = $db -> SelectLimit("SELECT `id`, `log`, `czas` FROM `log` WHERE `owner`=".$player -> id." ORDER BY `id` DESC", 30, $_GET['limit']); |
| 64 |
$arrdate = array(); |
| 65 |
$arrtext = array(); |
| 66 |
$arrid1 = array(0); |
| 67 |
$i = 0; |
| 68 |
while (!$log -> EOF) |
| 69 |
{ |
| 70 |
$arrdate[$i] = $log -> fields['czas']; |
| 71 |
$arrtext[$i] = $log -> fields['log']; |
| 72 |
$arrid1[$i] = $log -> fields['id']; |
| 73 |
$log -> MoveNext(); |
| 74 |
$i = $i + 1; |
| 75 |
} |
| 76 |
$log -> Close(); |
| 77 |
|
| 78 |
if ($_GET['limit'] >= 30) |
| 79 |
{ |
| 80 |
$intLimit = $_GET['limit'] - 30; |
| 81 |
$smarty -> assign("Previous", "<form method=\"post\" action=\"log.php?limit=".$intLimit."\"><input type=\"submit\" value=\"".A_PREVIOUS."\" /></form> "); |
| 82 |
} |
| 83 |
$_GET['limit'] = $_GET['limit'] + 30; |
| 84 |
if ($intAmount > 30 && $_GET['limit'] < $intAmount) |
| 85 |
{ |
| 86 |
$smarty -> assign("Next", "<form method=\"post\" action=\"log.php?limit=".$_GET['limit']."\"><input type=\"submit\" value=\"".A_NEXT."\" /></form>"); |
| 87 |
} |
| 88 |
|
| 89 |
if (isset($_GET['akcja']) && $_GET['akcja'] == 'wyczysc') |
| 90 |
{ |
| 91 |
$db -> Execute("DELETE FROM log WHERE owner=".$player -> id); |
| 92 |
error ("<br />".YOU_CLEAR." (<a href=\"log.php\">".A_REFRESH."</a>)"); |
| 93 |
} |
| 94 |
|
| 95 |
if (isset($_GET['send'])) |
| 96 |
{ |
| 97 |
$sid = $db -> Execute("SELECT id, user FROM players WHERE rank='Admin' OR rank='Staff'"); |
| 98 |
$arrname = array(); |
| 99 |
$arrid = array(); |
| 100 |
$i = 0; |
| 101 |
while (!$sid -> EOF) { |
| 102 |
$arrname[$i] = $sid -> fields['user']; |
| 103 |
$arrid[$i] = $sid -> fields['id']; |
| 104 |
$sid -> MoveNext(); |
| 105 |
$i = $i + 1; |
| 106 |
} |
| 107 |
$sid -> Close(); |
| 108 |
$smarty -> assign(array("Name" => $arrname, |
| 109 |
"StaffId" => $arrid, |
| 110 |
"Sendthis" => SEND_THIS, |
| 111 |
"Asend" => A_SEND)); |
| 112 |
if (isset ($_GET['step']) && $_GET['step'] == 'send') |
| 113 |
{ |
| 114 |
if (!ereg("^[1-9][0-9]*$", $_POST['staff'])) |
| 115 |
{ |
| 116 |
error (ERROR); |
| 117 |
} |
| 118 |
if (!ereg("^[1-9][0-9]*$", $_POST['lid'])) |
| 119 |
{ |
| 120 |
error (ERROR); |
| 121 |
} |
| 122 |
$arrtest = $db -> Execute("SELECT id, user, rank FROM players WHERE id=".$_POST['staff']); |
| 123 |
if (!$arrtest -> fields['id']) |
| 124 |
{ |
| 125 |
error (NO_PLAYER); |
| 126 |
} |
| 127 |
if ($arrtest -> fields['rank'] != 'Admin' && $arrtest -> fields['rank'] != 'Staff') |
| 128 |
{ |
| 129 |
error (NOT_STAFF); |
| 130 |
} |
| 131 |
$arrmessage = $db -> Execute("SELECT * FROM log WHERE id=".$_POST['lid']); |
| 132 |
if (!$arrmessage -> fields['id']) |
| 133 |
{ |
| 134 |
error (NO_EVENT); |
| 135 |
} |
| 136 |
if ($arrmessage -> fields['owner'] != $player -> id) |
| 137 |
{ |
| 138 |
error (NOT_YOUR); |
| 139 |
} |
| 140 |
$strDate = $db -> DBDate($newdate); |
| 141 |
$db -> Execute("INSERT INTO log (owner, log, czas) VALUES(".$arrtest -> fields['id'].",'".L_PLAYER."<a href=view.php?view=".$player -> id.">".$player -> user."</a>".L_ID.$player -> id.SEND_YOU."', ".$strDate.")"); |
| 142 |
$db -> Execute("INSERT INTO mail (sender,senderid,owner,subject,body) values('".$player -> user."','".$player -> id."',".$arrtest -> fields['id'].",'".L_TITLE."','".$arrmessage -> fields['czas']."<br />".$arrmessage -> fields['log']."')"); |
| 143 |
error (YOU_SEND.$arrtest -> fields['user'].". <a href=log.php>".A_REFRESH."</a>"); |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Delete selected logs |
| 149 |
*/ |
| 150 |
if (isset($_GET['action']) && $_GET['action'] == 'delete') |
| 151 |
{ |
| 152 |
$objLid = $db -> Execute("SELECT id FROM log WHERE owner=".$player -> id); |
| 153 |
$arrId = array(); |
| 154 |
$i = 0; |
| 155 |
while (!$objLid -> EOF) |
| 156 |
{ |
| 157 |
$arrId[$i] = $objLid -> fields['id']; |
| 158 |
$i = $i + 1; |
| 159 |
$objLid -> MoveNext(); |
| 160 |
} |
| 161 |
$objLid -> Close(); |
| 162 |
foreach ($arrId as $bid) |
| 163 |
{ |
| 164 |
if (isset($_POST[$bid])) |
| 165 |
{ |
| 166 |
$db -> Execute("DELETE FROM log WHERE id=".$bid); |
| 167 |
} |
| 168 |
} |
| 169 |
error(DELETED); |
| 170 |
} |
| 171 |
|
| 172 |
/** |
| 173 |
* Delete old logs |
| 174 |
*/ |
| 175 |
if (isset($_GET['step']) && $_GET['step'] == 'deleteold') |
| 176 |
{ |
| 177 |
$arrAmount = array(7, 14, 30); |
| 178 |
if (!in_array($_POST['oldtime'], $arrAmount)) |
| 179 |
{ |
| 180 |
error(ERROR); |
| 181 |
} |
| 182 |
$arrDate = explode("-", $data); |
| 183 |
$arrDate[0] = date("Y"); |
| 184 |
$arrDate[2] = $arrDate[2] - $_POST['oldtime']; |
| 185 |
if ($arrDate[2] < 1) |
| 186 |
{ |
| 187 |
$arrDays = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
| 188 |
$arrDate[1] = $arrDate[1] - 1; |
| 189 |
if ($arrDate[1] == 0) |
| 190 |
{ |
| 191 |
$arrDate[1] = 12; |
| 192 |
} |
| 193 |
$intKey = $arrDate[1] - 1; |
| 194 |
$arrDate[2] = $arrDays[$intKey] + $arrDate[2]; |
| 195 |
} |
| 196 |
$strDate = implode("-", $arrDate); |
| 197 |
$strDate = $db -> DBDate($strDate); |
| 198 |
$db -> Execute("DELETE FROM `log` WHERE `owner`=".$player -> id." AND `czas`<".$strDate); |
| 199 |
error(DELETED2); |
| 200 |
} |
| 201 |
|
| 202 |
/** |
| 203 |
* Initialization of variable |
| 204 |
*/ |
| 205 |
if (!isset($_GET['send'])) |
| 206 |
{ |
| 207 |
$_GET['send'] = ''; |
| 208 |
} |
| 209 |
|
| 210 |
/** |
| 211 |
* Assign variables to template and display page |
| 212 |
*/ |
| 213 |
$smarty -> assign(array("Date" => $arrdate, |
| 214 |
"Text" => $arrtext, |
| 215 |
"LogId" => $arrid1, |
| 216 |
"Send" => $_GET['send'], |
| 217 |
"Loginfo" => LOG_INFO2, |
| 218 |
"Event" => EVENT, |
| 219 |
"Edate" => E_DATE, |
| 220 |
"Sendevent" => SEND_EVENT, |
| 221 |
"Clearlog" => CLEAR_LOG, |
| 222 |
"Adeleteold" => A_DELETE_OLD, |
| 223 |
"Aweek" => A_WEEK, |
| 224 |
"A2week" => A_2WEEK, |
| 225 |
"Amonth" => A_MONTH, |
| 226 |
"Adelete" => A_DELETE)); |
| 227 |
$smarty -> display ('log.tpl'); |
| 228 |
|
| 229 |
require_once("includes/foot.php"); |
| 230 |
?> |