r1430 + trac#85 --- got rid of the following functions:
[racktables] / inc / pagehandlers.php
CommitLineData
b325120a 1<?php
e673ee24
DO
2/*
3*
4* This file is a library of page handlers for RackTables.
5*
6*/
7
8// This function assures that specified argument was passed
9// and is a number greater than zero.
10function assertUIntArg ($argname, $allow_zero = FALSE)
11{
12 if (!isset ($_REQUEST[$argname]))
13 {
14 showError ("Parameter '${argname}' is missing.");
15 die();
16 }
17 if (!is_numeric ($_REQUEST[$argname]))
18 {
19 showError ("Parameter '${argname}' is not a number.");
20 die();
21 }
22 if ($_REQUEST[$argname] < 0)
23 {
24 showError ("Parameter '${argname}' is less than zero.");
25 die();
26 }
27 if (!$allow_zero and $_REQUEST[$argname] == 0)
28 {
29 showError ("Parameter '${argname}' is equal to zero.");
30 die();
31 }
32}
33
34// This function assures that specified argument was passed
35// and is a non-empty string.
36function assertStringArg ($argname, $ok_if_empty = FALSE)
37{
38 if (!isset ($_REQUEST[$argname]))
39 {
40 showError ("Parameter '${argname}' is missing.");
41 die();
42 }
43 if (!is_string ($_REQUEST[$argname]))
44 {
45 showError ("Parameter '${argname}' is not a string.");
46 die();
47 }
48 if (!$ok_if_empty and empty ($_REQUEST[$argname]))
49 {
50 showError ("Parameter '${argname}' is an empty string.");
51 die();
52 }
53}
54
55function assertBoolArg ($argname, $ok_if_empty = FALSE)
56{
57 if (!isset ($_REQUEST[$argname]))
58 {
59 showError ("Parameter '${argname}' is missing.");
60 die();
61 }
62 if (!is_string ($_REQUEST[$argname]) or $_REQUEST[$argname] != 'on')
63 {
64 showError ("Parameter '${argname}' is not a string.");
65 die();
66 }
67 if (!$ok_if_empty and empty ($_REQUEST[$argname]))
68 {
69 showError ("Parameter '${argname}' is an empty string.");
70 die();
71 }
72}
73
e673ee24
DO
74function handler_objgroup ()
75{
76 assertUIntArg ('group_id');
77 renderObjectGroup ($_REQUEST['group_id']);
78}
79
e673ee24
DO
80function handler_search ($tabno)
81{
82 renderSearchResults();
83}
84
85function handler_config ($tabno)
86{
87 switch ($tabno)
88 {
89 case 'default':
90 renderConfigMainpage();
91 break;
92 default:
93 showError ("Invalid tab '${tabno}' requested in handler_config().");
94 }
95}
96
e673ee24
DO
97function handler_portmap ($tabno)
98{
99 switch ($tabno)
100 {
101 case 'default':
102 renderPortMap (FALSE);
103 break;
104 case 'edit':
105 renderPortMap (TRUE);
106 break;
107 default:
108 showError ("Invalid tab '${tabno}' requested in handler_portmap().");
109 }
110}
111
e673ee24 112?>