forked from GDRCD/GDRCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ref_header.inc.php
378 lines (336 loc) · 24.7 KB
/
ref_header.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<?php
session_start();
header('Content-Type:text/html; charset=UTF-8');
$last_message = isset($_SESSION['last_message']) ? $_SESSION['last_message'] : 0;
//Includio i parametri, la configurazione, la lingua e le funzioni
require ('includes/required.php');
//Eseguo la connessione al database
$handleDBConnection = gdrcd_connect();
//Ricevo il tempo di reload
$i_ref_time = gdrcd_filter_get($_GET['ref']);
/**********************************************************************************/
if((gdrcd_filter_get($_REQUEST['chat']) == 'yes') && (empty($_SESSION['login']) === false)) {
/*Aggiornamento chat*/
/*Se ho inviato un azione*/
if((gdrcd_filter('get', $_POST['op']) == 'take_action') && (($PARAMETERS['mode']['skillsystem'] == 'ON') || ($PARAMETERS['mode']['dices'] == 'ON'))) {
$actual_healt = gdrcd_query("SELECT salute FROM personaggio WHERE nome = '".$_SESSION['login']."'");
if(gdrcd_filter('get', $_POST['id_ab']) != 'no_skill') {
if($actual_healt['salute'] > 0) {
$skill = gdrcd_query("SELECT nome, car FROM abilita WHERE id_abilita = ".gdrcd_filter('num', $_POST['id_ab'])." LIMIT 1");
$car = gdrcd_query("SELECT car".gdrcd_filter('num', $skill['car'])." AS car_now FROM personaggio WHERE nome = '".$_SESSION['login']."' LIMIT 1");
$bonus = gdrcd_query("SELECT SUM(oggetto.bonus_car".gdrcd_filter('num', $skill['car']).") as bonus FROM oggetto JOIN clgpersonaggiooggetto ON clgpersonaggiooggetto.id_oggetto=oggetto.id_oggetto WHERE clgpersonaggiooggetto.nome='".$_SESSION['login']."' AND clgpersonaggiooggetto.posizione > 1");
$racial_bonus = gdrcd_query("SELECT bonus_car".gdrcd_filter('num', $skill['car'])." AS racial_bonus FROM razza WHERE id_razza IN (SELECT id_razza FROM personaggio WHERE nome='".$_SESSION['login']."')");
$rank = gdrcd_query("SELECT grado FROM clgpersonaggioabilita WHERE id_abilita=".gdrcd_filter('num', $_POST['id_ab'])." AND nome='".$_SESSION['login']."' LIMIT 1");
if($PARAMETERS['mode']['dices'] == 'ON') {
mt_srand((double) microtime() * 1000000);
$die = mt_rand(1, (int) $_POST['dice']);
$chat_dice_msg = gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['die']).' '.gdrcd_filter('num', $die).',';
} else {
$chat_dice_msg = '';
$die = 0;
}
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '', NOW(), 'C', '".$_SESSION['login'].' '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['uses']).' '.gdrcd_filter('in', $skill['nome']).': '.gdrcd_filter('in', $PARAMETERS['names']['stats']['car'.$skill['car'].'']).' '.gdrcd_filter('num', $car['car_now'] + $racial_bonus['racial_bonus']).', '.$chat_dice_msg.' '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['ramk']).' '.gdrcd_filter('num', $rank['grado']).', '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['items']).' '.gdrcd_filter('num', $bonus['bonus']).', '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['sum']).' '.(gdrcd_filter('num', $car['car_now'] + $racial_bonus['racial_bonus']) + gdrcd_filter('num', $die) + gdrcd_filter('num', $rank['grado']) + gdrcd_filter('in', $bonus['bonus']))."')");
} else {
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '".gdrcd_capital_letter(gdrcd_filter('in', $_SESSION['login'])."', NOW(), 'S', '".gdrcd_filter('in', $MESSAGE['status_pg']['exausted'])."')"));
}
/** * Tiro su caratteristica
* @author Blancks
*/
} elseif(gdrcd_filter('get', $_POST['id_stats']) != 'no_stats' && gdrcd_filter('get', $_POST['dice']) != 'no_dice') {
mt_srand((double) microtime() * 1000000);
$die = mt_rand(1, gdrcd_filter('num', (int) $_POST['dice']));
$id_stats = explode('_', $_POST['id_stats']);
$car = gdrcd_query("SELECT car".gdrcd_filter('num', $id_stats[1])." AS car_now FROM personaggio WHERE nome = '".$_SESSION['login']."' LIMIT 1");
$racial_bonus = gdrcd_query("SELECT bonus_car".gdrcd_filter('num', $id_stats[1])." AS racial_bonus FROM razza WHERE id_razza IN (SELECT id_razza FROM personaggio WHERE nome='".$_SESSION['login']."')");
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '', NOW(), 'C', '".$_SESSION['login'].' '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['uses']).' '.gdrcd_filter('in', $PARAMETERS['names']['stats']['car'.$id_stats[1]]).': '.gdrcd_filter('in', $PARAMETERS['names']['stats']['car'.$id_stats[1].'']).' '.gdrcd_filter('num', $car['car_now'] + $racial_bonus['racial_bonus']).', '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['die']).' '.gdrcd_filter('num', $die).', '.gdrcd_filter('in', $MESSAGE['chat']['commands']['use_skills']['sum']).' '.(gdrcd_filter('num', $car['car_now'] + $racial_bonus['racial_bonus']) + gdrcd_filter('num', $die) + gdrcd_filter('num', $rank['grado']) + gdrcd_filter('in', $bonus['bonus']))."')");
} elseif(gdrcd_filter('get', $_POST['dice']) != 'no_dice') {
mt_srand((double) microtime() * 1000000);
$die = mt_rand(1, gdrcd_filter('num', $_POST['dice']));
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '', NOW(), 'D', '".$_SESSION['login'].' '.gdrcd_filter('in', $MESSAGE['chat']['commands']['die']['cast']).gdrcd_filter('num', $_POST['dice']).': '.gdrcd_filter('in', $MESSAGE['chat']['commands']['die']['sum']).' '.gdrcd_filter('num', $die)."')");
} elseif(gdrcd_filter('get', $_POST['id_item']) != 'no_item') {
$item = explode('-', gdrcd_filter('in', $_POST['id_item']));
if($item[1] == 1) {
$query = "DELETE FROM clgpersonaggiooggetto WHERE nome ='".$_SESSION['login']."' AND id_oggetto='".gdrcd_filter('num', $item[0])."' LIMIT 1";
} elseif($item[1] > 1) {
$query = "UPDATE clgpersonaggiooggetto SET cariche = cariche -1 WHERE nome ='".$_SESSION['login']."' AND id_oggetto='".gdrcd_filter('num', $item[0]
)."' LIMIT 1";
}
gdrcd_query($query);
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '', NOW(), 'O', '".$_SESSION['login'].' '.gdrcd_filter('in', $MESSAGE['chat']['commands']['die']['item']).': '.gdrcd_filter('in', $item[2])."')");
}
}
/*Se ho inviato un messaggio*/
if(gdrcd_filter('get', $_POST['op']) == 'new_chat_message') {
$actual_healt = gdrcd_query("SELECT salute FROM personaggio WHERE nome = '".$_SESSION['login']."'");
$chat_message = gdrcd_filter('in', gdrcd_angs($_POST['message']));
$tag_n_beyond = gdrcd_filter('in', $_POST['tag']);
$type = gdrcd_filter('in', $_POST['type']);
$first_char = substr($chat_message, 0, 1);
if($PARAMETERS['mode']['exp_by_chat'] == 'ON') {
$msg_length = strlen($chat_message);
$char_needed = gdrcd_filter('num', $PARAMETERS['settings']['exp_by_chat']['number']);
$exp_bonus = ($PARAMETERS['settings']['exp_by_chat']['value'] = '0') ? $msg_length / $char_needed : gdrcd_filter_num($PARAMETERS['settings']['exp_by_chat']['value']);
}
if($type < "5") {
if( ! empty($_POST['message'])) {
//E' un messaggio.
/*Verifico il tipo di messaggio*/
if(($type == "4") || ($first_char == "@")) { /*Sussurro*/
$m_type = 'S';
if($type != '4') {
$dest_end = strpos(substr($chat_message, 1), "@");
if($dest_end === false) {
/*Se il destinatario e' mal formattato lo prendo come parlato*/
$m_type = 'P';
} else {
$tag_n_beyond = gdrcd_capital_letter(substr($chat_message, 1, $dest_end));
$chat_message = substr($chat_message, $dest_end + 2);
}
} elseif($m_type == 'S') {/*Se il sussurro e' inviato correttamente*/
$r_check_dest = gdrcd_query("SELECT nome FROM personaggio WHERE DATE_ADD(ultimo_refresh, INTERVAL 2 MINUTE) > NOW() AND ultimo_luogo = ".$_SESSION['luogo']." AND nome = '".$tag_n_beyond."' LIMIT 1", 'result');
if(gdrcd_query($r_check_dest, 'num_rows') < 1) {
$chat_message = $tag_n_beyond.' '.gdrcd_filter('in', $MESSAGE['chat']['whisper']['no']);
$tag_n_beyond = $_SESSION['login'];
}
} else {
$tag_n_beyond = $_SESSION['tag'];
}
} elseif($first_char == "#") { //Dado
$m_type = 'C';
if(preg_match("/^#d+([1-9][0-9]*)$/si", $chat_message, $matches)) {
$nstring = $matches[1];
$die = mt_rand(1, (int) $nstring);
$chat_message = "A ".$_SESSION['login']." esce ".$die." su ".$nstring;
} elseif(preg_match("/^#([1-9][0-9]*)d+([1-9][0-9]*)$/si", $chat_message, $matches)) {
$numero = (int) $matches[1];
$dado = (int) $matches[2];
$x = 0;
$chat_message = "A ".$_SESSION['login']." esce ";
for($x = 0; $x < $numero; $x++) {
$die = mt_rand(1, $dado);
$chat_message .= $die." su ".$dado.", ";
}
$chat_message = substr($chat_message, 0, -2);
}
} elseif(($type == "1") || ($first_char == "+")) { /*Azione*/
if($actual_healt['salute'] > 0) {
if($first_char == "+") {
$chat_message = substr($chat_message, 1);
}
$m_type = 'A';
$_SESSION['tag'] = $tag_n_beyond;
} else {
$m_type = 'S';
$tag_n_beyond = $_SESSION['login'];
$chat_message = gdrcd_filter('in', $MESSAGE['status_pg']['exausted']);
}
} elseif((($type == "2") || ($first_char == "§") || ($first_char == "-") || ($first_char == "*")) && ($_SESSION['permessi'] >= GAMEMASTER)) { /*Master*/
$m_type = 'M';
if(($first_char == "§") || ($first_char == "-")) {
$chat_message = substr($chat_message, 1);
} elseif($first_char == "*") {
$chat_message = substr($chat_message, 1);
$m_type = 'I';
}
} elseif(($type == "3") && ($_SESSION['permessi'] >= GAMEMASTER)) { /*PNG*/
$m_type = 'N';
$_SESSION['tag'] = $tag_n_beyond;
} else {
if(($type == "0") || (empty($type) === true)) { /*Parlato*/
if($actual_healt['salute'] > 0) {
$m_type = 'P';
$_SESSION['tag'] = $tag_n_beyond;
} else {
$m_type = 'S';
$tag_n_beyond = $_SESSION['login'];
$chat_message = gdrcd_filter('in', $MESSAGE['status_pg']['exausted']);
}
}
}
/*Inserisco il messaggio*/
/*E controllo se la chat non era una privata scaduta @author GoddessDanielle*/
$mappa = gdrcd_query("SELECT * FROM mappa where id = '".$_SESSION['luogo']."'");
if ($mappa['privata']==1 && strtotime($mappa['scadenza']) < time()) {
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '".gdrcd_capital_letter(gdrcd_filter('in', $tag_n_beyond))."', NOW(), 'M', 'Chat scaduta')");
} else {
gdrcd_query("INSERT INTO chat ( stanza, imgs, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", '".$_SESSION['sesso'].";".$_SESSION['img_razza']."', '".$_SESSION['login']."', '".gdrcd_capital_letter(gdrcd_filter('in', $tag_n_beyond))."', NOW(), '".$m_type."', '".$chat_message."')");
}
if($PARAMETERS['mode']['exp_by_chat'] == 'ON') {
if($PARAMETERS['mode']['exp_in_private'] == 'ON') {
if($mappa['privata']==0 && ($m_type == 'A' || $m_type == 'P' || $m_type == 'M')) {
gdrcd_query("UPDATE personaggio SET esperienza = esperienza + ".$exp_bonus." WHERE nome = '".$_SESSION['login']."' LIMIT 1");
}
} else {
if($m_type == 'A' || $m_type == 'P' || $m_type == 'M') {
gdrcd_query("UPDATE personaggio SET esperienza = esperienza + ".$exp_bonus." WHERE nome = '".$_SESSION['login']."' LIMIT 1");
}
}
}
}//Not empty message
} else { //Altrimenti e' un comando di stanza privata.
$info = gdrcd_query("SELECT invitati, nome, proprietario FROM mappa WHERE id=".$_SESSION['luogo']."");
$ok_command = false;
if($info['proprietario'] == $_SESSION['login'] || strpos($_SESSION['gilda'], $info['proprietario']) != false) {
$ok_command = true;
}
if(($type == "5") && ($ok_command === true)) { //invita
gdrcd_query("UPDATE mappa SET invitati = '".$info['invitati'].','.gdrcd_capital_letter(strtolower(gdrcd_filter('in', $tag_n_beyond)))."' WHERE id=".$_SESSION['luogo']." LIMIT 1");
gdrcd_query("INSERT INTO chat ( stanza, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", 'System message', '".$_SESSION['login']."', NOW(), 'S', '".gdrcd_capital_letter(gdrcd_filter('in', $tag_n_beyond)).' '.$MESSAGE['chat']['warning']['invited']."')");
if(empty($_POST['tag']) === false) {
gdrcd_query("INSERT INTO messaggi ( mittente, destinatario, spedito, letto, testo ) VALUES ('System message', '".gdrcd_capital_letter(gdrcd_filter('in', $_POST['tag']))."', NOW(), 0, '".$_SESSION['login'].' '.$MESSAGE['chat']['warning']['invited_message'].' '.$info['nome']."')");
}
} else {
if(($type == "6") && ($ok_command === true)) { //caccia
$scaccia = str_replace(','.gdrcd_capital_letter(gdrcd_filter('in', $tag_n_beyond)), '', $info['invitati']);
gdrcd_query("UPDATE mappa SET invitati = '".$scaccia."' WHERE id=".$_SESSION['luogo']." LIMIT 1");
gdrcd_query("INSERT INTO chat ( stanza, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", 'System message', '".$_SESSION['login']."', NOW(), 'S', '".gdrcd_capital_letter(gdrcd_filter('in', $tag_n_beyond)).' '.$MESSAGE['chat']['warning']['expelled']."')");
} elseif($ok_command === true) { //elenco
$ospiti = str_replace(',', '', $info['invitati']);
gdrcd_query("INSERT INTO chat ( stanza, mittente, destinatario, ora, tipo, testo ) VALUES (".$_SESSION['luogo'].", 'System message', '".$_SESSION['login']."', NOW(), 'S', '".$MESSAGE['chat']['warning']['list'].': '.$ospiti."')");
}
}
}//else
}//Fine if ($type < "5")
}//Fine (gdrcd_filter('get', $_POST['op']) == 'new_chat_message')
$_SESSION['tag'] = gdrcd_filter('in', $_POST['tag']);
/**
* Scorrimento dei messaggi in chat, verifico se non è stato invertito il flusso, shorthand
* @author Breaker
*/
$typeOrder = ($PARAMETERS['mode']['chat_from_bottom'] == 'ON') ? 'DESC' : 'ASC';
/** * Controllo per impedire il print in chat delle azioni dei precedenti proprietari di una stanza privata
* Per stanze non private ora_prenotazione equivarrà ad un tempo sempre inferiore all\'orario dell'azione inviata
* facendo risultare quindi sempre veritiero il controllo in questo caso.
* @author Blancks
*/
$query = gdrcd_query(" SELECT chat.id, chat.imgs, chat.mittente, chat.destinatario, chat.tipo, chat.ora, chat.testo, personaggio.url_img_chat, mappa.ora_prenotazione
FROM chat
INNER JOIN mappa ON mappa.id = chat.stanza
LEFT JOIN personaggio ON personaggio.nome = chat.mittente
WHERE chat.id > ".$last_message." AND stanza = ".$_SESSION['luogo']." AND chat.ora > IFNULL(mappa.ora_prenotazione, '0000-00-00 00:00:00') AND DATE_SUB(NOW(), INTERVAL 30 MINUTE) < ora ORDER BY id ".$typeOrder, 'result');
while($row = gdrcd_query($query, 'fetch')) {
//Impedisci XSS nelle immagini
$row['url_img_chat'] = gdrcd_filter('fullurl', $row['url_img_chat']);
if($PARAMETERS['mode']['chaticons'] == 'ON') {
$icone_chat = explode(";", gdrcd_filter('out', $row['imgs']));
$add_icon = '<span class="chat_icons"> <img class="presenti_ico" src="themes/'.$PARAMETERS['themes']['current_theme'].'/imgs/races/'.$icone_chat[1].'"><img class="presenti_ico" src="imgs/icons/testamini'.$icone_chat[0].'.png"> </span>';
}
/** * Fix problema visualizzazione spazi vuoti con i sussurri
* @author eLDiabolo
*/
$add_chat .= '<div class="chat_row_'.$row['tipo'].'">';
$alert_new_msg = ($PARAMETERS['mode']['allow_new_chat_audio'] == 'ON' && $row['mittente'] != $_SESSION['login']) ? 1 : null;
switch($row['tipo']) {
case 'A':
case 'P':
/** * Avatar di chat
* @author Blancks
*/
if($PARAMETERS['mode']['chat_avatar'] == 'ON' && ! empty($row['url_img_chat'])) {
$add_chat .= '<img src="'.$row['url_img_chat'].'" class="chat_avatar" style="width:'.$PARAMETERS['settings']['chat_avatar']['width'].'px; height:'.$PARAMETERS['settings']['chat_avatar']['height'].'px;" />';
}
$add_chat .= '<span class="chat_time">'.gdrcd_format_time($row['ora']).'</span>';
if($PARAMETERS['mode']['chaticons'] == 'ON') {
$add_chat .= $add_icon;
}
$add_chat .= '<span class="chat_name"><a href="#" onclick="Javascript: document.getElementById(\'tag\').value=\''.$row['mittente'].'\'; document.getElementById(\'type\')[2].selected = \'1\'; document.getElementById(\'message\').focus();">'.$row['mittente'].'</a>';
if(empty ($row['destinatario']) === false) {
$add_chat .= '<span class="chat_tag"> ['.gdrcd_filter('out', $row['destinatario']).']</span>';
}
$add_chat .= ($row['tipo'] === 'P') ? ': </span> ' : '</span> ';
$add_chat .= '<span class="chat_msg">'.gdrcd_chatme($_SESSION['login'], gdrcd_chatcolor(gdrcd_filter('out', $row['testo']))).'</span>';
/** * Fix problema visualizzazione spazi vuoti con i sussurri
* @author eLDiabolo
*/
if($PARAMETERS['mode']['chat_avatar'] == 'ON') {
$add_chat .= '<br style="clear:both;" />';
}
break;
case 'S':
if($_SESSION['login'] == $row['destinatario']) {
$add_chat .= '<span class="chat_name">'.$row['mittente'].' '.$MESSAGE['chat']['whisper']['by'].': </span> ';
$add_chat .= '<span class="chat_msg">'.gdrcd_filter('out', $row['testo']).'</span>';
} elseif($_SESSION['login'] == $row['mittente']) {
$add_chat .= '<span class="chat_msg">'.$MESSAGE['chat']['whisper']['to'].' '.gdrcd_filter('out', $row['destinatario']).': </span>';
$add_chat .= '<span class="chat_msg">'.gdrcd_filter('out', $row['testo']).'</span>';
} elseif(($_SESSION['permessi'] >= MODERATOR) && ($PARAMETERS['mode']['spyprivaterooms'] == 'ON')) {
$add_chat .= '<span class="chat_msg">'.$row['mittente'].' '.$MESSAGE['chat']['whisper']['from_to'].' '.gdrcd_filter('out', $row['destinatario']).' </span>';
$add_chat .= '<span class="chat_msg">'.gdrcd_filter('out', $row['testo']).'</span>';
}
break;
case 'N':
$add_chat .= '<span class="chat_time">'.gdrcd_format_time($row['ora']).'</span>';
$add_chat .= '<span class="chat_name">'.$row['destinatario'].'</span> ';
$add_chat .= '<span class="chat_msg">'.gdrcd_chatcolor(gdrcd_filter('out', $row['testo'])).'</span>';
break;
case 'M':
$add_chat .= '<span class="chat_master">'.gdrcd_chatme($_SESSION['login'], gdrcd_filter('out', $row['testo']), true).'</span>';
break;
case 'I':
$add_chat .= '<img class="chat_img" src="'.gdrcd_filter('fullurl', $row['testo']).'" />';
break;
case 'C':
case 'D':
case 'O':
$add_chat .= '<span class="chat_time">'.gdrcd_format_time($row['ora']).'</span>';
$add_chat .= '<span class="chat_msg">'.gdrcd_filter('out', $row['testo']).'</span>';
break;
}
$add_chat .= '</div>';
if($row['id'] > (int) $last_message) {
$last_message = $row['id'];
}
}
gdrcd_query($query, 'free');
$_SESSION['last_message'] = $last_message;
/******************************************************************************************/
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
<!--meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="<?php echo $i_ref_time; ?>">
<link rel="stylesheet" href="../themes/<?php echo $PARAMETERS['themes']['current_theme']; ?>/presenti.css" TYPE="text/css">
<link rel="stylesheet" href="../themes/<?php echo $PARAMETERS['themes']['current_theme']; ?>/main.css" TYPE="text/css">
<link rel="stylesheet" href="../themes/<?php echo $PARAMETERS['themes']['current_theme']; ?>/chat.css" TYPE="text/css">
<title>Chat</title>
</head>
<body class="transparent_body" <?php if(gdrcd_filter('get', $_REQUEST['chat']) == 'yes') {
echo 'onLoad="echoChat();"';
} ?> >
<?php
if(gdrcd_filter('get', $_REQUEST['chat']) == 'yes') {
echo '<script type="text/javascript"> function echoChat(){';
/** * Gestione dell'ordinamento
* @author Blancks
*/
if($PARAMETERS['mode']['chat_from_bottom'] == 'OFF') {
echo 'parent.document.getElementById(\'pagina_chat\').innerHTML+= '.json_encode((string) $add_chat).';';
echo 'scrolling = parent.document.getElementById(\'pagina_chat\').scrollHeight;';
} elseif($PARAMETERS['mode']['chat_from_bottom'] == 'ON') {
echo 'parent.document.getElementById(\'pagina_chat\').innerHTML= '.json_encode((string) $add_chat).'+parent.document.getElementById(\'pagina_chat\').innerHTML;';
echo 'scrolling = 0;';
}
/** * Gestione intelligente della scrollbar
* Forza lo scroll solo quando ci sono nuovi messaggi
* @author Blancks
*/
if( ! empty($add_chat)) {
echo 'parent.document.getElementById(\'pagina_chat\').scrollTop = scrolling;';
}
if((gdrcd_filter('get', $_POST['op']) == 'take_action') || (gdrcd_filter('get', $_POST['op']) == 'new_chat_message')) {
if($PARAMETERS['mode']['skillsystem'] == 'ON') {
echo 'parent.document.getElementById(\'chat_form_actions\').reset();';
}
echo 'parent.document.getElementById(\'chat_form_messages\').reset();
parent.document.getElementById(\'chat_form_messages\').elements["tag"].value=\''.$_SESSION["tag"].'\';';
}//if
echo '}</script>';
}
if ($PARAMETERS['mode']['allow_audio'] == 'ON' && $_SESSION['blocca_media'] != 1 && $add_chat != '' && isset($alert_new_msg) && $alert_new_msg == 1) { ?>
<script type="text/javascript">
var mediaElementChat = parent.document.getElementById("sound_player_chat");
mediaElementChat.play();
</script>
<?php } ?>