Completed
Pull Request — master (#532)
06:37
created
app/admin/requests/edit.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -5,44 +5,44 @@  discard block
 block discarded – undo
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 11
 $Database 	= new Database_PDO;
12
-$User 		= new User ($Database);
12
+$User = new User ($Database);
13 13
 $Admin	 	= new Admin ($Database, false);
14 14
 $Addresses	= new Addresses ($Database);
15 15
 $Subnets	= new Subnets ($Database);
16
-$Tools		= new Tools ($Database);
16
+$Tools = new Tools ($Database);
17 17
 $Result 	= new Result ();
18 18
 
19 19
 # verify that user is logged in
20
-$User->check_user_session();
20
+$User->check_user_session ();
21 21
 
22 22
 # create csrf token
23 23
 $csrf = $User->csrf_cookie ("create", "requests");
24 24
 
25 25
 # fetch request
26
-$request = $Admin->fetch_object("requests", "id", $_POST['requestId']);
26
+$request = $Admin->fetch_object ("requests", "id", $_POST['requestId']);
27 27
 
28 28
 //fail
29
-if($request===false) { $Result->show("danger", _("Request does not exist"), true, true); }
30
-else				 { $request = (array) $request; }
29
+if ($request === false) { $Result->show ("danger", _ ("Request does not exist"), true, true); }
30
+else { $request = (array) $request; }
31 31
 
32 32
 # verify permissions
33
-if($Subnets->check_permission($User->user, $request['subnetId']) != 3)	{ $Result->show("danger", _('You do not have permissions to process this request')."!", true, true); }
33
+if ($Subnets->check_permission ($User->user, $request['subnetId']) != 3) { $Result->show ("danger", _ ('You do not have permissions to process this request')."!", true, true); }
34 34
 
35 35
 
36 36
 # set IP address
37 37
 # if provided (requested from logged in user) check if already in use, if it is warn and set next free
38 38
 # else get next free
39
-if(strlen($request['ip_addr'])>0) {
39
+if (strlen ($request['ip_addr']) > 0) {
40 40
 	// check if it exists
41
-	if ( $Addresses->address_exists ($request['ip_addr'], $request['subnetId'])) {
41
+	if ($Addresses->address_exists ($request['ip_addr'], $request['subnetId'])) {
42 42
 		$errmsg = "Requested IP address ($request[ip_addr]) already used. First available address automatically provided.";
43 43
 		$errmsg_class = "warning";
44 44
 		//fetch first free
45
-		$ip_address = $Addresses->transform_to_dotted($Addresses->get_first_available_address ($request['subnetId'], $Subnets));
45
+		$ip_address = $Addresses->transform_to_dotted ($Addresses->get_first_available_address ($request['subnetId'], $Subnets));
46 46
 	}
47 47
 	else {
48 48
 		$ip_address = $request['ip_addr'];
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 
51 51
 } else {
52 52
 	// fetch first free
53
-	$ip_address = $Addresses->transform_to_dotted($Addresses->get_first_available_address ($request['subnetId'], $Subnets));
53
+	$ip_address = $Addresses->transform_to_dotted ($Addresses->get_first_available_address ($request['subnetId'], $Subnets));
54 54
 }
55 55
 
56 56
 // false
57
-if ($ip_address===false) {
57
+if ($ip_address === false) {
58 58
 	$ip_address = "";
59 59
 	$errmsg = "No IP addresses available in requested subnet";
60 60
 	$errmsg_class = "danger";
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
 
64 64
 # set selected address fields array
65
-$selected_ip_fields = explode(";", $User->settings->IPfilter);
65
+$selected_ip_fields = explode (";", $User->settings->IPfilter);
66 66
 # fetch custom fields
67
-$custom_fields = $Tools->fetch_custom_fields('ipaddresses');
67
+$custom_fields = $Tools->fetch_custom_fields ('ipaddresses');
68 68
 ?>
69 69
 
70 70
 <!-- header -->
71
-<div class="pHeader"><?php print _('Manage IP address request'); ?></div>
71
+<div class="pHeader"><?php print _ ('Manage IP address request'); ?></div>
72 72
 
73 73
 <!-- content -->
74 74
 <div class="pContent">
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	<?php
77 77
 	// if error / warning message provided
78 78
 	if (isset($errmsg)) {
79
-		$Result->show($errmsg_class, $errmsg, false, false);
79
+		$Result->show ($errmsg_class, $errmsg, false, false);
80 80
 		print "<hr>";
81 81
 	}
82 82
 	// error check
83
-	if (@$errmsg_class!="danger") {
83
+	if (@$errmsg_class != "danger") {
84 84
 	?>
85 85
 
86 86
 	<!-- IP address request form -->
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
 
96 96
 	<!-- Subnet -->
97 97
 	<tr>
98
-		<th><?php print _('Requested subnet'); ?></th>
98
+		<th><?php print _ ('Requested subnet'); ?></th>
99 99
 		<td>
100 100
 			<select name="subnetId" id="subnetId" class="form-control input-sm input-w-auto">
101 101
 			<?php
102
-			$request_subnets = $Admin->fetch_multiple_objects("subnets", "allowRequests", 1);
102
+			$request_subnets = $Admin->fetch_multiple_objects ("subnets", "allowRequests", 1);
103 103
 
104
-			foreach($request_subnets as $subnet) {
104
+			foreach ($request_subnets as $subnet) {
105 105
 				$subnet = (array) $subnet;
106 106
 				# print
107
-				if($request['subnetId']==$subnet['id'])	{ print '<option value="'. $subnet['id'] .'" selected>' . $Addresses->transform_to_dotted($subnet['subnet']) .'/'. $subnet['mask'] .' ['. $subnet['description'] .']</option>'; }
108
-				else 									{ print '<option value="'. $subnet['id'] .'">' 			. $Addresses->transform_to_dotted($subnet['subnet']) .'/'. $subnet['mask'] .' ['. $subnet['description'] .']</option>'; }
107
+				if ($request['subnetId'] == $subnet['id']) { print '<option value="'.$subnet['id'].'" selected>'.$Addresses->transform_to_dotted ($subnet['subnet']).'/'.$subnet['mask'].' ['.$subnet['description'].']</option>'; }
108
+				else { print '<option value="'.$subnet['id'].'">'.$Addresses->transform_to_dotted ($subnet['subnet']).'/'.$subnet['mask'].' ['.$subnet['description'].']</option>'; }
109 109
 			}
110 110
 			?>
111 111
 			</select>
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	</tr>
114 114
 	<!-- IP address -->
115 115
 	<tr>
116
-		<th><?php print _('IP address'); ?></th>
116
+		<th><?php print _ ('IP address'); ?></th>
117 117
 		<td>
118 118
 			<input type="text" name="ip_addr" class="ip_addr form-control input-sm" value="<?php print $ip_address; ?>" size="30">
119 119
 			<input type="hidden" name="requestId" value="<?php print $request['id']; ?>">
@@ -123,32 +123,32 @@  discard block
 block discarded – undo
123 123
 	</tr>
124 124
 	<!-- description -->
125 125
 	<tr>
126
-		<th><?php print _('Description'); ?></th>
126
+		<th><?php print _ ('Description'); ?></th>
127 127
 		<td>
128
-			<input type="text" name="description" class="form-control input-sm" value="<?php print @$request['description']; ?>" size="30" placeholder="<?php print _('Enter IP description'); ?>">
128
+			<input type="text" name="description" class="form-control input-sm" value="<?php print @$request['description']; ?>" size="30" placeholder="<?php print _ ('Enter IP description'); ?>">
129 129
 		</td>
130 130
 	</tr>
131 131
 	<!-- DNS name -->
132 132
 	<tr>
133
-		<th><?php print _('Hostname'); ?></th>
133
+		<th><?php print _ ('Hostname'); ?></th>
134 134
 		<td>
135
-			<input type="text" name="dns_name" class="form-control input-sm" value="<?php print @$request['dns_name']; ?>" size="30" placeholder="<?php print _('Enter hostname'); ?>">
135
+			<input type="text" name="dns_name" class="form-control input-sm" value="<?php print @$request['dns_name']; ?>" size="30" placeholder="<?php print _ ('Enter hostname'); ?>">
136 136
 		</td>
137 137
 	</tr>
138 138
 
139
-	<?php if(in_array('state', $selected_ip_fields)) { ?>
139
+	<?php if (in_array ('state', $selected_ip_fields)) { ?>
140 140
 	<!-- state -->
141 141
 	<tr>
142
-		<th><?php print _('State'); ?></th>
142
+		<th><?php print _ ('State'); ?></th>
143 143
 		<td>
144 144
 			<select name="state" class="form-control input-sm input-w-auto">
145 145
 			<?php
146 146
 			$states = $Addresses->addresses_types_fetch ();
147 147
 			# default tag
148
-			if (!isset($request['state']))	{ $request['state'] = "2"; }
149
-			foreach($states as $s) {
150
-				if ($request['state']==$s['id'])	{ print "<option value='$s[id]' selected='selected'>$s[type]</option>"; }
151
-				else								{ print "<option value='$s[id]'>$s[type]</option>"; }
148
+			if (!isset($request['state'])) { $request['state'] = "2"; }
149
+			foreach ($states as $s) {
150
+				if ($request['state'] == $s['id']) { print "<option value='$s[id]' selected='selected'>$s[type]</option>"; }
151
+				else { print "<option value='$s[id]'>$s[type]</option>"; }
152 152
 			}
153 153
 			?>
154 154
 			</select>
@@ -156,41 +156,41 @@  discard block
 block discarded – undo
156 156
 	</tr>
157 157
 	<?php } ?>
158 158
 
159
-	<?php if(in_array('owner', $selected_ip_fields)) { ?>
159
+	<?php if (in_array ('owner', $selected_ip_fields)) { ?>
160 160
 	<!-- owner -->
161 161
 	<tr>
162
-		<th><?php print _('Owner'); ?></th>
162
+		<th><?php print _ ('Owner'); ?></th>
163 163
 		<td>
164
-			<input type="text" name="owner" class="form-control input-sm" id="owner" value="<?php print @$request['owner']; ?>" size="30" placeholder="<?php print _('Enter IP owner'); ?>">
164
+			<input type="text" name="owner" class="form-control input-sm" id="owner" value="<?php print @$request['owner']; ?>" size="30" placeholder="<?php print _ ('Enter IP owner'); ?>">
165 165
 		</td>
166 166
 	</tr>
167 167
 	<?php } ?>
168 168
 
169
-	<?php if(in_array('switch', $selected_ip_fields)) { ?>
169
+	<?php if (in_array ('switch', $selected_ip_fields)) { ?>
170 170
 	<!-- switch / port -->
171 171
 	<tr>
172
-		<th><?php print _('Device'); ?> / <?php print _('port'); ?></th>
172
+		<th><?php print _ ('Device'); ?> / <?php print _ ('port'); ?></th>
173 173
 		<td>
174 174
 			<select name="switch" class="form-control input-sm input-w-100">
175
-				<option disabled><?php print _('Select device'); ?>:</option>
176
-				<option value="" selected><?php print _('None'); ?></option>
175
+				<option disabled><?php print _ ('Select device'); ?>:</option>
176
+				<option value="" selected><?php print _ ('None'); ?></option>
177 177
 				<?php
178
-				$devices = $Tools->fetch_all_objects("devices", "hostname");
178
+				$devices = $Tools->fetch_all_objects ("devices", "hostname");
179 179
 				//loop
180
-				if ($devices!==false) {
181
-    				foreach($devices as $device) {
180
+				if ($devices !== false) {
181
+    				foreach ($devices as $device) {
182 182
     					//cast
183 183
     					$device = (array) $device;
184 184
 
185
-    					if($device['id'] == @$request['switch']) { print '<option value="'. $device['id'] .'" selected>'. $device['hostname'] .'</option>'. "\n"; }
186
-    					else 									 { print '<option value="'. $device['id'] .'">'. 		 $device['hostname'] .'</option>'. "\n"; }
185
+    					if ($device['id'] == @$request['switch']) { print '<option value="'.$device['id'].'" selected>'.$device['hostname'].'</option>'."\n"; }
186
+    					else { print '<option value="'.$device['id'].'">'.$device['hostname'].'</option>'."\n"; }
187 187
     				}
188 188
 				}
189 189
 				?>
190 190
 			</select>
191
-			<?php if(in_array('port', $selected_ip_fields)) { ?>
191
+			<?php if (in_array ('port', $selected_ip_fields)) { ?>
192 192
 			/
193
-			<input type="text" name="port" class="form-control input-sm input-w-100" value="<?php print @$request['port']; ?>"  placeholder="<?php print _('Port'); ?>">
193
+			<input type="text" name="port" class="form-control input-sm input-w-100" value="<?php print @$request['port']; ?>"  placeholder="<?php print _ ('Port'); ?>">
194 194
 		</td>
195 195
 	</tr>
196 196
 	<?php } ?>
@@ -198,53 +198,53 @@  discard block
 block discarded – undo
198 198
 	</tr>
199 199
 	<?php } ?>
200 200
 
201
-	<?php if(in_array('note', $selected_ip_fields)) { ?>
201
+	<?php if (in_array ('note', $selected_ip_fields)) { ?>
202 202
 	<!-- note -->
203 203
 	<tr>
204
-		<th><?php print _('Note'); ?></th>
204
+		<th><?php print _ ('Note'); ?></th>
205 205
 		<td>
206
-			<input type="text" name="note" class="form-control input-sm" id="note" placeholder="<?php print _('Write note'); ?>" size="30">
206
+			<input type="text" name="note" class="form-control input-sm" id="note" placeholder="<?php print _ ('Write note'); ?>" size="30">
207 207
 		</td>
208 208
 	</tr>
209 209
 	<?php } ?>
210 210
 
211 211
 	<!-- Custom fields -->
212 212
 	<?php
213
-	if(sizeof(@$custom_fields) > 0) {
213
+	if (sizeof (@$custom_fields) > 0) {
214 214
 	    # count datepickers
215 215
 	    $timeP = 0;
216 216
 
217 217
 	    # all my fields
218
-	    foreach($custom_fields as $myField) {
218
+	    foreach ($custom_fields as $myField) {
219 219
 	        # replace spaces with |
220
-	        $myField['nameNew'] = str_replace(" ", "___", $myField['name']);
220
+	        $myField['nameNew'] = str_replace (" ", "___", $myField['name']);
221 221
 
222 222
 	        # required
223
-	        if($myField['Null']=="NO")  { $required = "*"; }
224
-	        else                        { $required = ""; }
223
+	        if ($myField['Null'] == "NO") { $required = "*"; }
224
+	        else { $required = ""; }
225 225
 
226
-	        print '<tr>'. "\n";
227
-	        print ' <td>'. $myField['name'] .' '.$required.'</td>'. "\n";
228
-	        print ' <td>'. "\n";
226
+	        print '<tr>'."\n";
227
+	        print ' <td>'.$myField['name'].' '.$required.'</td>'."\n";
228
+	        print ' <td>'."\n";
229 229
 
230 230
 	        //set type
231
-		    if(substr($myField['type'], 0,3) == "set" || substr($myField['type'], 0,4) == "enum") {
231
+		    if (substr ($myField['type'], 0, 3) == "set" || substr ($myField['type'], 0, 4) == "enum") {
232 232
 				//parse values
233
-				$tmp = substr($myField['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $myField['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $myField['type']));
233
+				$tmp = substr ($myField['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $myField['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $myField['type']));
234 234
 	            //null
235
-	            if($myField['Null']!="NO") { array_unshift($tmp, ""); }
235
+	            if ($myField['Null'] != "NO") { array_unshift ($tmp, ""); }
236 236
 
237 237
 	            print "<select name='$myField[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$myField[Comment]'>";
238
-	            foreach($tmp as $v) {
239
-	                if($v==@$details[$myField['name']])  { print "<option value='$v' selected='selected'>$v</option>"; }
240
-	                else                                 { print "<option value='$v'>$v</option>"; }
238
+	            foreach ($tmp as $v) {
239
+	                if ($v == @$details[$myField['name']]) { print "<option value='$v' selected='selected'>$v</option>"; }
240
+	                else { print "<option value='$v'>$v</option>"; }
241 241
 	            }
242 242
 	            print "</select>";
243 243
 	        }
244 244
 	        //date and time picker
245
-	        elseif($myField['type'] == "date" || $myField['type'] == "datetime") {
245
+	        elseif ($myField['type'] == "date" || $myField['type'] == "datetime") {
246 246
 	            // just for first
247
-	            if($timeP==0) {
247
+	            if ($timeP == 0) {
248 248
 	                print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">';
249 249
 	                print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>';
250 250
 	                print '<script type="text/javascript">';
@@ -260,38 +260,38 @@  discard block
 block discarded – undo
260 260
 	            $timeP++;
261 261
 
262 262
 	            //set size
263
-	            if($myField['type'] == "date")  { $size = 10; $class='datepicker';      $format = "yyyy-MM-dd"; }
264
-	            else                            { $size = 19; $class='datetimepicker';  $format = "yyyy-MM-dd"; }
263
+	            if ($myField['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; }
264
+	            else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; }
265 265
 
266 266
 	            //field
267
-	            if(!isset($details[$myField['name']]))  { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $myField['nameNew'] .'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'. "\n"; }
268
-	            else                                    { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $myField['nameNew'] .'" maxlength="'.$size.'" value="'. @$details[$myField['name']]. '" rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'. "\n"; }
267
+	            if (!isset($details[$myField['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$myField['nameNew'].'" maxlength="'.$size.'" rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'."\n"; }
268
+	            else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$myField['nameNew'].'" maxlength="'.$size.'" value="'.@$details[$myField['name']].'" rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'."\n"; }
269 269
 	        }
270 270
 	        //boolean
271
-	        elseif($myField['type'] == "tinyint(1)") {
271
+	        elseif ($myField['type'] == "tinyint(1)") {
272 272
 	            print "<select name='$myField[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$myField[Comment]'>";
273
-	            $tmp = array(0=>"No",1=>"Yes");
273
+	            $tmp = array (0=>"No", 1=>"Yes");
274 274
 	            //null
275
-	            if($myField['Null']!="NO") { $tmp[2] = ""; }
275
+	            if ($myField['Null'] != "NO") { $tmp[2] = ""; }
276 276
 
277
-	            foreach($tmp as $k=>$v) {
278
-	                if(strlen(@$details[$myField['name']])==0 && $k==2)  { print "<option value='$k' selected='selected'>"._($v)."</option>"; }
279
-	                elseif($k==@$details[$myField['name']])              { print "<option value='$k' selected='selected'>"._($v)."</option>"; }
280
-	                else                                                 { print "<option value='$k'>"._($v)."</option>"; }
277
+	            foreach ($tmp as $k=>$v) {
278
+	                if (strlen (@$details[$myField['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; }
279
+	                elseif ($k == @$details[$myField['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; }
280
+	                else { print "<option value='$k'>"._ ($v)."</option>"; }
281 281
 	            }
282 282
 	            print "</select>";
283 283
 	        }
284 284
 	        //text
285
-	        elseif($myField['type'] == "text") {
286
-	            print ' <textarea class="form-control input-sm" name="'. $myField['nameNew'] .'" placeholder="'. $myField['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'. $details[$myField['name']]. '</textarea>'. "\n";
285
+	        elseif ($myField['type'] == "text") {
286
+	            print ' <textarea class="form-control input-sm" name="'.$myField['nameNew'].'" placeholder="'.$myField['name'].'" rowspan=3 rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'.$details[$myField['name']].'</textarea>'."\n";
287 287
 	        }
288 288
 	        //default - input field
289 289
 	        else {
290
-	            print ' <input type="text" class="ip_addr form-control input-sm" name="'. $myField['nameNew'] .'" placeholder="'. $myField['name'] .'" value="'. @$details[$myField['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'. "\n";
290
+	            print ' <input type="text" class="ip_addr form-control input-sm" name="'.$myField['nameNew'].'" placeholder="'.$myField['name'].'" value="'.@$details[$myField['name']].'" size="30" rel="tooltip" data-placement="right" title="'.$myField['Comment'].'">'."\n";
291 291
 	        }
292 292
 
293
-	        print ' </td>'. "\n";
294
-	        print '</tr>'. "\n";
293
+	        print ' </td>'."\n";
294
+	        print '</tr>'."\n";
295 295
 	    }
296 296
 	}
297 297
 	?>
@@ -303,23 +303,23 @@  discard block
 block discarded – undo
303 303
 
304 304
 	<!-- requested by -->
305 305
 	<tr>
306
-		<th><?php print _('Requester email'); ?></th>
306
+		<th><?php print _ ('Requester email'); ?></th>
307 307
 		<td>
308 308
 			<input type="text" disabled="disabled" class="form-control" value="<?php print @$request['requester']; ?>">
309 309
 		</td>
310 310
 	</tr>
311 311
 	<!-- comment -->
312 312
 	<tr>
313
-		<th><?php print _('Requester comment'); ?></th>
313
+		<th><?php print _ ('Requester comment'); ?></th>
314 314
 		<td>
315 315
 			<input type="text" disabled="disabled" class="form-control" value="<?php print @$request['comment']; ?>">
316 316
 			<?php print "<input type='hidden' name='comment' value='".@$request['comment']."'>"; ?></i></td>
317 317
 	</tr>
318 318
 	<!-- Admin comment -->
319 319
 	<tr>
320
-		<th><?php print _('Comment approval/reject'); ?>:</th>
320
+		<th><?php print _ ('Comment approval/reject'); ?>:</th>
321 321
 		<td>
322
-			<textarea name="adminComment" rows="3" cols="30" class="form-control input-sm" placeholder="<?php print _('Enter reason for reject/approval to be sent to requester'); ?>"></textarea>
322
+			<textarea name="adminComment" rows="3" cols="30" class="form-control input-sm" placeholder="<?php print _ ('Enter reason for reject/approval to be sent to requester'); ?>"></textarea>
323 323
 		</td>
324 324
 	</tr>
325 325
 
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
 <!-- footer -->
332 332
 <div class="pFooter">
333 333
 	<div class="btn-group">
334
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
335
-		<?php if (@$errmsg_class!="danger") { ?>
336
-		<button class="btn btn-sm btn-default btn-danger manageRequest" data-action='reject'><i class="fa fa-times"></i> <?php print _('Reject'); ?></button>
337
-		<button class="btn btn-sm btn-default btn-success manageRequest" data-action='accept'><i class="fa fa-check"></i> <?php print _('Accept'); ?></button>
334
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
335
+		<?php if (@$errmsg_class != "danger") { ?>
336
+		<button class="btn btn-sm btn-default btn-danger manageRequest" data-action='reject'><i class="fa fa-times"></i> <?php print _ ('Reject'); ?></button>
337
+		<button class="btn btn-sm btn-default btn-success manageRequest" data-action='accept'><i class="fa fa-check"></i> <?php print _ ('Accept'); ?></button>
338 338
 		<?php } ?>
339 339
 	</div>
340 340
 
Please login to merge, or discard this patch.
app/admin/requests/edit-result.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,50 +5,50 @@  discard block
 block discarded – undo
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 11
 $Database 	= new Database_PDO;
12
-$User 		= new User ($Database);
12
+$User = new User ($Database);
13 13
 $Admin	 	= new Admin ($Database, false);
14 14
 $Addresses	= new Addresses ($Database);
15 15
 $Subnets	= new Subnets ($Database);
16
-$Tools		= new Tools ($Database);
16
+$Tools = new Tools ($Database);
17 17
 $Result 	= new Result ();
18 18
 
19 19
 # verify that user is logged in
20
-$User->check_user_session();
20
+$User->check_user_session ();
21 21
 
22 22
 # strip input tags
23
-$_POST = $Admin->strip_input_tags($_POST);
23
+$_POST = $Admin->strip_input_tags ($_POST);
24 24
 
25 25
 # validate csrf cookie
26
-$User->csrf_cookie ("validate", "requests", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
26
+$User->csrf_cookie ("validate", "requests", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : "";
27 27
 
28 28
 # verify permissions
29
-if($Subnets->check_permission($User->user, $_POST['subnetId']) != 3)	{ $Result->show("danger", _('You do not have permissions to process this request')."!", true); }
29
+if ($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) { $Result->show ("danger", _ ('You do not have permissions to process this request')."!", true); }
30 30
 
31 31
 # fetch custom fields
32
-$custom = $Tools->fetch_custom_fields('ipaddresses');
33
-if(sizeof($custom) > 0) {
34
-	foreach($custom as $myField) {
35
-		if(isset($_POST[$myField['name']])) { $_POST[$myField['name']] = $_POST[$myField['name']];}
32
+$custom = $Tools->fetch_custom_fields ('ipaddresses');
33
+if (sizeof ($custom) > 0) {
34
+	foreach ($custom as $myField) {
35
+		if (isset($_POST[$myField['name']])) { $_POST[$myField['name']] = $_POST[$myField['name']]; }
36 36
 	}
37 37
 }
38 38
 
39 39
 # fetch subnet
40
-$subnet = (array) $Admin->fetch_object("subnets", "id", $_POST['subnetId']);
40
+$subnet = (array) $Admin->fetch_object ("subnets", "id", $_POST['subnetId']);
41 41
 
42 42
 /* if action is reject set processed and accepted to 1 and 0 */
43
-if($_POST['action'] == "reject") {
43
+if ($_POST['action'] == "reject") {
44 44
 	//set reject values
45
-	$values = array("id"=>$_POST['requestId'],
45
+	$values = array ("id"=>$_POST['requestId'],
46 46
 					"processed"=>1,
47 47
 					"accepted"=>0,
48 48
 					"adminComment"=>@$_POST['adminComment']
49 49
 					);
50
-	if(!$Admin->object_modify("requests", "edit", "id", $values))		{ $Result->show("danger",  _("Failed to reject IP request"), true); }
51
-	else																{ $Result->show("success", _("Request has beed rejected"), false); }
50
+	if (!$Admin->object_modify ("requests", "edit", "id", $values)) { $Result->show ("danger", _ ("Failed to reject IP request"), true); }
51
+	else { $Result->show ("success", _ ("Request has beed rejected"), false); }
52 52
 
53 53
 	# send mail
54 54
 	$Tools->ip_request_send_mail ("reject", $_POST);
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
 	$subnet_temp = $Addresses->transform_to_dotted ($subnet['subnet'])."/".$subnet['mask'];
60 60
 
61 61
 	//verify IP and subnet
62
-	$Addresses->verify_address( $Addresses->transform_address($_POST['ip_addr'], "dotted"), $subnet_temp, false, true);
62
+	$Addresses->verify_address ($Addresses->transform_address ($_POST['ip_addr'], "dotted"), $subnet_temp, false, true);
63 63
 
64 64
 	//check if already existing and die
65
-	if ($Addresses->address_exists($Addresses->transform_address($_POST['ip_addr'], "decimal"), $subnet['id'])) { $Result->show("danger", _('IP address already exists'), true); }
65
+	if ($Addresses->address_exists ($Addresses->transform_address ($_POST['ip_addr'], "decimal"), $subnet['id'])) { $Result->show ("danger", _ ('IP address already exists'), true); }
66 66
 
67 67
 	//insert to ipaddresses table
68
-	$values = array("action"=>"add",
69
-					"ip_addr"=>$Addresses->transform_address($_POST['ip_addr'],"decimal"),
68
+	$values = array ("action"=>"add",
69
+					"ip_addr"=>$Addresses->transform_address ($_POST['ip_addr'], "decimal"),
70 70
 					"subnetId"=>$_POST['subnetId'],
71 71
 					"description"=>@$_POST['description'],
72 72
 					"dns_name"=>@$_POST['dns_name'],
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
 					"port"=>@$_POST['port'],
78 78
 					"note"=>@$_POST['note']
79 79
 					);
80
-	if(!$Addresses->modify_address($values))	{ $Result->show("danger",  _("Failed to create IP address"), true); }
80
+	if (!$Addresses->modify_address ($values)) { $Result->show ("danger", _ ("Failed to create IP address"), true); }
81 81
 
82 82
 	//accept message
83
-	$values2 = array("id"=>$_POST['requestId'],
83
+	$values2 = array ("id"=>$_POST['requestId'],
84 84
 					"processed"=>1,
85 85
 					"accepted"=>1,
86 86
 					"adminComment"=>$comment
87 87
 					);
88
-	if(!$Admin->object_modify("requests", "edit", "id", $values2))		{ $Result->show("danger",  _("Cannot confirm IP address"), true); }
89
-	else																{ $Result->show("success", _("IP request accepted/rejected"), false); }
88
+	if (!$Admin->object_modify ("requests", "edit", "id", $values2)) { $Result->show ("danger", _ ("Cannot confirm IP address"), true); }
89
+	else { $Result->show ("success", _ ("IP request accepted/rejected"), false); }
90 90
 
91 91
 
92 92
 	# send mail
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 	$tmp['subnetId'] = $_POST['subnetId'];
96 96
 	unset($_POST['subnetId']);
97 97
 	// gateway
98
-	$gateway=$Subnets->find_gateway ($tmp['subnetId']);
99
-	if($gateway !== false) { $tmp['gateway'] = $Subnets->transform_address($gateway->ip_addr,"dotted"); }
98
+	$gateway = $Subnets->find_gateway ($tmp['subnetId']);
99
+	if ($gateway !== false) { $tmp['gateway'] = $Subnets->transform_address ($gateway->ip_addr, "dotted"); }
100 100
 	//set vlan
101 101
 	$vlan = $Tools->fetch_object ("vlans", "vlanId", $subnet['vlanId']);
102
-	$tmp['vlan'] = $vlan==false ? "" : $vlan->number." - ".$vlan->description;
102
+	$tmp['vlan'] = $vlan == false ? "" : $vlan->number." - ".$vlan->description;
103 103
 	//set dns
104 104
 	$dns = $Tools->fetch_object ("nameservers", "id", $subnet['nameserverId']);
105
-	$tmp['dns'] = $dns==false ? "" : $dns->description." <br> ".str_replace(";", ", ", $dns->namesrv1);
105
+	$tmp['dns'] = $dns == false ? "" : $dns->description." <br> ".str_replace (";", ", ", $dns->namesrv1);
106 106
 
107
-	$_POST = array_merge($tmp, $_POST);
107
+	$_POST = array_merge ($tmp, $_POST);
108 108
 
109 109
 	$Tools->ip_request_send_mail ("accept", $_POST);
110 110
 }
Please login to merge, or discard this patch.
app/admin/requests/index.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@  discard block
 block discarded – undo
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 Active requests
11 11
 $active_requests   = $Admin->fetch_multiple_objects ("requests", "processed", 0, "id", false);
12 12
 $inactive_requests = $Admin->fetch_multiple_objects ("requests", "processed", 1, "id", false);
13 13
 ?>
14 14
 
15
-<h4><?php print _('List of all active IP addresses requests'); ?></h4>
15
+<h4><?php print _ ('List of all active IP addresses requests'); ?></h4>
16 16
 <hr><br>
17 17
 
18 18
 <?php
19 19
 # none
20
-if($active_requests===false) { print "<div class='alert alert-info'>"._('No IP address requests available')."!</div>"; }
20
+if ($active_requests === false) { print "<div class='alert alert-info'>"._ ('No IP address requests available')."!</div>"; }
21 21
 else {
22 22
 ?>
23 23
 <table id="requestedIPaddresses" class="table sorted table-striped table-condensed table-hover table-top">
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
 <thead>
27 27
 <tr>
28 28
 	<th style="width:50px;"></th>
29
-	<th><?php print _('IP'); ?></th>
30
-	<th><?php print _('Subnet'); ?></th>
31
-	<th><?php print _('Hostname'); ?></th>
32
-	<th><?php print _('Description'); ?></th>
33
-	<th><?php print _('Requested by'); ?></th>
34
-	<th><?php print _('Comment'); ?></th>
29
+	<th><?php print _ ('IP'); ?></th>
30
+	<th><?php print _ ('Subnet'); ?></th>
31
+	<th><?php print _ ('Hostname'); ?></th>
32
+	<th><?php print _ ('Description'); ?></th>
33
+	<th><?php print _ ('Requested by'); ?></th>
34
+	<th><?php print _ ('Comment'); ?></th>
35 35
 </tr>
36 36
 </thead>
37 37
 
38 38
 <tbody>
39 39
 <?php
40 40
 	# print requests
41
-	foreach($active_requests as $k=>$request) {
41
+	foreach ($active_requests as $k=>$request) {
42 42
 		//cast
43 43
 		$request = (array) $request;
44 44
 
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 		$subnet = (array) $Subnets->fetch_subnet (null, $request['subnetId']);
47 47
 
48 48
 		//valid
49
-		if(sizeof($subnet)==0 || @$subnet[0]===false) {
49
+		if (sizeof ($subnet) == 0 || @$subnet[0] === false) {
50 50
 			unset($active_requests[$k]);
51 51
 		}
52 52
 		else {
53 53
 			// ip not provided
54
-			$request['ip_addr'] = strlen($request['ip_addr'])>0 ? $request['ip_addr'] : _("Automatic");
55
-
56
-			print '<tr>'. "\n";
57
-			print "	<td><button class='btn btn-sm btn-default' data-requestid='$request[id]'><i class='fa fa-pencil'></i> "._('Process')."</button></td>";
58
-			print '	<td>'. $request['ip_addr'] .'</td>'. "\n";
59
-			print '	<td>'. $Subnets->transform_to_dotted($subnet['subnet']) .'/'. $subnet['mask'] .' ('. $subnet['description'] .')</td>'. "\n";
60
-			print '	<td>'. $request['dns_name'] .'</td>'. "\n";
61
-			print '	<td>'. $request['description'] .'</td>'. "\n";
62
-			print '	<td>'. $request['requester'] .'</td>'. "\n";
63
-			print '	<td>'. $request['comment'] .'</td>'. "\n";
64
-			print '</tr>'. "\n";
54
+			$request['ip_addr'] = strlen ($request['ip_addr']) > 0 ? $request['ip_addr'] : _ ("Automatic");
55
+
56
+			print '<tr>'."\n";
57
+			print "	<td><button class='btn btn-sm btn-default' data-requestid='$request[id]'><i class='fa fa-pencil'></i> "._ ('Process')."</button></td>";
58
+			print '	<td>'.$request['ip_addr'].'</td>'."\n";
59
+			print '	<td>'.$Subnets->transform_to_dotted ($subnet['subnet']).'/'.$subnet['mask'].' ('.$subnet['description'].')</td>'."\n";
60
+			print '	<td>'.$request['dns_name'].'</td>'."\n";
61
+			print '	<td>'.$request['description'].'</td>'."\n";
62
+			print '	<td>'.$request['requester'].'</td>'."\n";
63
+			print '	<td>'.$request['comment'].'</td>'."\n";
64
+			print '</tr>'."\n";
65 65
 		}
66 66
 	}
67 67
 ?>
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 <?php
71 71
 }
72 72
 # print resolved if present
73
-if($inactive_requests!==false) { ?>
73
+if ($inactive_requests !== false) { ?>
74 74
 
75
-<h4 style="margin-top:50px;"><?php print _('List of all processes IP addresses requests'); ?></h4>
75
+<h4 style="margin-top:50px;"><?php print _ ('List of all processes IP addresses requests'); ?></h4>
76 76
 <hr><br>
77 77
 
78 78
 <table id="requestedIPaddresses" class="table sorted table-striped table-condensed table-hover table-top table-auto1">
@@ -80,20 +80,20 @@  discard block
 block discarded – undo
80 80
 <!-- headers -->
81 81
 <thead>
82 82
 <tr>
83
-	<th><?php print _('Subnet'); ?></th>
84
-	<th><?php print _('Hostname'); ?></th>
85
-	<th><?php print _('Description'); ?></th>
86
-	<th><?php print _('Requested by'); ?></th>
87
-	<th><?php print _('Comment'); ?></th>
88
-	<th><?php print _('Admin comment'); ?></th>
89
-	<th><?php print _('Accepted'); ?></th>
83
+	<th><?php print _ ('Subnet'); ?></th>
84
+	<th><?php print _ ('Hostname'); ?></th>
85
+	<th><?php print _ ('Description'); ?></th>
86
+	<th><?php print _ ('Requested by'); ?></th>
87
+	<th><?php print _ ('Comment'); ?></th>
88
+	<th><?php print _ ('Admin comment'); ?></th>
89
+	<th><?php print _ ('Accepted'); ?></th>
90 90
 </tr>
91 91
 </thead>
92 92
 
93 93
 <tbody>
94 94
 <?php
95 95
 	# print requests
96
-	foreach($inactive_requests as $k=>$request) {
96
+	foreach ($inactive_requests as $k=>$request) {
97 97
 		//cast
98 98
 		$request = (array) $request;
99 99
 
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
 		$subnet = (array) $Subnets->fetch_subnet (null, $request['subnetId']);
102 102
 
103 103
 		//valid
104
-		if(sizeof($subnet)==0 || @$subnet[0]===false) {
104
+		if (sizeof ($subnet) == 0 || @$subnet[0] === false) {
105 105
 			unset($inactive_requests[$k]);
106 106
 		}
107 107
 		else {
108
-			print '<tr>'. "\n";
109
-			print '	<td>'. $Subnets->transform_to_dotted($subnet['subnet']) .'/'. $subnet['mask'] .' ('. $subnet['description'] .')</td>'. "\n";
110
-			print '	<td>'. $request['dns_name'] .'</td>'. "\n";
111
-			print '	<td>'. $request['description'] .'</td>'. "\n";
112
-			print '	<td>'. $request['requester'] .'</td>'. "\n";
113
-			print '	<td>'. $request['comment'] .'</td>'. "\n";
114
-			print '	<td>'. $request['adminComment'] .'</td>'. "\n";
108
+			print '<tr>'."\n";
109
+			print '	<td>'.$Subnets->transform_to_dotted ($subnet['subnet']).'/'.$subnet['mask'].' ('.$subnet['description'].')</td>'."\n";
110
+			print '	<td>'.$request['dns_name'].'</td>'."\n";
111
+			print '	<td>'.$request['description'].'</td>'."\n";
112
+			print '	<td>'.$request['requester'].'</td>'."\n";
113
+			print '	<td>'.$request['comment'].'</td>'."\n";
114
+			print '	<td>'.$request['adminComment'].'</td>'."\n";
115 115
 			print '	<td>';
116
-			print $request['accepted']==1 ? "Yes" : "No";
117
-			print '</td>'. "\n";
118
-			print '</tr>'. "\n";
116
+			print $request['accepted'] == 1 ? "Yes" : "No";
117
+			print '</td>'."\n";
118
+			print '</tr>'."\n";
119 119
 		}
120 120
 	}
121 121
 ?>
Please login to merge, or discard this patch.
app/admin/index.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 block discarded – undo
5 5
 
6 6
 <?php
7 7
 # print
8
-foreach($admin_menu as $k=>$menu) {
8
+foreach ($admin_menu as $k=>$menu) {
9 9
 
10 10
 	# headers
11
-	print "<h4>"._($k)."</h4>";
11
+	print "<h4>"._ ($k)."</h4>";
12 12
 	print "<hr>";
13 13
 
14 14
 	# items
15
-	foreach($menu as $t) {
15
+	foreach ($menu as $t) {
16 16
 		print "	<div class='col-xs-12 col-md-6 col-lg-6 widget-dash'>";
17 17
 		print "	<div class='inner thumbnail'>";
18 18
 		print "		<div class='hContent'>";
19
-		print "			<div class='icon'><a href='".create_link("administration",$t['href'])."'><i class='fa $t[icon]'></i></a></div>";
20
-		print "			<div class='text'><a href='".create_link("administration",$t['href'])."'>"._($t['name'])."</a><hr><span class='text-muted'>"._($t['description'])."</span></div>";
19
+		print "			<div class='icon'><a href='".create_link ("administration", $t['href'])."'><i class='fa $t[icon]'></i></a></div>";
20
+		print "			<div class='text'><a href='".create_link ("administration", $t['href'])."'>"._ ($t['name'])."</a><hr><span class='text-muted'>"._ ($t['description'])."</span></div>";
21 21
 		print "		</div>";
22 22
 		print "	</div>";
23 23
 		print "	</div>";
Please login to merge, or discard this patch.
app/admin/scan-agents/edit.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -5,42 +5,42 @@  discard block
 block discarded – undo
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", "agent");
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
 	$agent = $Admin->fetch_object ("scanAgents", "id", $_POST['id']);
29 29
 	# null ?
30
-	$agent===false ? $Result->show("danger", _("Invalid ID"), true) : null;
30
+	$agent === false ? $Result->show ("danger", _ ("Invalid ID"), true) : null;
31 31
 	# title
32
-	$title =  ucwords($_POST['action']) .' '._('agent').' '.$agent->name;
32
+	$title = ucwords ($_POST['action']).' '._ ('agent').' '.$agent->name;
33 33
 } else {
34 34
 	# generate new code
35 35
 	$agent = new StdClass;
36
-	$agent->code = str_shuffle(md5(microtime()));
36
+	$agent->code = str_shuffle (md5 (microtime ()));
37 37
 	# title
38
-	$title = _('Create new scan agent');
38
+	$title = _ ('Create new scan agent');
39 39
 }
40 40
 
41 41
 # die if direct and delete
42
-if (@$agent->type=="direct" && $_POST['action']=="delete") {
43
-	$Result->show("danger", _("Cannot remove localhost scan agent"),true, true);
42
+if (@$agent->type == "direct" && $_POST['action'] == "delete") {
43
+	$Result->show ("danger", _ ("Cannot remove localhost scan agent"), true, true);
44 44
 }
45 45
 ?>
46 46
 
@@ -56,47 +56,47 @@  discard block
 block discarded – undo
56 56
 
57 57
 	<!-- name -->
58 58
 	<tr>
59
-	    <td><?php print _('Name'); ?></td>
59
+	    <td><?php print _ ('Name'); ?></td>
60 60
 	    <td>
61
-	    	<input type="text" name="name" class="form-control input-sm" value="<?php print @$agent->name; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>>
61
+	    	<input type="text" name="name" class="form-control input-sm" value="<?php print @$agent->name; ?>" <?php if ($_POST['action'] == "delete") print "readonly"; ?>>
62 62
 	        <input type="hidden" name="id" value="<?php print $agent->id; ?>">
63 63
     		<input type="hidden" name="action" value="<?php print $_POST['action']; ?>">
64 64
     		<input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>">
65 65
 	    </td>
66
-       	<td class="info2"><?php print _('Enter scan agent name'); ?></td>
66
+       	<td class="info2"><?php print _ ('Enter scan agent name'); ?></td>
67 67
     </tr>
68 68
 
69 69
 	<!-- description -->
70 70
 	<tr>
71
-	    <td><?php print _('Description'); ?></td>
72
-	    <td><input type="text" id="description" name="description" class="form-control input-sm"  value="<?php print @$agent->description; ?>"  <?php if($_POST['action'] == "delete") print "readonly"; ?>></td>
73
-       	<td class="info2"><?php print _('Agent description'); ?></td>
71
+	    <td><?php print _ ('Description'); ?></td>
72
+	    <td><input type="text" id="description" name="description" class="form-control input-sm"  value="<?php print @$agent->description; ?>"  <?php if ($_POST['action'] == "delete") print "readonly"; ?>></td>
73
+       	<td class="info2"><?php print _ ('Agent description'); ?></td>
74 74
     </tr>
75 75
 
76
-	<?php if(@$agent->type!=="direct") { ?>
76
+	<?php if (@$agent->type !== "direct") { ?>
77 77
 	<!-- code -->
78 78
 	<tr>
79
-	    <td><?php print _('Code'); ?></td>
80
-	    <td><input type="text" id="code" name="code" class="form-control input-sm"  value="<?php print @$agent->code; ?>"  maxlength='32' <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>></td>
81
-       	<td class="info2"><?php print _('Agent code'); ?><?php if(@$agent->type!="direct") { ?> <button class="btn btn-xs btn-default" id="regAgentKey"><i class="fa fa-random"></i> <?php print _('Regenerate'); ?></button><?php } ?></td>
79
+	    <td><?php print _ ('Code'); ?></td>
80
+	    <td><input type="text" id="code" name="code" class="form-control input-sm"  value="<?php print @$agent->code; ?>"  maxlength='32' <?php if (@$agent->type == "direct" || $_POST['action'] == "delete") print "readonly"; ?>></td>
81
+       	<td class="info2"><?php print _ ('Agent code'); ?><?php if (@$agent->type != "direct") { ?> <button class="btn btn-xs btn-default" id="regAgentKey"><i class="fa fa-random"></i> <?php print _ ('Regenerate'); ?></button><?php } ?></td>
82 82
     </tr>
83 83
 
84 84
 	<!-- type -->
85 85
 	<tr>
86
-	    <td><?php print _('Agent type'); ?></td>
86
+	    <td><?php print _ ('Agent type'); ?></td>
87 87
 	    <td>
88
-	    	<select name="type" class="form-control input-sm input-w-auto" <?php if(@$agent->type=="direct"||$_POST['action'] == "delete") print "readonly"; ?>>
88
+	    	<select name="type" class="form-control input-sm input-w-auto" <?php if (@$agent->type == "direct" || $_POST['action'] == "delete") print "readonly"; ?>>
89 89
 	    	<?php
90 90
 	    	//$types = array("mysql"=>"MySQL", "api"=>"Api");
91
-	    	$types = array("mysql"=>"MySQL");
91
+	    	$types = array ("mysql"=>"MySQL");
92 92
 
93
-	    	foreach($types as $k=>$p) {
94
-		    	if($k==$agent->type)	{ print "<option value='$k' selected='selected'>"._($p)."</option>"; }
95
-		    	else					{ print "<option value='$k' 				   >"._($p)."</option>"; }
93
+	    	foreach ($types as $k=>$p) {
94
+		    	if ($k == $agent->type) { print "<option value='$k' selected='selected'>"._ ($p)."</option>"; }
95
+		    	else { print "<option value='$k' 				   >"._ ($p)."</option>"; }
96 96
 	    	}
97 97
 	    	?>
98 98
 	    	</select>
99
-       	<td class="info2"><?php print _('Agent type'); ?></td>
99
+       	<td class="info2"><?php print _ ('Agent type'); ?></td>
100 100
     </tr>
101 101
     <?php } ?>
102 102
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 <!-- footer -->
110 110
 <div class="pFooter">
111 111
 	<div class="btn-group">
112
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
113
-		<button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="agentEditSubmit"><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>
112
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
113
+		<button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="agentEditSubmit"><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>
114 114
 	</div>
115 115
 	<!-- Result -->
116 116
 	<div class="agentEditResult"></div>
Please login to merge, or discard this patch.
app/admin/scan-agents/edit-result.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,60 +5,60 @@  discard block
 block discarded – undo
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
 # strip input tags
20
-$_POST = $Admin->strip_input_tags($_POST);
20
+$_POST = $Admin->strip_input_tags ($_POST);
21 21
 
22 22
 # validate csrf cookie
23
-$User->csrf_cookie ("validate", "agent", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
23
+$User->csrf_cookie ("validate", "agent", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : "";
24 24
 
25 25
 /* checks */
26
-$error = array();
26
+$error = array ();
27 27
 
28 28
 # for edit check old details
29
-if ($_POST['action']=="edit" || $_POST['action']=="delete") {
29
+if ($_POST['action'] == "edit" || $_POST['action'] == "delete") {
30 30
 	# old
31 31
 	$agent_old = $Admin->fetch_object ("scanAgents", "id", $_POST['id']);
32 32
 	// invalid id
33
-	if($agent_old===false)	{ $error[] = "Invalid agent Id"; }
33
+	if ($agent_old === false) { $error[] = "Invalid agent Id"; }
34 34
 	// remove type and code if direct
35
-	if (@$agent_old->type=="direct") {
35
+	if (@$agent_old->type == "direct") {
36 36
 		unset($_POST['type'], $_POST['code']);
37 37
 	}
38 38
 }
39 39
 
40 40
 # die if direct and delete
41
-if (@$agent_old->type=="direct" && $_POST['action']=="delete") {
42
-	$Result->show("danger", _("Cannot remove localhost scan agent"),true);
41
+if (@$agent_old->type == "direct" && $_POST['action'] == "delete") {
42
+	$Result->show ("danger", _ ("Cannot remove localhost scan agent"), true);
43 43
 }
44 44
 
45 45
 # checks for edit / add
46
-if($_POST['action']!="delete") {
46
+if ($_POST['action'] != "delete") {
47 47
 	# code must be exactly 32 chars long and alfanumeric if app_security = crypt
48
-	if(@$agent_old->type!="direct") {
49
-	if(strlen($_POST['code'])!=32 || !ctype_alnum($_POST['code']))		{ $error[] = "Invalid agent code"; }
48
+	if (@$agent_old->type != "direct") {
49
+	if (strlen ($_POST['code']) != 32 || !ctype_alnum ($_POST['code'])) { $error[] = "Invalid agent code"; }
50 50
 	}
51 51
 	# name must be more than 2 and alphanumberic
52
-	if(strlen($_POST['name'])==0)										{ $error[] = "Invalid agent name"; }
52
+	if (strlen ($_POST['name']) == 0) { $error[] = "Invalid agent name"; }
53 53
 }
54 54
 
55 55
 # die if errors
56
-if(sizeof($error) > 0) {
57
-	$Result->show("danger", $error, true);
56
+if (sizeof ($error) > 0) {
57
+	$Result->show ("danger", $error, true);
58 58
 }
59 59
 else {
60 60
 	# create array of values for modification
61
-	$values = array("id"=>@$_POST['id'],
61
+	$values = array ("id"=>@$_POST['id'],
62 62
 					"name"=>$_POST['name'],
63 63
 					"description"=>@$_POST['description'],
64 64
 					"code"=>@$_POST['code'],
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 	$values = $Admin->remove_empty_array_fields ($values);
69 69
 
70 70
 	# execute
71
-	if(!$Admin->object_modify("scanAgents", $_POST['action'], "id", $values)) 	{ $Result->show("danger",  _("Agent $_POST[action] error"), true); }
72
-	else 																		{ $Result->show("success", _("Agent $_POST[action] success"), false); }
71
+	if (!$Admin->object_modify ("scanAgents", $_POST['action'], "id", $values)) { $Result->show ("danger", _ ("Agent $_POST[action] error"), true); }
72
+	else { $Result->show ("success", _ ("Agent $_POST[action] success"), false); }
73 73
 
74 74
 	# delete - unset scanning in all subnets
75
-	if ($_POST['action']=="delete") {
75
+	if ($_POST['action'] == "delete") {
76 76
 		$query = "update `subnets` set `scanAgent`=0, `pingSubnet`=0, `discoverSubnet`=0 where `scanAgent` = ?;";
77 77
 
78
-		try { $Database->runQuery($query, array($_POST['id'])); }
78
+		try { $Database->runQuery ($query, array ($_POST['id'])); }
79 79
 		catch (Exception $e) {
80
-			$this->Result->show("danger", _("Error: ").$e->getMessage());
80
+			$this->Result->show ("danger", _ ("Error: ").$e->getMessage ());
81 81
 			return false;
82 82
 		}
83 83
 		// references removed
84
-		$this->Result->show("info", _("Scan agent references removed"));
84
+		$this->Result->show ("info", _ ("Scan agent references removed"));
85 85
 	}
86 86
 }
87 87
 
Please login to merge, or discard this patch.
app/admin/scan-agents/index.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,33 +5,33 @@  discard block
 block discarded – undo
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_agents = $Admin->fetch_all_objects("scanAgents");
11
+$all_agents = $Admin->fetch_all_objects ("scanAgents");
12 12
 ?>
13 13
 
14 14
 <!-- display existing groups -->
15
-<h4><?php print _('phpipam Scan agents'); ?></h4>
15
+<h4><?php print _ ('phpipam Scan agents'); ?></h4>
16 16
 <hr><br>
17 17
 
18 18
 <!-- Add new -->
19
-<button class='btn btn-sm btn-default editAgent' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _('Create new agent'); ?></button>
19
+<button class='btn btn-sm btn-default editAgent' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _ ('Create new agent'); ?></button>
20 20
 
21 21
 
22 22
 <?php
23 23
 /* print existing APIs */
24
-if($all_agents!==false) {
24
+if ($all_agents !== false) {
25 25
 
26 26
 	print '<table id="userPrint" class="table table-striped table-top table-auto">';
27 27
 	# headers
28 28
 	print '<tr>';
29
-    print "<th>"._('Agent id').'</th>';
30
-	print "<th>"._('Name').'</th>';
31
-    print "<th>"._('Description').'</th>';
32
-    print "<th>"._('Type').'</th>';
33
-    print "<th>"._('Code').'</th>';
34
-    print "<th>"._('Last access').'</th>';
29
+    print "<th>"._ ('Agent id').'</th>';
30
+	print "<th>"._ ('Name').'</th>';
31
+    print "<th>"._ ('Description').'</th>';
32
+    print "<th>"._ ('Type').'</th>';
33
+    print "<th>"._ ('Code').'</th>';
34
+    print "<th>"._ ('Last access').'</th>';
35 35
     print '<th></th>';
36 36
 	print '</tr>';
37 37
 
@@ -41,35 +41,35 @@  discard block
 block discarded – undo
41 41
 		$a = (array) $a;
42 42
 
43 43
 		// fixes
44
-		$a['code'] = strlen($a['code'])===0 ? "/" : $a['code'];
45
-		$a['last_access'] = strlen($a['last_access'])===0 ? "<span class='text-muted'>Never</span>" : $a['last_access'];
44
+		$a['code'] = strlen ($a['code']) === 0 ? "/" : $a['code'];
45
+		$a['last_access'] = strlen ($a['last_access']) === 0 ? "<span class='text-muted'>Never</span>" : $a['last_access'];
46 46
 
47 47
 		// print
48
-		print '<tr>' . "\n";
49
-		print '	<td>' . $a['id'] . '</td>'. "\n";
50
-		print '	<td>' . $a['name'] . '</td>'. "\n";
51
-		print '	<td>' . $a['description'] . '</td>'. "\n";
52
-		print '	<td>' . $a['type'] . '</td>'. "\n";
53
-		print '	<td>' . $a['code'] . '</td>'. "\n";
54
-		print '	<td>' . $a['last_access'] . '</td>'. "\n";
48
+		print '<tr>'."\n";
49
+		print '	<td>'.$a['id'].'</td>'."\n";
50
+		print '	<td>'.$a['name'].'</td>'."\n";
51
+		print '	<td>'.$a['description'].'</td>'."\n";
52
+		print '	<td>'.$a['type'].'</td>'."\n";
53
+		print '	<td>'.$a['code'].'</td>'."\n";
54
+		print '	<td>'.$a['last_access'].'</td>'."\n";
55 55
 
56 56
 		// add/remove agents
57 57
 		print "	<td class='actions'>";
58 58
 		print "	<div class='btn-group'>";
59
-		print "		<button class='btn btn-xs btn-default editAgent'  data-container='body' data-id='$a[id]' data-action='edit'   rel='tooltip' title='"._('edit agent details')."'>	<i class='fa fa-pencil'></i></button>";
60
-		print "		<button class='btn btn-xs btn-default editAgent'  data-container='body' data-id='$a[id]' data-action='delete' rel='tooltip' title='"._('remove agent')."'>		<i class='fa fa-times'></i></button>";
59
+		print "		<button class='btn btn-xs btn-default editAgent'  data-container='body' data-id='$a[id]' data-action='edit'   rel='tooltip' title='"._ ('edit agent details')."'>	<i class='fa fa-pencil'></i></button>";
60
+		print "		<button class='btn btn-xs btn-default editAgent'  data-container='body' data-id='$a[id]' data-action='delete' rel='tooltip' title='"._ ('remove agent')."'>		<i class='fa fa-times'></i></button>";
61 61
 		print "	</div>";
62 62
 		print "</td>";
63 63
 
64
-		print '</tr>' . "\n";
64
+		print '</tr>'."\n";
65 65
 	}
66 66
 	print "</table>";
67 67
 }
68 68
 else {
69
-	$Result->show("info alert-nomargin", _("No agents available")."!", false);
69
+	$Result->show ("info alert-nomargin", _ ("No agents available")."!", false);
70 70
 }
71 71
 ?>
72 72
 <hr>
73 73
 
74
-<h4><?php print _('phpipam-agent documentation'); ?></h4>
74
+<h4><?php print _ ('phpipam-agent documentation'); ?></h4>
75 75
 <a href="https://github.com/phpipam/phpipam-agent">https://github.com/phpipam/phpipam-agent</a>
Please login to merge, or discard this patch.
app/admin/groups/remove-users-result.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,55 +5,55 @@
 block discarded – undo
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
 
20 20
 # id must be numeric
21
-if(!is_numeric($_POST['gid']))		{ $Result->show("danger", _("Invalid ID"), true); }
21
+if (!is_numeric ($_POST['gid'])) { $Result->show ("danger", _ ("Invalid ID"), true); }
22 22
 
23 23
 # parse result
24
-foreach($_POST as $k=>$p) {
25
-	if(substr($k, 0,4) == "user") {
26
-		$users[substr($k, 4)] = substr($k, 4);
24
+foreach ($_POST as $k=>$p) {
25
+	if (substr ($k, 0, 4) == "user") {
26
+		$users[substr ($k, 4)] = substr ($k, 4);
27 27
 	}
28 28
 }
29 29
 
30 30
 # remove each user from group
31
-if(sizeof($users)>0) {
32
-	foreach($users as $key=>$u) {
33
-		if(!$Admin->remove_group_from_user($_POST['gid'], $u)) {
31
+if (sizeof ($users) > 0) {
32
+	foreach ($users as $key=>$u) {
33
+		if (!$Admin->remove_group_from_user ($_POST['gid'], $u)) {
34 34
 			# get user details
35
-			$user = $Admin->fetch_object("users", "id", $u);
35
+			$user = $Admin->fetch_object ("users", "id", $u);
36 36
 			$errors[] = $user->real_name;
37 37
 		}
38 38
 	}
39 39
 }
40 40
 else {
41
-	$errors[] = _("Please select user(s) to remove from group!");
41
+	$errors[] = _ ("Please select user(s) to remove from group!");
42 42
 }
43 43
 
44 44
 # print result
45
-if(isset($errors)) {
45
+if (isset($errors)) {
46 46
 	print "<div class='alert alert alert-danger'>";
47
-	print _("Failed to remove users").":<hr>";
47
+	print _ ("Failed to remove users").":<hr>";
48 48
 	print "<ul>";
49
-	foreach($errors as $e) {
49
+	foreach ($errors as $e) {
50 50
 		print "<li>$e</li>";
51 51
 	}
52 52
 	print "</ul>";
53 53
 	print "</div>";
54 54
 }
55 55
 else {
56
-	$Result->show("success", _('Users removed from group'), true);
56
+	$Result->show ("success", _ ('Users removed from group'), true);
57 57
 }
58 58
 
59 59
 ?>
60 60
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/groups/add-users.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,36 +5,36 @@  discard block
 block discarded – undo
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
 
20 20
 # id must be numeric
21
-if(!is_numeric($_POST['g_id']))		{ $Result->show("danger", _("Invalid ID"), true, true); }
21
+if (!is_numeric ($_POST['g_id'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); }
22 22
 
23 23
 # get group details
24
-$group   = $Admin->fetch_object("userGroups", "g_id", $_POST['g_id']);
24
+$group   = $Admin->fetch_object ("userGroups", "g_id", $_POST['g_id']);
25 25
 # not in group - array of ids
26 26
 $missing = $Admin->group_fetch_missing_users ($_POST['g_id']);
27 27
 ?>
28 28
 
29 29
 
30 30
 <!-- header -->
31
-<div class="pHeader"><?php print _('Add users to group'); ?> <?php print $group->g_name; ?></div>
31
+<div class="pHeader"><?php print _ ('Add users to group'); ?> <?php print $group->g_name; ?></div>
32 32
 
33 33
 
34 34
 <!-- content -->
35 35
 <div class="pContent">
36 36
 
37
-	<?php if(sizeof($missing) > 0) { ?>
37
+	<?php if (sizeof ($missing) > 0) { ?>
38 38
 
39 39
 	<form id="groupAddUsers" name="groupAddUsers">
40 40
 	<table class="groupEdit table table-condensed table-hover table-top">
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 		<th>
44 44
 			<input type="hidden" name="gid" value="<?php print $_POST['g_id']; ?>">
45 45
 		</th>
46
-		<th><?php print _('Name'); ?></th>
47
-		<th><?php print _('Username'); ?></th>
48
-		<th><?php print _('Email'); ?></th>
46
+		<th><?php print _ ('Name'); ?></th>
47
+		<th><?php print _ ('Username'); ?></th>
48
+		<th><?php print _ ('Email'); ?></th>
49 49
 	</tr>
50 50
 
51 51
 	<?php
52 52
 	# show missing
53
-	foreach($missing as $k=>$m) {
53
+	foreach ($missing as $k=>$m) {
54 54
 		# get user details
55
-		$u = (array) $Admin->fetch_object("users", "id", $m);
55
+		$u = (array) $Admin->fetch_object ("users", "id", $m);
56 56
 
57 57
 		print "<tr>";
58 58
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     </table>
72 72
     </form>
73 73
 
74
-    <?php } else { $Result->show("info", _('No available users to add to group'), false); } ?>
74
+    <?php } else { $Result->show ("info", _ ('No available users to add to group'), false); } ?>
75 75
 </div>
76 76
 
77 77
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 <div class="pFooter">
80 80
 	<div class="btn-group">
81 81
 		<button class="btn btn-sm btn-default hidePopups">Cancel</button>
82
-		<?php if(sizeof($missing) > 0) { ?>
82
+		<?php if (sizeof ($missing) > 0) { ?>
83 83
 		<button class="btn btn-sm btn-default btn-success" id="groupAddUsersSubmit"><i class="fa fa-plus"></i> Add selected users</button>
84 84
 		<?php } ?>
85 85
 	</div>
Please login to merge, or discard this patch.