forked from gbishop/TarHeelGameplay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameplay.php
More file actions
60 lines (54 loc) · 1.33 KB
/
gameplay.php
File metadata and controls
60 lines (54 loc) · 1.33 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
<?php
/*
Template Name: Gameplay
Play a game
*/
?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// posting a new or updated book
global $log;
$json = getParam('gp', '', null, 'post');
$name = gps_get_key($json);
$res = array('name'=>$name);
$output = json_encode($res);
header('Content-Type: application/json');
header('Content-Size: ' . mb_strlen($output));
echo $output;
die();
}
$accept = $_SERVER['HTTP_ACCEPT'];
if (strpos($accept, 'application/json') !== false ||
strpos($accept, 'text/javascript') !== false) {
$key = getParam('key', '', null);
if ($key) {
$res = gps_get_json($key);
$output = $res;
header('Content-Type: application/json');
header('Content-Size: ' . mb_strlen($output));
echo $output;
die();
}
}
get_header();
$key = getParam('key', '', null);
$id = getParam('id', '', null);
$script = "";
if ($key) {
$json = gps_get_json($key);
$script = "<script>window.game_init=$json; </script>";
} elseif($id) {
$json = get_post_meta($id, 'gamedata', true);
$script = "<script>window.game_init=$json; </script>";
}
?>
<body>
<?php echo $script; ?>
<div class="gameplay-page">
<div id="player"></div>
<div id="shade">
<table id="message"></table>
</div>
<?php
get_footer();
?>