forked from kestasjk/webDiplomacy
-
Notifications
You must be signed in to change notification settings - Fork 13
/
message.php
77 lines (59 loc) · 1.77 KB
/
message.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
<?php
require_once('header.php');
if ( ! isset($_REQUEST['gameID']) )
{
header('HTTP/1.1 400 Bad Request');
die("No Game Specified");
}
$gameID = (int)$_REQUEST['gameID'];
try
{
require_once(l_r('objects/game.php'));
require_once(l_r('board/chatbox.php'));
require_once(l_r('gamepanel/gameboard.php'));
$Variant = libVariant::loadFromGameID($gameID);
libVariant::setGlobals($Variant);
$Game = $Variant->panelGameBoard($gameID);
if ($Game->Members->isJoined() && !$Game->Members->isTempBanned())
{
// We are a member, load the extra code that we might need
require_once(l_r('gamemaster/gamemaster.php'));
require_once(l_r('board/member.php'));
require_once(l_r('board/orders/orderinterface.php'));
global $Member;
$Game->Members->makeUserMember($User->id);
$Member = $Game->Members->ByUserID[$User->id];
}
}
catch (Exception $e)
{
header('HTTP/1.1 500 Internal Server Error');
die("Error loading Game");
}
if ( 'Pre-game' != $Game->phase )
{
$CB = $Game->Variant->Chatbox();
// Now that we have retrieved the latest messages we can update the time we last viewed the messages
// Post messages we sent, and get the user we're speaking to
$msgCountryID = $CB->findTab();
$CB->postMessage($msgCountryID);
$DB->sql_put("COMMIT");
}
else
{
$CB = $Game->Variant->Chatbox();
// Pregame CountryID is always 0
$msgCountryID = 0;
$CB->postMessage($msgCountryID);
$DB->sql_put("COMMIT");
}
//RE-generate chat box
$messages = $CB->getMessages($msgCountryID);
if ( $messages == "" )
{
$messages .= '<TR class="barAlt1"><td class="notice">
'.l_t('No messages yet posted.').
'</td></TR>';
}
echo '<TABLE class="chatbox">'.$messages.'</TABLE>';
?>