-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.php
More file actions
35 lines (28 loc) · 899 Bytes
/
data.php
File metadata and controls
35 lines (28 loc) · 899 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
<?php
/*
Very simple "web service" for twine.
Author: JP Reardon <http://jpreardon.com>
Last Updated: 2012-11-28
This file is for testing purposes only. Use at your own risk!
If an orientation and the proper key has been passed in the URL,
the orientation is saved to a file. Otherwise, the last known
orientation is returned.
The key is primative "security" so just anyone can't write data.
Yes, I said it was primative. Change the key variable to one of
your choice.
*/
// Change the key value to a key of your choice.
$key = "<key goes here>";
$datafile = "datastore.txt";
if ($_GET[orientation] && $_GET[key] == $key) {
// Update the data file and set the current orientation
if (file_put_contents($datafile, $_GET[orientation])) {
print "OK";
}else {
print "ERROR";
}
} else {
// Send the current orientation in [brackets]
print "[" . file_get_contents($datafile) . "]";
}
?>