add the roadmap .dia file for 2019Q2
[racktables-contribs] / oneshot.php
CommitLineData
8b30586b
DO
1<?php
2/*
3This is a version of local.php file, which implements 'oneshot'
4extension for RackTables. This extension makes it possible to
5forward a user to a RackTables object page without knowing the
6internal ID of that object. This is mainly intended to be used
7together with other systems like Nagios, which only share
8object's name in common with RackTables. For example:
9
f33edde5 10http://example.com/racktables/index.php?page=oneshot&realm=object&q=myserver
8b30586b
DO
11
12(This would instantly redirect the user to myserver's page in
13RackTables, if "myserver" exists.)
14
f33edde5
DO
15This revision of extension has been tested to work with RackTables
16versions 0.18.x and 0.19.x.
8b30586b
DO
17
18*/
19
f33edde5
DO
20$page['oneshot']['handler'] = 'handleOneShotRequest';
21
8b30586b
DO
22function handleOneShotRequest ()
23{
f983b8f5
DO
24 assertStringArg ('realm');
25 assertStringArg ('q');
8b30586b
DO
26 switch ($_REQUEST['realm'])
27 {
28 case 'object':
29 if (NULL === ($id = lookupEntityByString ($_REQUEST['realm'], $_REQUEST['q'])))
30 echo "<h2>Nothing found for '${_REQUEST['q']}'</h2>";
31 else
32 echo "<script language='Javascript'>document.location='index.php?page=object&object_id=${id}';//</script>";
33 break;
34 default:
35 dragon();
36 break;
37 }
38}