forked from richpri/board18v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
board18SnapMap.php
157 lines (145 loc) · 4.97 KB
/
board18SnapMap.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
<?php
/*
* The board18SnapMap page is used to display snapshots of the
* the game board for an existing game. This page cannot be used
* to update the game in any way.
*
* Copyright (c) 2015 Richard E. Price under the The MIT License.
* A copy of this license can be found in the LICENSE.text file.
*/
require_once('php/auth.php');
require_once('php/config.php');
//Function to sanitize values received from POST.
//Prevents SQL injection
function clean( $conn, $str ) {
$str = @trim($str);
return mysqli_real_escape_string( $conn, $str );
}
//Initialize $status flag.
$status = 'ok';
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
if ( !$link ) {
error_log('Failed to connect to server: ' . mysqli_connect_error());
$status = 'fail';
}
//Sanitize the snap shot ID
$cpid = clean( $link, $_REQUEST['show']);
$intsnap = intval($cpid);
$qry1 = "SELECT * FROM game_snap WHERE cp_id = $intsnap";
$result1 = mysqli_query( $link, $qry1 );
if ($result1 && (mysqli_num_rows($result1) == 1)) {
$row1 = mysqli_fetch_assoc($result1);
$gameid = $row1['game_id']; // game id
$gname = '';//$row1['gname']; // game name ## ajprog -- Field not in table
$ground = $row1['game_round']; // game round
} else {
error_log("game_snap query failed");
$status = 'fail';
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BOARD18 - Remote Play Tool For 18xx Style Games
</title>
<link rel="shortcut icon" href="images/favicon.ico" >
<link rel="stylesheet" href="style/board18com.css" />
<link rel="stylesheet" href="style/board18Map.css" />
<script type="text/javascript" src="scripts/jquery.js">
</script>
<script type="text/javascript" src="scripts/board18com.js">
</script>
<script type="text/javascript" src="scripts/board18Map1.js">
</script>
<script type="text/javascript" src="scripts/board18Map2.js">
</script>
<script type="text/javascript" src="scripts/board18SnapMap.js">
</script>
<script type="text/javascript">
$(function() {
if ('<?php echo "$status"; ?>' === 'fail') {
var errmsg = 'Data Base access failed.\n';
errmsg += 'Please contact the BOARD18 webmaster.';
alert(errmsg);
}
BD18.welcomename = "<?php echo "$welcomename"; ?>";
BD18.headermessage = "<?php echo "$headermessage"; ?>";
BD18.gameID = "<?php echo $gameid; ?>";
BD18.snapID = "<?php echo $cpid; ?>";
var startMessage = BD18.welcomename + ": ";
startMessage += BD18.headermessage;
$('#lognote').text(startMessage);
setUpKeys();
var snapToShow = 'snapshot='+BD18.snapID;
$.getJSON("php/gameSnap.php", snapToShow, loadSession)
.fail(function() {
var msg = "Error loading game file. \n";
alert(msg);
});
});
</script>
</head>
<body onclick="$('.menu').hide();$('.menu ul ul').hide();">
<div id="topofpage">
<div id="logo">
<img src="images/logo.png" alt="Logo"/>
</div>
<div id="heading">
<h1>BOARD18 - <?php echo $gname; ?> -
<span style="font-size: smaller">Snapshot:
<?php echo $ground; ?></span></h1>
</div>
<div>
<span id="newmainmenu" onclick="$('#traymenu').hide();
$('#mainmenu').toggle();event.stopPropagation();"> MENU </span>
<p id="lognote"></p>
<div id="mainmenu" class="menu">
<ul class="bigMenu" style="width: 300px;">
<li onclick="hideShow();">Hide/Show(H)
</li>
<li onclick="window.location = 'board18SnapMrk.php?show=' + BD18.snapID;">
Go To Snapshot Stock Market(M)
</li>
<li onclick="window.location = 'board18SnapList.php?gameid=' + BD18.gameID;">
Return to Snap List(S)
</li>
<li onclick="window.location = 'board18Map.php?dogame=' + BD18.gameID;">
Return to Game(G)
</li>
<li onclick="window.location = 'board18Main.php';">Go To Main Page(O)
</li>
<li onclick="$.post('php/logout.php', logoutOK);">Log Out(X)
</li>
<li onclick="window.open(BD18.help, 'HelpGuide');">Help
</li>
<li onclick="$('.menu').hide();aboutBoard18();">About BOARD18</li>
</ul>
</div>
</div>
</div>
<div id="topleftofpage">
<span id="traybutton" onclick="$('#mainmenu').hide();
$('#traymenu').toggle();event.stopPropagation();"> Trays </span>
</div>
<div id="traymenu" class="menu"></div>
<div id="botleftofpage">
<div id="sidebar">
<div id="tiles" onclick="traySelect(event);">
<canvas id="canvas0" width="120">
Your browser does not support the HTML 5 Canvas.
</canvas>
</div>
</div>
</div>
<div id="rightofpage">
<div id="content">
<canvas id="canvas1">
Your browser does not support the HTML 5 Canvas.
</canvas>
<canvas id="canvas2">
</canvas>
</div>
</div>
</body>
</html>