Completed
Pull Request — master (#532)
06:37
created
app/admin/requests/index.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
 
38 38
 <tbody>
39 39
 <?php
40
-	# print requests
41
-	foreach($active_requests as $k=>$request) {
42
-		//cast
43
-		$request = (array) $request;
44
-
45
-		//get subnet details
46
-		$subnet = (array) $Subnets->fetch_subnet (null, $request['subnetId']);
47
-
48
-		//valid
49
-		if(sizeof($subnet)==0 || @$subnet[0]===false) {
50
-			unset($active_requests[$k]);
51
-		}
52
-		else {
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";
65
-		}
66
-	}
40
+    # print requests
41
+    foreach($active_requests as $k=>$request) {
42
+        //cast
43
+        $request = (array) $request;
44
+
45
+        //get subnet details
46
+        $subnet = (array) $Subnets->fetch_subnet (null, $request['subnetId']);
47
+
48
+        //valid
49
+        if(sizeof($subnet)==0 || @$subnet[0]===false) {
50
+            unset($active_requests[$k]);
51
+        }
52
+        else {
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";
65
+        }
66
+    }
67 67
 ?>
68 68
 </tbody>
69 69
 </table>
@@ -92,32 +92,32 @@  discard block
 block discarded – undo
92 92
 
93 93
 <tbody>
94 94
 <?php
95
-	# print requests
96
-	foreach($inactive_requests as $k=>$request) {
97
-		//cast
98
-		$request = (array) $request;
99
-
100
-		//get subnet details
101
-		$subnet = (array) $Subnets->fetch_subnet (null, $request['subnetId']);
102
-
103
-		//valid
104
-		if(sizeof($subnet)==0 || @$subnet[0]===false) {
105
-			unset($inactive_requests[$k]);
106
-		}
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";
115
-			print '	<td>';
116
-			print $request['accepted']==1 ? "Yes" : "No";
117
-			print '</td>'. "\n";
118
-			print '</tr>'. "\n";
119
-		}
120
-	}
95
+    # print requests
96
+    foreach($inactive_requests as $k=>$request) {
97
+        //cast
98
+        $request = (array) $request;
99
+
100
+        //get subnet details
101
+        $subnet = (array) $Subnets->fetch_subnet (null, $request['subnetId']);
102
+
103
+        //valid
104
+        if(sizeof($subnet)==0 || @$subnet[0]===false) {
105
+            unset($inactive_requests[$k]);
106
+        }
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";
115
+            print '	<td>';
116
+            print $request['accepted']==1 ? "Yes" : "No";
117
+            print '</td>'. "\n";
118
+            print '</tr>'. "\n";
119
+        }
120
+    }
121 121
 ?>
122 122
 </tbody>
123 123
 </table>
Please login to merge, or discard this 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 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
 # print
8 8
 foreach($admin_menu as $k=>$menu) {
9 9
 
10
-	# headers
11
-	print "<h4>"._($k)."</h4>";
12
-	print "<hr>";
10
+    # headers
11
+    print "<h4>"._($k)."</h4>";
12
+    print "<hr>";
13 13
 
14
-	# items
15
-	foreach($menu as $t) {
16
-		print "	<div class='col-xs-12 col-md-6 col-lg-6 widget-dash'>";
17
-		print "	<div class='inner thumbnail'>";
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>";
21
-		print "		</div>";
22
-		print "	</div>";
23
-		print "	</div>";
24
-	}
14
+    # items
15
+    foreach($menu as $t) {
16
+        print "	<div class='col-xs-12 col-md-6 col-lg-6 widget-dash'>";
17
+        print "	<div class='inner thumbnail'>";
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>";
21
+        print "		</div>";
22
+        print "	</div>";
23
+        print "	</div>";
24
+    }
25 25
 
26
-	# clear and break
27
-	print "<div class='clearfix'></div>";
26
+    # clear and break
27
+    print "<div class='clearfix'></div>";
28 28
 }
29 29
 ?>
30 30
 </div>
Please login to merge, or discard this 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/subnets/permissions-submit.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@
 block discarded – undo
24 24
 
25 25
 # get posted permissions
26 26
 foreach($_POST as $key=>$val) {
27
-	if(substr($key, 0,5) == "group") {
28
-		if($val != 0) {
29
-			$perm[substr($key,5)] = $val;
30
-		}
31
-	}
27
+    if(substr($key, 0,5) == "group") {
28
+        if($val != 0) {
29
+            $perm[substr($key,5)] = $val;
30
+        }
31
+    }
32 32
 }
33 33
 
34 34
 # set values and update
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,46 +5,46 @@
 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
-$Sections	= new Sections ($Database);
14
+$Sections = new Sections ($Database);
15 15
 $Subnets	= new Subnets ($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", "permissions", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
22
+$User->csrf_cookie ("validate", "permissions", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : "";
23 23
 
24 24
 
25 25
 # get posted permissions
26
-foreach($_POST as $key=>$val) {
27
-	if(substr($key, 0,5) == "group") {
28
-		if($val != 0) {
29
-			$perm[substr($key,5)] = $val;
26
+foreach ($_POST as $key=>$val) {
27
+	if (substr ($key, 0, 5) == "group") {
28
+		if ($val != 0) {
29
+			$perm[substr ($key, 5)] = $val;
30 30
 		}
31 31
 	}
32 32
 }
33 33
 
34 34
 # set values and update
35
-$permissions = isset($perm) ? array("permissions"=>json_encode($perm)) : array("permissions"=>"");
35
+$permissions = isset($perm) ? array ("permissions"=>json_encode ($perm)) : array ("permissions"=>"");
36 36
 
37 37
 # propagate ?
38
-if (@$_POST['set_inheritance']=="Yes") {
38
+if (@$_POST['set_inheritance'] == "Yes") {
39 39
     # fetch all possible slaves + master
40
-    $Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']);
40
+    $Subnets->fetch_subnet_slaves_recursive ($_POST['subnetId']);
41 41
     # update
42
-    if(!$Admin->object_modify("subnets", "edit-multiple", $Subnets->slaves, $permissions))	{ $Result->show("danger",  _("Failed to set subnet permissons")."!", true); }
43
-    else																					{ $Result->show("success", _("Subnet permissions set")."!", true); }
42
+    if (!$Admin->object_modify ("subnets", "edit-multiple", $Subnets->slaves, $permissions)) { $Result->show ("danger", _ ("Failed to set subnet permissons")."!", true); }
43
+    else { $Result->show ("success", _ ("Subnet permissions set")."!", true); }
44 44
 }
45 45
 else {
46
-    if(!$Admin->object_modify("subnets", "edit", "id", array_merge(array("id"=>$_POST['subnetId']), $permissions)))	{ $Result->show("danger",  _("Failed to set subnet permissons")."!", true); }
47
-    else																					                        { $Result->show("success", _("Subnet permissions set")."!", true); }
46
+    if (!$Admin->object_modify ("subnets", "edit", "id", array_merge (array ("id"=>$_POST['subnetId']), $permissions))) { $Result->show ("danger", _ ("Failed to set subnet permissons")."!", true); }
47
+    else { $Result->show ("success", _ ("Subnet permissions set")."!", true); }
48 48
 }
49 49
 
50 50
 ?>
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/subnets/permissions-show.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -63,52 +63,52 @@
 block discarded – undo
63 63
 <!-- content -->
64 64
 <div class="pContent">
65 65
 	<?php
66
-	if($subnet->isFolder==1)	{ print _('Manage permissions for folder')." $subnet->description"; }
67
-	else						{ print _('Manage permissions for subnet'); ?> <?php print $Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask." ($subnet->description)"; }
68
-	?>
66
+    if($subnet->isFolder==1)	{ print _('Manage permissions for folder')." $subnet->description"; }
67
+    else						{ print _('Manage permissions for subnet'); ?> <?php print $Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask." ($subnet->description)"; }
68
+    ?>
69 69
 	<hr>
70 70
 
71 71
 	<form id="editSubnetPermissions">
72 72
 	<table class="editSubnetPermissions table table-noborder table-condensed">
73 73
 
74 74
 	<?php
75
-	# parse permissions
76
-	if(strlen($subnet->permissions)>1) 	{ $permissons = $Sections->parse_section_permissions($subnet->permissions); }
77
-	else 								{ $permissons = ""; }
78
-
79
-	# print each group
80
-	if($groups) {
81
-		foreach($groups as $g) {
82
-			//cast
83
-			$g = (array) $g;
84
-
85
-			print "<tr>";
86
-			print "	<td>$g[g_name]</td>";
87
-			print "	<td>";
88
-
89
-			print "<span class='checkbox inline noborder'>";
90
-
91
-			print "	<input type='radio' name='group$g[g_id]' value='0' checked> na";
92
-			if(@$permissons[$g['g_id']]==1)	{ print " <input type='radio' name='group$g[g_id]' value='1' checked> ro"; }
93
-			else							{ print " <input type='radio' name='group$g[g_id]' value='1'> ro"; }
94
-			if(@$permissons[$g['g_id']]==2)	{ print " <input type='radio' name='group$g[g_id]' value='2' checked> rw"; }
95
-			else							{ print " <input type='radio' name='group$g[g_id]' value='2'> rw"; }
96
-			if(@$permissons[$g['g_id']]==3)	{ print " <input type='radio' name='group$g[g_id]' value='3' checked> rwa"; }
97
-			else							{ print " <input type='radio' name='group$g[g_id]' value='3'> rwa"; }
98
-			print "</span>";
99
-
100
-			# hidden
101
-			print "<input type='hidden' name='subnetId' value='$_POST[subnetId]'>";
102
-
103
-			print "	</td>";
104
-			print "</tr>";
105
-		}
106
-	} else {
107
-		print "<tr>";
108
-		print "	<td colspan='2'><span class='alert alert-info'>"._('No groups available')."</span></td>";
109
-		print "</tr>";
110
-	}
111
-	?>
75
+    # parse permissions
76
+    if(strlen($subnet->permissions)>1) 	{ $permissons = $Sections->parse_section_permissions($subnet->permissions); }
77
+    else 								{ $permissons = ""; }
78
+
79
+    # print each group
80
+    if($groups) {
81
+        foreach($groups as $g) {
82
+            //cast
83
+            $g = (array) $g;
84
+
85
+            print "<tr>";
86
+            print "	<td>$g[g_name]</td>";
87
+            print "	<td>";
88
+
89
+            print "<span class='checkbox inline noborder'>";
90
+
91
+            print "	<input type='radio' name='group$g[g_id]' value='0' checked> na";
92
+            if(@$permissons[$g['g_id']]==1)	{ print " <input type='radio' name='group$g[g_id]' value='1' checked> ro"; }
93
+            else							{ print " <input type='radio' name='group$g[g_id]' value='1'> ro"; }
94
+            if(@$permissons[$g['g_id']]==2)	{ print " <input type='radio' name='group$g[g_id]' value='2' checked> rw"; }
95
+            else							{ print " <input type='radio' name='group$g[g_id]' value='2'> rw"; }
96
+            if(@$permissons[$g['g_id']]==3)	{ print " <input type='radio' name='group$g[g_id]' value='3' checked> rwa"; }
97
+            else							{ print " <input type='radio' name='group$g[g_id]' value='3'> rwa"; }
98
+            print "</span>";
99
+
100
+            # hidden
101
+            print "<input type='hidden' name='subnetId' value='$_POST[subnetId]'>";
102
+
103
+            print "	</td>";
104
+            print "</tr>";
105
+        }
106
+    } else {
107
+        print "<tr>";
108
+        print "	<td colspan='2'><span class='alert alert-info'>"._('No groups available')."</span></td>";
109
+        print "</tr>";
110
+    }
111
+    ?>
112 112
 	<input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>">
113 113
 
114 114
     <!-- set parameters to slave subnets -->
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@
 block discarded – undo
53 53
 		$cfield = $extfields[$std_field]["field"];
54 54
 		$ctable = $extfields[$std_field]["table"];
55 55
 		$pname  = $extfields[$std_field]["pname"]." ";
56
-	} else {
56
+	}
57
+	else {
57 58
 		# default table and field
58 59
 		$cfield = $std_field;
59 60
 		$ctable = $mtable;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@  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
-$Sections	= new Sections ($Database);
14
+$Sections = new Sections ($Database);
15 15
 $Subnets	= new Subnets ($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
 # create csrf token
22 22
 $csrf = $User->csrf_cookie ("create", "permissions");
23 23
 
24 24
 
25 25
 # ID must be numeric
26
-if(!is_numeric($_POST['subnetId']))	{ $Result->show("danger", _("Invalid ID"), true, true); }
26
+if (!is_numeric ($_POST['subnetId'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); }
27 27
 
28 28
 # get all groups
29 29
 $groups = $Admin->fetch_all_objects ("userGroups", "g_id");
30 30
 # get subnet details
31
-$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
31
+$subnet = $Subnets->fetch_subnet (null, $_POST['subnetId']);
32 32
 ?>
33 33
 
34 34
 
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 
59 59
 
60 60
 <!-- header -->
61
-<div class="pHeader"><?php print $subnet->isFolder==1 ? _('Manage folder permissions') : _('Manage subnet permissions'); ?></div>
61
+<div class="pHeader"><?php print $subnet->isFolder == 1 ? _ ('Manage folder permissions') : _ ('Manage subnet permissions'); ?></div>
62 62
 
63 63
 <!-- content -->
64 64
 <div class="pContent">
65 65
 	<?php
66
-	if($subnet->isFolder==1)	{ print _('Manage permissions for folder')." $subnet->description"; }
67
-	else						{ print _('Manage permissions for subnet'); ?> <?php print $Subnets->transform_to_dotted($subnet->subnet)."/".$subnet->mask." ($subnet->description)"; }
66
+	if ($subnet->isFolder == 1) { print _ ('Manage permissions for folder')." $subnet->description"; }
67
+	else { print _ ('Manage permissions for subnet'); ?> <?php print $Subnets->transform_to_dotted ($subnet->subnet)."/".$subnet->mask." ($subnet->description)"; }
68 68
 	?>
69 69
 	<hr>
70 70
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
 	<?php
75 75
 	# parse permissions
76
-	if(strlen($subnet->permissions)>1) 	{ $permissons = $Sections->parse_section_permissions($subnet->permissions); }
77
-	else 								{ $permissons = ""; }
76
+	if (strlen ($subnet->permissions) > 1) { $permissons = $Sections->parse_section_permissions ($subnet->permissions); }
77
+	else { $permissons = ""; }
78 78
 
79 79
 	# print each group
80
-	if($groups) {
81
-		foreach($groups as $g) {
80
+	if ($groups) {
81
+		foreach ($groups as $g) {
82 82
 			//cast
83 83
 			$g = (array) $g;
84 84
 
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 			print "<span class='checkbox inline noborder'>";
90 90
 
91 91
 			print "	<input type='radio' name='group$g[g_id]' value='0' checked> na";
92
-			if(@$permissons[$g['g_id']]==1)	{ print " <input type='radio' name='group$g[g_id]' value='1' checked> ro"; }
93
-			else							{ print " <input type='radio' name='group$g[g_id]' value='1'> ro"; }
94
-			if(@$permissons[$g['g_id']]==2)	{ print " <input type='radio' name='group$g[g_id]' value='2' checked> rw"; }
95
-			else							{ print " <input type='radio' name='group$g[g_id]' value='2'> rw"; }
96
-			if(@$permissons[$g['g_id']]==3)	{ print " <input type='radio' name='group$g[g_id]' value='3' checked> rwa"; }
97
-			else							{ print " <input type='radio' name='group$g[g_id]' value='3'> rwa"; }
92
+			if (@$permissons[$g['g_id']] == 1) { print " <input type='radio' name='group$g[g_id]' value='1' checked> ro"; }
93
+			else { print " <input type='radio' name='group$g[g_id]' value='1'> ro"; }
94
+			if (@$permissons[$g['g_id']] == 2) { print " <input type='radio' name='group$g[g_id]' value='2' checked> rw"; }
95
+			else { print " <input type='radio' name='group$g[g_id]' value='2'> rw"; }
96
+			if (@$permissons[$g['g_id']] == 3) { print " <input type='radio' name='group$g[g_id]' value='3' checked> rwa"; }
97
+			else { print " <input type='radio' name='group$g[g_id]' value='3'> rwa"; }
98 98
 			print "</span>";
99 99
 
100 100
 			# hidden
@@ -105,26 +105,26 @@  discard block
 block discarded – undo
105 105
 		}
106 106
 	} else {
107 107
 		print "<tr>";
108
-		print "	<td colspan='2'><span class='alert alert-info'>"._('No groups available')."</span></td>";
108
+		print "	<td colspan='2'><span class='alert alert-info'>"._ ('No groups available')."</span></td>";
109 109
 		print "</tr>";
110 110
 	}
111 111
 	?>
112 112
 	<input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>">
113 113
 
114 114
     <!-- set parameters to slave subnets -->
115
-    <?php if($Subnets->has_slaves($_POST['subnetId'])) { ?>
115
+    <?php if ($Subnets->has_slaves ($_POST['subnetId'])) { ?>
116 116
     <tr>
117 117
         <td colspan="2" class="hr"><hr></td>
118 118
     </tr>
119 119
     <tr>
120
-        <td><?php print _('Propagate changes'); ?></td>
120
+        <td><?php print _ ('Propagate changes'); ?></td>
121 121
         <td>
122 122
             <input type="checkbox" name="set_inheritance" class="input-switch" value="Yes" checked="checked">
123 123
         </td>
124 124
     </tr>
125 125
     <tr class="warning2">
126 126
         <td colspan="2">
127
-        <?php $Result->show("info", _('Permissions for all nested subnets will be overridden')."!", false); ?>
127
+        <?php $Result->show ("info", _ ('Permissions for all nested subnets will be overridden')."!", false); ?>
128 128
         </td>
129 129
     </tr>
130 130
     <tr>
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 <!-- footer -->
142 142
 <div class="pFooter">
143 143
 	<div class="btn-group">
144
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
145
-		<button class="btn btn-sm btn-default btn-success editSubnetPermissionsSubmit"><i class="fa fa-check"></i> <?php print _('Set permissions'); ?></button>
144
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
145
+		<button class="btn btn-sm btn-default btn-success editSubnetPermissionsSubmit"><i class="fa fa-check"></i> <?php print _ ('Set permissions'); ?></button>
146 146
 	</div>
147 147
 
148 148
 	<div class="editSubnetPermissionsResult"></div>
Please login to merge, or discard this patch.
app/admin/subnets/edit-nameserver-dropdown.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@  discard block
 block discarded – undo
6 6
 
7 7
 /* required functions */
8 8
 if(!is_object($User)) {
9
-	/* functions */
10
-	require( dirname(__FILE__) . '/../../../functions/functions.php');
11
-
12
-	# initialize user object
13
-	$Database 	= new Database_PDO;
14
-	$User 		= new User ($Database);
15
-	$Tools	 	= new Tools ($Database);
16
-	$Sections	= new Sections ($Database);
17
-	$Result 	= new Result ();
9
+    /* functions */
10
+    require( dirname(__FILE__) . '/../../../functions/functions.php');
11
+
12
+    # initialize user object
13
+    $Database 	= new Database_PDO;
14
+    $User 		= new User ($Database);
15
+    $Tools	 	= new Tools ($Database);
16
+    $Sections	= new Sections ($Database);
17
+    $Result 	= new Result ();
18 18
 }
19 19
 
20 20
 # verify that user is logged in
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
 
29 29
 # Only parse nameserver if any exists
30 30
 if($permitted_nameservers != false) {
31
-	foreach($permitted_nameservers as $k=>$n) {
32
-		// fetch nameserver sets and append
33
-		$nameserver_set = $Tools->fetch_multiple_objects("nameservers", "id", $n, "name", "namesrv1");
34
-
35
-		//save to array
36
-		$nsout[$n] = $nameserver_set;
37
-
38
-		//count add
39
-		$cnt++;
40
-	}
41
-	//filter out empty
42
-	$permitted_nameservers = isset($nsout) ? array_filter($nsout) : false;
31
+    foreach($permitted_nameservers as $k=>$n) {
32
+        // fetch nameserver sets and append
33
+        $nameserver_set = $Tools->fetch_multiple_objects("nameservers", "id", $n, "name", "namesrv1");
34
+
35
+        //save to array
36
+        $nsout[$n] = $nameserver_set;
37
+
38
+        //count add
39
+        $cnt++;
40
+    }
41
+    //filter out empty
42
+    $permitted_nameservers = isset($nsout) ? array_filter($nsout) : false;
43 43
 }
44 44
 
45 45
 ?>
@@ -49,25 +49,25 @@  discard block
 block discarded – undo
49 49
 
50 50
 	<option value="0"><?php print _('No nameservers'); ?></option>
51 51
 	<?php
52
-	# print all available nameserver sets
53
-	if ($permitted_nameservers!==false) {
54
-		foreach($permitted_nameservers as $n) {
55
-
56
-			if($n[0]!==null) {
57
-				foreach($n as $ns) {
58
-					// set print
59
-					$printNS = "$ns->name";
60
-					$printNS .= " (" . array_shift(explode(";",$ns->namesrv1)).",...)";
61
-
62
-					/* selected? */
63
-					if(@$subnet_old_details['nameserverId']==$ns->id) 	{ print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; }
64
-					elseif(@$_POST['nameserverId'] == $ns->id) 			{ print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; }
65
-					else 												{ print '<option value="'. $ns->id .'">'. $printNS .'</option>'. "\n"; }
66
-				}
67
-			}
68
-		}
69
-	}
70
-	?>
52
+    # print all available nameserver sets
53
+    if ($permitted_nameservers!==false) {
54
+        foreach($permitted_nameservers as $n) {
55
+
56
+            if($n[0]!==null) {
57
+                foreach($n as $ns) {
58
+                    // set print
59
+                    $printNS = "$ns->name";
60
+                    $printNS .= " (" . array_shift(explode(";",$ns->namesrv1)).",...)";
61
+
62
+                    /* selected? */
63
+                    if(@$subnet_old_details['nameserverId']==$ns->id) 	{ print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; }
64
+                    elseif(@$_POST['nameserverId'] == $ns->id) 			{ print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; }
65
+                    else 												{ print '<option value="'. $ns->id .'">'. $printNS .'</option>'. "\n"; }
66
+                }
67
+            }
68
+        }
69
+    }
70
+    ?>
71 71
 	</optgroup>
72 72
 
73 73
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@  discard block
 block discarded – undo
5 5
  *******************************/
6 6
 
7 7
 /* required functions */
8
-if(!is_object($User)) {
8
+if (!is_object ($User)) {
9 9
 	/* functions */
10
-	require( dirname(__FILE__) . '/../../../functions/functions.php');
10
+	require(dirname (__FILE__).'/../../../functions/functions.php');
11 11
 
12 12
 	# initialize user object
13
-	$Database 	= new Database_PDO;
14
-	$User 		= new User ($Database);
13
+	$Database = new Database_PDO;
14
+	$User = new User ($Database);
15 15
 	$Tools	 	= new Tools ($Database);
16
-	$Sections	= new Sections ($Database);
16
+	$Sections = new Sections ($Database);
17 17
 	$Result 	= new Result ();
18 18
 }
19 19
 
20 20
 # verify that user is logged in
21
-$User->check_user_session();
21
+$User->check_user_session ();
22 22
 
23 23
 # fetch all permitted domains
24 24
 $permitted_nameservers = $Sections->fetch_section_nameserver_sets ($_POST['sectionId']);
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 $cnt = 0;
28 28
 
29 29
 # Only parse nameserver if any exists
30
-if($permitted_nameservers != false) {
31
-	foreach($permitted_nameservers as $k=>$n) {
30
+if ($permitted_nameservers != false) {
31
+	foreach ($permitted_nameservers as $k=>$n) {
32 32
 		// fetch nameserver sets and append
33
-		$nameserver_set = $Tools->fetch_multiple_objects("nameservers", "id", $n, "name", "namesrv1");
33
+		$nameserver_set = $Tools->fetch_multiple_objects ("nameservers", "id", $n, "name", "namesrv1");
34 34
 
35 35
 		//save to array
36 36
 		$nsout[$n] = $nameserver_set;
@@ -39,30 +39,30 @@  discard block
 block discarded – undo
39 39
 		$cnt++;
40 40
 	}
41 41
 	//filter out empty
42
-	$permitted_nameservers = isset($nsout) ? array_filter($nsout) : false;
42
+	$permitted_nameservers = isset($nsout) ? array_filter ($nsout) : false;
43 43
 }
44 44
 
45 45
 ?>
46 46
 
47 47
 <select name="nameserverId" class="form-control input-sm input-w-auto">
48
-	<optgroup label='<?php print _('Select nameserver set'); ?>'>
48
+	<optgroup label='<?php print _ ('Select nameserver set'); ?>'>
49 49
 
50
-	<option value="0"><?php print _('No nameservers'); ?></option>
50
+	<option value="0"><?php print _ ('No nameservers'); ?></option>
51 51
 	<?php
52 52
 	# print all available nameserver sets
53
-	if ($permitted_nameservers!==false) {
54
-		foreach($permitted_nameservers as $n) {
53
+	if ($permitted_nameservers !== false) {
54
+		foreach ($permitted_nameservers as $n) {
55 55
 
56
-			if($n[0]!==null) {
57
-				foreach($n as $ns) {
56
+			if ($n[0] !== null) {
57
+				foreach ($n as $ns) {
58 58
 					// set print
59 59
 					$printNS = "$ns->name";
60
-					$printNS .= " (" . array_shift(explode(";",$ns->namesrv1)).",...)";
60
+					$printNS .= " (".array_shift (explode (";", $ns->namesrv1)).",...)";
61 61
 
62 62
 					/* selected? */
63
-					if(@$subnet_old_details['nameserverId']==$ns->id) 	{ print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; }
64
-					elseif(@$_POST['nameserverId'] == $ns->id) 			{ print '<option value="'. $ns->id .'" selected>'. $printNS .'</option>'. "\n"; }
65
-					else 												{ print '<option value="'. $ns->id .'">'. $printNS .'</option>'. "\n"; }
63
+					if (@$subnet_old_details['nameserverId'] == $ns->id) { print '<option value="'.$ns->id.'" selected>'.$printNS.'</option>'."\n"; }
64
+					elseif (@$_POST['nameserverId'] == $ns->id) { print '<option value="'.$ns->id.'" selected>'.$printNS.'</option>'."\n"; }
65
+					else { print '<option value="'.$ns->id.'">'.$printNS.'</option>'."\n"; }
66 66
 				}
67 67
 			}
68 68
 		}
Please login to merge, or discard this patch.
app/admin/subnets/edit-vlan-dropdown.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@  discard block
 block discarded – undo
6 6
 
7 7
 /* required functions */
8 8
 if(!isset($User)) {
9
-	/* functions */
10
-	require( dirname(__FILE__) . '/../../../functions/functions.php');
9
+    /* functions */
10
+    require( dirname(__FILE__) . '/../../../functions/functions.php');
11 11
 
12
-	# initialize user object
13
-	$Database 	= new Database_PDO;
14
-	$User 		= new User ($Database);
15
-	$Tools	 	= new Tools ($Database);
16
-	$Sections	= new Sections ($Database);
17
-	$Result 	= new Result ();
12
+    # initialize user object
13
+    $Database 	= new Database_PDO;
14
+    $User 		= new User ($Database);
15
+    $Tools	 	= new Tools ($Database);
16
+    $Sections	= new Sections ($Database);
17
+    $Result 	= new Result ();
18 18
 }
19 19
 
20 20
 # verify that user is logged in
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 # fetch all belonging vlans
27 27
 $cnt = 0;
28 28
 foreach($permitted_domains as $k=>$d) {
29
-	//fetch domain
30
-	$domain = $Tools->fetch_object("vlanDomains","id",$d);
31
-	// fetch vlans and append
32
-	$vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "number");
33
-	//save to array
34
-	$out[$d]['domain'] = $domain;
35
-	$out[$d]['vlans']  = $vlans;
36
-	//count add
37
-	$cnt++;
29
+    //fetch domain
30
+    $domain = $Tools->fetch_object("vlanDomains","id",$d);
31
+    // fetch vlans and append
32
+    $vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "number");
33
+    //save to array
34
+    $out[$d]['domain'] = $domain;
35
+    $out[$d]['vlans']  = $vlans;
36
+    //count add
37
+    $cnt++;
38 38
 }
39 39
 //filter out empty
40 40
 $permitted_domains = array_filter($out);
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
 	<option disabled="disabled"><?php print _('Select VLAN'); ?>:</option>
45 45
 	<option value="0"><?php print _('No VLAN'); ?></option>
46 46
 	<?php
47
-	# print all available domains
48
-	foreach($permitted_domains as $d) {
49
-		//more than default
50
-			print "<optgroup label='".$d['domain']->name."'>";
51
-			//add
52
-			print "<option value='Add' data-domain='".$d['domain']->id."'>"._('+ Add new VLAN')."</option>";
47
+    # print all available domains
48
+    foreach($permitted_domains as $d) {
49
+        //more than default
50
+            print "<optgroup label='".$d['domain']->name."'>";
51
+            //add
52
+            print "<option value='Add' data-domain='".$d['domain']->id."'>"._('+ Add new VLAN')."</option>";
53 53
 
54
-			if($d['vlans'][0]!==null) {
55
-				foreach($d['vlans'] as $v) {
56
-					// set print
57
-					$printVLAN = $v->number;
58
-					if(!empty($v->name)) { $printVLAN .= " ($v->name)"; }
54
+            if($d['vlans'][0]!==null) {
55
+                foreach($d['vlans'] as $v) {
56
+                    // set print
57
+                    $printVLAN = $v->number;
58
+                    if(!empty($v->name)) { $printVLAN .= " ($v->name)"; }
59 59
 
60
-					/* selected? */
61
-					if(@$subnet_old_details['vlanId']==$v->vlanId) 	{ print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; }
62
-					elseif(@$_POST['vlanId'] == $v->vlanId) 	{ print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; }
63
-					else 										{ print '<option value="'. $v->vlanId .'">'. $printVLAN .'</option>'. "\n"; }
64
-				}
65
-			}
66
-			else {
67
-				print "<option value='0' disabled>"._('No VLANs')."</option>";
68
-			}
69
-			print "</optgroup>";
70
-	}
71
-	?>
60
+                    /* selected? */
61
+                    if(@$subnet_old_details['vlanId']==$v->vlanId) 	{ print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; }
62
+                    elseif(@$_POST['vlanId'] == $v->vlanId) 	{ print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; }
63
+                    else 										{ print '<option value="'. $v->vlanId .'">'. $printVLAN .'</option>'. "\n"; }
64
+                }
65
+            }
66
+            else {
67
+                print "<option value='0' disabled>"._('No VLANs')."</option>";
68
+            }
69
+            print "</optgroup>";
70
+    }
71
+    ?>
72 72
 </select>
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@  discard block
 block discarded – undo
5 5
  *******************************/
6 6
 
7 7
 /* required functions */
8
-if(!isset($User)) {
8
+if (!isset($User)) {
9 9
 	/* functions */
10
-	require( dirname(__FILE__) . '/../../../functions/functions.php');
10
+	require(dirname (__FILE__).'/../../../functions/functions.php');
11 11
 
12 12
 	# initialize user object
13
-	$Database 	= new Database_PDO;
14
-	$User 		= new User ($Database);
13
+	$Database = new Database_PDO;
14
+	$User = new User ($Database);
15 15
 	$Tools	 	= new Tools ($Database);
16
-	$Sections	= new Sections ($Database);
16
+	$Sections = new Sections ($Database);
17 17
 	$Result 	= new Result ();
18 18
 }
19 19
 
20 20
 # verify that user is logged in
21
-$User->check_user_session();
21
+$User->check_user_session ();
22 22
 
23 23
 # fetch all permitted domains
24 24
 $permitted_domains = $Sections->fetch_section_domains ($_POST['sectionId']);
25 25
 
26 26
 # fetch all belonging vlans
27 27
 $cnt = 0;
28
-foreach($permitted_domains as $k=>$d) {
28
+foreach ($permitted_domains as $k=>$d) {
29 29
 	//fetch domain
30
-	$domain = $Tools->fetch_object("vlanDomains","id",$d);
30
+	$domain = $Tools->fetch_object ("vlanDomains", "id", $d);
31 31
 	// fetch vlans and append
32
-	$vlans = $Tools->fetch_multiple_objects("vlans", "domainId", $domain->id, "number");
32
+	$vlans = $Tools->fetch_multiple_objects ("vlans", "domainId", $domain->id, "number");
33 33
 	//save to array
34 34
 	$out[$d]['domain'] = $domain;
35 35
 	$out[$d]['vlans']  = $vlans;
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
 	$cnt++;
38 38
 }
39 39
 //filter out empty
40
-$permitted_domains = array_filter($out);
40
+$permitted_domains = array_filter ($out);
41 41
 ?>
42 42
 
43 43
 <select name="vlanId" class="form-control input-sm input-w-auto">
44
-	<option disabled="disabled"><?php print _('Select VLAN'); ?>:</option>
45
-	<option value="0"><?php print _('No VLAN'); ?></option>
44
+	<option disabled="disabled"><?php print _ ('Select VLAN'); ?>:</option>
45
+	<option value="0"><?php print _ ('No VLAN'); ?></option>
46 46
 	<?php
47 47
 	# print all available domains
48
-	foreach($permitted_domains as $d) {
48
+	foreach ($permitted_domains as $d) {
49 49
 		//more than default
50 50
 			print "<optgroup label='".$d['domain']->name."'>";
51 51
 			//add
52
-			print "<option value='Add' data-domain='".$d['domain']->id."'>"._('+ Add new VLAN')."</option>";
52
+			print "<option value='Add' data-domain='".$d['domain']->id."'>"._ ('+ Add new VLAN')."</option>";
53 53
 
54
-			if($d['vlans'][0]!==null) {
55
-				foreach($d['vlans'] as $v) {
54
+			if ($d['vlans'][0] !== null) {
55
+				foreach ($d['vlans'] as $v) {
56 56
 					// set print
57 57
 					$printVLAN = $v->number;
58
-					if(!empty($v->name)) { $printVLAN .= " ($v->name)"; }
58
+					if (!empty($v->name)) { $printVLAN .= " ($v->name)"; }
59 59
 
60 60
 					/* selected? */
61
-					if(@$subnet_old_details['vlanId']==$v->vlanId) 	{ print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; }
62
-					elseif(@$_POST['vlanId'] == $v->vlanId) 	{ print '<option value="'. $v->vlanId .'" selected>'. $printVLAN .'</option>'. "\n"; }
63
-					else 										{ print '<option value="'. $v->vlanId .'">'. $printVLAN .'</option>'. "\n"; }
61
+					if (@$subnet_old_details['vlanId'] == $v->vlanId) { print '<option value="'.$v->vlanId.'" selected>'.$printVLAN.'</option>'."\n"; }
62
+					elseif (@$_POST['vlanId'] == $v->vlanId) { print '<option value="'.$v->vlanId.'" selected>'.$printVLAN.'</option>'."\n"; }
63
+					else { print '<option value="'.$v->vlanId.'">'.$printVLAN.'</option>'."\n"; }
64 64
 				}
65 65
 			}
66 66
 			else {
67
-				print "<option value='0' disabled>"._('No VLANs')."</option>";
67
+				print "<option value='0' disabled>"._ ('No VLANs')."</option>";
68 68
 			}
69 69
 			print "</optgroup>";
70 70
 	}
Please login to merge, or discard this patch.
app/admin/subnets/index.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -24,87 +24,87 @@
 block discarded – undo
24 24
 /* Foreach section fetch subnets and print it! */
25 25
 if(sizeof($sections) > 0) {
26 26
 
27
-	# print  table structure
28
-	print "<table id='manageSubnets' class='table sorted table-striped table-condensed table-top'>";
29
-
30
-	# headers
31
-	print "<thead>";
32
-	print "	<tr>";
33
-	print "	<th>"._('Subnet')."</th>";
34
-	print "	<th>"._('Description')."</th>";
35
-	print "	<th>"._('VLAN')."</th>";
36
-	if($User->settings->enableVRF == 1) {
37
-	print "	<th>"._('VRF')."</th>";
38
-	}
39
-	print "	<th>"._('Master Subnet')."</th>";
40
-	print "	<th>"._('Device')."</th>";
41
-	print "	<th class='hidden-xs hidden-sm'>"._('Requests')."</th>";
42
-
43
-	if(sizeof($custom_fields) > 0) {
44
-		foreach($custom_fields as $field) {
45
-			# hidden?
46
-			if(!in_array($field['name'], $hidden_custom_fields)) {
47
-				print "	<th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>";
48
-			}
49
-		}
50
-	}
51
-	# actions
52
-	print "<th class='actions' style='padding:0px;'></th>";
53
-	print "</tr>";
54
-	print "</thead>";
55
-
56
-
57
-	$m = 0;	//for subnet index
27
+    # print  table structure
28
+    print "<table id='manageSubnets' class='table sorted table-striped table-condensed table-top'>";
29
+
30
+    # headers
31
+    print "<thead>";
32
+    print "	<tr>";
33
+    print "	<th>"._('Subnet')."</th>";
34
+    print "	<th>"._('Description')."</th>";
35
+    print "	<th>"._('VLAN')."</th>";
36
+    if($User->settings->enableVRF == 1) {
37
+    print "	<th>"._('VRF')."</th>";
38
+    }
39
+    print "	<th>"._('Master Subnet')."</th>";
40
+    print "	<th>"._('Device')."</th>";
41
+    print "	<th class='hidden-xs hidden-sm'>"._('Requests')."</th>";
42
+
43
+    if(sizeof($custom_fields) > 0) {
44
+        foreach($custom_fields as $field) {
45
+            # hidden?
46
+            if(!in_array($field['name'], $hidden_custom_fields)) {
47
+                print "	<th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>";
48
+            }
49
+        }
50
+    }
51
+    # actions
52
+    print "<th class='actions' style='padding:0px;'></th>";
53
+    print "</tr>";
54
+    print "</thead>";
55
+
56
+
57
+    $m = 0;	//for subnet index
58 58
 
59 59
     print "<tbody>";
60
-	# print titles and content
61
-	if($sections!==false) {
62
-		foreach($sections as $section) {
63
-			//cast
64
-			$section = (array) $section;
65
-			# set colcount
66
-			$colCount = $User->settings->enableVRF==1 ? 10 : 9;
67
-
68
-			# just for count
69
-			if(sizeof($custom_fields) > 0) {
70
-				foreach($custom_fields as $field) {
71
-					if(!in_array($field['name'], $hidden_custom_fields)) {
72
-						$colCount++;
73
-					}
74
-				}
75
-			}
76
-
77
-			# print name
78
-			print "<tr class='subnet-title'>";
79
-			print "	<th colspan='$colCount'>";
80
-			print "		<h4> $section[name] </h4>";
81
-			print "	</th>";
82
-			print "</tr>";
83
-
84
-			# get all subnets in section
85
-			$section_subnets = $Subnets->fetch_section_subnets($section['id']);
86
-
87
-			# add new link
88
-			print "<tr>";
89
-			print "	<td colspan='$colCount'>";
90
-			print "		<button class='btn btn-sm btn-default editSubnet' data-action='add' data-sectionid='$section[id]' data-subnetId='' rel='tooltip' data-placement='right' title='"._('Add new subnet to section')." $section[name]'><i class='fa fa-plus'></i> "._('Add subnet')."</button>";
91
-			print "	</td>";
92
-			print "	</tr>";
93
-
94
-			# no subnets
95
-			if(sizeof($section_subnets) == 0) {
96
-				print "<tr><td colspan='$colCount'><div class='alert alert-info'>"._('Section has no subnets')."!</div></td></tr>";
97
-			}
98
-			else {
99
-				# subnets
100
-				$Subnets->print_subnets_tools($User->user, $section_subnets, $custom_fields);
101
-			}
102
-			$m++;
103
-		}
104
-	}
105
-	print "</tbody>";
106
-
107
-	# end master table
108
-	print "</table>";
60
+    # print titles and content
61
+    if($sections!==false) {
62
+        foreach($sections as $section) {
63
+            //cast
64
+            $section = (array) $section;
65
+            # set colcount
66
+            $colCount = $User->settings->enableVRF==1 ? 10 : 9;
67
+
68
+            # just for count
69
+            if(sizeof($custom_fields) > 0) {
70
+                foreach($custom_fields as $field) {
71
+                    if(!in_array($field['name'], $hidden_custom_fields)) {
72
+                        $colCount++;
73
+                    }
74
+                }
75
+            }
76
+
77
+            # print name
78
+            print "<tr class='subnet-title'>";
79
+            print "	<th colspan='$colCount'>";
80
+            print "		<h4> $section[name] </h4>";
81
+            print "	</th>";
82
+            print "</tr>";
83
+
84
+            # get all subnets in section
85
+            $section_subnets = $Subnets->fetch_section_subnets($section['id']);
86
+
87
+            # add new link
88
+            print "<tr>";
89
+            print "	<td colspan='$colCount'>";
90
+            print "		<button class='btn btn-sm btn-default editSubnet' data-action='add' data-sectionid='$section[id]' data-subnetId='' rel='tooltip' data-placement='right' title='"._('Add new subnet to section')." $section[name]'><i class='fa fa-plus'></i> "._('Add subnet')."</button>";
91
+            print "	</td>";
92
+            print "	</tr>";
93
+
94
+            # no subnets
95
+            if(sizeof($section_subnets) == 0) {
96
+                print "<tr><td colspan='$colCount'><div class='alert alert-info'>"._('Section has no subnets')."!</div></td></tr>";
97
+            }
98
+            else {
99
+                # subnets
100
+                $Subnets->print_subnets_tools($User->user, $section_subnets, $custom_fields);
101
+            }
102
+            $m++;
103
+        }
104
+    }
105
+    print "</tbody>";
106
+
107
+    # end master table
108
+    print "</table>";
109 109
 }
110 110
 ?>
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -5,24 +5,24 @@  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 custom fields
11
-$custom_fields = $Tools->fetch_custom_fields('subnets');
11
+$custom_fields = $Tools->fetch_custom_fields ('subnets');
12 12
 
13 13
 # fetch all sections
14
-$sections = $Sections->fetch_all_sections();
14
+$sections = $Sections->fetch_all_sections ();
15 15
 
16 16
 # set hidden fields
17
-$hidden_custom_fields = json_decode($User->settings->hiddenCustomFields, true);
18
-$hidden_custom_fields = is_array(@$hidden_custom_fields['subnets']) ? $hidden_custom_fields['subnets'] : array();
17
+$hidden_custom_fields = json_decode ($User->settings->hiddenCustomFields, true);
18
+$hidden_custom_fields = is_array (@$hidden_custom_fields['subnets']) ? $hidden_custom_fields['subnets'] : array ();
19 19
 
20 20
 # print all sections with delete / edit button
21
-print '<h4>'._('Subnet management').'</h4>';
21
+print '<h4>'._ ('Subnet management').'</h4>';
22 22
 print "<hr>";
23 23
 
24 24
 /* Foreach section fetch subnets and print it! */
25
-if(sizeof($sections) > 0) {
25
+if (sizeof ($sections) > 0) {
26 26
 
27 27
 	# print  table structure
28 28
 	print "<table id='manageSubnets' class='table sorted table-striped table-condensed table-top'>";
@@ -30,20 +30,20 @@  discard block
 block discarded – undo
30 30
 	# headers
31 31
 	print "<thead>";
32 32
 	print "	<tr>";
33
-	print "	<th>"._('Subnet')."</th>";
34
-	print "	<th>"._('Description')."</th>";
35
-	print "	<th>"._('VLAN')."</th>";
36
-	if($User->settings->enableVRF == 1) {
37
-	print "	<th>"._('VRF')."</th>";
33
+	print "	<th>"._ ('Subnet')."</th>";
34
+	print "	<th>"._ ('Description')."</th>";
35
+	print "	<th>"._ ('VLAN')."</th>";
36
+	if ($User->settings->enableVRF == 1) {
37
+	print "	<th>"._ ('VRF')."</th>";
38 38
 	}
39
-	print "	<th>"._('Master Subnet')."</th>";
40
-	print "	<th>"._('Device')."</th>";
41
-	print "	<th class='hidden-xs hidden-sm'>"._('Requests')."</th>";
39
+	print "	<th>"._ ('Master Subnet')."</th>";
40
+	print "	<th>"._ ('Device')."</th>";
41
+	print "	<th class='hidden-xs hidden-sm'>"._ ('Requests')."</th>";
42 42
 
43
-	if(sizeof($custom_fields) > 0) {
44
-		foreach($custom_fields as $field) {
43
+	if (sizeof ($custom_fields) > 0) {
44
+		foreach ($custom_fields as $field) {
45 45
 			# hidden?
46
-			if(!in_array($field['name'], $hidden_custom_fields)) {
46
+			if (!in_array ($field['name'], $hidden_custom_fields)) {
47 47
 				print "	<th class='hidden-xs hidden-sm hidden-md'>$field[name]</th>";
48 48
 			}
49 49
 		}
@@ -54,21 +54,21 @@  discard block
 block discarded – undo
54 54
 	print "</thead>";
55 55
 
56 56
 
57
-	$m = 0;	//for subnet index
57
+	$m = 0; //for subnet index
58 58
 
59 59
     print "<tbody>";
60 60
 	# print titles and content
61
-	if($sections!==false) {
62
-		foreach($sections as $section) {
61
+	if ($sections !== false) {
62
+		foreach ($sections as $section) {
63 63
 			//cast
64 64
 			$section = (array) $section;
65 65
 			# set colcount
66
-			$colCount = $User->settings->enableVRF==1 ? 10 : 9;
66
+			$colCount = $User->settings->enableVRF == 1 ? 10 : 9;
67 67
 
68 68
 			# just for count
69
-			if(sizeof($custom_fields) > 0) {
70
-				foreach($custom_fields as $field) {
71
-					if(!in_array($field['name'], $hidden_custom_fields)) {
69
+			if (sizeof ($custom_fields) > 0) {
70
+				foreach ($custom_fields as $field) {
71
+					if (!in_array ($field['name'], $hidden_custom_fields)) {
72 72
 						$colCount++;
73 73
 					}
74 74
 				}
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
 			print "</tr>";
83 83
 
84 84
 			# get all subnets in section
85
-			$section_subnets = $Subnets->fetch_section_subnets($section['id']);
85
+			$section_subnets = $Subnets->fetch_section_subnets ($section['id']);
86 86
 
87 87
 			# add new link
88 88
 			print "<tr>";
89 89
 			print "	<td colspan='$colCount'>";
90
-			print "		<button class='btn btn-sm btn-default editSubnet' data-action='add' data-sectionid='$section[id]' data-subnetId='' rel='tooltip' data-placement='right' title='"._('Add new subnet to section')." $section[name]'><i class='fa fa-plus'></i> "._('Add subnet')."</button>";
90
+			print "		<button class='btn btn-sm btn-default editSubnet' data-action='add' data-sectionid='$section[id]' data-subnetId='' rel='tooltip' data-placement='right' title='"._ ('Add new subnet to section')." $section[name]'><i class='fa fa-plus'></i> "._ ('Add subnet')."</button>";
91 91
 			print "	</td>";
92 92
 			print "	</tr>";
93 93
 
94 94
 			# no subnets
95
-			if(sizeof($section_subnets) == 0) {
96
-				print "<tr><td colspan='$colCount'><div class='alert alert-info'>"._('Section has no subnets')."!</div></td></tr>";
95
+			if (sizeof ($section_subnets) == 0) {
96
+				print "<tr><td colspan='$colCount'><div class='alert alert-info'>"._ ('Section has no subnets')."!</div></td></tr>";
97 97
 			}
98 98
 			else {
99 99
 				# subnets
100
-				$Subnets->print_subnets_tools($User->user, $section_subnets, $custom_fields);
100
+				$Subnets->print_subnets_tools ($User->user, $section_subnets, $custom_fields);
101 101
 			}
102 102
 			$m++;
103 103
 		}
Please login to merge, or discard this patch.
app/admin/subnets/split.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
 
47 47
 //set mask options
48 48
 for($mask=($subnet->mask+1); $mask<=$max_new_mask; $mask++) {
49
-	# set vars
50
-	$opts[$m]['mask']   = $mask;
51
-	$opts[$m]['number'] = $n;
52
-	$opts[$m]['max']    = $Subnets->get_max_hosts ($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)));
53
-
54
-	# next
55
-	$m++;
56
-	$n = $n * 2;
57
-
58
-	# max number = 16!
59
-	if($n > 256) {
60
-		$mask = 1000;
61
-	}
49
+    # set vars
50
+    $opts[$m]['mask']   = $mask;
51
+    $opts[$m]['number'] = $n;
52
+    $opts[$m]['max']    = $Subnets->get_max_hosts ($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)));
53
+
54
+    # next
55
+    $m++;
56
+    $n = $n * 2;
57
+
58
+    # max number = 16!
59
+    if($n > 256) {
60
+        $mask = 1000;
61
+    }
62 62
 }
63 63
 ?>
64 64
 
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
         <td style="vertical-align:middle">
85 85
 	    	<select name="number" class="form-control input-sm input-w-auto">
86 86
 	    	<?php
87
-	    	foreach($opts as $line) {
88
-		    	print "<option value='$line[number]'>$line[number]x /$line[mask] subnet ($line[number]x $line[max] hosts)</option>";
89
-	    	}
90
-	    	?>
87
+            foreach($opts as $line) {
88
+                print "<option value='$line[number]'>$line[number]x /$line[mask] subnet ($line[number]x $line[max] hosts)</option>";
89
+            }
90
+            ?>
91 91
 	    	</select>
92 92
 	    	<input type="hidden" name="subnetId" value="<?php print $subnet->id; ?>">
93 93
 	    	<input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>">
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -5,65 +5,65 @@  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, false);
14 14
 $Subnets	= new Subnets ($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", "split");
22 22
 
23 23
 
24 24
 # ID must be numeric
25
-if(!is_numeric($_POST['subnetId']))		{ $Result->show("danger", _("Invalid ID"), true, true); }
25
+if (!is_numeric ($_POST['subnetId'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); }
26 26
 
27 27
 # get subnet details
28 28
 $subnet = $Subnets->fetch_subnet (null, $_POST['subnetId']);
29 29
 
30 30
 # verify that user has write permissions for subnet
31 31
 $subnetPerm = $Subnets->check_permission ($User->user, $subnet->id);
32
-if($subnetPerm < 3) 					{ $Result->show("danger", _('You do not have permissions to resize subnet').'!', true, true); }
32
+if ($subnetPerm < 3) { $Result->show ("danger", _ ('You do not have permissions to resize subnet').'!', true, true); }
33 33
 
34 34
 # check if it has slaves - if yes it cannot be splitted!
35
-if($Subnets->has_slaves($subnet->id))	{ $Result->show("danger", _('Only subnets that have no nested subnets can be splitted')."!", true, true); }
35
+if ($Subnets->has_slaves ($subnet->id)) { $Result->show ("danger", _ ('Only subnets that have no nested subnets can be splitted')."!", true, true); }
36 36
 
37 37
 # calculate max mask
38
-$max_new_mask = $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet))=="IPv4" ? 32 : 128;
38
+$max_new_mask = $Subnets->identify_address ($Subnets->transform_to_dotted ($subnet->subnet)) == "IPv4" ? 32 : 128;
39 39
 
40 40
 
41 41
 # die if too small
42
-if($max_new_mask < $subnet->mask)		{ $Result->show("danger", _("Subnet too small to be splitted"), true, true); }
42
+if ($max_new_mask < $subnet->mask) { $Result->show ("danger", _ ("Subnet too small to be splitted"), true, true); }
43 43
 
44
-$n = 2;		# step
45
-$m = 0;		# array id
44
+$n = 2; # step
45
+$m = 0; # array id
46 46
 
47 47
 //set mask options
48
-for($mask=($subnet->mask+1); $mask<=$max_new_mask; $mask++) {
48
+for ($mask = ($subnet->mask + 1); $mask <= $max_new_mask; $mask++) {
49 49
 	# set vars
50 50
 	$opts[$m]['mask']   = $mask;
51 51
 	$opts[$m]['number'] = $n;
52
-	$opts[$m]['max']    = $Subnets->get_max_hosts ($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)));
52
+	$opts[$m]['max']    = $Subnets->get_max_hosts ($mask, $Subnets->identify_address ($Subnets->transform_to_dotted ($subnet->subnet)));
53 53
 
54 54
 	# next
55 55
 	$m++;
56 56
 	$n = $n * 2;
57 57
 
58 58
 	# max number = 16!
59
-	if($n > 256) {
59
+	if ($n > 256) {
60 60
 		$mask = 1000;
61 61
 	}
62 62
 }
63 63
 ?>
64 64
 
65 65
 <!-- header -->
66
-<div class="pHeader"><?php print _('Split subnet'); ?></div>
66
+<div class="pHeader"><?php print _ ('Split subnet'); ?></div>
67 67
 
68 68
 
69 69
 <!-- content -->
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
 
75 75
     <!-- subnet -->
76 76
     <tr>
77
-        <td class="middle"><?php print _('Subnet'); ?></td>
78
-        <td><?php print $Subnets->transform_to_dotted($subnet->subnet) . "/$subnet->mask ($subnet->description)"; ?></td>
77
+        <td class="middle"><?php print _ ('Subnet'); ?></td>
78
+        <td><?php print $Subnets->transform_to_dotted ($subnet->subnet)."/$subnet->mask ($subnet->description)"; ?></td>
79 79
     </tr>
80 80
 
81 81
     <!-- number of new subnets -->
82 82
     <tr>
83
-        <td class="middle"><?php print _('Number of subnets'); ?></td>
83
+        <td class="middle"><?php print _ ('Number of subnets'); ?></td>
84 84
         <td style="vertical-align:middle">
85 85
 	    	<select name="number" class="form-control input-sm input-w-auto">
86 86
 	    	<?php
87
-	    	foreach($opts as $line) {
87
+	    	foreach ($opts as $line) {
88 88
 		    	print "<option value='$line[number]'>$line[number]x /$line[mask] subnet ($line[number]x $line[max] hosts)</option>";
89 89
 	    	}
90 90
 	    	?>
@@ -96,18 +96,18 @@  discard block
 block discarded – undo
96 96
 
97 97
     <!-- Group under current -->
98 98
     <tr>
99
-        <td class="middle"><?php print _('Group under current'); ?></td>
99
+        <td class="middle"><?php print _ ('Group under current'); ?></td>
100 100
         <td>
101 101
 	        <select name="group" class="form-control input-sm input-w-auto">
102
-	        	<option value="yes"><?php print _('Yes'); ?></option>
103
-	        	<option value="no" ><?php print _('No'); ?></option>
102
+	        	<option value="yes"><?php print _ ('Yes'); ?></option>
103
+	        	<option value="no" ><?php print _ ('No'); ?></option>
104 104
 	        </select>
105 105
         </td>
106 106
     </tr>
107 107
 
108 108
     <!-- strict mode -->
109 109
     <tr>
110
-    	<td><?php print _('Strict mode'); ?></td>
110
+    	<td><?php print _ ('Strict mode'); ?></td>
111 111
     	<td>
112 112
 	    	<input type="checkbox" name="strict" value="yes" checked="checked">
113 113
     	</td>
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
     <!-- Prefix -->
117 117
     <tr>
118
-    	<td><?php print _('Name prefix'); ?></td>
118
+    	<td><?php print _ ('Name prefix'); ?></td>
119 119
     	<td>
120 120
 	    	<input type="text" name="prefix" value="<?php print $subnet->description."_"; ?>">
121 121
     	</td>
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
     <!-- warning -->
128 128
     <div class="alert alert-warning">
129
-    <?php print _('You can split subnet to smaller subnets by specifying new subnets. Please note:'); ?>
129
+    <?php print _ ('You can split subnet to smaller subnets by specifying new subnets. Please note:'); ?>
130 130
     <ul>
131
-    	<li><?php print _('Existing IP addresses will be assigned to new subnets'); ?></li>
132
-    	<li><?php print _('Group under current will create new nested subnets under current one'); ?></li>
133
-    	<li><?php print _('If existing IP will fall to subnet/broadcast of new subnets split will fail, except if strict mode is disabled'); ?></li>
131
+    	<li><?php print _ ('Existing IP addresses will be assigned to new subnets'); ?></li>
132
+    	<li><?php print _ ('Group under current will create new nested subnets under current one'); ?></li>
133
+    	<li><?php print _ ('If existing IP will fall to subnet/broadcast of new subnets split will fail, except if strict mode is disabled'); ?></li>
134 134
     </ul>
135 135
     </div>
136 136
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 <!-- footer -->
141 141
 <div class="pFooter">
142 142
 	<div class="btn-group">
143
-		<button class="btn btn-sm btn-default hidePopup2"><?php print _('Cancel'); ?></button>
144
-		<button class="btn btn-sm btn-default btn-success" id="subnetSplitSubmit"><i class="fa fa-ok"></i> <?php print _('Split subnet'); ?></button>
143
+		<button class="btn btn-sm btn-default hidePopup2"><?php print _ ('Cancel'); ?></button>
144
+		<button class="btn btn-sm btn-default btn-success" id="subnetSplitSubmit"><i class="fa fa-ok"></i> <?php print _ ('Split subnet'); ?></button>
145 145
 	</div>
146 146
 
147 147
 	<div class="subnetSplitResult"></div>
Please login to merge, or discard this patch.
app/admin/subnets/edit-folder.php 3 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 
25 25
 # ID must be numeric
26 26
 if($_POST['action']!="add") {
27
-	if(!is_numeric($_POST['subnetId']))										{ $Result->show("danger", _("Invalid ID"), true, true); }
27
+    if(!is_numeric($_POST['subnetId']))										{ $Result->show("danger", _("Invalid ID"), true, true); }
28 28
 }
29 29
 
30 30
 # verify that user has permissions to add subnet
31 31
 if($_POST['action'] == "add") {
32
-	if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); }
32
+    if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); }
33 33
 }
34 34
 # otherwise check subnet permission
35 35
 else {
36
-	if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) 	{ $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); }
36
+    if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) 	{ $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); }
37 37
 }
38 38
 
39 39
 
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 }
44 44
 # we are adding new folder - get folder details
45 45
 else {
46
-	# for selecting master subnet if added from subnet details!
47
-	if(strlen($_POST['subnetId']) > 0) {
48
-    	$subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
49
-    	$subnet_old_details['masterSubnetId'] 	= @$subnet_old_temp['id'];			// same master subnet ID for nested
50
-    	$subnet_old_details['vlanId'] 		 	= @$subnet_old_temp['vlanId'];		// same default vlan for nested
51
-    	$subnet_old_details['vrfId'] 		 	= @$subnet_old_temp['vrfId'];		// same default vrf for nested
52
-	}
46
+    # for selecting master subnet if added from subnet details!
47
+    if(strlen($_POST['subnetId']) > 0) {
48
+        $subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
49
+        $subnet_old_details['masterSubnetId'] 	= @$subnet_old_temp['id'];			// same master subnet ID for nested
50
+        $subnet_old_details['vlanId'] 		 	= @$subnet_old_temp['vlanId'];		// same default vlan for nested
51
+        $subnet_old_details['vrfId'] 		 	= @$subnet_old_temp['vrfId'];		// same default vrf for nested
52
+    }
53 53
 }
54 54
 
55 55
 # fetch custom fields
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
         <td>
91 91
         	<select name="sectionIdNew" class="form-control input-sm input-w-auto">
92 92
             	<?php
93
-	            if($sections!==false) {
94
-	            	foreach($sections as $section) {
95
-	            		/* selected? */
96
-	            		if($_POST['sectionId'] == $section->id)  { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; }
97
-	            		else 									 { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; }
98
-	            	}
99
-            	}
100
-            	?>
93
+                if($sections!==false) {
94
+                    foreach($sections as $section) {
95
+                        /* selected? */
96
+                        if($_POST['sectionId'] == $section->id)  { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; }
97
+                        else 									 { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; }
98
+                    }
99
+                }
100
+                ?>
101 101
             </select>
102 102
 
103 103
         	</select>
@@ -124,100 +124,100 @@  discard block
 block discarded – undo
124 124
 	<input type="hidden" name="csrf_cookie"     value="<?php print $csrf; ?>">
125 125
 
126 126
     <?php
127
-    	# custom Subnet fields
128
-	    if(sizeof($custom_fields) > 0) {
129
-	    	# count datepickers
130
-			$timeP = 0;
131
-
132
-	    	print "<tr>";
133
-	    	print "	<td colspan='3' class='hr'><hr></td>";
134
-	    	print "</tr>";
135
-		    foreach($custom_fields as $field) {
136
-
137
-		    	# replace spaces
138
-		    	$field['nameNew'] = str_replace(" ", "___", $field['name']);
139
-		    	# retain newlines
140
-		    	$folder_old_details[$field['name']] = str_replace("\n", "\\n", @$folder_old_details[$field['name']]);
141
-
142
-				# set default value !
143
-				if ($_POST['action']=="add"){ $folder_old_details[$field['name']] = $field['Default']; }
144
-
145
-		    	# required
146
-				if($field['Null']=="NO")	{ $required = "*"; }
147
-				else						{ $required = ""; }
148
-
149
-				print '<tr>'. "\n";
150
-				print '	<td>'. $field['name'] .' '.$required.'</td>'. "\n";
151
-				print '	<td colspan="2">'. "\n";
152
-
153
-				//set type
154
-				if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") {
155
-					//parse values
156
-					$tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type']));
157
-
158
-					//null
159
-					if($field['Null']!="NO") { array_unshift($tmp, ""); }
160
-
161
-					print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
162
-					foreach($tmp as $v) {
163
-						if($v==$folder_old_details[$field['name']])	{ print "<option value='$v' selected='selected'>$v</option>"; }
164
-						else								{ print "<option value='$v'>$v</option>"; }
165
-					}
166
-					print "</select>";
167
-				}
168
-				//date and time picker
169
-				elseif($field['type'] == "date" || $field['type'] == "datetime") {
170
-					// just for first
171
-					if($timeP==0) {
172
-						print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">';
173
-						print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>';
174
-						print '<script type="text/javascript">';
175
-						print '$(document).ready(function() {';
176
-						//date only
177
-						print '	$(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });';
178
-						//date + time
179
-						print '	$(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );';
180
-
181
-						print '})';
182
-						print '</script>';
183
-					}
184
-					$timeP++;
185
-
186
-					//set size
187
-					if($field['type'] == "date")	{ $size = 10; $class='datepicker';		$format = "yyyy-MM-dd"; }
188
-					else							{ $size = 19; $class='datetimepicker';	$format = "yyyy-MM-dd"; }
189
-
190
-					//field
191
-					if(!isset($folder_old_details[$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"; }
192
-					else										{ print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $folder_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; }
193
-				}
194
-				//boolean
195
-				elseif($field['type'] == "tinyint(1)") {
196
-					print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
197
-					$tmp = array(0=>"No",1=>"Yes");
198
-					//null
199
-					if($field['Null']!="NO") { $tmp[2] = ""; }
200
-
201
-					foreach($tmp as $k=>$v) {
202
-						if(strlen($folder_old_details[$field['name']])==0 && $k==2)	{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
203
-						elseif($k==$folder_old_details[$field['name']])				{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
204
-						else													{ print "<option value='$k'>"._($v)."</option>"; }
205
-					}
206
-					print "</select>";
207
-				}
208
-				//text
209
-				elseif($field['type'] == "text") {
210
-					print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$folder_old_details[$field['name']]). '</textarea>'. "\n";
211
-				}
212
-				//default - input field
213
-				else {
214
-					print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $folder_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n";
215
-				}
216
-
217
-				print '	</td>'. "\n";
218
-				print '</tr>'. "\n";
219
-		    }
220
-	    }
127
+        # custom Subnet fields
128
+        if(sizeof($custom_fields) > 0) {
129
+            # count datepickers
130
+            $timeP = 0;
131
+
132
+            print "<tr>";
133
+            print "	<td colspan='3' class='hr'><hr></td>";
134
+            print "</tr>";
135
+            foreach($custom_fields as $field) {
136
+
137
+                # replace spaces
138
+                $field['nameNew'] = str_replace(" ", "___", $field['name']);
139
+                # retain newlines
140
+                $folder_old_details[$field['name']] = str_replace("\n", "\\n", @$folder_old_details[$field['name']]);
141
+
142
+                # set default value !
143
+                if ($_POST['action']=="add"){ $folder_old_details[$field['name']] = $field['Default']; }
144
+
145
+                # required
146
+                if($field['Null']=="NO")	{ $required = "*"; }
147
+                else						{ $required = ""; }
148
+
149
+                print '<tr>'. "\n";
150
+                print '	<td>'. $field['name'] .' '.$required.'</td>'. "\n";
151
+                print '	<td colspan="2">'. "\n";
152
+
153
+                //set type
154
+                if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") {
155
+                    //parse values
156
+                    $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type']));
157
+
158
+                    //null
159
+                    if($field['Null']!="NO") { array_unshift($tmp, ""); }
160
+
161
+                    print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
162
+                    foreach($tmp as $v) {
163
+                        if($v==$folder_old_details[$field['name']])	{ print "<option value='$v' selected='selected'>$v</option>"; }
164
+                        else								{ print "<option value='$v'>$v</option>"; }
165
+                    }
166
+                    print "</select>";
167
+                }
168
+                //date and time picker
169
+                elseif($field['type'] == "date" || $field['type'] == "datetime") {
170
+                    // just for first
171
+                    if($timeP==0) {
172
+                        print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">';
173
+                        print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>';
174
+                        print '<script type="text/javascript">';
175
+                        print '$(document).ready(function() {';
176
+                        //date only
177
+                        print '	$(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });';
178
+                        //date + time
179
+                        print '	$(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );';
180
+
181
+                        print '})';
182
+                        print '</script>';
183
+                    }
184
+                    $timeP++;
185
+
186
+                    //set size
187
+                    if($field['type'] == "date")	{ $size = 10; $class='datepicker';		$format = "yyyy-MM-dd"; }
188
+                    else							{ $size = 19; $class='datetimepicker';	$format = "yyyy-MM-dd"; }
189
+
190
+                    //field
191
+                    if(!isset($folder_old_details[$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"; }
192
+                    else										{ print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $folder_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; }
193
+                }
194
+                //boolean
195
+                elseif($field['type'] == "tinyint(1)") {
196
+                    print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
197
+                    $tmp = array(0=>"No",1=>"Yes");
198
+                    //null
199
+                    if($field['Null']!="NO") { $tmp[2] = ""; }
200
+
201
+                    foreach($tmp as $k=>$v) {
202
+                        if(strlen($folder_old_details[$field['name']])==0 && $k==2)	{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
203
+                        elseif($k==$folder_old_details[$field['name']])				{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
204
+                        else													{ print "<option value='$k'>"._($v)."</option>"; }
205
+                    }
206
+                    print "</select>";
207
+                }
208
+                //text
209
+                elseif($field['type'] == "text") {
210
+                    print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$folder_old_details[$field['name']]). '</textarea>'. "\n";
211
+                }
212
+                //default - input field
213
+                else {
214
+                    print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $folder_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n";
215
+                }
216
+
217
+                print '	</td>'. "\n";
218
+                print '</tr>'. "\n";
219
+            }
220
+        }
221 221
 
222 222
 
223 223
     # divider
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     <?php
233 233
     # warning if delete
234 234
     if($_POST['action'] == "delete") {
235
-	    print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>";
235
+        print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>";
236 236
     }
237 237
     ?>
238 238
 
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	<div class="btn-group">
246 246
 		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
247 247
 		<?php
248
-		//if action == edit and location = IPaddresses print also delete form
249
-		if(($_POST['action'] == "edit") && ($_POST['location'] == "IPaddresses") ) {
250
-			print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._('Delete folder')."</button>";
251
-		}
252
-		?>
248
+        //if action == edit and location = IPaddresses print also delete form
249
+        if(($_POST['action'] == "edit") && ($_POST['location'] == "IPaddresses") ) {
250
+            print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._('Delete folder')."</button>";
251
+        }
252
+        ?>
253 253
 		<button class="btn btn-sm btn-default editFolderSubmit <?php if($_POST['action']=="delete") print "btn-danger"; else print "btn-success"; ?>"><i class="<?php if($_POST['action']=="add") { print "fa fa-plus"; } else if ($_POST['action']=="delete") { print "fa fa-trash-o"; } else { print "fa fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button>
254 254
 	</div>
255 255
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -1 removed lines patch added patch discarded remove patch
@@ -250,7 +250,15 @@
 block discarded – undo
250 250
 			print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._('Delete folder')."</button>";
251 251
 		}
252 252
 		?>
253
-		<button class="btn btn-sm btn-default editFolderSubmit <?php if($_POST['action']=="delete") print "btn-danger"; else print "btn-success"; ?>"><i class="<?php if($_POST['action']=="add") { print "fa fa-plus"; } else if ($_POST['action']=="delete") { print "fa fa-trash-o"; } else { print "fa fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button>
253
+		<button class="btn btn-sm btn-default editFolderSubmit <?php if($_POST['action']=="delete") {
254
+    print "btn-danger";
255
+}
256
+else {
257
+    print "btn-success";
258
+}
259
+?>"><i class="<?php if($_POST['action']=="add") { print "fa fa-plus"; }
260
+else if ($_POST['action']=="delete") { print "fa fa-trash-o"; }
261
+else { print "fa fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button>
254 262
 	</div>
255 263
 
256 264
 	<div class="manageFolderEditResult"></div>
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -5,67 +5,67 @@  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, false);
14
-$Sections	= new Sections ($Database);
14
+$Sections = new Sections ($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", "folder");
24 24
 
25 25
 # ID must be numeric
26
-if($_POST['action']!="add") {
27
-	if(!is_numeric($_POST['subnetId']))										{ $Result->show("danger", _("Invalid ID"), true, true); }
26
+if ($_POST['action'] != "add") {
27
+	if (!is_numeric ($_POST['subnetId'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); }
28 28
 }
29 29
 
30 30
 # verify that user has permissions to add subnet
31
-if($_POST['action'] == "add") {
32
-	if($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show("danger", _('You do not have permissions to add new subnet in this section')."!", true, true); }
31
+if ($_POST['action'] == "add") {
32
+	if ($Sections->check_permission ($User->user, $_POST['sectionId']) != 3) { $Result->show ("danger", _ ('You do not have permissions to add new subnet in this section')."!", true, true); }
33 33
 }
34 34
 # otherwise check subnet permission
35 35
 else {
36
-	if($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) 	{ $Result->show("danger", _('You do not have permissions to add edit/delete this subnet')."!", true, true); }
36
+	if ($Subnets->check_permission ($User->user, $_POST['subnetId']) != 3) { $Result->show ("danger", _ ('You do not have permissions to add edit/delete this subnet')."!", true, true); }
37 37
 }
38 38
 
39 39
 
40 40
 # we are editing or deleting existing subnet, get old details
41 41
 if ($_POST['action'] != "add") {
42
-    $folder_old_details = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
42
+    $folder_old_details = (array) $Subnets->fetch_subnet (null, $_POST['subnetId']);
43 43
 }
44 44
 # we are adding new folder - get folder details
45 45
 else {
46 46
 	# for selecting master subnet if added from subnet details!
47
-	if(strlen($_POST['subnetId']) > 0) {
48
-    	$subnet_old_temp = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']);
49
-    	$subnet_old_details['masterSubnetId'] 	= @$subnet_old_temp['id'];			// same master subnet ID for nested
50
-    	$subnet_old_details['vlanId'] 		 	= @$subnet_old_temp['vlanId'];		// same default vlan for nested
51
-    	$subnet_old_details['vrfId'] 		 	= @$subnet_old_temp['vrfId'];		// same default vrf for nested
47
+	if (strlen ($_POST['subnetId']) > 0) {
48
+    	$subnet_old_temp = (array) $Subnets->fetch_subnet (null, $_POST['subnetId']);
49
+    	$subnet_old_details['masterSubnetId'] = @$subnet_old_temp['id']; // same master subnet ID for nested
50
+    	$subnet_old_details['vlanId'] = @$subnet_old_temp['vlanId']; // same default vlan for nested
51
+    	$subnet_old_details['vrfId'] = @$subnet_old_temp['vrfId']; // same default vrf for nested
52 52
 	}
53 53
 }
54 54
 
55 55
 # fetch custom fields
56
-$custom_fields = $Tools->fetch_custom_fields('subnets');
56
+$custom_fields = $Tools->fetch_custom_fields ('subnets');
57 57
 # fetch all sections
58
-$sections = $Sections->fetch_all_sections();
58
+$sections = $Sections->fetch_all_sections ();
59 59
 
60 60
 
61 61
 # set readonly flag
62
-$readonly = $_POST['action']=="edit" || $_POST['action']=="delete" ? true : false;
62
+$readonly = $_POST['action'] == "edit" || $_POST['action'] == "delete" ? true : false;
63 63
 ?>
64 64
 
65 65
 
66 66
 
67 67
 <!-- header -->
68
-<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('folder'); ?></div>
68
+<div class="pHeader"><?php print ucwords (_ ("$_POST[action]")); ?> <?php print _ ('folder'); ?></div>
69 69
 
70 70
 
71 71
 <!-- content -->
@@ -76,25 +76,25 @@  discard block
 block discarded – undo
76 76
 
77 77
     <!-- name -->
78 78
     <tr>
79
-        <td class="middle"><?php print _('Name'); ?></td>
79
+        <td class="middle"><?php print _ ('Name'); ?></td>
80 80
         <td>
81 81
             <input type="text" class="form-control input-sm input-w-250" id="field-description" name="description" value="<?php print @$folder_old_details['description']; ?>">
82 82
         </td>
83
-        <td class="info2"><?php print _('Enter folder name'); ?></td>
83
+        <td class="info2"><?php print _ ('Enter folder name'); ?></td>
84 84
     </tr>
85 85
 
86
-    <?php if($_POST['action'] != "add") { ?>
86
+    <?php if ($_POST['action'] != "add") { ?>
87 87
     <!-- section -->
88 88
     <tr>
89
-        <td class="middle"><?php print _('Section'); ?></td>
89
+        <td class="middle"><?php print _ ('Section'); ?></td>
90 90
         <td>
91 91
         	<select name="sectionIdNew" class="form-control input-sm input-w-auto">
92 92
             	<?php
93
-	            if($sections!==false) {
94
-	            	foreach($sections as $section) {
93
+	            if ($sections !== false) {
94
+	            	foreach ($sections as $section) {
95 95
 	            		/* selected? */
96
-	            		if($_POST['sectionId'] == $section->id)  { print '<option value="'. $section->id .'" selected>'. $section->name .'</option>'. "\n"; }
97
-	            		else 									 { print '<option value="'. $section->id .'">'. $section->name .'</option>'. "\n"; }
96
+	            		if ($_POST['sectionId'] == $section->id) { print '<option value="'.$section->id.'" selected>'.$section->name.'</option>'."\n"; }
97
+	            		else { print '<option value="'.$section->id.'">'.$section->name.'</option>'."\n"; }
98 98
 	            	}
99 99
             	}
100 100
             	?>
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
 
103 103
         	</select>
104 104
         </td>
105
-        <td class="info2"><?php print _('Move to different section'); ?></td>
105
+        <td class="info2"><?php print _ ('Move to different section'); ?></td>
106 106
     </tr>
107 107
     <?php } ?>
108 108
 
109 109
     <!-- Master subnet -->
110 110
     <tr>
111
-        <td><?php print _('Master Folder'); ?></td>
111
+        <td><?php print _ ('Master Folder'); ?></td>
112 112
         <td>
113
-        	<?php $Subnets->print_mastersubnet_dropdown_menu($_POST['sectionId'], @$folder_old_details['masterSubnetId'], true); ?>
113
+        	<?php $Subnets->print_mastersubnet_dropdown_menu ($_POST['sectionId'], @$folder_old_details['masterSubnetId'], true); ?>
114 114
         </td>
115
-        <td class="info2"><?php print _('Enter master folder if you want to nest it under existing folder, or select root to create root folder'); ?>!</td>
115
+        <td class="info2"><?php print _ ('Enter master folder if you want to nest it under existing folder, or select root to create root folder'); ?>!</td>
116 116
     </tr>
117 117
 
118 118
     <!-- hidden values -->
119
-    <input type="hidden" name="sectionId"       value="<?php print $_POST['sectionId'];    ?>">
120
-    <input type="hidden" name="subnetId"        value="<?php print $_POST['subnetId'];     ?>">
119
+    <input type="hidden" name="sectionId"       value="<?php print $_POST['sectionId']; ?>">
120
+    <input type="hidden" name="subnetId"        value="<?php print $_POST['subnetId']; ?>">
121 121
     <input type="hidden" name="action"    		value="<?php print $_POST['action']; ?>">
122 122
 	<input type="hidden" name="vlanId" 			value="0">
123 123
 	<input type="hidden" name="vrfId" 			value="0">
@@ -125,50 +125,50 @@  discard block
 block discarded – undo
125 125
 
126 126
     <?php
127 127
     	# custom Subnet fields
128
-	    if(sizeof($custom_fields) > 0) {
128
+	    if (sizeof ($custom_fields) > 0) {
129 129
 	    	# count datepickers
130 130
 			$timeP = 0;
131 131
 
132 132
 	    	print "<tr>";
133 133
 	    	print "	<td colspan='3' class='hr'><hr></td>";
134 134
 	    	print "</tr>";
135
-		    foreach($custom_fields as $field) {
135
+		    foreach ($custom_fields as $field) {
136 136
 
137 137
 		    	# replace spaces
138
-		    	$field['nameNew'] = str_replace(" ", "___", $field['name']);
138
+		    	$field['nameNew'] = str_replace (" ", "___", $field['name']);
139 139
 		    	# retain newlines
140
-		    	$folder_old_details[$field['name']] = str_replace("\n", "\\n", @$folder_old_details[$field['name']]);
140
+		    	$folder_old_details[$field['name']] = str_replace ("\n", "\\n", @$folder_old_details[$field['name']]);
141 141
 
142 142
 				# set default value !
143
-				if ($_POST['action']=="add"){ $folder_old_details[$field['name']] = $field['Default']; }
143
+				if ($_POST['action'] == "add") { $folder_old_details[$field['name']] = $field['Default']; }
144 144
 
145 145
 		    	# required
146
-				if($field['Null']=="NO")	{ $required = "*"; }
147
-				else						{ $required = ""; }
146
+				if ($field['Null'] == "NO") { $required = "*"; }
147
+				else { $required = ""; }
148 148
 
149
-				print '<tr>'. "\n";
150
-				print '	<td>'. $field['name'] .' '.$required.'</td>'. "\n";
151
-				print '	<td colspan="2">'. "\n";
149
+				print '<tr>'."\n";
150
+				print '	<td>'.$field['name'].' '.$required.'</td>'."\n";
151
+				print '	<td colspan="2">'."\n";
152 152
 
153 153
 				//set type
154
-				if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") {
154
+				if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") {
155 155
 					//parse values
156
-					$tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type']));
156
+					$tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type']));
157 157
 
158 158
 					//null
159
-					if($field['Null']!="NO") { array_unshift($tmp, ""); }
159
+					if ($field['Null'] != "NO") { array_unshift ($tmp, ""); }
160 160
 
161 161
 					print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
162
-					foreach($tmp as $v) {
163
-						if($v==$folder_old_details[$field['name']])	{ print "<option value='$v' selected='selected'>$v</option>"; }
164
-						else								{ print "<option value='$v'>$v</option>"; }
162
+					foreach ($tmp as $v) {
163
+						if ($v == $folder_old_details[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; }
164
+						else { print "<option value='$v'>$v</option>"; }
165 165
 					}
166 166
 					print "</select>";
167 167
 				}
168 168
 				//date and time picker
169
-				elseif($field['type'] == "date" || $field['type'] == "datetime") {
169
+				elseif ($field['type'] == "date" || $field['type'] == "datetime") {
170 170
 					// just for first
171
-					if($timeP==0) {
171
+					if ($timeP == 0) {
172 172
 						print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">';
173 173
 						print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>';
174 174
 						print '<script type="text/javascript">';
@@ -184,38 +184,38 @@  discard block
 block discarded – undo
184 184
 					$timeP++;
185 185
 
186 186
 					//set size
187
-					if($field['type'] == "date")	{ $size = 10; $class='datepicker';		$format = "yyyy-MM-dd"; }
188
-					else							{ $size = 19; $class='datetimepicker';	$format = "yyyy-MM-dd"; }
187
+					if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; }
188
+					else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; }
189 189
 
190 190
 					//field
191
-					if(!isset($folder_old_details[$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"; }
192
-					else										{ print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $folder_old_details[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; }
191
+					if (!isset($folder_old_details[$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"; }
192
+					else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" value="'.$folder_old_details[$field['name']].'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; }
193 193
 				}
194 194
 				//boolean
195
-				elseif($field['type'] == "tinyint(1)") {
195
+				elseif ($field['type'] == "tinyint(1)") {
196 196
 					print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
197
-					$tmp = array(0=>"No",1=>"Yes");
197
+					$tmp = array (0=>"No", 1=>"Yes");
198 198
 					//null
199
-					if($field['Null']!="NO") { $tmp[2] = ""; }
199
+					if ($field['Null'] != "NO") { $tmp[2] = ""; }
200 200
 
201
-					foreach($tmp as $k=>$v) {
202
-						if(strlen($folder_old_details[$field['name']])==0 && $k==2)	{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
203
-						elseif($k==$folder_old_details[$field['name']])				{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
204
-						else													{ print "<option value='$k'>"._($v)."</option>"; }
201
+					foreach ($tmp as $k=>$v) {
202
+						if (strlen ($folder_old_details[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; }
203
+						elseif ($k == $folder_old_details[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; }
204
+						else { print "<option value='$k'>"._ ($v)."</option>"; }
205 205
 					}
206 206
 					print "</select>";
207 207
 				}
208 208
 				//text
209
-				elseif($field['type'] == "text") {
210
-					print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. str_replace("\\n","",$folder_old_details[$field['name']]). '</textarea>'. "\n";
209
+				elseif ($field['type'] == "text") {
210
+					print ' <textarea class="form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'.str_replace ("\\n", "", $folder_old_details[$field['name']]).'</textarea>'."\n";
211 211
 				}
212 212
 				//default - input field
213 213
 				else {
214
-					print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. $folder_old_details[$field['name']]. '" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n";
214
+					print ' <input type="text" class="ip_addr form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" value="'.$folder_old_details[$field['name']].'" size="30" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n";
215 215
 				}
216 216
 
217
-				print '	</td>'. "\n";
218
-				print '</tr>'. "\n";
217
+				print '	</td>'."\n";
218
+				print '</tr>'."\n";
219 219
 		    }
220 220
 	    }
221 221
 
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 
232 232
     <?php
233 233
     # warning if delete
234
-    if($_POST['action'] == "delete") {
235
-	    print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._('Warning')."</strong><br>"._('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>";
234
+    if ($_POST['action'] == "delete") {
235
+	    print "<div class='alert alert-warning' style='margin-top:0px;'><strong>"._ ('Warning')."</strong><br>"._ ('Removing subnets will delete ALL underlaying subnets and belonging IP addresses')."!</div>";
236 236
     }
237 237
     ?>
238 238
 
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 <!-- footer -->
244 244
 <div class="pFooter">
245 245
 	<div class="btn-group">
246
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
246
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
247 247
 		<?php
248 248
 		//if action == edit and location = IPaddresses print also delete form
249
-		if(($_POST['action'] == "edit") && ($_POST['location'] == "IPaddresses") ) {
250
-			print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._('Delete folder')."</button>";
249
+		if (($_POST['action'] == "edit") && ($_POST['location'] == "IPaddresses")) {
250
+			print "<button class='btn btn-sm btn-default btn-danger editFolderSubmitDelete' data-action='delete' data-subnetId='$folder_old_details[id]'><i class='fa fa-trash-o'></i> "._ ('Delete folder')."</button>";
251 251
 		}
252 252
 		?>
253
-		<button class="btn btn-sm btn-default editFolderSubmit <?php if($_POST['action']=="delete") print "btn-danger"; else print "btn-success"; ?>"><i class="<?php if($_POST['action']=="add") { print "fa fa-plus"; } else if ($_POST['action']=="delete") { print "fa fa-trash-o"; } else { print "fa fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button>
253
+		<button class="btn btn-sm btn-default editFolderSubmit <?php if ($_POST['action'] == "delete") print "btn-danger"; else print "btn-success"; ?>"><i class="<?php if ($_POST['action'] == "add") { print "fa fa-plus"; } else if ($_POST['action'] == "delete") { print "fa fa-trash-o"; } else { print "fa fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button>
254 254
 	</div>
255 255
 
256 256
 	<div class="manageFolderEditResult"></div>
Please login to merge, or discard this patch.