@@ -5,34 +5,34 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch all APIs |
11 | -$all_apis = $Admin->fetch_all_objects("api"); |
|
11 | +$all_apis = $Admin->fetch_all_objects ("api"); |
|
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <!-- display existing groups --> |
15 | -<h4><?php print _('API management'); ?></h4> |
|
15 | +<h4><?php print _ ('API management'); ?></h4> |
|
16 | 16 | <hr><br> |
17 | 17 | |
18 | 18 | <!-- only IF aPI enabled --> |
19 | -<?php if($User->settings->api==1) { ?> |
|
19 | +<?php if ($User->settings->api == 1) { ?> |
|
20 | 20 | <!-- Add new --> |
21 | - <button class='btn btn-sm btn-default editAPI' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _('Create API key'); ?></button> |
|
21 | + <button class='btn btn-sm btn-default editAPI' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _ ('Create API key'); ?></button> |
|
22 | 22 | |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | /* print existing APIs */ |
26 | - if($all_apis!==false) { |
|
26 | + if ($all_apis !== false) { |
|
27 | 27 | |
28 | 28 | print '<table id="userPrint" class="table table-striped table-top table-auto">'; |
29 | 29 | # headers |
30 | 30 | print '<tr>'; |
31 | - print "<th>"._('App id').'</th>'; |
|
32 | - print "<th>"._('App code').'</th>'; |
|
33 | - print "<th>"._('App permissions').'</th>'; |
|
34 | - print "<th>"._('App security').'</th>'; |
|
35 | - print "<th>"._('Comment').'</th>'; |
|
31 | + print "<th>"._ ('App id').'</th>'; |
|
32 | + print "<th>"._ ('App code').'</th>'; |
|
33 | + print "<th>"._ ('App permissions').'</th>'; |
|
34 | + print "<th>"._ ('App security').'</th>'; |
|
35 | + print "<th>"._ ('Comment').'</th>'; |
|
36 | 36 | print '<th></th>'; |
37 | 37 | print '</tr>'; |
38 | 38 | |
@@ -42,74 +42,74 @@ discard block |
||
42 | 42 | $a = (array) $a; |
43 | 43 | |
44 | 44 | # hide key if not crpt |
45 | - if($a['app_security']!="crypt") { $a['app_code']="<span class='text-muted'>"._('Not used')."</span>"; } |
|
46 | - if($a['app_security']=="ssl") { $a['app_security'] = "SSL"; } |
|
45 | + if ($a['app_security'] != "crypt") { $a['app_code'] = "<span class='text-muted'>"._ ('Not used')."</span>"; } |
|
46 | + if ($a['app_security'] == "ssl") { $a['app_security'] = "SSL"; } |
|
47 | 47 | |
48 | - print '<tr>' . "\n"; |
|
48 | + print '<tr>'."\n"; |
|
49 | 49 | |
50 | - print ' <td>' . $a['app_id'] . '</td>'. "\n"; |
|
51 | - print ' <td>' . $a['app_code'] . '</td>'. "\n"; |
|
50 | + print ' <td>'.$a['app_id'].'</td>'."\n"; |
|
51 | + print ' <td>'.$a['app_code'].'</td>'."\n"; |
|
52 | 52 | |
53 | 53 | # reformat permissions |
54 | - if($a['app_permissions']==0) { $a['app_permissions'] = _("Disabled"); } |
|
55 | - elseif($a['app_permissions']==1) { $a['app_permissions'] = _("Read"); } |
|
56 | - elseif($a['app_permissions']==2) { $a['app_permissions'] = _("Read / Write"); } |
|
57 | - elseif($a['app_permissions']==3) { $a['app_permissions'] = _("Read / Write / Admin"); } |
|
54 | + if ($a['app_permissions'] == 0) { $a['app_permissions'] = _ ("Disabled"); } |
|
55 | + elseif ($a['app_permissions'] == 1) { $a['app_permissions'] = _ ("Read"); } |
|
56 | + elseif ($a['app_permissions'] == 2) { $a['app_permissions'] = _ ("Read / Write"); } |
|
57 | + elseif ($a['app_permissions'] == 3) { $a['app_permissions'] = _ ("Read / Write / Admin"); } |
|
58 | 58 | |
59 | 59 | # override permissions if user |
60 | - if($a['app_security']=="user") { $a['app_permissions']="<span class='text-muted'>"._('Per user')."</span>"; } |
|
60 | + if ($a['app_security'] == "user") { $a['app_permissions'] = "<span class='text-muted'>"._ ('Per user')."</span>"; } |
|
61 | 61 | |
62 | - print ' <td>' . $a['app_permissions'] . '</td>'. "\n"; |
|
63 | - print ' <td>' . ucwords($a['app_security']) . '</td>'. "\n"; |
|
64 | - print ' <td>' . $a['app_comment'] . '</td>'. "\n"; |
|
62 | + print ' <td>'.$a['app_permissions'].'</td>'."\n"; |
|
63 | + print ' <td>'.ucwords ($a['app_security']).'</td>'."\n"; |
|
64 | + print ' <td>'.$a['app_comment'].'</td>'."\n"; |
|
65 | 65 | |
66 | 66 | # add/remove APIs |
67 | 67 | print " <td class='actions'>"; |
68 | 68 | print " <div class='btn-group'>"; |
69 | - print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='edit' rel='tooltip' title='"._('edit app details')."'> <i class='fa fa-pencil'></i></button>"; |
|
70 | - print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='delete' rel='tooltip' title='"._('remove app')."'> <i class='fa fa-times'></i></button>"; |
|
69 | + print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='edit' rel='tooltip' title='"._ ('edit app details')."'> <i class='fa fa-pencil'></i></button>"; |
|
70 | + print " <button class='btn btn-xs btn-default editAPI' data-container='body' data-appid='$a[id]' data-action='delete' rel='tooltip' title='"._ ('remove app')."'> <i class='fa fa-times'></i></button>"; |
|
71 | 71 | print " </div>"; |
72 | 72 | print "</td>"; |
73 | 73 | |
74 | - print '</tr>' . "\n"; |
|
74 | + print '</tr>'."\n"; |
|
75 | 75 | } |
76 | 76 | print "</table>"; |
77 | 77 | } |
78 | 78 | else { |
79 | - $Result->show("info alert-nomargin", _("No Apps available")."!", false); |
|
79 | + $Result->show ("info alert-nomargin", _ ("No Apps available")."!", false); |
|
80 | 80 | } |
81 | 81 | ?> |
82 | 82 | |
83 | 83 | <?php |
84 | 84 | # print error if extensions are not available on server! |
85 | - $requiredExt = array("mcrypt", "curl"); |
|
86 | - $availableExt = get_loaded_extensions(); |
|
85 | + $requiredExt = array ("mcrypt", "curl"); |
|
86 | + $availableExt = get_loaded_extensions (); |
|
87 | 87 | # check for missing ext |
88 | - $missingExt = array(); |
|
88 | + $missingExt = array (); |
|
89 | 89 | foreach ($requiredExt as $extension) { |
90 | - if (!in_array($extension, $availableExt)) { |
|
90 | + if (!in_array ($extension, $availableExt)) { |
|
91 | 91 | $missingExt[] = $extension; |
92 | 92 | } |
93 | 93 | } |
94 | 94 | # print warning if missing |
95 | - if (sizeof($missingExt) > 0) { |
|
96 | - print "<div class='alert alert alert-danger'><strong>"._('The following PHP extensions for API server are missing').":</strong><br><hr>"; |
|
97 | - print '<ul>' . "\n"; |
|
95 | + if (sizeof ($missingExt) > 0) { |
|
96 | + print "<div class='alert alert alert-danger'><strong>"._ ('The following PHP extensions for API server are missing').":</strong><br><hr>"; |
|
97 | + print '<ul>'."\n"; |
|
98 | 98 | foreach ($missingExt as $missing) { |
99 | - print '<li>'. $missing .'</li>' . "\n"; |
|
99 | + print '<li>'.$missing.'</li>'."\n"; |
|
100 | 100 | } |
101 | 101 | print '</ul>'; |
102 | - print _('Please recompile PHP to include missing extensions for API server') . "\n"; |
|
102 | + print _ ('Please recompile PHP to include missing extensions for API server')."\n"; |
|
103 | 103 | print "</div>"; |
104 | 104 | } |
105 | 105 | ?> |
106 | 106 | <hr> |
107 | 107 | |
108 | - <h4><?php print _('API documentation'); ?></h4> |
|
108 | + <h4><?php print _ ('API documentation'); ?></h4> |
|
109 | 109 | <a href="http://phpipam.net/api-documentation/">http://phpipam.net/api-documentation/</a> |
110 | 110 | |
111 | 111 | <?php |
112 | 112 | } else { |
113 | - $Result->show("info", _('Please enable API module under server management'), false); |
|
113 | + $Result->show ("info", _ ('Please enable API module under server management'), false); |
|
114 | 114 | } |
115 | 115 | ?> |
116 | 116 | \ No newline at end of file |
@@ -5,40 +5,40 @@ discard block |
||
5 | 5 | ************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # create csrf token |
21 | 21 | $csrf = $User->csrf_cookie ("create", "device"); |
22 | 22 | |
23 | 23 | # fetch custom fields |
24 | -$custom = $Tools->fetch_custom_fields('devices'); |
|
24 | +$custom = $Tools->fetch_custom_fields ('devices'); |
|
25 | 25 | |
26 | 26 | # ID must be numeric |
27 | -if($_POST['action']!="add" && !is_numeric($_POST['switchId'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
27 | +if ($_POST['action'] != "add" && !is_numeric ($_POST['switchId'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
28 | 28 | |
29 | 29 | # fetch device details |
30 | -if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
|
31 | - $device = (array) $Admin->fetch_object("devices", "id", $_POST['switchId']); |
|
30 | +if (($_POST['action'] == "edit") || ($_POST['action'] == "delete")) { |
|
31 | + $device = (array) $Admin->fetch_object ("devices", "id", $_POST['switchId']); |
|
32 | 32 | // false |
33 | - if ($device===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
33 | + if ($device === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | # set readonly flag |
37 | -$readonly = $_POST['action']=="delete" ? "readonly" : ""; |
|
37 | +$readonly = $_POST['action'] == "delete" ? "readonly" : ""; |
|
38 | 38 | |
39 | 39 | // set show for rack |
40 | -if (is_null($device['rack'])) { $display='display:none'; } |
|
41 | -else { $display=''; } |
|
40 | +if (is_null ($device['rack'])) { $display = 'display:none'; } |
|
41 | +else { $display = ''; } |
|
42 | 42 | ?> |
43 | 43 | |
44 | 44 | <script type="text/javascript"> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | <!-- header --> |
60 | -<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('device'); ?></div> |
|
60 | +<div class="pHeader"><?php print ucwords (_ ("$_POST[action]")); ?> <?php print _ ('device'); ?></div> |
|
61 | 61 | |
62 | 62 | |
63 | 63 | <!-- content --> |
@@ -68,30 +68,30 @@ discard block |
||
68 | 68 | |
69 | 69 | <!-- hostname --> |
70 | 70 | <tr> |
71 | - <td><?php print _('Name'); ?></td> |
|
71 | + <td><?php print _ ('Name'); ?></td> |
|
72 | 72 | <td> |
73 | - <input type="text" name="hostname" class="form-control input-sm" placeholder="<?php print _('Hostname'); ?>" value="<?php if(isset($device['hostname'])) print $device['hostname']; ?>" <?php print $readonly; ?>> |
|
73 | + <input type="text" name="hostname" class="form-control input-sm" placeholder="<?php print _ ('Hostname'); ?>" value="<?php if (isset($device['hostname'])) print $device['hostname']; ?>" <?php print $readonly; ?>> |
|
74 | 74 | </td> |
75 | 75 | </tr> |
76 | 76 | |
77 | 77 | <!-- IP address --> |
78 | 78 | <tr> |
79 | - <td><?php print _('IP address'); ?></td> |
|
79 | + <td><?php print _ ('IP address'); ?></td> |
|
80 | 80 | <td> |
81 | - <input type="text" name="ip_addr" class="form-control input-sm" placeholder="<?php print _('IP address'); ?>" value="<?php if(isset($device['ip_addr'])) print $device['ip_addr']; ?>" <?php print $readonly; ?>> |
|
81 | + <input type="text" name="ip_addr" class="form-control input-sm" placeholder="<?php print _ ('IP address'); ?>" value="<?php if (isset($device['ip_addr'])) print $device['ip_addr']; ?>" <?php print $readonly; ?>> |
|
82 | 82 | </td> |
83 | 83 | </tr> |
84 | 84 | |
85 | 85 | <!-- Type --> |
86 | 86 | <tr> |
87 | - <td><?php print _('Device type'); ?></td> |
|
87 | + <td><?php print _ ('Device type'); ?></td> |
|
88 | 88 | <td> |
89 | 89 | <select name="type" class="form-control input-sm input-w-auto"> |
90 | 90 | <?php |
91 | - $types = $Admin->fetch_all_objects("deviceTypes", "tid"); |
|
92 | - foreach($types as $name) { |
|
93 | - if($device['type'] == $name->tid) { print "<option value='$name->tid' selected='selected'>$name->tname</option>"; } |
|
94 | - else { print "<option value='$name->tid' >$name->tname</option>"; } |
|
91 | + $types = $Admin->fetch_all_objects ("deviceTypes", "tid"); |
|
92 | + foreach ($types as $name) { |
|
93 | + if ($device['type'] == $name->tid) { print "<option value='$name->tid' selected='selected'>$name->tname</option>"; } |
|
94 | + else { print "<option value='$name->tid' >$name->tname</option>"; } |
|
95 | 95 | } |
96 | 96 | ?> |
97 | 97 | </select> |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | </tr> |
100 | 100 | |
101 | 101 | <!-- Rack --> |
102 | - <?php if($User->settings->enableRACK=="1") { ?> |
|
102 | + <?php if ($User->settings->enableRACK == "1") { ?> |
|
103 | 103 | <tr> |
104 | 104 | <td colspan="2"><hr></td> |
105 | 105 | </tr> |
106 | 106 | <tr> |
107 | 107 | <?php |
108 | 108 | $Racks = new phpipam_rack ($Database); |
109 | - $Racks->fetch_all_racks(); |
|
109 | + $Racks->fetch_all_racks (); |
|
110 | 110 | ?> |
111 | - <td><?php print _('Rack'); ?></td> |
|
111 | + <td><?php print _ ('Rack'); ?></td> |
|
112 | 112 | <td> |
113 | 113 | <select name="rack" class="form-control"> |
114 | - <option value=""><?php print _("None"); ?></option> |
|
114 | + <option value=""><?php print _ ("None"); ?></option> |
|
115 | 115 | <?php |
116 | 116 | foreach ($Racks->all_racks as $r) { |
117 | - if($device['rack'] == $r->id) { print "<option value='$r->id' selected='selected'>$r->name</option>"; } |
|
118 | - else { print "<option value='$r->id' >$r->name</option>"; } |
|
117 | + if ($device['rack'] == $r->id) { print "<option value='$r->id' selected='selected'>$r->name</option>"; } |
|
118 | + else { print "<option value='$r->id' >$r->name</option>"; } |
|
119 | 119 | } |
120 | 120 | ?> |
121 | 121 | </select> |
@@ -124,16 +124,16 @@ discard block |
||
124 | 124 | |
125 | 125 | <tbody id="rack" style="<?php print $display; ?>"> |
126 | 126 | <tr> |
127 | - <td><?php print _('Start position'); ?></td> |
|
127 | + <td><?php print _ ('Start position'); ?></td> |
|
128 | 128 | <td> |
129 | 129 | <div class="input-group" style="width:100px;"> |
130 | 130 | <input type="text" name="rack_start" size="2" class="form-control input-w-auto input-sm" placeholder="1" value="<?php print @$device['rack_start']; ?>"> |
131 | - <a href="" class="input-group-addon showRackPopup" rel='tooltip' data-placement='right' data-rackid="<?php print @$device['rack']; ?>" data-deviceid='<?php print @$device['id']; ?>' title='<?php print _("Show rack"); ?>'><i class='fa fa-server'></i></a> |
|
131 | + <a href="" class="input-group-addon showRackPopup" rel='tooltip' data-placement='right' data-rackid="<?php print @$device['rack']; ?>" data-deviceid='<?php print @$device['id']; ?>' title='<?php print _ ("Show rack"); ?>'><i class='fa fa-server'></i></a> |
|
132 | 132 | </div> |
133 | 133 | </td> |
134 | 134 | </tr> |
135 | 135 | <tr> |
136 | - <td><?php print _('Size'); ?> (U)</td> |
|
136 | + <td><?php print _ ('Size'); ?> (U)</td> |
|
137 | 137 | <td> |
138 | 138 | <input type="text" name="rack_size" size="2" class="form-control input-w-auto input-sm" style="width:100px;" placeholder="1" value="<?php print @$device['rack_size']; ?>"> |
139 | 139 | </td> |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | |
147 | 147 | <!-- Version --> |
148 | 148 | <tr> |
149 | - <td><?php print _('SW version'); ?></td> |
|
149 | + <td><?php print _ ('SW version'); ?></td> |
|
150 | 150 | <td> |
151 | - <input type="text" name="version" class="form-control input-sm" placeholder="<?php print _('Software version'); ?>" value="<?php if(isset($device['version'])) print $device['version']; ?>" <?php print $readonly; ?>> |
|
151 | + <input type="text" name="version" class="form-control input-sm" placeholder="<?php print _ ('Software version'); ?>" value="<?php if (isset($device['version'])) print $device['version']; ?>" <?php print $readonly; ?>> |
|
152 | 152 | </td> |
153 | 153 | </tr> |
154 | 154 | |
155 | 155 | <!-- Description --> |
156 | 156 | <tr> |
157 | - <td><?php print _('Description'); ?></td> |
|
157 | + <td><?php print _ ('Description'); ?></td> |
|
158 | 158 | <td> |
159 | - <textarea name="description" class="form-control input-sm" placeholder="<?php print _('Description'); ?>" <?php print $readonly; ?>><?php if(isset($device['description'])) print $device['description']; ?></textarea> |
|
159 | + <textarea name="description" class="form-control input-sm" placeholder="<?php print _ ('Description'); ?>" <?php print $readonly; ?>><?php if (isset($device['description'])) print $device['description']; ?></textarea> |
|
160 | 160 | <?php |
161 | - if( ($_POST['action'] == "edit") || ($_POST['action'] == "delete") ) { |
|
162 | - print '<input type="hidden" name="switchId" value="'. $_POST['switchId'] .'">'. "\n"; |
|
161 | + if (($_POST['action'] == "edit") || ($_POST['action'] == "delete")) { |
|
162 | + print '<input type="hidden" name="switchId" value="'.$_POST['switchId'].'">'."\n"; |
|
163 | 163 | } ?> |
164 | 164 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
165 | 165 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | <!-- Custom --> |
170 | 170 | <?php |
171 | - if(sizeof($custom) > 0) { |
|
171 | + if (sizeof ($custom) > 0) { |
|
172 | 172 | |
173 | 173 | print '<tr>'; |
174 | 174 | print ' <td colspan="2"><hr></td>'; |
@@ -178,39 +178,39 @@ discard block |
||
178 | 178 | $timeP = 0; |
179 | 179 | |
180 | 180 | # all my fields |
181 | - foreach($custom as $field) { |
|
181 | + foreach ($custom as $field) { |
|
182 | 182 | # replace spaces with | |
183 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
183 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
184 | 184 | |
185 | 185 | # required |
186 | - if($field['Null']=="NO") { $required = "*"; } |
|
187 | - else { $required = ""; } |
|
186 | + if ($field['Null'] == "NO") { $required = "*"; } |
|
187 | + else { $required = ""; } |
|
188 | 188 | |
189 | 189 | # set default value ! |
190 | - if ($_POST['action']=="add") { $device[$field['name']] = $field['Default']; } |
|
190 | + if ($_POST['action'] == "add") { $device[$field['name']] = $field['Default']; } |
|
191 | 191 | |
192 | - print '<tr>'. "\n"; |
|
193 | - print ' <td>'. ucwords($field['name']) .' '.$required.'</td>'. "\n"; |
|
194 | - print ' <td>'. "\n"; |
|
192 | + print '<tr>'."\n"; |
|
193 | + print ' <td>'.ucwords ($field['name']).' '.$required.'</td>'."\n"; |
|
194 | + print ' <td>'."\n"; |
|
195 | 195 | |
196 | 196 | //set type |
197 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
197 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
198 | 198 | //parse values |
199 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
199 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
200 | 200 | //null |
201 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
201 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
202 | 202 | |
203 | 203 | print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
204 | - foreach($tmp as $v) { |
|
205 | - if($v==$device[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
206 | - else { print "<option value='$v'>$v</option>"; } |
|
204 | + foreach ($tmp as $v) { |
|
205 | + if ($v == $device[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
206 | + else { print "<option value='$v'>$v</option>"; } |
|
207 | 207 | } |
208 | 208 | print "</select>"; |
209 | 209 | } |
210 | 210 | //date and time picker |
211 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
211 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
212 | 212 | // just for first |
213 | - if($timeP==0) { |
|
213 | + if ($timeP == 0) { |
|
214 | 214 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
215 | 215 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
216 | 216 | print '<script type="text/javascript">'; |
@@ -226,38 +226,38 @@ discard block |
||
226 | 226 | $timeP++; |
227 | 227 | |
228 | 228 | //set size |
229 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
230 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
229 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
230 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
231 | 231 | |
232 | 232 | //field |
233 | - if(!isset($device[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
234 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $device[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
233 | + if (!isset($device[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
234 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" value="'.$device[$field['name']].'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
235 | 235 | } |
236 | 236 | //boolean |
237 | - elseif($field['type'] == "tinyint(1)") { |
|
237 | + elseif ($field['type'] == "tinyint(1)") { |
|
238 | 238 | print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
239 | - $tmp = array(0=>"No",1=>"Yes"); |
|
239 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
240 | 240 | //null |
241 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
241 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
242 | 242 | |
243 | - foreach($tmp as $k=>$v) { |
|
244 | - if(strlen($device[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
245 | - elseif($k==$device[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
246 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
243 | + foreach ($tmp as $k=>$v) { |
|
244 | + if (strlen ($device[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
245 | + elseif ($k == $device[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
246 | + else { print "<option value='$k'>"._ ($v)."</option>"; } |
|
247 | 247 | } |
248 | 248 | print "</select>"; |
249 | 249 | } |
250 | 250 | //text |
251 | - elseif($field['type'] == "text") { |
|
252 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $device[$field['name']]. '</textarea>'. "\n"; |
|
251 | + elseif ($field['type'] == "text") { |
|
252 | + print ' <textarea class="form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'.$device[$field['name']].'</textarea>'."\n"; |
|
253 | 253 | } |
254 | 254 | //default - input field |
255 | 255 | else { |
256 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $device[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
256 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" value="'.$device[$field['name']].'" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; |
|
257 | 257 | } |
258 | 258 | |
259 | - print ' </td>'. "\n"; |
|
260 | - print '</tr>'. "\n"; |
|
259 | + print ' </td>'."\n"; |
|
260 | + print '</tr>'."\n"; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | </td> |
272 | 272 | </tr> |
273 | 273 | <tr> |
274 | - <td colspan="2"><?php print _('Sections to display device in'); ?>:</td> |
|
274 | + <td colspan="2"><?php print _ ('Sections to display device in'); ?>:</td> |
|
275 | 275 | </tr> |
276 | 276 | <tr> |
277 | 277 | <td></td> |
@@ -279,16 +279,16 @@ discard block |
||
279 | 279 | <?php |
280 | 280 | # select sections |
281 | 281 | $Sections = new Sections ($Database); |
282 | - $sections = $Sections->fetch_all_sections(); |
|
282 | + $sections = $Sections->fetch_all_sections (); |
|
283 | 283 | |
284 | 284 | # reformat device sections to array |
285 | - $deviceSections = explode(";", $device['sections']); |
|
286 | - $deviceSections = is_array($deviceSections) ? $deviceSections : array(); |
|
285 | + $deviceSections = explode (";", $device['sections']); |
|
286 | + $deviceSections = is_array ($deviceSections) ? $deviceSections : array (); |
|
287 | 287 | |
288 | - if ($sections!==false) { |
|
289 | - foreach($sections as $section) { |
|
290 | - if(in_array($section->id, $deviceSections)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
291 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
288 | + if ($sections !== false) { |
|
289 | + foreach ($sections as $section) { |
|
290 | + if (in_array ($section->id, $deviceSections)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'.$section->id.'" value="on" checked> '.$section->name.'</div>'."\n"; } |
|
291 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'.$section->id.'" value="on">'.$section->name.'</span></div>'."\n"; } |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | ?> |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | <!-- footer --> |
303 | 303 | <div class="pFooter"> |
304 | 304 | <div class="btn-group"> |
305 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
306 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editSwitchsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
305 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
306 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editSwitchsubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
307 | 307 | </div> |
308 | 308 | |
309 | 309 | <!-- result --> |
@@ -5,72 +5,72 @@ discard block |
||
5 | 5 | ***************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | -$Racks = new phpipam_rack ($Database); |
|
15 | +$Racks = new phpipam_rack ($Database); |
|
16 | 16 | $Result = new Result (); |
17 | 17 | |
18 | 18 | # verify that user is logged in |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # validate csrf cookie |
22 | -$User->csrf_cookie ("validate", "device", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
22 | +$User->csrf_cookie ("validate", "device", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
23 | 23 | |
24 | 24 | # get modified details |
25 | -$device = $Admin->strip_input_tags($_POST); |
|
25 | +$device = $Admin->strip_input_tags ($_POST); |
|
26 | 26 | |
27 | 27 | # ID must be numeric |
28 | -if($_POST['action']!="add" && !is_numeric($_POST['switchId'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
28 | +if ($_POST['action'] != "add" && !is_numeric ($_POST['switchId'])) { $Result->show ("danger", _ ("Invalid ID"), true); } |
|
29 | 29 | |
30 | 30 | # available devices set |
31 | -foreach($device as $key=>$line) { |
|
32 | - if (strlen(strstr($key,"section-"))>0) { |
|
33 | - $key2 = str_replace("section-", "", $key); |
|
31 | +foreach ($device as $key=>$line) { |
|
32 | + if (strlen (strstr ($key, "section-")) > 0) { |
|
33 | + $key2 = str_replace ("section-", "", $key); |
|
34 | 34 | $temp[] = $key2; |
35 | 35 | |
36 | 36 | unset($device[$key]); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | # glue sections together |
40 | -$device['sections'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
40 | +$device['sections'] = sizeof ($temp) > 0 ? implode (";", $temp) : null; |
|
41 | 41 | |
42 | 42 | # Hostname must be present |
43 | -if($device['hostname'] == "") { $Result->show("danger", _('Hostname is mandatory').'!', true); } |
|
43 | +if ($device['hostname'] == "") { $Result->show ("danger", _ ('Hostname is mandatory').'!', true); } |
|
44 | 44 | |
45 | 45 | # rack checks |
46 | -if (strlen(@$device['rack']>0)) { |
|
47 | - if ($User->settings->enableRACK!="1") { |
|
46 | +if (strlen (@$device['rack'] > 0)) { |
|
47 | + if ($User->settings->enableRACK != "1") { |
|
48 | 48 | unset($device['rack']); |
49 | 49 | } |
50 | 50 | else { |
51 | 51 | # validate position and size |
52 | - if (!is_numeric($device['rack'])) { $Result->show("danger", _('Invalid rack identifier').'!', true); } |
|
53 | - if (!is_numeric($device['rack_start'])) { $Result->show("danger", _('Invalid rack start position').'!', true); } |
|
54 | - if (!is_numeric($device['rack_size'])) { $Result->show("danger", _('Invalid rack size').'!', true); } |
|
52 | + if (!is_numeric ($device['rack'])) { $Result->show ("danger", _ ('Invalid rack identifier').'!', true); } |
|
53 | + if (!is_numeric ($device['rack_start'])) { $Result->show ("danger", _ ('Invalid rack start position').'!', true); } |
|
54 | + if (!is_numeric ($device['rack_size'])) { $Result->show ("danger", _ ('Invalid rack size').'!', true); } |
|
55 | 55 | # validate rack |
56 | 56 | $rack = $Racks->fetch_rack_details ($device['rack']); |
57 | - if ($rack===false) { $Result->show("danger", _('Rack does not exist').'!', true); } |
|
57 | + if ($rack === false) { $Result->show ("danger", _ ('Rack does not exist').'!', true); } |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | # fetch custom fields |
62 | -$custom = $Tools->fetch_custom_fields('devices'); |
|
63 | -if(sizeof($custom) > 0) { |
|
64 | - foreach($custom as $myField) { |
|
62 | +$custom = $Tools->fetch_custom_fields ('devices'); |
|
63 | +if (sizeof ($custom) > 0) { |
|
64 | + foreach ($custom as $myField) { |
|
65 | 65 | //booleans can be only 0 and 1! |
66 | - if($myField['type']=="tinyint(1)") { |
|
67 | - if($device[$myField['name']]>1) { |
|
66 | + if ($myField['type'] == "tinyint(1)") { |
|
67 | + if ($device[$myField['name']] > 1) { |
|
68 | 68 | $device[$myField['name']] = 0; |
69 | 69 | } |
70 | 70 | } |
71 | 71 | //not null! |
72 | - if($myField['Null']=="NO" && strlen($device[$myField['name']])==0) { |
|
73 | - { $Result->show("danger", $myField['name'].'" can not be empty!', true); } |
|
72 | + if ($myField['Null'] == "NO" && strlen ($device[$myField['name']]) == 0) { |
|
73 | + { $Result->show ("danger", $myField['name'].'" can not be empty!', true); } |
|
74 | 74 | } |
75 | 75 | # save to update array |
76 | 76 | $update[$myField['name']] = $device[$myField['name']]; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | # set update values |
81 | -$values = array("id"=>@$device['switchId'], |
|
81 | +$values = array ("id"=>@$device['switchId'], |
|
82 | 82 | "hostname"=>@$device['hostname'], |
83 | 83 | "ip_addr"=>@$device['ip_addr'], |
84 | 84 | "type"=>@$device['type'], |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | "sections"=>@$device['sections'] |
87 | 87 | ); |
88 | 88 | # custom fields |
89 | -if(isset($update)) { |
|
90 | - $values = array_merge($values, $update); |
|
89 | +if (isset($update)) { |
|
90 | + $values = array_merge ($values, $update); |
|
91 | 91 | } |
92 | 92 | # rack |
93 | -if (strlen(@$device['rack']>0)) { |
|
93 | +if (strlen (@$device['rack'] > 0)) { |
|
94 | 94 | $values['rack'] = $device['rack']; |
95 | 95 | $values['rack_start'] = $device['rack_start']; |
96 | 96 | $values['rack_size'] = $device['rack_size']; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | # update device |
101 | -if(!$Admin->object_modify("devices", $_POST['action'], "id", $values)) {} |
|
102 | -else { $Result->show("success", _("Device $device[action] successfull").'!', false); } |
|
101 | +if (!$Admin->object_modify ("devices", $_POST['action'], "id", $values)) {} |
|
102 | +else { $Result->show ("success", _ ("Device $device[action] successfull").'!', false); } |
|
103 | 103 | |
104 | -if($_POST['action']=="delete"){ |
|
104 | +if ($_POST['action'] == "delete") { |
|
105 | 105 | # remove all references from subnets and ip addresses |
106 | 106 | $Admin->remove_object_references ("subnets", "device", $values["id"]); |
107 | 107 | $Admin->remove_object_references ("ipaddresses", "switch", $values["id"]); |
@@ -5,16 +5,16 @@ discard block |
||
5 | 5 | ***************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # rack object |
11 | -$Racks = new phpipam_rack ($Database); |
|
11 | +$Racks = new phpipam_rack ($Database); |
|
12 | 12 | |
13 | 13 | # fetch all Devices |
14 | -$devices = $Admin->fetch_all_objects("devices", "hostname"); |
|
14 | +$devices = $Admin->fetch_all_objects ("devices", "hostname"); |
|
15 | 15 | |
16 | 16 | # fetch all Device types and reindex |
17 | -$device_types = $Admin->fetch_all_objects("deviceTypes", "tid"); |
|
17 | +$device_types = $Admin->fetch_all_objects ("deviceTypes", "tid"); |
|
18 | 18 | if ($device_types !== false) { |
19 | 19 | foreach ($device_types as $dt) { |
20 | 20 | $device_types_i[$dt->tid] = $dt; |
@@ -22,24 +22,24 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | # fetch custom fields |
25 | -$custom = $Tools->fetch_custom_fields('devices'); |
|
25 | +$custom = $Tools->fetch_custom_fields ('devices'); |
|
26 | 26 | |
27 | 27 | # get hidden fields |
28 | -$hidden_custom_fields = json_decode($User->settings->hiddenCustomFields, true); |
|
29 | -$hidden_custom_fields = is_array(@$hidden_custom_fields['devices']) ? $hidden_custom_fields['devices'] : array(); |
|
28 | +$hidden_custom_fields = json_decode ($User->settings->hiddenCustomFields, true); |
|
29 | +$hidden_custom_fields = is_array (@$hidden_custom_fields['devices']) ? $hidden_custom_fields['devices'] : array (); |
|
30 | 30 | ?> |
31 | 31 | |
32 | -<h4><?php print _('Device management'); ?></h4> |
|
32 | +<h4><?php print _ ('Device management'); ?></h4> |
|
33 | 33 | <hr> |
34 | 34 | <div class="btn-group"> |
35 | - <button class='btn btn-sm btn-default editSwitch' data-action='add' data-switchid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _('Add device'); ?></button> |
|
36 | - <a href="<?php print create_link("administration", "device-types"); ?>" class="btn btn-sm btn-default"><i class="fa fa-tablet"></i> <?php print _('Manage device types'); ?></a> |
|
35 | + <button class='btn btn-sm btn-default editSwitch' data-action='add' data-switchid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _ ('Add device'); ?></button> |
|
36 | + <a href="<?php print create_link ("administration", "device-types"); ?>" class="btn btn-sm btn-default"><i class="fa fa-tablet"></i> <?php print _ ('Manage device types'); ?></a> |
|
37 | 37 | </div> |
38 | 38 | |
39 | 39 | <?php |
40 | 40 | /* first check if they exist! */ |
41 | -if($devices===false) { |
|
42 | - $Result->show("warn alert-absolute", _('No devices configured').'!', false); |
|
41 | +if ($devices === false) { |
|
42 | + $Result->show ("warn alert-absolute", _ ('No devices configured').'!', false); |
|
43 | 43 | } |
44 | 44 | /* Print them out */ |
45 | 45 | else { |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | # headers |
50 | 50 | print "<thead>"; |
51 | 51 | print '<tr>'; |
52 | - print ' <th>'._('Name').'</th>'; |
|
53 | - print ' <th>'._('IP address').'</th>'; |
|
54 | - print ' <th>'._('Type').'</th>'; |
|
55 | - print ' <th>'._('Description').'</th>'; |
|
56 | - if($User->settings->enableSNMP=="1") |
|
57 | - print ' <th>'._('SNMP').'</th>'; |
|
58 | - if($User->settings->enableRACK=="1") |
|
59 | - print ' <th>'._('Rack').'</th>'; |
|
60 | - print ' <th><i class="icon-gray icon-info-sign" rel="tooltip" title="'._('Shows in which sections device will be visible for selection').'"></i> '._('Sections').'</th>'; |
|
61 | - if(sizeof($custom) > 0) { |
|
62 | - foreach($custom as $field) { |
|
63 | - if(!in_array($field['name'], $hidden_custom_fields)) { |
|
52 | + print ' <th>'._ ('Name').'</th>'; |
|
53 | + print ' <th>'._ ('IP address').'</th>'; |
|
54 | + print ' <th>'._ ('Type').'</th>'; |
|
55 | + print ' <th>'._ ('Description').'</th>'; |
|
56 | + if ($User->settings->enableSNMP == "1") |
|
57 | + print ' <th>'._ ('SNMP').'</th>'; |
|
58 | + if ($User->settings->enableRACK == "1") |
|
59 | + print ' <th>'._ ('Rack').'</th>'; |
|
60 | + print ' <th><i class="icon-gray icon-info-sign" rel="tooltip" title="'._ ('Shows in which sections device will be visible for selection').'"></i> '._ ('Sections').'</th>'; |
|
61 | + if (sizeof ($custom) > 0) { |
|
62 | + foreach ($custom as $field) { |
|
63 | + if (!in_array ($field['name'], $hidden_custom_fields)) { |
|
64 | 64 | print "<th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>"; |
65 | 65 | } |
66 | 66 | } |
@@ -76,71 +76,71 @@ discard block |
||
76 | 76 | $device = (array) $device; |
77 | 77 | |
78 | 78 | //print details |
79 | - print '<tr>'. "\n"; |
|
79 | + print '<tr>'."\n"; |
|
80 | 80 | |
81 | - print ' <td><a href="'.create_link("tools","devices","hosts",$device['id']).'">'. $device['hostname'] .'</a></td>'. "\n"; |
|
82 | - print ' <td>'. $device['ip_addr'] .'</td>'. "\n"; |
|
83 | - print ' <td>'. @$device_types_i[$device['type']]->tname .'</td>'. "\n"; |
|
84 | - print ' <td class="description">'. $device['description'] .'</td>'. "\n"; |
|
81 | + print ' <td><a href="'.create_link ("tools", "devices", "hosts", $device['id']).'">'.$device['hostname'].'</a></td>'."\n"; |
|
82 | + print ' <td>'.$device['ip_addr'].'</td>'."\n"; |
|
83 | + print ' <td>'.@$device_types_i[$device['type']]->tname.'</td>'."\n"; |
|
84 | + print ' <td class="description">'.$device['description'].'</td>'."\n"; |
|
85 | 85 | |
86 | 86 | // SNMP |
87 | - if($User->settings->enableSNMP=="1") { |
|
87 | + if ($User->settings->enableSNMP == "1") { |
|
88 | 88 | print "<td>"; |
89 | 89 | // not set |
90 | - if ($device['snmp_version']==0 || strlen($device['snmp_version'])==0) { |
|
91 | - print "<span class='text-muted'>"._("Disabled")."</span>"; |
|
90 | + if ($device['snmp_version'] == 0 || strlen ($device['snmp_version']) == 0) { |
|
91 | + print "<span class='text-muted'>"._ ("Disabled")."</span>"; |
|
92 | 92 | } |
93 | 93 | else { |
94 | - print _("Version").": $device[snmp_version]<br>"; |
|
95 | - print _("Community").": $device[snmp_community]<br>"; |
|
94 | + print _ ("Version").": $device[snmp_version]<br>"; |
|
95 | + print _ ("Community").": $device[snmp_community]<br>"; |
|
96 | 96 | } |
97 | 97 | print "</td>"; |
98 | 98 | } |
99 | 99 | |
100 | 100 | // rack |
101 | - if($User->settings->enableRACK=="1") { |
|
101 | + if ($User->settings->enableRACK == "1") { |
|
102 | 102 | print "<td>"; |
103 | 103 | # rack |
104 | 104 | $rack = $Racks->fetch_rack_details ($device['rack']); |
105 | - if ($rack!==false) { |
|
106 | - print "<a href='".create_link("administration", "racks", $rack->id)."'>".$rack->name."</a><br>"; |
|
107 | - print "<span class='badge badge1 badge5'>"._('Position').": $device[rack_start], "._("Size").": $device[rack_size] U</span>"; |
|
105 | + if ($rack !== false) { |
|
106 | + print "<a href='".create_link ("administration", "racks", $rack->id)."'>".$rack->name."</a><br>"; |
|
107 | + print "<span class='badge badge1 badge5'>"._ ('Position').": $device[rack_start], "._ ("Size").": $device[rack_size] U</span>"; |
|
108 | 108 | } |
109 | 109 | print "</td>"; |
110 | 110 | } |
111 | 111 | |
112 | 112 | //sections |
113 | 113 | print ' <td class="sections">'; |
114 | - $temp = explode(";",$device['sections']); |
|
115 | - if( (sizeof($temp) > 0) && (!empty($temp[0])) ) { |
|
116 | - foreach($temp as $line) { |
|
117 | - $section = $Sections->fetch_section(null, $line); |
|
118 | - if(!empty($section)) { |
|
119 | - print '<div class="switchSections text-muted">'. $section->name .'</div>'. "\n"; |
|
114 | + $temp = explode (";", $device['sections']); |
|
115 | + if ((sizeof ($temp) > 0) && (!empty($temp[0]))) { |
|
116 | + foreach ($temp as $line) { |
|
117 | + $section = $Sections->fetch_section (null, $line); |
|
118 | + if (!empty($section)) { |
|
119 | + print '<div class="switchSections text-muted">'.$section->name.'</div>'."\n"; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - print ' </td>'. "\n"; |
|
124 | + print ' </td>'."\n"; |
|
125 | 125 | |
126 | 126 | //custom |
127 | - if(sizeof($custom) > 0) { |
|
128 | - foreach($custom as $field) { |
|
129 | - if(!in_array($field['name'], $hidden_custom_fields)) { |
|
127 | + if (sizeof ($custom) > 0) { |
|
128 | + foreach ($custom as $field) { |
|
129 | + if (!in_array ($field['name'], $hidden_custom_fields)) { |
|
130 | 130 | print "<td class='hidden-xs hidden-sm hidden-md'>"; |
131 | 131 | |
132 | 132 | // create links |
133 | 133 | $device[$field['name']] = $Result->create_links ($device[$field['name']], $field['type']); |
134 | 134 | |
135 | 135 | //booleans |
136 | - if($field['type']=="tinyint(1)") { |
|
137 | - if($device[$field['name']] == "0") { print _("No"); } |
|
138 | - elseif($device[$field['name']] == "1") { print _("Yes"); } |
|
136 | + if ($field['type'] == "tinyint(1)") { |
|
137 | + if ($device[$field['name']] == "0") { print _ ("No"); } |
|
138 | + elseif ($device[$field['name']] == "1") { print _ ("Yes"); } |
|
139 | 139 | } |
140 | 140 | //text |
141 | - elseif($field['type']=="text") { |
|
142 | - if(strlen($device[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $device[$field['name']])."'>"; } |
|
143 | - else { print ""; } |
|
141 | + elseif ($field['type'] == "text") { |
|
142 | + if (strlen ($device[$field['name']]) > 0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace ("\n", "<br>", $device[$field['name']])."'>"; } |
|
143 | + else { print ""; } |
|
144 | 144 | } |
145 | 145 | else { |
146 | 146 | print $device[$field['name']]; |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - print ' <td class="actions">'. "\n"; |
|
154 | + print ' <td class="actions">'."\n"; |
|
155 | 155 | print " <div class='btn-group'>"; |
156 | 156 | print " <button class='btn btn-xs btn-default editSwitch' data-action='edit' data-switchid='$device[id]'><i class='fa fa-pencil'></i></button>"; |
157 | - if($User->settings->enableSNMP=="1") |
|
157 | + if ($User->settings->enableSNMP == "1") |
|
158 | 158 | print " <button class='btn btn-xs btn-default editSwitchSNMP' data-action='edit' data-switchid='$device[id]'><i class='fa fa-cogs'></i></button>"; |
159 | 159 | print " <button class='btn btn-xs btn-default editSwitch' data-action='delete' data-switchid='$device[id]'><i class='fa fa-times'></i></button>"; |
160 | 160 | print " </div>"; |
161 | - print ' </td>'. "\n"; |
|
161 | + print ' </td>'."\n"; |
|
162 | 162 | |
163 | - print '</tr>'. "\n"; |
|
163 | + print '</tr>'."\n"; |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | print "</tbody>"; |
@@ -5,54 +5,54 @@ discard block |
||
5 | 5 | ***************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # validate csrf cookie |
20 | -$User->csrf_cookie ("validate", "device_snmp", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
20 | +$User->csrf_cookie ("validate", "device_snmp", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
21 | 21 | |
22 | 22 | # get modified details |
23 | -$device = $Admin->strip_input_tags($_POST); |
|
23 | +$device = $Admin->strip_input_tags ($_POST); |
|
24 | 24 | |
25 | 25 | # ID, port snd community must be numeric |
26 | -if(!is_numeric($_POST['device_id'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
27 | -if(!is_numeric($_POST['snmp_version'])) { $Result->show("danger", _("Invalid version"), true); } |
|
28 | -if($_POST['snmp_version']!=0) { |
|
29 | -if(!is_numeric($_POST['snmp_port'])) { $Result->show("danger", _("Invalid port"), true); } |
|
30 | -if(!is_numeric($_POST['snmp_timeout'])) { $Result->show("danger", _("Invalid timeout"), true); } |
|
26 | +if (!is_numeric ($_POST['device_id'])) { $Result->show ("danger", _ ("Invalid ID"), true); } |
|
27 | +if (!is_numeric ($_POST['snmp_version'])) { $Result->show ("danger", _ ("Invalid version"), true); } |
|
28 | +if ($_POST['snmp_version'] != 0) { |
|
29 | +if (!is_numeric ($_POST['snmp_port'])) { $Result->show ("danger", _ ("Invalid port"), true); } |
|
30 | +if (!is_numeric ($_POST['snmp_timeout'])) { $Result->show ("danger", _ ("Invalid timeout"), true); } |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | # version can be 0, 1 or 2 |
34 | -if ($_POST['snmp_version']<0 || $_POST['snmp_version']>3) { $Result->show("danger", _("Invalid version"), true); } |
|
34 | +if ($_POST['snmp_version'] < 0 || $_POST['snmp_version'] > 3) { $Result->show ("danger", _ ("Invalid version"), true); } |
|
35 | 35 | |
36 | 36 | # validate device |
37 | 37 | $device = $Admin->fetch_object ("devices", "id", $_POST['device_id']); |
38 | -if($device===false) { $Result->show("danger", _("Invalid device"), true); } |
|
38 | +if ($device === false) { $Result->show ("danger", _ ("Invalid device"), true); } |
|
39 | 39 | |
40 | 40 | # validate device ip |
41 | -if ($Admin->validate_ip($device->ip_addr)===false) { $Result->show("danger", _("Invalid device IP address"), true); } |
|
41 | +if ($Admin->validate_ip ($device->ip_addr) === false) { $Result->show ("danger", _ ("Invalid device IP address"), true); } |
|
42 | 42 | |
43 | 43 | # set snmp queries |
44 | -foreach($_POST as $key=>$line) { |
|
45 | - if (strlen(strstr($key,"query-"))>0) { |
|
46 | - $key2 = str_replace("query-", "", $key); |
|
44 | +foreach ($_POST as $key=>$line) { |
|
45 | + if (strlen (strstr ($key, "query-")) > 0) { |
|
46 | + $key2 = str_replace ("query-", "", $key); |
|
47 | 47 | $temp[] = $key2; |
48 | 48 | unset($_POST[$key]); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | # glue sections together |
52 | -$_POST['snmp_queries'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
52 | +$_POST['snmp_queries'] = sizeof ($temp) > 0 ? implode (";", $temp) : null; |
|
53 | 53 | |
54 | 54 | # set update values |
55 | -$values = array("id"=>$_POST['device_id'], |
|
55 | +$values = array ("id"=>$_POST['device_id'], |
|
56 | 56 | "snmp_version"=>$_POST['snmp_version'], |
57 | 57 | "snmp_community"=>$_POST['snmp_community'], |
58 | 58 | "snmp_port"=>$_POST['snmp_port'], |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ); |
62 | 62 | |
63 | 63 | # update device |
64 | -if(!$Admin->object_modify("devices", "edit", "id", $values)) { $Result->show("danger", _("SNMP edit failed").'!', false); } |
|
65 | -else { $Result->show("success", _("SNMP edit successfull").'!', false); } |
|
64 | +if (!$Admin->object_modify ("devices", "edit", "id", $values)) { $Result->show ("danger", _ ("SNMP edit failed").'!', false); } |
|
65 | +else { $Result->show ("success", _ ("SNMP edit successfull").'!', false); } |
|
66 | 66 | |
67 | 67 | ?> |
@@ -5,38 +5,38 @@ discard block |
||
5 | 5 | ************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | -$Snmp = new phpipamSNMP (); |
|
15 | +$Snmp = new phpipamSNMP (); |
|
16 | 16 | $Result = new Result (); |
17 | 17 | |
18 | 18 | # verify that user is logged in |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # create csrf token |
22 | 22 | $csrf = $User->csrf_cookie ("create", "device_snmp"); |
23 | 23 | |
24 | 24 | # fetch custom fields |
25 | -$custom = $Tools->fetch_custom_fields('devices'); |
|
25 | +$custom = $Tools->fetch_custom_fields ('devices'); |
|
26 | 26 | |
27 | 27 | # ID must be numeric |
28 | -if(!is_numeric($_POST['switchId'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
28 | +if (!is_numeric ($_POST['switchId'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
29 | 29 | |
30 | 30 | # fetch device details |
31 | -$device = $Admin->fetch_object("devices", "id", $_POST['switchId']); |
|
32 | -if ($device===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
31 | +$device = $Admin->fetch_object ("devices", "id", $_POST['switchId']); |
|
32 | +if ($device === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
33 | 33 | |
34 | 34 | // set show |
35 | -if ($device->snmp_version=="1" || $device->snmp_version=="2") { $display=''; } |
|
36 | -else { $display='display:none'; } |
|
35 | +if ($device->snmp_version == "1" || $device->snmp_version == "2") { $display = ''; } |
|
36 | +else { $display = 'display:none'; } |
|
37 | 37 | |
38 | 38 | // default values |
39 | -if (strlen($device->snmp_timeout)==0) { $device->snmp_timeout = 1000000; } |
|
39 | +if (strlen ($device->snmp_timeout) == 0) { $device->snmp_timeout = 1000000; } |
|
40 | 40 | ?> |
41 | 41 | |
42 | 42 | <script type="text/javascript"> |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | |
54 | 54 | <!-- header --> |
55 | -<div class="pHeader"><?php print _("Edit"); ?> <?php print _('device'); ?> SNMP</div> |
|
55 | +<div class="pHeader"><?php print _ ("Edit"); ?> <?php print _ ('device'); ?> SNMP</div> |
|
56 | 56 | |
57 | 57 | |
58 | 58 | <!-- content --> |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | |
73 | 73 | <!-- version --> |
74 | 74 | <tr> |
75 | - <td><?php print _('Version'); ?></td> |
|
75 | + <td><?php print _ ('Version'); ?></td> |
|
76 | 76 | <td> |
77 | 77 | <select class="form-control" name="snmp_version"> |
78 | - <option value="0"><?php print _("Not used"); ?></option> |
|
79 | - <option value="1" <?php if($device->snmp_version=="1") print "selected"; ?>>SNMP v1</option> |
|
80 | - <option value="2" <?php if($device->snmp_version=="2") print "selected"; ?>>SNMP v2c</option> |
|
81 | - <option value="3" <?php if($device->snmp_version=="3") print "selected"; ?>>SNMP v3</option> |
|
78 | + <option value="0"><?php print _ ("Not used"); ?></option> |
|
79 | + <option value="1" <?php if ($device->snmp_version == "1") print "selected"; ?>>SNMP v1</option> |
|
80 | + <option value="2" <?php if ($device->snmp_version == "2") print "selected"; ?>>SNMP v2c</option> |
|
81 | + <option value="3" <?php if ($device->snmp_version == "3") print "selected"; ?>>SNMP v3</option> |
|
82 | 82 | </select> |
83 | 83 | <input type="hidden" name="device_id" value="<?php print $device->id; ?>"> |
84 | 84 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | <tbody id="details" style="<?php print $display; ?>"> |
91 | 91 | <!-- version --> |
92 | 92 | <tr> |
93 | - <td><?php print _('Community'); ?></td> |
|
93 | + <td><?php print _ ('Community'); ?></td> |
|
94 | 94 | <td> |
95 | - <input name="snmp_community" class="form-control" placeholder="SNMP <?php print _('Community'); ?>" value='<?php print $device->snmp_community; ?>'> |
|
95 | + <input name="snmp_community" class="form-control" placeholder="SNMP <?php print _ ('Community'); ?>" value='<?php print $device->snmp_community; ?>'> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | |
99 | 99 | <!-- port --> |
100 | 100 | <tr> |
101 | - <td><?php print _('Port'); ?></td> |
|
101 | + <td><?php print _ ('Port'); ?></td> |
|
102 | 102 | <td> |
103 | 103 | <input type="number" name="snmp_port" class="form-control" placeholder="161" value='<?php print $device->snmp_port; ?>'> |
104 | 104 | </td> |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | <!-- timeout --> |
108 | 108 | <tr> |
109 | - <td><?php print _('Timeout'); ?> [ms]</td> |
|
109 | + <td><?php print _ ('Timeout'); ?> [ms]</td> |
|
110 | 110 | <td> |
111 | 111 | <input type="number" name="snmp_timeout" class="form-control" placeholder="500000" value='<?php print $device->snmp_timeout; ?>'> |
112 | 112 | </td> |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | </td> |
120 | 120 | </tr> |
121 | 121 | <tr> |
122 | - <td><?php print _('Queries'); ?></td> |
|
122 | + <td><?php print _ ('Queries'); ?></td> |
|
123 | 123 | <td style="text-align:top"> |
124 | 124 | <?php |
125 | 125 | # select queries |
126 | - $queries = explode(";", $device->snmp_queries); |
|
127 | - $queries = is_array($queries) ? $queries : array(); |
|
126 | + $queries = explode (";", $device->snmp_queries); |
|
127 | + $queries = is_array ($queries) ? $queries : array (); |
|
128 | 128 | // loop |
129 | - foreach($Snmp->snmp_queries as $k=>$m) { |
|
130 | - if(in_array($k, $queries)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'. $k .'" value="on" checked> '. $k .'</div>'. "\n"; } |
|
131 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'. $k .'" value="on">'. $k .'</span></div>'. "\n"; } |
|
129 | + foreach ($Snmp->snmp_queries as $k=>$m) { |
|
130 | + if (in_array ($k, $queries)) { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'.$k.'" value="on" checked> '.$k.'</div>'."\n"; } |
|
131 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="query-'.$k.'" value="on">'.$k.'</span></div>'."\n"; } |
|
132 | 132 | } |
133 | 133 | ?> |
134 | 134 | </td> |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | <tr> |
144 | 144 | <td></td> |
145 | 145 | <td class="text-right"> |
146 | - <a href="#" id="test-snmp" class="btn btn-sm btn-info"><?php print _("Test"); ?></a> |
|
146 | + <a href="#" id="test-snmp" class="btn btn-sm btn-info"><?php print _ ("Test"); ?></a> |
|
147 | 147 | </td> |
148 | 148 | </tr> |
149 | 149 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | <!-- footer --> |
159 | 159 | <div class="pFooter"> |
160 | 160 | <div class="btn-group"> |
161 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
162 | - <button class="btn btn-sm btn-default btn-success" id="editSwitchSNMPsubmit"><i class="fa fa-check"></i> <?php print _("Edit"); ?></button> |
|
161 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
162 | + <button class="btn btn-sm btn-default btn-success" id="editSwitchSNMPsubmit"><i class="fa fa-check"></i> <?php print _ ("Edit"); ?></button> |
|
163 | 163 | </div> |
164 | 164 | |
165 | 165 | <!-- result --> |
@@ -5,35 +5,35 @@ discard block |
||
5 | 5 | ***********************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # create csrf token |
11 | 11 | $csrf = $User->csrf_cookie ("create", "replace_fields"); |
12 | 12 | ?> |
13 | 13 | |
14 | -<h4><?php print _('Search and replace fields in IP address list'); ?></h4> |
|
14 | +<h4><?php print _ ('Search and replace fields in IP address list'); ?></h4> |
|
15 | 15 | <hr><br> |
16 | 16 | |
17 | 17 | <form id="searchReplace"> |
18 | 18 | <table class="table" style="width:auto"> |
19 | 19 | |
20 | 20 | <tr> |
21 | - <td><?php print _('Select field to replace'); ?>:</td> |
|
21 | + <td><?php print _ ('Select field to replace'); ?>:</td> |
|
22 | 22 | <td> |
23 | 23 | <select name="field" class="form-control input-sm input-w-auto"> |
24 | - <option value="description"><?php print _('Description'); ?></option> |
|
25 | - <option value="dns_name"><?php print _('Hostname'); ?></option> |
|
26 | - <option value="owner"><?php print _('Owner'); ?></option> |
|
27 | - <option value="mac"><?php print _('MAC address'); ?></option> |
|
28 | - <option value="switch"><?php print _('Device'); ?></option> |
|
29 | - <option value="port"><?php print _('Port'); ?></option> |
|
24 | + <option value="description"><?php print _ ('Description'); ?></option> |
|
25 | + <option value="dns_name"><?php print _ ('Hostname'); ?></option> |
|
26 | + <option value="owner"><?php print _ ('Owner'); ?></option> |
|
27 | + <option value="mac"><?php print _ ('MAC address'); ?></option> |
|
28 | + <option value="switch"><?php print _ ('Device'); ?></option> |
|
29 | + <option value="port"><?php print _ ('Port'); ?></option> |
|
30 | 30 | <?php |
31 | 31 | # fetch custom fields |
32 | - $custom = $Tools->fetch_custom_fields('ipaddresses'); |
|
32 | + $custom = $Tools->fetch_custom_fields ('ipaddresses'); |
|
33 | 33 | |
34 | - if(sizeof($custom) > 0) { |
|
35 | - foreach($custom as $myField) { |
|
36 | - print '<option value="'. $myField['name'] .'"> '. $myField['name'] .'</option>'; |
|
34 | + if (sizeof ($custom) > 0) { |
|
35 | + foreach ($custom as $myField) { |
|
36 | + print '<option value="'.$myField['name'].'"> '.$myField['name'].'</option>'; |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | ?> |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | </tr> |
43 | 43 | |
44 | 44 | <tr> |
45 | - <td><?php print _('Select search string'); ?></td> |
|
45 | + <td><?php print _ ('Select search string'); ?></td> |
|
46 | 46 | <td> |
47 | - <input type="text" name="search" class="form-control input-sm" placeholder="<?php print _('search string'); ?>"> |
|
47 | + <input type="text" name="search" class="form-control input-sm" placeholder="<?php print _ ('search string'); ?>"> |
|
48 | 48 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
49 | 49 | </td> |
50 | 50 | </tr> |
51 | 51 | |
52 | 52 | <tr> |
53 | - <td><?php print _('Select replace string'); ?></td> |
|
53 | + <td><?php print _ ('Select replace string'); ?></td> |
|
54 | 54 | <td> |
55 | - <input type="text" name="replace" class="form-control input-sm" placeholder="<?php print _('replace string'); ?>"> |
|
55 | + <input type="text" name="replace" class="form-control input-sm" placeholder="<?php print _ ('replace string'); ?>"> |
|
56 | 56 | </td> |
57 | 57 | </tr> |
58 | 58 | |
59 | 59 | <tr class="th"> |
60 | 60 | <td></td> |
61 | 61 | <td> |
62 | - <button class="btn btn-sm btn-default" id="searchReplaceSave"><i class="fa fa-check"></i> <?php print _('Replace'); ?></button> |
|
62 | + <button class="btn btn-sm btn-default" id="searchReplaceSave"><i class="fa fa-check"></i> <?php print _ ('Replace'); ?></button> |
|
63 | 63 | </td> |
64 | 64 | </tr> |
65 | 65 |
@@ -5,27 +5,27 @@ |
||
5 | 5 | ***********************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # validate csrf cookie |
20 | -$User->csrf_cookie ("validate", "replace_fields", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
20 | +$User->csrf_cookie ("validate", "replace_fields", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
21 | 21 | |
22 | 22 | |
23 | 23 | //verify post |
24 | -if(empty($_POST['search'])) { $Result->show("danger", _('Please enter something in search field').'!', true); } |
|
24 | +if (empty($_POST['search'])) { $Result->show ("danger", _ ('Please enter something in search field').'!', true); } |
|
25 | 25 | //if device verify that it exists |
26 | -if($_POST['field'] == "switch") { |
|
27 | - if(!$device1 = $Admin->fetch_object("devices", "hostname", $_POST['search'])) { $Result->show("danger alert-absolute", _('Switch').' "<i>'. $_POST['search'] .'</i>" '._('does not exist, first create switch under admin menu').'!', true); } |
|
28 | - if(!$device2 = $Admin->fetch_object("devices", "hostname", $_POST['replace'])) { $Result->show("danger alert-absolute", _('Switch').' "<i>'. $_POST['search'] .'</i>" '._('does not exist, first create switch under admin menu').'!', true); } |
|
26 | +if ($_POST['field'] == "switch") { |
|
27 | + if (!$device1 = $Admin->fetch_object ("devices", "hostname", $_POST['search'])) { $Result->show ("danger alert-absolute", _ ('Switch').' "<i>'.$_POST['search'].'</i>" '._ ('does not exist, first create switch under admin menu').'!', true); } |
|
28 | + if (!$device2 = $Admin->fetch_object ("devices", "hostname", $_POST['replace'])) { $Result->show ("danger alert-absolute", _ ('Switch').' "<i>'.$_POST['search'].'</i>" '._ ('does not exist, first create switch under admin menu').'!', true); } |
|
29 | 29 | |
30 | 30 | //replace posts |
31 | 31 | $_POST['search'] = $device1->id; |
@@ -5,29 +5,29 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # create csrf token |
20 | 20 | $csrf = $User->csrf_cookie ("create", "tags"); |
21 | 21 | |
22 | 22 | # ID must be numeric |
23 | -if($_POST['action']!="add" && !is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
23 | +if ($_POST['action'] != "add" && !is_numeric ($_POST['id'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | -if($_POST['action']!="add") { |
|
26 | +if ($_POST['action'] != "add") { |
|
27 | 27 | # fetch api details |
28 | 28 | $tag = $Admin->fetch_object ("ipTags", "id", $_POST['id']); |
29 | 29 | # null ? |
30 | - $tag===false ? $Result->show("danger", _("Invalid ID"), true, true) : null; |
|
30 | + $tag === false ? $Result->show ("danger", _ ("Invalid ID"), true, true) : null; |
|
31 | 31 | } |
32 | 32 | ?> |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | |
47 | 47 | <!-- header --> |
48 | -<div class="pHeader"><?php print ucwords($_POST['action']) .' '._('tag'); ?></div> |
|
48 | +<div class="pHeader"><?php print ucwords ($_POST['action']).' '._ ('tag'); ?></div> |
|
49 | 49 | |
50 | 50 | <!-- content --> |
51 | 51 | <div class="pContent"> |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | <!-- type --> |
57 | 57 | <tr> |
58 | - <td style="width:120px;"><?php print _('Type'); ?></td> |
|
58 | + <td style="width:120px;"><?php print _ ('Type'); ?></td> |
|
59 | 59 | <td> |
60 | - <input type="text" name="type" class="form-control input-sm" value="<?php print @$tag->type; ?>" maxlength='32' <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
60 | + <input type="text" name="type" class="form-control input-sm" value="<?php print @$tag->type; ?>" maxlength='32' <?php if ($_POST['action'] == "delete") print "readonly"; ?>> |
|
61 | 61 | <input type="hidden" name="id" value="<?php print @$tag->id; ?>"> |
62 | 62 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
63 | 63 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -66,42 +66,42 @@ discard block |
||
66 | 66 | |
67 | 67 | <!-- show tag --> |
68 | 68 | <tr> |
69 | - <td style="white-space: nowrap;"><?php print _('Show tag'); ?></td> |
|
69 | + <td style="white-space: nowrap;"><?php print _ ('Show tag'); ?></td> |
|
70 | 70 | <td> |
71 | 71 | <select name="showtag" class="form-control input-w-auto"> |
72 | - <option value="0"><?php print _("No"); ?></option> |
|
73 | - <option value="1" <?php if(@$tag->showtag==1) { print "selected='selected'"; } ?>><?php print _("Yes"); ?></option> |
|
72 | + <option value="0"><?php print _ ("No"); ?></option> |
|
73 | + <option value="1" <?php if (@$tag->showtag == 1) { print "selected='selected'"; } ?>><?php print _ ("Yes"); ?></option> |
|
74 | 74 | </select> |
75 | 75 | </td> |
76 | 76 | </tr> |
77 | 77 | |
78 | 78 | <!-- bg color --> |
79 | 79 | <tr> |
80 | - <td><?php print _('Bg color'); ?></td> |
|
80 | + <td><?php print _ ('Bg color'); ?></td> |
|
81 | 81 | <td> |
82 | 82 | <div class="input-group select-bgcolor"> |
83 | - <input type="text" name="bgcolor" class="form-control input-xs" value="<?php print @$tag->bgcolor; ?>" maxlength='32' <?php if($_POST['action'] == "delete") print "readonly"; ?>><span class="input-group-addon"><i></i></span> |
|
83 | + <input type="text" name="bgcolor" class="form-control input-xs" value="<?php print @$tag->bgcolor; ?>" maxlength='32' <?php if ($_POST['action'] == "delete") print "readonly"; ?>><span class="input-group-addon"><i></i></span> |
|
84 | 84 | </div> |
85 | 85 | </td> |
86 | 86 | </tr> |
87 | 87 | |
88 | 88 | <!-- fg color --> |
89 | 89 | <tr> |
90 | - <td><?php print _('Fg color'); ?></td> |
|
90 | + <td><?php print _ ('Fg color'); ?></td> |
|
91 | 91 | <td> |
92 | 92 | <div class="input-group select-fgcolor"> |
93 | - <input type="text" name="fgcolor" class="form-control input-sm" value="<?php print @$tag->fgcolor; ?>" maxlength='32' <?php if($_POST['action'] == "delete") print "readonly"; ?>><span class="input-group-addon"><i></i></span> |
|
93 | + <input type="text" name="fgcolor" class="form-control input-sm" value="<?php print @$tag->fgcolor; ?>" maxlength='32' <?php if ($_POST['action'] == "delete") print "readonly"; ?>><span class="input-group-addon"><i></i></span> |
|
94 | 94 | </div> |
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | |
98 | 98 | <!-- Compress --> |
99 | 99 | <tr> |
100 | - <td><?php print _('Compress range'); ?></td> |
|
100 | + <td><?php print _ ('Compress range'); ?></td> |
|
101 | 101 | <td> |
102 | 102 | <select name="compress" class="form-control input-w-auto"> |
103 | - <option value="No"><?php print _("No"); ?></option> |
|
104 | - <option value="Yes" <?php if(@$tag->compress=="Yes") { print "selected='selected'"; } ?>><?php print _("Yes"); ?></option> |
|
103 | + <option value="No"><?php print _ ("No"); ?></option> |
|
104 | + <option value="Yes" <?php if (@$tag->compress == "Yes") { print "selected='selected'"; } ?>><?php print _ ("Yes"); ?></option> |
|
105 | 105 | </select> |
106 | 106 | </td> |
107 | 107 | </tr> |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | <!-- footer --> |
115 | 115 | <div class="pFooter"> |
116 | 116 | <div class="btn-group"> |
117 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
118 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editTypesubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
117 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
118 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editTypesubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
119 | 119 | </div> |
120 | 120 | <!-- Result --> |
121 | 121 | <div class="editTypeResult"></div> |