-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathguestbook.php
More file actions
40 lines (31 loc) · 841 Bytes
/
guestbook.php
File metadata and controls
40 lines (31 loc) · 841 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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
$bg = getenv('GUESTBOOK_BG');
if (isset($_GET['cmd']) === true) {
$host = 'redis-master';
header('Content-Type: application/json');
if ($_GET['cmd'] == 'set') {
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => $host,
'port' => getenv('GUESTBOOK_REDIS_PORT'),
]);
$client->set($_GET['key'], $_GET['value']);
print('{"message": "Updated"}');
} else {
$host = 'redis-slave';
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => $host,
'port' => getenv('GUESTBOOK_REDIS_PORT'),
]);
$value = $client->get($_GET['key']);
print('{"data": "' . $value . '", "bg": "' . $bg . '"}');
}
} else {
phpinfo();
}
?>