| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Show text in chat, send messages, color player names, ban/unban players in chat |
| 5 |
* |
| 6 |
* @name : chatmsg.php |
| 7 |
* @copyright : (C) 2004,2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : Marek Chosor <marek.chodor@gmail.com> |
| 9 |
* @version : 1.0 |
| 10 |
* @since : 27.09.2007 |
| 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$ |
| 31 |
|
| 32 |
//ajax initialization |
| 33 |
header('Content-Type: text/json; charset=utf-8'); |
| 34 |
|
| 35 |
require_once('includes/sessions.php'); |
| 36 |
require_once('includes/config.php'); |
| 37 |
require_once('libs/Smarty.class.php'); |
| 38 |
require_once('class/player_class.php'); |
| 39 |
|
| 40 |
$smarty = new Smarty; |
| 41 |
$smarty -> compile_check = true; |
| 42 |
|
| 43 |
require_once('includes/franks.php'); |
| 44 |
require_once('includes/tags.php'); |
| 45 |
|
| 46 |
//db fetch mode NUM |
| 47 |
$db -> SetFetchMode(ADODB_FETCH_NUM); |
| 48 |
|
| 49 |
$strEmail = $db -> qstr($_SESSION['email'],get_magic_quotes_gpc()); |
| 50 |
$player = $db -> getRow("SELECT `id`, `overlib`, `lang` FROM `players` WHERE `email`=".$strEmail); |
| 51 |
$db -> Execute("UPDATE `players` SET `lpv`=".time()." WHERE `email`=".$strEmail); |
| 52 |
|
| 53 |
if (isset($_GET['opis'])) |
| 54 |
{ |
| 55 |
$_SESSION['opisinlist'] = $_GET['opis']; |
| 56 |
} |
| 57 |
$limit = ($_SESSION['opisinlist']) ? 15 : 30; |
| 58 |
|
| 59 |
//page to display |
| 60 |
if (!isset($_GET['page'])) |
| 61 |
{ |
| 62 |
$_GET['page'] = 0; |
| 63 |
} |
| 64 |
$_SESSION['page'] = (int)$_GET['page']; |
| 65 |
$page = (int)$_GET['page'] * $limit; |
| 66 |
|
| 67 |
$sql = "SELECT `players`.`id`, `user`, `rank`, `tribe`, `tribe_rank`, `opis`, `gender`"; |
| 68 |
if ($player[1]) |
| 69 |
{ |
| 70 |
$sql .= ", sum(`reputation`.`points`), `miejsce`, `page`, `rasa`, `hp`, `avatar`"; |
| 71 |
} |
| 72 |
$sql2 = " FROM `players`"; |
| 73 |
$sql3 = " LEFT JOIN `reputation` ON `reputation`.`player_id` = `players`.`id`"; |
| 74 |
$sql4 = " WHERE `players`.`lpv` >=".(time() - 180); |
| 75 |
$sql5 = " GROUP BY `players`.`id` ORDER BY `players`.`id` ASC LIMIT ".$page.",".$limit; |
| 76 |
|
| 77 |
$plOnline = $db -> getRow("SELECT count(*) ".$sql2.$sql4) or die($db -> ErrorMsg()); |
| 78 |
$playersOnline = (int)$plOnline[0]; |
| 79 |
|
| 80 |
$logcount = $db -> GetRow('SELECT count(*) FROM `log` WHERE `owner`='.$player[0].' AND `unread`=\'F\''); |
| 81 |
$logcount2 = empty($logcount) ? 0 : $logcount[0]; |
| 82 |
|
| 83 |
$mailcount = $db -> GetRow('SELECT count(*) FROM `mail` WHERE `owner`='.$player[0].' AND `zapis`=\'N\' AND `unread`=\'F\' AND `send`=0'); |
| 84 |
$mailcount2 = empty($mailcount) ? 0 : $mailcount[0]; |
| 85 |
|
| 86 |
$arrPlayers = $db -> getAll($sql.$sql2.$sql3.$sql4.$sql5); |
| 87 |
$arrRankImages = array( |
| 88 |
'Admin' => 'admin', |
| 89 |
'Staff' => 'ksiaze', |
| 90 |
'Sędzia' => 'sedzia', |
| 91 |
'Ławnik' => 'lawnik', |
| 92 |
'Prawnik' => 'prawnik', |
| 93 |
'Bibliotekarz' => 'bibliotekarz', |
| 94 |
'Rycerz' => 'rycerz', |
| 95 |
'Dama' => 'dama', |
| 96 |
'Marszałek Rady' => 'marszalek', |
| 97 |
'Redaktor' => 'redaktor', |
| 98 |
'Karczmarka' => 'karczmarz', |
| 99 |
'Techniczny' => 'techniczny', |
| 100 |
'Hero' => 'hero', |
| 101 |
'Prokurator' => 'prokurator'); |
| 102 |
|
| 103 |
|
| 104 |
for ($i = 0, $intMax = count($arrPlayers), $arrPlayers2 = array(); $i < $intMax; $i++) |
| 105 |
{ |
| 106 |
// If user is on page city.php, determine city's name. |
| 107 |
if ($arrPlayers[$i][9] =='Altara') |
| 108 |
$arrPlayers[$i][9] = ($arrPlayers[$i][8] =='Altara') ? 'Meredith' : 'Agarakar'; |
| 109 |
elseif( $arrPlayers[$i][9] =='Chat') |
| 110 |
$arrPlayers[$i][9] = 'Tawerna'; |
| 111 |
|
| 112 |
$rankName = footselectrank($arrPlayers[$i][2], $arrPlayers[$i][6],$player[2]); |
| 113 |
$rankIcon = array_key_exists($arrPlayers[$i][2], $arrRankImages) ? '<img src="images/ranks/'.$arrRankImages[$arrPlayers[$i][2]].'.png" title="'.$rankName.'" alt="'.$rankName.'" /> ' : ''; |
| 114 |
|
| 115 |
$playerName = getTaggedPlayerName ($arrPlayers[$i][1], $arrPlayers[$i][3], $arrPlayers[$i][4]); |
| 116 |
|
| 117 |
//id |
| 118 |
$arrPlayers2[$i]['id'] = $arrPlayers[$i][0]; |
| 119 |
//name |
| 120 |
$arrPlayers2[$i]['name'] = $playerName; |
| 121 |
//opis |
| 122 |
$arrPlayers2[$i]['opis'] = $arrPlayers[$i][5]; |
| 123 |
//rankIcon |
| 124 |
$arrPlayers2[$i]['rankIcon'] = $rankIcon; |
| 125 |
//rankName |
| 126 |
$arrPlayers2[$i]['rankName'] = $rankName; |
| 127 |
if ($player[1]) |
| 128 |
{ |
| 129 |
//reputation |
| 130 |
$arrPlayers2[$i]['reputation'] = (empty($arrPlayers[$i][7])) ? 0 : $arrPlayers[$i][7]; |
| 131 |
//place |
| 132 |
$arrPlayers2[$i]['place'] = $arrPlayers[$i][9]; |
| 133 |
//rasa |
| 134 |
$arrPlayers2[$i]['rasa'] = $arrPlayers[$i][10]; |
| 135 |
//hp |
| 136 |
$arrPlayers2[$i]['hp'] = ($arrPlayers[$i][11] > 0)? 1 : 0; |
| 137 |
//gender |
| 138 |
$arrPlayers2[$i]['gender'] = $arrPlayers[$i][6]; |
| 139 |
//avatar |
| 140 |
$arrPlayers2[$i]['avatar'] = $arrPlayers[$i][12]; |
| 141 |
} |
| 142 |
} |
| 143 |
unset($arrPlayers, $arrRankImages); |
| 144 |
|
| 145 |
$arrReply = array( |
| 146 |
'players' => $arrPlayers2, |
| 147 |
'max' => $playersOnline, |
| 148 |
'logc' => $logcount2, |
| 149 |
'mailc' => $mailcount2 |
| 150 |
); |
| 151 |
|
| 152 |
require_once('includes/json.php'); |
| 153 |
$jsonlist = new Services_JSON(); |
| 154 |
$smarty -> assign('Reply', $jsonlist -> encode($arrReply)); |
| 155 |
$smarty -> display('onlinelist.tpl'); |
| 156 |
|
| 157 |
?> |