-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
79 lines (64 loc) · 1.53 KB
/
index.php
File metadata and controls
79 lines (64 loc) · 1.53 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
<html>
<head>
<style TYPE="text/css">
<!--
.files {
padding: 10px;
}
.message {
color: red;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="100%">
<tr>
<td>Welcome to the sabsl adventure games.</td>
<td align="right"><a href="editor.php">Edit</a></td>
</tr>
</table>
<hr>
<?php
$userdirs = glob ("games/*");
if ( !$userdirs ) {
?>
<p>No games are available. Ask a game editor to create one.</p>
<?php } else { ?>
<p>Click on a game to get started.</p>
<div style="padding: 10px; background-color: #ff8888; width: 600;">
<table cell-padding="4" width="100%">
<tr style="background-color: white;">
<th class="files">Game</th>
<th class="files">Author</th>
<th class="files">Description</th>
</tr>
<?php
foreach ( $userdirs as $userdir ) {
$username = basename ( $userdir );
foreach ( glob ("$userdir/*") as $file ) {
$gamename = basename ( $file, '.json' );
$game_definition = file_get_contents ( $file );
$locations = json_decode($game_definition, true);
if ( is_array ( $locations )
&&array_key_exists ( 'description', $locations )) {
$game_desc = $locations['description'];
} else {
$game_desc = "<No description>";
}
?>
<tr style="background-color: white;">
<td class="files" width="*%"><?php echo "<a href=\"play.php/$file\">$gamename</a>"; ?></td>
<td class="files" width="*%"><?php echo "$username"; ?></td>
<td class="files" width="*%"><?php echo "$game_desc"; ?></td>
</tr>
<?php
} // foreach
} // else
}
?>
</table>
</div>
</body>
</html>