source: admin/WebConsole/rest/index.php @ 8c7b374

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 8c7b374 was 13dc959, checked in by ramon <ramongomez@…>, 8 years ago

#708: Añadir mensajes de log al inicio/fin de cada ruta REST.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5467 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 1.9 KB
Line 
1<?php
2/**
3 * @file    index.php
4 * @brief   OpenGnsys REST API manager.
5 * @warning All input and output messages are formatted in JSON.
6 * @note    Some ideas are based on article "How to create REST API for Android app using PHP, Slim and MySQL" by Ravi Tamada, thanx.
7 * @license GNU GPLv3+
8 * @author  Ramón M. Gómez, ETSII Univ. Sevilla
9 * @version 1.1
10 * @date    2016-05-19
11 */
12
13// Inclussion files.
14
15// Server access data.
16include_once("../controlacceso.php");
17include_once("../clases/AdoPhp.php");
18include_once("../includes/CreaComando.php");
19// Connection class.
20@include_once("../includes/constantes.php");
21include_once("../includes/comunes.php");
22include_once("../clases/SockHidra.php");
23// REST functions.
24@include_once("../includes/restfunctions.php");
25// Slim framework.
26include_once("Slim/Slim.php");
27\Slim\Slim::registerAutoloader();
28
29// Server access control.
30$cmd = CreaComando($cnx);
31if (!$cmd)
32        die("Access Error");
33
34// Install Slim application (development mode).
35//$app = new \Slim\Slim(array('mode' => 'production', ... );
36$app = new \Slim\Slim(array(
37                'mode' => 'development',
38                'log.enabled' => true,
39                'log.level' => \Slim\Log::ERROR,
40                'debug' => true));
41$app->setName('opengnsys');
42
43// Global variables.
44$userid = NULL;                 // User id. with access to REST API.
45
46// Common funtions and routes.
47include("common.php");
48
49// Check if services are running.
50$config = parse_ini_file("/etc/default/opengnsys");
51
52// If server is running, include its routes and OGAgent push routes.
53if ($config['RUN_OGADMSERVER'] === "yes") {
54    include("server.php");
55    include("ogagent.php");
56    include("remotepc.php");
57}
58
59// If repository is running, include its routes.
60if ($config['RUN_OGADMREPO'] === "yes") {
61    include("repository.php");
62}
63
64// Showing API information page using Swagger-UI.
65$app->get('/',
66    function() use ($app) {
67        $app->response->redirect('swagger-ui/index.html?url=../../opengnsys-api.yml');
68    }
69);
70
71
72// Execute REST using Slim.
73$app->run();
74
75?>
Note: See TracBrowser for help on using the repository browser.