source: admin/WebConsole/rest/index.php @ 13e20ad

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 13e20ad was 3551804, checked in by ramon <ramongomez@…>, 8 years ago

#708: Separar funciones y rutas REST comunes; nueva ruta /info con información de versión y servicios activos.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5096 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', 'debug' => false));
36$app = new \Slim\Slim(array(
37                'mode' => 'development',
38                'debug' => true));
39$app->setName('opengnsys');
40
41// Global variables.
42$userid = NULL;                 // User id. with access to REST API.
43
44// Common funtions and routes.
45include("common.php");
46
47// Check if services are running.
48$config = parse_ini_file("/etc/default/opengnsys");
49
50// If server is running, include its routes and OGAgent push routes.
51if ($config['RUN_OGADMSERVER'] === "yes") {
52    include("server.php");
53    include("ogagent.php");
54}
55
56// If repository is running, include its routes.
57if ($config['RUN_OGADMREPO'] === "yes") {
58    include("repository.php");
59}
60
61// Showing API information page using Swagger-UI.
62$app->get('/',
63    function() use ($app) {
64        $app->response->redirect('swagger-ui/index.html?url=../../opengnsys-api.yml');
65    }
66);
67
68
69// Execute REST using Slim.
70$app->run();
71
72?>
73
Note: See TracBrowser for help on using the repository browser.