Last active
July 30, 2016 17:26
-
-
Save hex128/e2bfc60c6a62e4b67014 to your computer and use it in GitHub Desktop.
Remote Control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$APC_KEY = "remote_command"; | |
$now = time(); | |
$msec = 0; | |
$success = false; | |
while (!$success && $msec < 20000) { | |
$command = apc_fetch($APC_KEY, $success); | |
usleep(1000); | |
$msec ++; | |
} | |
apc_delete($APC_KEY); | |
header("Content-type: application/json"); | |
echo json_encode([ | |
"command" => $command, | |
"status" => http_response_code() | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$APC_KEY = "remote_command"; | |
$command = $_REQUEST['command']; | |
if (!$command) | |
http_response_code(400); | |
apc_delete($APC_KEY); | |
if (!apc_add($APC_KEY, $command, 1)) | |
http_response_code(500); | |
header("Content-type: application/json"); | |
echo json_encode([ | |
"command" => $command, | |
"status" => http_response_code() | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment