Skip to content

Instantly share code, notes, and snippets.

@opn
Last active November 17, 2017 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opn/e89f0ceca2a927b4b22e4c6c75d7089b to your computer and use it in GitHub Desktop.
Save opn/e89f0ceca2a927b4b22e4c6c75d7089b to your computer and use it in GitHub Desktop.
This is Revigniter controller 'echo.lc' from the domain 'rest.livecode.world'.
<?lc
/* = DESCRIPTION =
--
The echo.lc controller can be found at: echo.lc
Here is some test help
Below we declare the global variables gControllerHandlers AND gData
And put the public method names that we wish to expose into gControllerHandlers
--
*/
global gControllerHandlers, gData
put "index,server,postraw,myip,echo" into gControllerHandlers
/* == INITIALISATION ==
--
Put all the handlers and variables that you wish to merge into your views
into the global array "gData".
Write any initialisation statements (loading any neeeded libraries for instance)
into the initialisation handler "echo.lc" below.
--
*/
command echo
start using stack (gAPPPATH & "stacks/lib_Fedwiki.livecode")
end echo
/* == CODE ==
--
Here we put the public handlers the controller uses and exposes as urls.
--
*/
on index
put fedwiki_GetDroppedUrl ($_POST_RAW) into someText
put CR & CR after someText
put $_POST_RAW after someText
put CR & CR after someText
put rigUserAgent() into tUserAgent
put rigVarCookie ("wikisession") into someCookie
put tUserAgent & CR & someCookie after someText
put CR & CR & rigIpAddress() after someText
put $_SERVER into tServerArray
combine tServerArray using CR and space
put CR & CR & tServerArray after someText
put fedwiki_ConstructErrorJSON (someText) into someJSON
fedwiki_ReturnJSON someJSON
end index
on myip
put rigIpAddress() after myIP
put myIP
end myip
on postraw
set the itemdelimiter to "&"
repeat for each item tVariablePair in $_POST_RAW
set the itemdelimiter to "="
put urlDecode(item 1 of tVariablePair) into tVariableKey
put urlDecode(item 2 of tVariablePair) into tVariableValue
-- do something with key and value --
put tVariableKey & ":" && tVariableValue & CR after someText
set the itemdelimiter to "&"
end repeat
put someText
end postraw
on server
put $_SERVER into someText
combine someText using CR and space
put someText
end server
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment