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
RevLine 
[7829e4e]1<?php
2/**
3 * @file    index.php
4 * @brief   OpenGnsys REST API manager.
[b584da5]5 * @warning All input and output messages are formatted in JSON.
[7829e4e]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
[1485b99]10 * @date    2016-05-19
[7829e4e]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.
[c03c7c3]20@include_once("../includes/constantes.php");
[7829e4e]21include_once("../includes/comunes.php");
22include_once("../clases/SockHidra.php");
[353c112]23// REST functions.
24@include_once("../includes/restfunctions.php");
[7829e4e]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).
[1ab1b31d]35//$app = new \Slim\Slim(array('mode' => 'production', ... );
[7829e4e]36$app = new \Slim\Slim(array(
37                'mode' => 'development',
[1ab1b31d]38                'log.enabled' => true,
39                'log.level' => \Slim\Log::ERROR,
[13dc959]40                'debug' => true));
[7829e4e]41$app->setName('opengnsys');
42
43// Global variables.
[4454169b]44$userid = NULL;                 // User id. with access to REST API.
[7829e4e]45
[3551804]46// Common funtions and routes.
47include("common.php");
48
[fb2ee20]49// Check if services are running.
50$config = parse_ini_file("/etc/default/opengnsys");
[7829e4e]51
[fb2ee20]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");
[e0b6a5e]56    include("remotepc.php");
[7829e4e]57}
58
[fb2ee20]59// If repository is running, include its routes.
60if ($config['RUN_OGADMREPO'] === "yes") {
61    include("repository.php");
[7829e4e]62}
63
[8b8e948]64// Showing API information page using Swagger-UI.
[036cb22]65$app->get('/',
[8b8e948]66    function() use ($app) {
67        $app->response->redirect('swagger-ui/index.html?url=../../opengnsys-api.yml');
[ac8b234e]68    }
69);
70
[b1735a7]71
72// Execute REST using Slim.
[7829e4e]73$app->run();
74
75?>
Note: See TracBrowser for help on using the repository browser.