summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/server.php
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-02-08 10:50:23 +0000
committerramon <ramongomez@us.es>2017-02-08 10:50:23 +0000
commit1ab1b31df17de5c1ebf80826c33299a1bc517151 (patch)
tree007ed304ba2c0b77bf754f78ffd3393a61a0c03a /admin/WebConsole/rest/server.php
parenta26527db3d1288c340fc503beca4dbde52d65131 (diff)
#708: Reorganizar funciones comunes y registrar errores en fichero {{{error.log}}} de Apache.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5178 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/server.php')
-rw-r--r--admin/WebConsole/rest/server.php97
1 files changed, 0 insertions, 97 deletions
diff --git a/admin/WebConsole/rest/server.php b/admin/WebConsole/rest/server.php
index 8119e519..b1742566 100644
--- a/admin/WebConsole/rest/server.php
+++ b/admin/WebConsole/rest/server.php
@@ -14,66 +14,6 @@
// Auxiliar functions.
/**
- * @brief Validate API key included in "Authorization" HTTP header.
- * @return JSON response on error.
- */
-function validateApiKey() {
- global $cmd;
- global $userid;
- $response = array();
- $app = \Slim\Slim::getInstance();
- // Read Authorization HTTP header.
- $headers = apache_request_headers();
- if (! empty($headers['Authorization'])) {
- // Assign user id. that match this key to global variable.
- $apikey = htmlspecialchars($headers['Authorization']);
- $cmd->texto = "SELECT idusuario
- FROM usuarios
- WHERE apikey='$apikey' LIMIT 1";
- $rs=new Recordset;
- $rs->Comando=&$cmd;
- if ($rs->Abrir()) {
- $rs->Primero();
- if (!$rs->EOF){
- // Fetch user id.
- $userid = $rs->campos["idusuario"];
- } else {
- // Credentials error.
- $response['message'] = 'Login failed. Incorrect credentials';
- jsonResponse(401, $response);
- $app->stop();
- }
- $rs->Cerrar();
- } else {
- // Access error.
- $response['message'] = "An error occurred, please try again";
- jsonResponse(500, $response);
- }
- } else {
- // Error: missing API key.
- $response['message'] = 'Missing API key';
- jsonResponse(400, $response);
- $app->stop();
- }
-}
-
-/**
- * @brief Check if parameter is set and print error messages if empty.
- * @param string param Parameter to check.
- * @return boolean "false" if parameter is null, otherwise "true".
- */
-function checkParameter($param) {
- if (isset($param)) {
- return true;
- } else {
- // Print error message.
- $response['message'] = 'Parameter not found';
- jsonResponse(400, $response);
- return false;
- }
-}
-
-/**
* @brief Check if user is administrator and print error messages if not.
* @param int adminid Administrator id.
* @return boolean "true" if admin id. is equals to global user id., otherwise "false".
@@ -114,43 +54,6 @@ function addClassroomGroup(&$classroomGroups, $rs){
});
}
-/**
- * @fn sendCommand($serverip, $serverport, $reqframe, &$values)
- * @brief Send a command to an OpenGnsys ogAdmServer and get request.
- * @param string serverip Server IP address.
- * @param string serverport Server port.
- * @param string reqframe Request frame (field's separator is "\r").
- * @param array values Response values (out parameter).
- * @return boolean "true" if success, otherwise "false".
- */
-function sendCommand($serverip, $serverport, $reqframe, &$values) {
- global $LONCABECERA;
- global $LONHEXPRM;
-
- // Connect to server.
- $respvalues = "";
- $connect = new SockHidra($serverip, $serverport);
- if ($connect->conectar()) {
- // Send request frame to server.
- $result = $connect->envia_peticion($reqframe);
- if ($result) {
- // Parse request frame.
- $respframe = $connect->recibe_respuesta();
- $connect->desconectar();
- $paramlen = hexdec(substr($respframe, $LONCABECERA, $LONHEXPRM));
- $params = substr($respframe, $LONCABECERA+$LONHEXPRM, $paramlen);
- // Fetch values and return result.
- $values = extrae_parametros($params, "\r", '=');
- return ($values);
- } else {
- // Return with error.
- return (false);
- }
- } else {
- // Return with error.
- return (false);
- }
-}
// REST routes.