-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgui_edit_command.php
More file actions
304 lines (277 loc) · 12.6 KB
/
gui_edit_command.php
File metadata and controls
304 lines (277 loc) · 12.6 KB
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
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
date_default_timezone_set('Europe/Berlin');
session_start();
// https://www.php-einfach.de/php-tutorial/php-sessions/
require('./logger.php');
require('./db.php');
if (!isset($_SESSION['playerid'])) {
echo "Not logged in... redirecting.<br>";
echo "<meta http-equiv='refresh' content='0;url=./login.php?auto=1'>";
header("Location: ./login.php?auto=1");
//die("Check position 6");
}
$pid = $_SESSION['playerid'];
$gid = $_SESSION['gameid'];
$pimage = $_SESSION['playerimage'];
$opt3 = $_SESSION['option3'];
$playMode = $opt3;
$isAdmin = $_SESSION['isAdmin'];
$commandId = isset($_GET["commandid"]) ? filter_var($_GET["commandid"], FILTER_VALIDATE_INT) : -1;
$sql_asc_playerround = "SELECT SQL_NO_CACHE * FROM asc_player where playerid = " . $pid . ";";
$result_asc_playerround = mysqli_query($conn, $sql_asc_playerround);
if (mysqli_num_rows($result_asc_playerround) > 0) {
while($row = mysqli_fetch_assoc($result_asc_playerround)) {
$CURRENTROUND = $row["round"];
}
}
$sql_asc_command = "SELECT SQL_NO_CACHE * FROM asc_command where commandid = " . $commandId . ";";
$result_asc_command = mysqli_query($conn, $sql_asc_command);
if (mysqli_num_rows($result_asc_command) > 0) {
while($row352 = mysqli_fetch_assoc($result_asc_command)) {
$COMMANDNAME = $row352["commandname"];
$COMMANDTYPE = $row352["type"];
$COMMANDFACTIONID = $row352["factionid"];
$COMMANDBACKGROUND = $row352["commandbackground"];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>ASCard.net AplhaStrike Card App (clanwolf.net): Edit Command</title>
<meta charset="utf-8">
<!-- <meta http-equiv="expires" content="0"> -->
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> -->
<meta name="description" content="Cards app for the AlphaStrike TableTop (BattleTech).">
<meta name="keywords" content="BattleTech, AlphaStrike">
<meta name="robots" content="noindex,nofollow">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="ASCard">
<meta name="viewport" content="width=device-width, initial-scale=0.75, minimum-scale=0.75, maximum-scale=1.85, user-scalable=yes" />
<link rel="manifest" href="/app/ascard.webmanifest">
<link rel="stylesheet" type="text/css" href="./fontawesome/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./styles/styles.css">
<link rel="stylesheet" type="text/css" href="./styles/editorstyles.css">
<link rel="icon" type="image/png" href="/app/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/app/favicon.svg" />
<link rel="shortcut icon" href="/app/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/app/apple-touch-icon.png" />
<!-- https://www.npmjs.com/package/passive-events-support?activeTab=readme -->
<script>
window.passiveSupport = {
debug: false,
events: ['touchstart', 'touchmove', 'wheel'],
listeners: [
{
element: '.jspContainer',
event: 'touchstart',
prevented: true
},
{
element: '.jspContainer',
event: 'touchmove',
prevented: true
},
{
element: '.jspContainer',
event: 'wheel',
prevented: true
}
]
}
</script>
<script type="text/javascript" src="./scripts/passive-events-support/main.js"></script>
<script type="text/javascript" src="./scripts/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="./scripts/howler.min.js"></script>
<script type="text/javascript" src="./scripts/cookies.js"></script>
<script>
let commandName = "<?php echo $COMMANDNAME; ?>";
let commandType = "<?php echo $COMMANDTYPE; ?>";
let commandFactionId = "<?php echo $COMMANDFACTIONID; ?>";
let commandbackground = "<?php echo $COMMANDBACKGROUND; ?>";
function correctStrings() {
let f1 = document.getElementById("NewCommandName").value.replace(/[^A-Za-z0-9 -_|]/g, '').replace(/\"/g, "").replace(/'/g, "");
let f2 = document.getElementById("NewCommandBackground").value.replace(/[^A-Za-z0-9 -_|]/g, '').replace(/\"/g, "").replace(/'/g, "");
document.getElementById("NewCommandName").value = f1;
document.getElementById("NewCommandBackground").value = f2;
}
function save() {
let n1 = document.getElementById("NewCommandName").value.replace(/[^A-Za-z0-9 -_|]/g, '').replace(/ +/g, ' ').replace(/\"/g, "").replace(/'/g, "");
let n2 = document.getElementById("NewCommandType").value;
let n3 = document.getElementById("NewCommandFaction").value;
let n4 = document.getElementById("NewCommandBackground").value.replace(/[^A-Za-z0-9 ]/g, '').replace(/ +/g, ' ').replace(/\"/g, "").replace(/'/g, "");
//if (!n1 || !n2 || !n3 || !n4) {
if (!n1) {
alert("Enter valid name!");
} else {
let param_n1 = encodeURIComponent(n1);
let param_n2 = encodeURIComponent(n2);
let param_n3 = encodeURIComponent(n3);
let param_n4 = encodeURIComponent(n4);
var url="./save_command_data.php?commandid="+<?php echo $commandId; ?>+"&newcommandname="+param_n1+"&newcommandtype="+param_n2+"&newcommandfaction="+param_n3+"&newcommandbackground="+param_n4;
window.frames['saveframe'].location.replace(url);
}
}
</script>
<style>
html, body {
background-image: url('./images/body-bg_2.jpg');
}
table {
margin-left: auto;
margin-right: auto;
}
input, select, textarea {
width: 80px;
vertical-align: middle;
color: #ddd;
border-width: 0px;
padding: 2px;
font-family: 'Pathway Gothic One', sans-serif;
}
select:focus, textarea:focus, input:focus {
outline: none;
}
select:invalid, input:invalid, textarea:invalid {
background: rgba(60,60,60,0.95);
}
select:valid, input:valid, textarea:valid {
background: rgba(70,70,70,0.75);
}
.scroll-pane {
width: 100%;
height: 100px;
overflow: auto;
}
.horizontal-only {
height: auto;
max-height: 100px;
}
</style>
</head>
<body>
<iframe name="saveframe" id="iframe_save"></iframe>
<script type="text/javascript" src="./scripts/log_enable.js"></script>
<script>
$(document).ready(function() {
$("#cover").hide();
document.getElementById("NewCommandName").value = commandName;
document.getElementById("NewCommandFaction").value = commandFactionId;
document.getElementById("NewCommandType").value = commandType;
document.getElementById("NewCommandBackground").value = commandbackground;
});
</script>
<div id="cover"></div>
<?php
if ($playMode) {
$buttonWidth = "33.3%"; // 3 columns in the middle
} else {
if ($isAdmin) {
$buttonWidth = "17%"; // 6 columns
} else {
$buttonWidth = "25%"; // 4 columns
}
}
?>
<div id="header">
<table style="width:100%;height:60px;border:none;border-collapse:collapse;background:rgba(50,50,50,1.0);" cellspacing="0" cellpadding="0">
<tr>
<td nowrap onclick="location.href='./logout.php'" style="width: 80px;background: rgba(50,50,50,1.0); text-align: center; vertical-align: middle;">
<div><a style="color: #eee;" href="./logout.php"> <i class="fas fa-power-off" aria-hidden="true"></i> </a></div>
</td>
<td nowrap onclick="location.href='./gui_edit_game.php'" style="width: 100px;background:rgba(56,87,26,1.0);">
<div style='vertical-align:middle;font-size:28px;color:#eee;'> G<?php echo $gid ?> R<?php echo $CURRENTROUND ?> </div>
</td>
<td style="width:5px;"> </td>
<td nowrap onclick="location.href='./gui_select_unit.php'" width="<?php echo $buttonWidth ?>" class='menu_button_active'><a href='./gui_select_unit.php'><i class="fa-solid fa-list"></i> ROSTER</a></td>
<td style="width:5px;"> </td>
<?php
if ($playMode) {
echo " <td nowrap onclick=\"location.href='./gui_select_formation.php'\" width=".$buttonWidth." class='menu_button_normal'><a href='./gui_select_formation.php'>CHALLENGE</a></td><td style='width:5px;'> </td>\n";
}
if (!$playMode) {
echo " <td nowrap onclick=\"location.href='./gui_assign_unit.php'\" width=".$buttonWidth." class='menu_button_normal'><a href='./gui_assign_unit.php'>ASSIGN</a></td><td style='width:5px;'> </td>\n";
echo " <td nowrap onclick=\"location.href='./gui_create_unit.php'\" width=".$buttonWidth." class='menu_button_normal'><a href='./gui_create_unit.php'>CREATE</a></td><td style='width:5px;'> </td>\n";
//echo " <td nowrap onclick=\"location.href='./gui_edit_game.php'\" width=".$buttonWidth." class='menu_button_normal'><a href='./gui_edit_game.php'>GAME</a></td><td style='width:5px;'> </td>\n";
if ($isAdmin) {
echo " <td nowrap onclick=\"location.href='./gui_create_player.php'\" width=".$buttonWidth." class='menu_button_normal'><a href='./gui_create_player.php'>PLAYER</a></td><td style='width:5px;'> </td>\n";
echo " <td nowrap onclick=\"location.href='./gui_admin.php'\" width=".$buttonWidth." class='menu_button_normal'><a href='./gui_admin.php'>ADMIN</a></td><td style='width:5px;'> </td>\n";
}
}
?>
<td nowrap onclick="location.href='./gui_edit_option.php'" width="<?php echo $buttonWidth ?>" class='menu_button_normal'><a href='./gui_edit_option.php'>OPTIONS</a></td>
<td style="width:5px;"> </td>
<td nowrap onclick="location.href='gui_show_playerlist.php'" style="width: 60px;" nowrap width="60px" style="background: rgba(50,50,50,1.0); text-align: center; vertical-align: middle;"><img src='./images/player/<?=$pimage?>' height='60px' style='height:auto;display:block;' width='60px' height='60px'></td>
</tr>
<tr><td colspan='999' style='background:rgba(50,50,50,1.0);height:5px;'></td></tr>
</table>
</div>
<div id="liberapay"><a href="./gui_show_support.php"><i class="fa-solid fa-handshake-simple"></i></a></div>
<div id="disclaimer"><a href="./gui_show_disclaimer.php">Disclaimer</a></div>
<br>
<form autocomplete="autocomplete_off_hack_xfr4!k">
<table width="40%" class="options" cellspacing="2" cellpadding="2" border="0px">
<tr>
<td colspan="1" width='5%' class='datalabel' nowrap align="left">Command name:</td>
<td colspan="1" width='90%' class='datalabel' style="width:100%;">
<input autocomplete="autocomplete_off_hack_xfr4!k" required onkeyup="correctStrings();" type="text" id="NewCommandName" width="100%" style="width:100%;">
</td>
</tr>
<tr>
<td width='5%' class='datalabel' colspan="1" align="left">Faction:</td>
<td width='90%' class='datalabel' colspan="1" style="width:100%;">
<select required name='NewCommandFaction' id='NewCommandFaction' size='1' style='width:100%;'>
<option value="3" selected>ComStar [CS]</option>
<option value="1">Clan Wolf [CW]</option>
<option value="13">Clan Wolf in Exile [CWiE]</option>
<option value="9">Clan Jade Falcon [CJF]</option>
<option value="5">Clan Ghostbear [CGB]</option>
<option value="12">Clan Smoke Jaguar [CSJ]</option>
<option value="14">Clan Snow Raven [CSR]</option>
<option value="15">Clan Nova Cat [CNC]</option>
<option value="2">Lyran Alliance [LA]</option>
<option value="7">Lyran Commonwealth [LC]</option>
<option value="4">Draconis Combine [DC]</option>
<option value="8">Federated Suns [FS]</option>
<option value="10">Free Worlds League [FWL]</option>
<option value="11">Capellan Confederation [CC]</option>
<option value="6">Wolfs Dragoons [M-WD]</option>
</select>
</td>
<td width='10px'></td>
</tr>
<tr>
<td width='5%' class='datalabel' colspan="1" align="left">Type:</td>
<td width='90%' class='datalabel' colspan="1" style="width:100%;">
<select required name='NewCommandType' id='NewCommandType' size='1' style='width:100%;'>
<option value="custom" selected>custom</option>
<option value="official">official</option>
</select>
</td>
<td width='10px'></td>
</tr>
<tr>
<td width='5%' class='datalabel' colspan="1" valign="top" align="left" style="vertical-align:top;">Background:</td>
<td width='90%' class='datalabel' colspan="1" style="width:100%;">
<textarea name="NewCommandBackground" id="NewCommandBackground" onkeyup="correctStrings();" cols="40" rows="5" required width="100%" style="width:100%;resize:none;"></textarea>
</td>
<td width='10px'></td>
</tr>
<tr>
<td colspan="3" width='5%' class='datalabel' nowrap align="left"><hr></td>
</tr>
<tr>
<td colspan="3" class='datalabel' align="right">
<span style='font-size:16px;'>
<a href="#" onClick="save();"><i class="fa-solid fa-floppy-disk"></i></a>
</span>
</td>
</tr>
</table>
</form>
</body>
</html>