-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrpc.php
More file actions
executable file
·42 lines (36 loc) · 777 Bytes
/
rpc.php
File metadata and controls
executable file
·42 lines (36 loc) · 777 Bytes
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
<?php
require('config.php');
foreach ($_POST as $key => $value) {
$$key = $value;
}
$result = array(
'success' => 1,
'payload' => array(),
);
if(!isset($_SESSION['heat'])){
$_SESSION['heat'] = 0;
}
$Vote = new Vote();
$currentHeat = $Vote->poll($_SESSION['heat']);
if(!$currentHeat){
$currentHeat = $Vote->poll(0);
}
if($action == 'poll'){
$i = 1;
foreach ($currentHeat as $key => $value) {
$result['payload']["s{$i}"] = $value;
$i++;
}
} elseif($action == 'vote'){
$Vote->cast($song_id);
foreach ($currentHeat as $key => $value) {
$_SESSION['heat'] = $value['id'];
}
} elseif($action == 'skip'){
foreach ($currentHeat as $key => $value) {
$_SESSION['heat'] = $value['id'];
}
}
header('Content-Type: application/json');
echo json_encode($result);
?>