From: paulr Date: Tue, 8 Feb 2011 05:43:30 +0000 (+1100) Subject: lots of coded stuff, the beginnings of the server/client comms bits X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=01b5d6290a0d704099cef17071c1fc50b3049bee;p=ga4php.git lots of coded stuff, the beginnings of the server/client comms bits --- diff --git a/doco/pseudo.txt b/doco/pseudo.txt index 7aa375f..4ab05c3 100644 --- a/doco/pseudo.txt +++ b/doco/pseudo.txt @@ -4,4 +4,38 @@ start: am I inited? yes: load from datastore (AD, database, etc) no: tell any request returns "uninited" - figure out my datastore. \ No newline at end of file + figure out my datastore. + + +Setup: + gaasd starts up with backend set to none + index.php, admin.php redirect to setup.php + setup.php asks questions (ad/in) + setup.php sends gaasd setup instructions + gaasd checks config + setup.php redirects to admin.php if setup works + + + +Plugins, how they work +so in globalLib you define a message: +define("MSG_STATUS", 18); + +then you define a functional prefix +$MESSAGES[MSG_STATUS] = "gaasStatus"; + +then in gaasClientMessages you define gaasStatus_clientsend($params) where $params is an array of parameters in the function call +this returns a "vals" structure thats sent to "sent" to the server, then gaasStatus_clientrecv(..) which accepts that data back from the server + +then in gaasdMessages.php you define gaasStatus_server(...) which defines a method for handling the data at the server side. + +In code you then call $class->MSG_STATUS(params); + + +$params in clientsend is the arguments sent via MSG_STATUS([0], [1], ...); + +$params is then played with to create a single text variable (such as a serialised data structure) and returned to the gasdclient and sent to the server + +server receives what clientsend returns in _server($params) as $params. + +server then returns its data via a text variable in the return which is then send back to clientrecv($params) as $params; \ No newline at end of file diff --git a/gaas/gaasd/gaasclient.php b/gaas/gaasd/gaasclient.php new file mode 100644 index 0000000..8151e17 --- /dev/null +++ b/gaas/gaasd/gaasclient.php @@ -0,0 +1,9 @@ +MSG_STATUS("asdf"); + +?> \ No newline at end of file diff --git a/gaas/gaasd/gaasd.php b/gaas/gaasd/gaasd.php index cb716a7..9ce58c6 100644 --- a/gaas/gaasd/gaasd.php +++ b/gaas/gaasd/gaasd.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/gaas/lib/gaasClientMessages.php b/gaas/lib/gaasClientMessages.php new file mode 100644 index 0000000..f401e1d --- /dev/null +++ b/gaas/lib/gaasClientMessages.php @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/gaas/lib/gaasdClient.php b/gaas/lib/gaasdClient.php index 36da285..4226368 100644 --- a/gaas/lib/gaasdClient.php +++ b/gaas/lib/gaasdClient.php @@ -1,5 +1,95 @@ -sendReceive($st_defined, $function_send($params))); + } else { + error_log("Function, $function does not exist!"); + } + } +} + ?> \ No newline at end of file diff --git a/gaas/lib/gaasdLib.php b/gaas/lib/gaasdLib.php index 5cfe52f..a9fd81d 100644 --- a/gaas/lib/gaasdLib.php +++ b/gaas/lib/gaasdLib.php @@ -1,14 +1,11 @@ \ No newline at end of file diff --git a/gaas/lib/globalLib.php b/gaas/lib/globalLib.php new file mode 100644 index 0000000..89e24b2 --- /dev/null +++ b/gaas/lib/globalLib.php @@ -0,0 +1,81 @@ +]_server() for the server side +// and $MESSAGE[]_client() for the client side + +$MESSAGES[MSG_AUTH_USER_TOKEN] = "gaasAuthUserToken"; +$MESSAGES[MSG_ADD_USER_TOKEN] = "gaasAddUserToken"; +$MESSAGES[MSG_DELETE_USER] = "gaasDeleteUser"; +$MESSAGES[MSG_AUTH_USER_PASSWORD] = "gaasAuthUserPass"; +$MESSAGES[MSG_SET_USER_PASSWORD] = "gaasSetUserPass"; +$MESSAGES[MSG_SET_USER_REALNAME] = "gaasSetUserRealName"; +$MESSAGES[MSG_SET_USER_TOKEN] = "gaasSetUserToken"; +$MESSAGES[MSG_SET_USER_TOKEN_TYPE] = "gaasSetUserTokenType"; +$MESSAGES[MSG_GET_USERS] = "gaasGetUsers"; +$MESSAGES[MSG_GET_OTK_PNG] = "gaasGetOTKPng"; +$MESSAGES[MSG_GET_OTK_ID] = "gaasGetOTKID"; +$MESSAGES[MSG_DELETE_USER_TOKEN] = "gaasDeleteUserToken"; +$MESSAGES[MSG_SYNC_TOKEN] = "gaasSyncToken"; +$MESSAGES[MSG_GET_TOKEN_TYPE] = "gaasGetTokenType"; +$MESSAGES[MSG_GET_RADIUS_CLIENTS] = "gaasGetRadiusClients"; +$MESSAGES[MSG_REMOVE_RADIUS_CLIENT] = "gaasRemoveRadiusClient"; +$MESSAGES[MSG_ADD_RADIUS_CLIENT] = "gaasAddRadiusClient"; +$MESSAGES[MSG_STATUS] = "gaasStatus"; +$MESSAGES[MSG_INIT_SERVER] = "gaasInitServer"; +global $MESSAGES; + +function generateRandomString($len) +{ + $str = ""; + $strpos = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + for($i=0; $i<$len; $i++) { + $str .= $strpos[rand(0, strlen($strpos)-1)]; + } + + return $str; +} + +function generateHexString($len) +{ + $str = ""; + $strpos = "0123456789ABCDEF"; + + for($i=0; $i<$len; $i++) { + $str .= $strpos[rand(0, strlen($strpos)-1)]; + } + + return $str; +} + + +?> \ No newline at end of file