Completed
Pull Request — master (#532)
06:37
created
app/admin/nameservers/edit-result.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,63 +5,63 @@
 block discarded – undo
5 5
  ***************************/
6 6
 
7 7
 /* functions */
8
-require( dirname(__FILE__) . '/../../../functions/functions.php');
8
+require(dirname (__FILE__).'/../../../functions/functions.php');
9 9
 
10 10
 # initialize user object
11
-$Database 	= new Database_PDO;
12
-$User 		= new User ($Database);
11
+$Database = new Database_PDO;
12
+$User = new User ($Database);
13 13
 $Admin	 	= new Admin ($Database);
14 14
 $Result 	= new Result ();
15 15
 
16 16
 # verify that user is logged in
17
-$User->check_user_session();
17
+$User->check_user_session ();
18 18
 
19 19
 # strip input tags
20
-$_POST = $Admin->strip_input_tags($_POST);
20
+$_POST = $Admin->strip_input_tags ($_POST);
21 21
 
22 22
 # validate csrf cookie
23
-$User->csrf_cookie ("validate", "ns", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
23
+$User->csrf_cookie ("validate", "ns", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : "";
24 24
 
25 25
 
26 26
 # Name and primary nameserver must be present!
27
-if ($_POST['action']!="delete") {
28
-	if($_POST['name'] == "") 				{ $Result->show("danger", _("Name is mandatory"), true); }
29
-	if(trim($_POST['namesrv-1']) == "") 	{ $Result->show("danger", _("Primary nameserver is mandatory"), true); }
27
+if ($_POST['action'] != "delete") {
28
+	if ($_POST['name'] == "") { $Result->show ("danger", _ ("Name is mandatory"), true); }
29
+	if (trim ($_POST['namesrv-1']) == "") { $Result->show ("danger", _ ("Primary nameserver is mandatory"), true); }
30 30
 }
31 31
 
32 32
 // merge nameservers
33
-foreach($_POST as $key=>$line) {
34
-	if (strlen(strstr($key,"namesrv-"))>0) {
35
-		if (strlen($line)>0) {
36
-			$all_nameservers[] = trim($line);
33
+foreach ($_POST as $key=>$line) {
34
+	if (strlen (strstr ($key, "namesrv-")) > 0) {
35
+		if (strlen ($line) > 0) {
36
+			$all_nameservers[] = trim ($line);
37 37
 		}
38 38
 	}
39 39
 }
40
-$_POST['namesrv1'] = isset($all_nameservers) ? implode(";", $all_nameservers) : "";
40
+$_POST['namesrv1'] = isset($all_nameservers) ? implode (";", $all_nameservers) : "";
41 41
 
42 42
 // set sections
43
-foreach($_POST as $key=>$line) {
44
-	if (strlen(strstr($key,"section-"))>0) {
45
-		$key2 = str_replace("section-", "", $key);
43
+foreach ($_POST as $key=>$line) {
44
+	if (strlen (strstr ($key, "section-")) > 0) {
45
+		$key2 = str_replace ("section-", "", $key);
46 46
 		$temp[] = $key2;
47 47
 		unset($_POST[$key]);
48 48
 	}
49 49
 }
50 50
 # glue sections together
51
-$_POST['permissions'] = sizeof($temp)>0 ? implode(";", $temp) : null;
51
+$_POST['permissions'] = sizeof ($temp) > 0 ? implode (";", $temp) : null;
52 52
 
53 53
 # set update array
54
-$values = array("id"=>@$_POST['nameserverId'],
54
+$values = array ("id"=>@$_POST['nameserverId'],
55 55
 				"name"=>$_POST['name'],
56 56
 				"permissions"=>$_POST['permissions'],
57 57
 				"namesrv1"=>$_POST['namesrv1'],
58 58
 				"description"=>$_POST['description']
59 59
 				);
60 60
 # update
61
-if(!$Admin->object_modify("nameservers", $_POST['action'], "id", $values))	{ $Result->show("danger",  _("Failed to $_POST[action] nameserver set").'!', true); }
62
-else																		{ $Result->show("success", _("Nameserver set $_POST[action] successfull").'!', false); }
61
+if (!$Admin->object_modify ("nameservers", $_POST['action'], "id", $values)) { $Result->show ("danger", _ ("Failed to $_POST[action] nameserver set").'!', true); }
62
+else { $Result->show ("success", _ ("Nameserver set $_POST[action] successfull").'!', false); }
63 63
 
64 64
 
65 65
 # remove all references if delete
66
-if($_POST['action']=="delete") { $Admin->remove_object_references ("nameservers", "id", $_POST['nameserverId']); }
66
+if ($_POST['action'] == "delete") { $Admin->remove_object_references ("nameservers", "id", $_POST['nameserverId']); }
67 67
 ?>
Please login to merge, or discard this patch.
app/admin/nameservers/index.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,34 +5,34 @@  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 vrfs
11
-$all_nameservers = $Admin->fetch_all_objects("nameservers", "id");
11
+$all_nameservers = $Admin->fetch_all_objects ("nameservers", "id");
12 12
 ?>
13 13
 
14
-<h4><?php print _('Manage Nameserver sets'); ?></h4>
14
+<h4><?php print _ ('Manage Nameserver sets'); ?></h4>
15 15
 <hr><br>
16 16
 
17
-<button class='btn btn-sm btn-default nameserverManagement' data-action='add' data-nameserverid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _('Add nameserver set'); ?></button>
17
+<button class='btn btn-sm btn-default nameserverManagement' data-action='add' data-nameserverid='' style='margin-bottom:10px;'><i class='fa fa-plus'></i> <?php print _ ('Add nameserver set'); ?></button>
18 18
 
19 19
 <!-- nameserver sets -->
20 20
 <?php
21 21
 
22 22
 # first check if they exist!
23
-if($all_nameservers===false) { $Result->show("danger", _("No nameserver sets defined")."!", true);}
23
+if ($all_nameservers === false) { $Result->show ("danger", _ ("No nameserver sets defined")."!", true); }
24 24
 else {
25
-	print '<table id="nameserverManagement" class="table sorted table-striped table-top table-hover table-td-top">'. "\n";
25
+	print '<table id="nameserverManagement" class="table sorted table-striped table-top table-hover table-td-top">'."\n";
26 26
 
27 27
 	# headers
28 28
 	print "<thead>";
29
-	print '<tr>'. "\n";
30
-	print '	<th>'._('Nameserver set').'</th>'. "\n";
31
-	print '	<th>'._('Nameservers').'</th>'. "\n";
32
-	print '	<th>'._('Sections').'</th>'. "\n";
33
-	print '	<th>'._('Description').'</th>'. "\n";
34
-	print '	<th></th>'. "\n";
35
-	print '</tr>'. "\n";
29
+	print '<tr>'."\n";
30
+	print '	<th>'._ ('Nameserver set').'</th>'."\n";
31
+	print '	<th>'._ ('Nameservers').'</th>'."\n";
32
+	print '	<th>'._ ('Sections').'</th>'."\n";
33
+	print '	<th>'._ ('Description').'</th>'."\n";
34
+	print '	<th></th>'."\n";
35
+	print '</tr>'."\n";
36 36
 	print "</thead>";
37 37
 
38 38
     print "<tbody>";
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
 		$nameservers = (array) $nameservers;
43 43
 
44 44
 		unset($permitted_sections);
45
-		$permitted_sections = array();
45
+		$permitted_sections = array ();
46 46
 
47 47
 		// sections
48
-		if (!is_null($nameservers['permissions'])) {
49
-			$sections = array_filter(explode(";", $nameservers['permissions']));
48
+		if (!is_null ($nameservers['permissions'])) {
49
+			$sections = array_filter (explode (";", $nameservers['permissions']));
50 50
 			// some
51
-			if (sizeof($sections)>0) {
52
-				foreach($sections as $id) {
51
+			if (sizeof ($sections) > 0) {
52
+				foreach ($sections as $id) {
53 53
 					$sect = $Admin->fetch_object ("sections", "id", $id);
54 54
 					// exists
55
-					if ($sect!==false) {
55
+					if ($sect !== false) {
56 56
 						$permitted_sections[] = "<span class='badge badge1 badge5'>".$sect->name."</span>";
57 57
 					}
58 58
 				}
@@ -67,24 +67,24 @@  discard block
 block discarded – undo
67 67
 		}
68 68
 
69 69
 		// merge all nmeservers
70
-		$all_nameservers = explode(";", $nameservers['namesrv1']);
70
+		$all_nameservers = explode (";", $nameservers['namesrv1']);
71 71
 
72 72
 		//print details
73
-		print '<tr>'. "\n";
74
-		print '	<td class="name"><strong>'. $nameservers['name'] .'</strong></td>'. "\n";
75
-		print '	<td class="namesrv1">'. implode("<br>", $all_nameservers) .'</td>'. "\n";
76
-		print '	<td class="sections">'. implode("<br>", $permitted_sections).'</td>'. "\n";
77
-		print '	<td class="description">'. $nameservers['description'] .'</td>'. "\n";
73
+		print '<tr>'."\n";
74
+		print '	<td class="name"><strong>'.$nameservers['name'].'</strong></td>'."\n";
75
+		print '	<td class="namesrv1">'.implode ("<br>", $all_nameservers).'</td>'."\n";
76
+		print '	<td class="sections">'.implode ("<br>", $permitted_sections).'</td>'."\n";
77
+		print '	<td class="description">'.$nameservers['description'].'</td>'."\n";
78 78
 		print "	<td class='actions'>";
79 79
 		print "	<div class='btn-group'>";
80 80
 		print "		<button class='btn btn-xs btn-default nameserverManagement' data-action='edit'   data-nameserverid='$nameservers[id]'><i class='fa fa-pencil'></i></button>";
81 81
 		print "		<button class='btn btn-xs btn-default nameserverManagement' data-action='delete' data-nameserverid='$nameservers[id]'><i class='fa fa-times'></i></button>";
82 82
 		print "	</div>";
83 83
 		print "	</td>";
84
-		print '</tr>'. "\n";
84
+		print '</tr>'."\n";
85 85
 	}
86 86
 	print "</tbody>";
87
-	print '</table>'. "\n";
87
+	print '</table>'."\n";
88 88
 }
89 89
 ?>
90 90
 
Please login to merge, or discard this patch.
app/admin/firewall-zones/zones-edit.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -6,36 +6,36 @@  discard block
 block discarded – undo
6 6
  ******************************************/
7 7
 
8 8
 # functions
9
-require( dirname(__FILE__) . '/../../../functions/functions.php');
9
+require(dirname (__FILE__).'/../../../functions/functions.php');
10 10
 
11 11
 # initialize classes
12 12
 $Database = new Database_PDO;
13
-$User 	  = new User ($Database);
14
-$Admin 	  = new Admin($Database);
13
+$User = new User ($Database);
14
+$Admin 	  = new Admin ($Database);
15 15
 $Subnets  = new Subnets ($Database);
16 16
 $Result   = new Result ();
17
-$Zones    = new FirewallZones($Database);
17
+$Zones    = new FirewallZones ($Database);
18 18
 
19 19
 # validate session parameters
20
-$User->check_user_session();
20
+$User->check_user_session ();
21 21
 
22 22
 
23 23
 # validate $_POST['id'] values
24
-if (!preg_match('/^[0-9]+$/i', $_POST['id'])) 												 { $Result->show("danger", _("Invalid ID. Do not manipulate the POST values!"), true); }
24
+if (!preg_match ('/^[0-9]+$/i', $_POST['id'])) { $Result->show ("danger", _ ("Invalid ID. Do not manipulate the POST values!"), true); }
25 25
 # validate $_POST['action'] values
26
-if ($_POST['action'] != 'add' && $_POST['action'] != 'edit' && $_POST['action'] != 'delete') { $Result->show("danger", _("Invalid action. Do not manipulate the POST values!"), true); }
26
+if ($_POST['action'] != 'add' && $_POST['action'] != 'edit' && $_POST['action'] != 'delete') { $Result->show ("danger", _ ("Invalid action. Do not manipulate the POST values!"), true); }
27 27
 
28 28
 
29 29
 # fetch module settings
30
-$firewallZoneSettings = json_decode($User->settings->firewallZoneSettings,true);
30
+$firewallZoneSettings = json_decode ($User->settings->firewallZoneSettings, true);
31 31
 
32 32
 # fetch old zone
33 33
 if ($_POST['action'] != 'add') {
34
-	$firewallZone = $Zones->get_zone($_POST['id']);
34
+	$firewallZone = $Zones->get_zone ($_POST['id']);
35 35
 }
36 36
 
37 37
 # disable edit on delete
38
-$readonly = $_POST['action']=="delete" ? "readonly" : "";
38
+$readonly = $_POST['action'] == "delete" ? "readonly" : "";
39 39
 ?>
40 40
 
41 41
 <script type="text/javascript">
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 </script>
52 52
 
53 53
 <!-- header  -->
54
-<div class="pHeader"><?php print _('Add a firewall zone'); ?></div>
54
+<div class="pHeader"><?php print _ ('Add a firewall zone'); ?></div>
55 55
 <!-- content -->
56 56
 <div class="pContent">
57 57
 <!-- form -->
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	<!-- zone name -->
62 62
 	<tr>
63 63
 		<td style="width:150px;">
64
-			<?php print _('Zone name'); ?>
64
+			<?php print _ ('Zone name'); ?>
65 65
 		</td>
66 66
 
67 67
 		<?php
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 		if ($_POST['action'] == 'add') {
77 77
 			# check if we have to autogenerate a zone name or if we have to display a text box
78 78
 			if ($firewallZoneSettings['zoneGenerator'] == 2) {
79
-				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._('Zone name (Only alphanumeric and special characters like .-_ and space.)').'" value="'.$firewallZone->zone.'" '.$readonly.'></td>';
79
+				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._ ('Zone name (Only alphanumeric and special characters like .-_ and space.)').'" value="'.$firewallZone->zone.'" '.$readonly.'></td>';
80 80
 			} else {
81
-				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._('The zone name will be automatically generated').'" value="'.$firewallZone->zone.'" '.$readonly.' disabled></td>';
81
+				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._ ('The zone name will be automatically generated').'" value="'.$firewallZone->zone.'" '.$readonly.' disabled></td>';
82 82
 			}
83 83
 		} else {
84 84
 			if ($firewallZone->generator == 1) {
85
-				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._('Zone name').'" readonly value="'.$firewallZone->zone.'"></td>';
85
+				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._ ('Zone name').'" readonly value="'.$firewallZone->zone.'"></td>';
86 86
 			} elseif ($firewallZone->generator != 2) {
87
-				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._('Zone name').'" readonly value="'.$firewallZone->zone.'"></td>';
87
+				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._ ('Zone name').'" readonly value="'.$firewallZone->zone.'"></td>';
88 88
 			} else {
89
-				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._('Zone name (Only alphanumeric and special characters like .-_ and space.)').'" value="'.$firewallZone->zone.'" '.$readonly.'></td>';
89
+				print '<td><input type="text" class="form-control input-sm" name="zone" placeholder="'._ ('Zone name (Only alphanumeric and special characters like .-_ and space.)').'" value="'.$firewallZone->zone.'" '.$readonly.'></td>';
90 90
 			}
91 91
 		}
92 92
 		?>
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	<tr>
97 97
 		<!-- zone indicator -->
98 98
 		<td rowspan="2">
99
-			<?php print _('Indicator'); ?>
99
+			<?php print _ ('Indicator'); ?>
100 100
 		</td>
101 101
 		<td>
102 102
 			<div class="radio" style="margin-top:5px;margin-bottom:2px;">
103 103
 				<label>
104
-					<input type="radio" name="indicator" value="0" <?php (($firewallZone->indicator == false) ? print 'checked' : print ''); ?> ><?php print '<span class="fa fa-home"  title="'._('Own zone').'"></span> '._('Own Zone'); ?>
104
+					<input type="radio" name="indicator" value="0" <?php (($firewallZone->indicator == false) ? print 'checked' : print ''); ?> ><?php print '<span class="fa fa-home"  title="'._ ('Own zone').'"></span> '._ ('Own Zone'); ?>
105 105
 				</label>
106 106
 			</div>
107 107
 		</td>
@@ -110,41 +110,41 @@  discard block
 block discarded – undo
110 110
 		<td>
111 111
 			<div class="radio" style="margin-top:2px;margin-bottom:2px;">
112 112
 				<label>
113
-					<input type="radio" name="indicator" value="1" <?php (($firewallZone->indicator == true) ? print 'checked' : print ''); ?> ><?php print '<span class="fa fa-group"  title="'._('Customer zone').'"></span> '._('Customer Zone'); ?>
113
+					<input type="radio" name="indicator" value="1" <?php (($firewallZone->indicator == true) ? print 'checked' : print ''); ?> ><?php print '<span class="fa fa-group"  title="'._ ('Customer zone').'"></span> '._ ('Customer Zone'); ?>
114 114
 				</label>
115 115
 			</div>
116 116
 		</td>
117 117
 	</tr>
118
-	<?php if($firewallZone->generator != 2 && $firewallZoneSettings['zoneGenerator'] != 2) { ?>
118
+	<?php if ($firewallZone->generator != 2 && $firewallZoneSettings['zoneGenerator'] != 2) { ?>
119 119
 		<tr>
120 120
 			<td>
121
-				<?php print _('Padding'); ?>
121
+				<?php print _ ('Padding'); ?>
122 122
 			</td>
123 123
 			<td>
124
-				<input type="checkbox" class="input-switch" name="padding" <?php if($_POST['action'] == 'edit' && $firewallZone->padding == 1){ print 'checked';} elseif($_POST['action'] == 'edit' && $firewallZone->padding == 0) {} elseif ($firewallZoneSettings['padding'] == 'on'){print 'checked';}?>>
124
+				<input type="checkbox" class="input-switch" name="padding" <?php if ($_POST['action'] == 'edit' && $firewallZone->padding == 1) { print 'checked'; } elseif ($_POST['action'] == 'edit' && $firewallZone->padding == 0) {} elseif ($firewallZoneSettings['padding'] == 'on') {print 'checked'; }?>>
125 125
 			</td>
126 126
 		</tr>
127 127
 	<?php } ?>
128 128
 	<tr>
129 129
 		<!-- description -->
130 130
 		<td>
131
-			<?php print _('Description'); ?>
131
+			<?php print _ ('Description'); ?>
132 132
 		</td>
133 133
 		<td>
134
-			<input type="text" class="form-control input-sm" name="description" placeholder="<?php print _('Zone description'); ?>" value="<?php print $firewallZone->description; ?>">
134
+			<input type="text" class="form-control input-sm" name="description" placeholder="<?php print _ ('Zone description'); ?>" value="<?php print $firewallZone->description; ?>">
135 135
 		</td>
136 136
 	</tr>
137 137
 </table>
138 138
 
139 139
 <!-- network information -->
140
-<span class="btn btn-sm btn-default btn-success editNetwork" style="margin-bottom:10px;margin-top: 25px;" data-action="add" data-zoneId="<?php print $firewallZone->id; ?>"><i style="padding-right:5px;" class="fa fa-plus"></i><?php print _('Add a network to the Zone'); ?></span>
140
+<span class="btn btn-sm btn-default btn-success editNetwork" style="margin-bottom:10px;margin-top: 25px;" data-action="add" data-zoneId="<?php print $firewallZone->id; ?>"><i style="padding-right:5px;" class="fa fa-plus"></i><?php print _ ('Add a network to the Zone'); ?></span>
141 141
 
142 142
 <div class="zoneNetwork">
143 143
 <table class="table table-noborder table-condensed" style="padding-bottom:20px;">
144 144
 <?php
145 145
 if ($firewallZone->network) {
146 146
 	print "<tr><td colspan='2'><hr></tr>";
147
-	$rowspan = count($firewallZone->network);
147
+	$rowspan = count ($firewallZone->network);
148 148
 	$i = 1;
149 149
 	foreach ($firewallZone->network as $network) {
150 150
 		print '<tr>';
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			print '<td rowspan="'.$rowspan.'" style="width:150px;vertical-align:top">Networks</td>';
153 153
 		}
154 154
 		print '<td>';
155
-		print '<a class="btn btn-xs btn-danger editNetwork" style="margin-right:5px;" alt="'._('Delete Network').'" title="'._('Delete Network').'" data-action="delete" data-zoneId="'.$firewallZone->id.'" data-subnetId="'.$network->subnetId.'">';
155
+		print '<a class="btn btn-xs btn-danger editNetwork" style="margin-right:5px;" alt="'._ ('Delete Network').'" title="'._ ('Delete Network').'" data-action="delete" data-zoneId="'.$firewallZone->id.'" data-subnetId="'.$network->subnetId.'">';
156 156
 		print '<span><i class="fa fa-close"></i></span>';
157 157
 		print "</a>";
158 158
 
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 			print 'Folder: '.$network->subnetDescription.'</td>';
161 161
 		} else {
162 162
 			# display network information with or without description
163
-			if ($network->subnetDescription) 	{	print $Subnets->transform_to_dotted($network->subnet).'/'.$network->subnetMask.' ('.$network->subnetDescription.')</td>';	}
164
-			else 								{	print $Subnets->transform_to_dotted($network->subnet).'/'.$network->subnetMask.'</td>';	}
163
+			if ($network->subnetDescription) {	print $Subnets->transform_to_dotted ($network->subnet).'/'.$network->subnetMask.' ('.$network->subnetDescription.')</td>'; }
164
+			else {	print $Subnets->transform_to_dotted ($network->subnet).'/'.$network->subnetMask.'</td>'; }
165 165
 		}
166 166
 		print '</tr>';
167 167
 		$i++;
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 
177 177
 <?php
178 178
 #print delete warning
179
-if($_POST['action'] == "delete"){
180
-	$Result->show("warning", "<strong>"._('Warning').":</strong> "._("Removing this firewall zone will also remove all referenced mappings!"), false);
179
+if ($_POST['action'] == "delete") {
180
+	$Result->show ("warning", "<strong>"._ ('Warning').":</strong> "._ ("Removing this firewall zone will also remove all referenced mappings!"), false);
181 181
 }
182 182
 ?>
183 183
 </div>
184 184
 <!-- footer -->
185 185
 <div class="pFooter">
186 186
 	<div class="btn-group">
187
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
188
-		<button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editZoneSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button>
187
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
188
+		<button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editZoneSubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button>
189 189
 	</div>
190 190
 	<!-- result -->
191 191
 	<div class="zones-edit-result"></div>
Please login to merge, or discard this patch.
app/admin/firewall-zones/subnet-to-zone-save.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,49 +6,49 @@
 block discarded – undo
6 6
  *********************************/
7 7
 
8 8
 # functions
9
-require( dirname(__FILE__) . '/../../../functions/functions.php');
9
+require(dirname (__FILE__).'/../../../functions/functions.php');
10 10
 
11 11
 # initialize classes
12 12
 $Database = new Database_PDO;
13
-$User 	  = new User ($Database);
13
+$User = new User ($Database);
14 14
 $Result   = new Result ();
15
-$Zones    = new FirewallZones($Database);
15
+$Zones    = new FirewallZones ($Database);
16 16
 
17 17
 # validate session parameters
18
-$User->check_user_session();
18
+$User->check_user_session ();
19 19
 
20 20
 # validate $_POST['subnetId'] values
21
-if (!preg_match('/^[0-9]+$/i', $_POST['subnetId']))  						{ $Result->show("danger", _("Invalid subnet ID. Do not manipulate the POST values!"), true); }
21
+if (!preg_match ('/^[0-9]+$/i', $_POST['subnetId'])) { $Result->show ("danger", _ ("Invalid subnet ID. Do not manipulate the POST values!"), true); }
22 22
 # validate $_POST['zoneId'] values
23
-if (!preg_match('/^[0-9]+$/i', $_POST['zoneId']) || $_POST['zoneId'] == 0) 	 { $Result->show("danger", _("Invalid or no zone ID. "), true); }
23
+if (!preg_match ('/^[0-9]+$/i', $_POST['zoneId']) || $_POST['zoneId'] == 0) { $Result->show ("danger", _ ("Invalid or no zone ID. "), true); }
24 24
 
25 25
 # validate $_POST['deviceId'] values
26
-if ($_POST['deviceId'] && !preg_match('/^[0-9]+$/i', $_POST['deviceId'])) 	 { $Result->show("danger", _("Invalid device ID. Do not manipulate the POST values!"), true); }
26
+if ($_POST['deviceId'] && !preg_match ('/^[0-9]+$/i', $_POST['deviceId'])) { $Result->show ("danger", _ ("Invalid device ID. Do not manipulate the POST values!"), true); }
27 27
 
28 28
 # check the zone alias. valid values are alphanumeric characters and special characters like ".-_ "
29
-if($_POST['alias'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['alias'])) {
30
-	$Result->show("danger", _("Invalid zone alias value."), true);
29
+if ($_POST['alias'] && !preg_match ('/^[0-9a-zA-Z.\/\-_ ]+$/i', $_POST['alias'])) {
30
+	$Result->show ("danger", _ ("Invalid zone alias value."), true);
31 31
 }
32 32
 # check the interface name. valid values are alphanumeric characters and special characters like ".-_/ "
33
-if($_POST['interface'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['interface'])) {
34
-	$Result->show("danger", _("Invalid interface."), true);
33
+if ($_POST['interface'] && !preg_match ('/^[0-9a-zA-Z.\/\-_ ]+$/i', $_POST['interface'])) {
34
+	$Result->show ("danger", _ ("Invalid interface."), true);
35 35
 }
36 36
 
37 37
 # check if there is any device mapping necessary
38 38
 if ($_POST['deviceId']) {
39 39
 	# build the query parameter arrary
40
-	$values = array('id' => '',
40
+	$values = array ('id' => '',
41 41
 					'zoneId' => $_POST['zoneId'],
42 42
 					'alias' => $_POST['alias'],
43 43
 					'deviceId' => $_POST['deviceId'],
44 44
 					'interface' => $_POST['interface']
45 45
 					);
46 46
 	# modify
47
-	if(!$Zones->modify_mapping('add',$values)) 	{ $Result->show("danger",  _("Cannot add mapping"), true); }
47
+	if (!$Zones->modify_mapping ('add', $values)) { $Result->show ("danger", _ ("Cannot add mapping"), true); }
48 48
 }
49 49
 # check and then add the network to the zone if possible
50
-if($Zones->check_zone_network($_POST['subnetId']))	{ 
51
-	if (!$Zones->add_zone_network($_POST['zoneId'],$_POST['subnetId']))	{ 	$Result->show("danger",  _("Cannot add this network to a zone."), true); }
52
-	else 																{	$Result->show("success", _("Zone modified successfully"), true); }
50
+if ($Zones->check_zone_network ($_POST['subnetId'])) { 
51
+	if (!$Zones->add_zone_network ($_POST['zoneId'], $_POST['subnetId'])) { 	$Result->show ("danger", _ ("Cannot add this network to a zone."), true); }
52
+	else {	$Result->show ("success", _ ("Zone modified successfully"), true); }
53 53
 }
54 54
 ?>
55 55
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/firewall-zones/zones-edit-result.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,55 +5,55 @@  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 classes
11 11
 $Database = new Database_PDO;
12
-$User 	  = new User ($Database);
12
+$User = new User ($Database);
13 13
 $Admin 	  = new Admin ($Database);
14 14
 $Result   = new Result ();
15
-$Zones 	  = new FirewallZones($Database);
15
+$Zones 	  = new FirewallZones ($Database);
16 16
 
17 17
 # validate session parameters
18
-$User->check_user_session();
18
+$User->check_user_session ();
19 19
 
20 20
 # fetch module settings
21
-$firewallZoneSettings = json_decode($User->settings->firewallZoneSettings,true);
21
+$firewallZoneSettings = json_decode ($User->settings->firewallZoneSettings, true);
22 22
 
23 23
 # validations
24 24
 # validate the action type
25
-if($_POST['action'] != 'add' && $_POST['action'] != 'delete' && $_POST['action'] != 'edit'){
26
-	$Result->show("danger", _("Invalid action."), true);
25
+if ($_POST['action'] != 'add' && $_POST['action'] != 'delete' && $_POST['action'] != 'edit') {
26
+	$Result->show ("danger", _ ("Invalid action."), true);
27 27
 }
28 28
 
29 29
 # check the zone name. valid values are alphanumeric characters and special characters like ".-_ "
30
-if($_POST['zone'] && !preg_match('/^[0-9a-zA-Z.\-_ ]+$/i',$_POST['zone'])) {
31
-	$Result->show("danger", _("Invalid zone name value."), true);
30
+if ($_POST['zone'] && !preg_match ('/^[0-9a-zA-Z.\-_ ]+$/i', $_POST['zone'])) {
31
+	$Result->show ("danger", _ ("Invalid zone name value."), true);
32 32
 }
33 33
 
34
-if($firewallZoneSettings['zoneGenerator']=="2")
35
-if(strlen(@$_POST['zone']) < 1 || strlen(@$_POST['zone'])>$firewallZoneSettings['zoneLength']) {
36
-	$Result->show("danger", _("Invalid zone name length."), true);
34
+if ($firewallZoneSettings['zoneGenerator'] == "2")
35
+if (strlen (@$_POST['zone']) < 1 || strlen (@$_POST['zone']) > $firewallZoneSettings['zoneLength']) {
36
+	$Result->show ("danger", _ ("Invalid zone name length."), true);
37 37
 }
38 38
 
39 39
 # check the zone indicator ID. valid values are 0 or 1.
40
-if($_POST['indicator'] && !preg_match('/^[0-1]$/i',$_POST['indicator'])) {
41
-	$Result->show("danger", _("Invalid indicator ID."), true);
40
+if ($_POST['indicator'] && !preg_match ('/^[0-1]$/i', $_POST['indicator'])) {
41
+	$Result->show ("danger", _ ("Invalid indicator ID."), true);
42 42
 }
43 43
 
44 44
 # check the generator value. valid value: integer
45
-if($_POST['generator'] && !preg_match('/^[0-9]+$/i',$_POST['generator'])) {
46
-	$Result->show("danger", _("Invalid generator ID."), true);
45
+if ($_POST['generator'] && !preg_match ('/^[0-9]+$/i', $_POST['generator'])) {
46
+	$Result->show ("danger", _ ("Invalid generator ID."), true);
47 47
 }
48 48
 
49 49
 # check the padding value. valid value: on or off
50
-if($_POST['padding'] && !preg_match('/^(on|off)$/i',$_POST['padding'])) {
51
-	$Result->show("danger", _("Invalid padding setting."), true);
50
+if ($_POST['padding'] && !preg_match ('/^(on|off)$/i', $_POST['padding'])) {
51
+	$Result->show ("danger", _ ("Invalid padding setting."), true);
52 52
 }
53 53
 
54 54
 # transform the padding checkbox values into 1 or 0
55
-if($_POST['generator'] != 2) {
56
-	if($_POST['padding']) {
55
+if ($_POST['generator'] != 2) {
56
+	if ($_POST['padding']) {
57 57
 		$padding = 1;
58 58
 	} else {
59 59
 		$padding = 0;
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 # transform description to valid value
64
-$description = trim(htmlspecialchars($_POST['description']));
64
+$description = trim (htmlspecialchars ($_POST['description']));
65 65
 
66 66
 # generate a unique zone name if the generator is set to decimal or hex
67
-if (!$_POST['zone'] && $_POST['action'] == 'add')  {
68
-	if(!$zone=$Zones->generate_zone_name()){
69
-		$Result->show("danger",  _("Cannot generate zone name"), true);
67
+if (!$_POST['zone'] && $_POST['action'] == 'add') {
68
+	if (!$zone = $Zones->generate_zone_name ()) {
69
+		$Result->show ("danger", _ ("Cannot generate zone name"), true);
70 70
 	}
71 71
 } else {
72 72
 	$zone = $_POST['zone'];
73 73
 }
74 74
 
75 75
 # validate the zone name if text mode is enabled
76
-if ($_POST['generator'] == 2 ) {
77
-	$textSettings = array ( $_POST['zone'],$_POST['id']);
78
-	if(!$zone=$Zones->generate_zone_name($textSettings)){
79
-		$Result->show("danger",  _("Cannot validate zone name"), true);
76
+if ($_POST['generator'] == 2) {
77
+	$textSettings = array ($_POST['zone'], $_POST['id']);
78
+	if (!$zone = $Zones->generate_zone_name ($textSettings)) {
79
+		$Result->show ("danger", _ ("Cannot validate zone name"), true);
80 80
 	}
81 81
 }
82 82
 
83 83
 # build the query parameter arrary
84
-if($_POST['generator'] != 2 && $_POST['action'] == 'edit') {
85
-	$values = array('id' => $_POST['id'],
84
+if ($_POST['generator'] != 2 && $_POST['action'] == 'edit') {
85
+	$values = array ('id' => $_POST['id'],
86 86
 					'indicator' => $_POST['indicator'],
87 87
 					'padding' => $padding,
88 88
 					'description' => $description,
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 					);
91 91
 }
92 92
 else {
93
-	$values = array('id' => $_POST['id'],
93
+	$values = array ('id' => $_POST['id'],
94 94
 					'generator' => $_POST['generator'],
95 95
 					'zone' => $zone,
96 96
 					'indicator' => $_POST['indicator'],
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 }
102 102
 
103 103
 # update
104
-if(!$Zones->modify_zone($_POST['action'],$values))	{ $Result->show("danger",  _("Cannot add zone"), true); }
105
-else 												{ $Result->show("success", _("Zone modified successfully"), true);  }
104
+if (!$Zones->modify_zone ($_POST['action'], $values)) { $Result->show ("danger", _ ("Cannot add zone"), true); }
105
+else { $Result->show ("success", _ ("Zone modified successfully"), true); }
106 106
 
107 107
 ?>
108 108
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/firewall-zones/index.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,36 +5,36 @@  discard block
 block discarded – undo
5 5
  ******************************************/
6 6
 
7 7
 # validate session parameters
8
-$User->check_user_session();
8
+$User->check_user_session ();
9 9
 
10 10
 ?>
11 11
 
12 12
 
13
-<h4><?php print _('Firewall zone management'); ?></h4>
13
+<h4><?php print _ ('Firewall zone management'); ?></h4>
14 14
 <hr><br>
15 15
 
16 16
 <?php
17 17
 # check if the feature is activated, otherwise provide a short notice to enable this feature in the phpIPAM settings menu
18
-if($User->settings->enableFirewallZones==1) {
18
+if ($User->settings->enableFirewallZones == 1) {
19 19
 ?>
20 20
 <!-- tabs -->
21 21
 <ul class="nav nav-tabs">
22 22
 	<?php
23 23
 	# tabs
24
-	$tabs = array("mapping", "zones", "settings");
24
+	$tabs = array ("mapping", "zones", "settings");
25 25
 
26 26
 	# default tab
27
-	if(!isset($_GET['subnetId'])) {
27
+	if (!isset($_GET['subnetId'])) {
28 28
 		$_GET['subnetId'] = "mapping";
29 29
 	}
30 30
 
31 31
 	# check
32
-	if(!in_array($_GET['subnetId'], $tabs)) 	{ $Result->show("danger", "Invalid request", true); }
32
+	if (!in_array ($_GET['subnetId'], $tabs)) { $Result->show ("danger", "Invalid request", true); }
33 33
 
34 34
 	# print
35
-	foreach($tabs as $t) {
36
-		$class = $_GET['subnetId']==$t ? "class='active'" : "";
37
-		print "<li role='presentation' $class><a href=".create_link("administration", "firewall-zones", "$t").">". _(ucwords($t))."</a></li>";
35
+	foreach ($tabs as $t) {
36
+		$class = $_GET['subnetId'] == $t ? "class='active'" : "";
37
+		print "<li role='presentation' $class><a href=".create_link ("administration", "firewall-zones", "$t").">"._ (ucwords ($t))."</a></li>";
38 38
 	}
39 39
 	?>
40 40
 </ul>
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 <div>
43 43
 <?php
44 44
 # include content
45
-if(!file_exists(dirname(__FILE__) . '/'.$_GET['subnetId'].".php")) 	{ $Result->show("danger", "Invalid request", true); }
46
-else																{ include(dirname(__FILE__) . '/'.$_GET['subnetId'].".php"); }
45
+if (!file_exists (dirname (__FILE__).'/'.$_GET['subnetId'].".php")) { $Result->show ("danger", "Invalid request", true); }
46
+else { include(dirname (__FILE__).'/'.$_GET['subnetId'].".php"); }
47 47
 ?>
48 48
 </div>
49 49
 
50 50
 <?php
51 51
 } else {
52
-	$Result->show("info", _('Please enable the firewall zone module under server management'), false);
52
+	$Result->show ("info", _ ('Please enable the firewall zone module under server management'), false);
53 53
 }
54 54
 ?>
55 55
 </div>
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/firewall-zones/zones.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
  *******************************/
7 7
 
8 8
 # validate session parameters
9
-$User->check_user_session();
9
+$User->check_user_session ();
10 10
 
11 11
 # initialize classes
12
-$Zones = new FirewallZones($Database);
13
-$firewallZones = $Zones->get_zones();
12
+$Zones = new FirewallZones ($Database);
13
+$firewallZones = $Zones->get_zones ();
14 14
 
15 15
 
16 16
 # Add new firewall zone
17
-print '<button class="btn btn-sm btn-default btn-success editFirewallZone" style="margin-bottom:10px;margin-top: 25px;" data-action="add" data-id="0"><i style="padding-right:5px;" class="fa fa-plus"></i>'._('Create Firewall zone').'</button>';
17
+print '<button class="btn btn-sm btn-default btn-success editFirewallZone" style="margin-bottom:10px;margin-top: 25px;" data-action="add" data-id="0"><i style="padding-right:5px;" class="fa fa-plus"></i>'._ ('Create Firewall zone').'</button>';
18 18
 
19 19
 
20 20
 # display the zone table if there are any zones in the database
21
-if($firewallZones) {
21
+if ($firewallZones) {
22 22
 
23 23
 	# table
24 24
 	print '<table id="zonesPrint" class="table table-top table-td-top table-condensed">';
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
 	# table headers
27 27
 	print "<thead>";
28 28
 	print '<tr style="background:white">';
29
-	print '<th>'._('Type').'</th>';
30
-	print '<th>'._('Zone').'</th>';
31
-	print '<th>'._('Description').'</th>';
32
-	print '<th>'._('Subnet').'</th>';
33
-	print '<th>'._('VLAN').'</th>';
29
+	print '<th>'._ ('Type').'</th>';
30
+	print '<th>'._ ('Zone').'</th>';
31
+	print '<th>'._ ('Description').'</th>';
32
+	print '<th>'._ ('Subnet').'</th>';
33
+	print '<th>'._ ('VLAN').'</th>';
34 34
 	print '<th style="width:60px;"></th>';
35 35
 	print '</tr>';
36 36
 	print "</thead>";
37 37
 
38 38
     print "<tbody>";
39 39
 	# display all firewall zones and network information
40
-	foreach ($firewallZones as $zoneObject ) {
40
+	foreach ($firewallZones as $zoneObject) {
41 41
 		# set rowspan in case if there are more than one networks bound to the zone
42
-		$counter = count($zoneObject->network);
42
+		$counter = count ($zoneObject->network);
43 43
 		if ($counter === 0) {
44 44
 			$counter = 1;
45 45
 		}
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 					// set title
53 53
 					$title = $zoneObject->indicator == 0 ? 'Own Zone' : 'Customer Zone';
54 54
 					// print
55
-					print '<td rowspan="'.$counter.'"><span class="fa '.($zoneObject->indicator == 0 ? 'fa-home':'fa-group').'"  title="'._($title).'"></span></td>';
55
+					print '<td rowspan="'.$counter.'"><span class="fa '.($zoneObject->indicator == 0 ? 'fa-home' : 'fa-group').'"  title="'._ ($title).'"></span></td>';
56 56
 					print '<td rowspan="'.$counter.'">'.$zoneObject->zone.'</td>';
57 57
 					print '<td rowspan="'.$counter.'">'.$zoneObject->description.'</td>';
58 58
 				}
59 59
 				# display subnet informations
60 60
 				if ($network->subnetId) {
61 61
 					// description fix
62
-					$network->subnetDescription = strlen($network->subnetDescription)>0 ? " (".$network->subnetDescription.")" : "";
62
+					$network->subnetDescription = strlen ($network->subnetDescription) > 0 ? " (".$network->subnetDescription.")" : "";
63 63
 
64 64
 					if (!$network->subnetIsFolder) {
65
-						print '<td><a href="'.create_link("subnets",$network->sectionId,$network->subnetId).'">'.$Subnets->transform_to_dotted($network->subnet).'/'.$network->subnetMask.$network->subnetDescription.'</a></td>';
65
+						print '<td><a href="'.create_link ("subnets", $network->sectionId, $network->subnetId).'">'.$Subnets->transform_to_dotted ($network->subnet).'/'.$network->subnetMask.$network->subnetDescription.'</a></td>';
66 66
 					} else {
67
-						print '<td><a href="'.create_link("subnets",$network->sectionId,$network->subnetId).'">Folder'.$network->subnetDescription.'</a></td>';
67
+						print '<td><a href="'.create_link ("subnets", $network->sectionId, $network->subnetId).'">Folder'.$network->subnetDescription.'</a></td>';
68 68
 					}
69 69
 				} else {
70 70
 					print '<td>/</td>';
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 				# display vlan informations
73 73
 				if ($network->vlanId) {
74 74
 					// name fix
75
-					$network->vlanName = strlen($network->vlanName)>0 ? " (".$network->vlanName.")" : "";
76
-					print '<td><a href="'.create_link('tools','vlan',$network->domainId,$network->vlanId).'">'.$network->vlan.$network->vlanName.'</a></td>';
75
+					$network->vlanName = strlen ($network->vlanName) > 0 ? " (".$network->vlanName.")" : "";
76
+					print '<td><a href="'.create_link ('tools', 'vlan', $network->domainId, $network->vlanId).'">'.$network->vlan.$network->vlanName.'</a></td>';
77 77
 				} else {
78 78
 					print '<td>/</td>';
79 79
 				}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			$title = $zoneObject->indicator == 0 ? 'Own Zone' : 'Customer Zone';
100 100
 
101 101
 			print '<tr class="border-top">';
102
-			print '<td rowspan="'.$counter.'"><span class="fa fa-home"  title="'._($title).'"></span></td>';
102
+			print '<td rowspan="'.$counter.'"><span class="fa fa-home"  title="'._ ($title).'"></span></td>';
103 103
 			print '<td>'.$zoneObject->zone.'</td>';
104 104
 			print '<td>'.$zoneObject->description.'</td>';
105 105
 			print '<td>/</td>';
@@ -118,6 +118,6 @@  discard block
 block discarded – undo
118 118
 	print '</table>';
119 119
 } else {
120 120
 	# print an info if there are no zones in the database
121
-	$Result->show("info", _("No firewall zones configured"), false);
121
+	$Result->show ("info", _ ("No firewall zones configured"), false);
122 122
 }
123 123
 ?>
Please login to merge, or discard this patch.
app/admin/firewall-zones/mapping-edit.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -5,48 +5,48 @@  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 classes
11 11
 $Database = new Database_PDO;
12
-$User 	  = new User ($Database);
12
+$User = new User ($Database);
13 13
 $Subnets  = new Subnets ($Database);
14 14
 $Tools 	  = new Tools ($Database);
15 15
 $Result   = new Result ();
16
-$Zones 	  = new FirewallZones($Database);
16
+$Zones 	  = new FirewallZones ($Database);
17 17
 
18 18
 # validate session parameters
19
-$User->check_user_session();
19
+$User->check_user_session ();
20 20
 
21 21
 # validate $_POST['id'] values
22
-if (!preg_match('/^[0-9]+$/i', $_POST['id'])) {
23
-	$Result->show("danger", _("Invalid ID. Do not manipulate the POST values!"), true);
22
+if (!preg_match ('/^[0-9]+$/i', $_POST['id'])) {
23
+	$Result->show ("danger", _ ("Invalid ID. Do not manipulate the POST values!"), true);
24 24
 }
25 25
 
26 26
 # validate $_POST['action'] values
27 27
 if ($_POST['action'] != 'add' && $_POST['action'] != 'edit' && $_POST['action'] != 'delete') {
28
-	$Result->show("danger", _("Invalid action. Do not manipulate the POST values!"), true);
28
+	$Result->show ("danger", _ ("Invalid action. Do not manipulate the POST values!"), true);
29 29
 }
30 30
 
31 31
 # disable edit on delete
32
-$readonly = $_POST['action']=="delete" ? "disabled" : "";
32
+$readonly = $_POST['action'] == "delete" ? "disabled" : "";
33 33
 
34 34
 # fetch all firewall zones
35
-$firewallZones = $Zones->get_zones();
35
+$firewallZones = $Zones->get_zones ();
36 36
 
37 37
 # fetch settings
38
-$firewallZoneSettings = json_decode($User->settings->firewallZoneSettings,true);
38
+$firewallZoneSettings = json_decode ($User->settings->firewallZoneSettings, true);
39 39
 
40 40
 # fetch all devices
41 41
 $devices = $Tools->fetch_multiple_objects ("devices", "type", $firewallZoneSettings['deviceType']);
42 42
 
43 43
 # fetch old mapping
44 44
 if ($_POST['action'] != 'add') {
45
-	$mapping = $Zones->get_zone_mapping($_POST['id']);
45
+	$mapping = $Zones->get_zone_mapping ($_POST['id']);
46 46
 }
47 47
 ?>
48 48
 <!-- header  -->
49
-<div class="pHeader"><?php print _('Add a mapping between a firewall device and a firewall zone'); ?></div>
49
+<div class="pHeader"><?php print _ ('Add a mapping between a firewall device and a firewall zone'); ?></div>
50 50
 <!-- content -->
51 51
 <div class="pContent">
52 52
 	<!-- form -->
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
 	<!-- zone name -->
58 58
 	<tr>
59 59
 		<td style="width:150px;">
60
-			<?php print _('Zone to map'); ?>
60
+			<?php print _ ('Zone to map'); ?>
61 61
 		</td>
62 62
 		<td>
63 63
 			<select name="zoneId" class="mappingZoneInformation form-control input-sm input-w-auto input-max-200"  <?php print $readonly; ?>>
64
-			<option value="0"><?php print _('Select a firewall zone'); ?></option>
64
+			<option value="0"><?php print _ ('Select a firewall zone'); ?></option>
65 65
 			<?php
66 66
 			foreach ($firewallZones as $zone) {
67
-				if ($zone->id == $mapping->id) 	{
68
-					if($zone->description) 	{ print '<option value="'.$zone->id.'" selected>'.$zone->zone.' ('.$zone->description.')</option>'; }
69
-					else 					{ print '<option value="'.$zone->id.'" selected>'.$zone->zone.'</option>'; }}
67
+				if ($zone->id == $mapping->id) {
68
+					if ($zone->description) { print '<option value="'.$zone->id.'" selected>'.$zone->zone.' ('.$zone->description.')</option>'; }
69
+					else { print '<option value="'.$zone->id.'" selected>'.$zone->zone.'</option>'; }}
70 70
 				else {
71
-					if($zone->description) 	{ print '<option value="'.$zone->id.'">'.		  $zone->zone.' ('.$zone->description.')</option>'; }
72
-					else 					{ print '<option value="'.$zone->id.'">'.		  $zone->zone.'</option>'; }}
71
+					if ($zone->description) { print '<option value="'.$zone->id.'">'.$zone->zone.' ('.$zone->description.')</option>'; }
72
+					else { print '<option value="'.$zone->id.'">'.$zone->zone.'</option>'; }}
73 73
 			}
74 74
 			?>
75 75
 			</select>
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				<?php
85 85
 				if ($mapping->zoneId) {
86 86
 					# return the zone details
87
-					$Zones->get_zone_detail($mapping->id);
87
+					$Zones->get_zone_detail ($mapping->id);
88 88
 				}
89 89
 				?>
90 90
 			</div>
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 	<tr>
94 94
 		<!-- zone indicator -->
95 95
 		<td>
96
-			<?php print _('Firewall to map'); ?>
96
+			<?php print _ ('Firewall to map'); ?>
97 97
 		</td>
98 98
 		<td>
99 99
 			<select name="deviceId" class="form-control input-sm input-w-auto input-max-200" <?php print $readonly; ?>>
100
-			<option value="0"><?php print _('Select firewall'); ?></option>
100
+			<option value="0"><?php print _ ('Select firewall'); ?></option>
101 101
 			<?php
102
-            if ($devices !==false) {
102
+            if ($devices !== false) {
103 103
     			foreach ($devices as $device) {
104
-    				if ($device->id == $mapping->deviceId) 	{
105
-    					if($device->description) 	{	print '<option value="'.$device->id.'" selected>'.	$device->hostname.' ('.$device->description.')</option>'; }
106
-    					else 						{ 	print '<option value="'.$device->id.'" selected>'.	$device->hostname.'</option>'; }}
104
+    				if ($device->id == $mapping->deviceId) {
105
+    					if ($device->description) {	print '<option value="'.$device->id.'" selected>'.$device->hostname.' ('.$device->description.')</option>'; }
106
+    					else { 	print '<option value="'.$device->id.'" selected>'.$device->hostname.'</option>'; }}
107 107
     				else {
108
-    					if($device->description)	{	print '<option value="'.$device->id.'">'.			$device->hostname.' ('.$device->description.')</option>'; }
109
-    					else 						{	print '<option value="'.$device->id.'">'.			$device->hostname.'</option>'; }}
108
+    					if ($device->description) {	print '<option value="'.$device->id.'">'.$device->hostname.' ('.$device->description.')</option>'; }
109
+    					else {	print '<option value="'.$device->id.'">'.$device->hostname.'</option>'; }}
110 110
     			}
111 111
 			}
112 112
 			?>
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
 	</tr>
116 116
 	<tr>
117 117
 		<td>
118
-			<?php print _('Interface'); ?>
118
+			<?php print _ ('Interface'); ?>
119 119
 		</td>
120 120
 		<td>
121
-			<input type="text" class="form-control input-sm" name="interface" placeholder="<?php print _('Firewall interface'); ?>" value="<?php print $mapping->interface; ?>" <?php print $readonly; ?>>
121
+			<input type="text" class="form-control input-sm" name="interface" placeholder="<?php print _ ('Firewall interface'); ?>" value="<?php print $mapping->interface; ?>" <?php print $readonly; ?>>
122 122
 		</td>
123 123
 	</tr>
124 124
 
125 125
 	<tr>
126 126
 		<!-- description -->
127 127
 		<td>
128
-			<?php print _('Zone alias'); ?>
128
+			<?php print _ ('Zone alias'); ?>
129 129
 		</td>
130 130
 		<td>
131
-			<input type="text" class="form-control input-sm" name="alias" placeholder="<?php print _('Local zone alias'); ?>" value="<?php print $mapping->alias; ?>" <?php print $readonly; ?>>
131
+			<input type="text" class="form-control input-sm" name="alias" placeholder="<?php print _ ('Local zone alias'); ?>" value="<?php print $mapping->alias; ?>" <?php print $readonly; ?>>
132 132
 		</td>
133 133
 	</tr>
134 134
 	</table>
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
 
140 140
 	<?php
141 141
 	# print delete warning
142
-	if($_POST['action'] == "delete"){
143
-		$Result->show("warning", "<strong>"._('Warning').":</strong> "._("You are about to remove the firewall to zone mapping!"), false);
142
+	if ($_POST['action'] == "delete") {
143
+		$Result->show ("warning", "<strong>"._ ('Warning').":</strong> "._ ("You are about to remove the firewall to zone mapping!"), false);
144 144
 	}
145 145
 	?>
146 146
 </div>
147 147
 <!-- footer -->
148 148
 <div class="pFooter">
149 149
 	<div class="btn-group">
150
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
151
-		<button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editMappingSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button>
150
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
151
+		<button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editMappingSubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button>
152 152
 	</div>
153 153
 	<!-- result -->
154 154
 	<div class="mapping-edit-result"></div>
Please login to merge, or discard this patch.
app/admin/firewall-zones/mapping-edit-result.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,57 +6,57 @@
 block discarded – undo
6 6
  **********************************************/
7 7
 
8 8
 # functions
9
-require( dirname(__FILE__) . '/../../../functions/functions.php');
9
+require(dirname (__FILE__).'/../../../functions/functions.php');
10 10
 
11 11
 # initialize classes
12 12
 $Database = new Database_PDO;
13 13
 $User = new User ($Database);
14 14
 $Result = new Result ();
15
-$Zones = new FirewallZones($Database);
15
+$Zones = new FirewallZones ($Database);
16 16
 
17 17
 # validate session parameters
18
-$User->check_user_session();
18
+$User->check_user_session ();
19 19
 
20 20
 # validate the action type
21
-if($_POST['action'] != 'add' && $_POST['action'] != 'delete' && $_POST['action'] != 'edit'){
22
-	$Result->show("danger", _("Invalid action."), true);
21
+if ($_POST['action'] != 'add' && $_POST['action'] != 'delete' && $_POST['action'] != 'edit') {
22
+	$Result->show ("danger", _ ("Invalid action."), true);
23 23
 }
24 24
 # check the zone alias. valid values are alphanumeric characters and special characters like ".-_ "
25
-if($_POST['alias'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['alias'])) {
26
-	$Result->show("danger", _("Invalid zone alias value."), true);
25
+if ($_POST['alias'] && !preg_match ('/^[0-9a-zA-Z.\/\-_ ]+$/i', $_POST['alias'])) {
26
+	$Result->show ("danger", _ ("Invalid zone alias value."), true);
27 27
 }
28 28
 # check the interface name. valid values are alphanumeric characters and special characters like ".-_/ "
29
-if($_POST['interface'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['interface'])) {
30
-	$Result->show("danger", _("Invalid interface."), true);
29
+if ($_POST['interface'] && !preg_match ('/^[0-9a-zA-Z.\/\-_ ]+$/i', $_POST['interface'])) {
30
+	$Result->show ("danger", _ ("Invalid interface."), true);
31 31
 }
32 32
 if ($_POST['action'] != 'delete') {
33 33
 	# check the zone  ID. valid value: integer
34
-	if(!preg_match('/^[0-9]+$/i',$_POST['zoneId'])) {
35
-		$Result->show("danger", _("Invalid zone ID."), true);
36
-	} elseif (preg_match('/^0$/i',$_POST['zoneId'])) {
37
-		$Result->show("danger", _("Invalid zone ID."), true);
34
+	if (!preg_match ('/^[0-9]+$/i', $_POST['zoneId'])) {
35
+		$Result->show ("danger", _ ("Invalid zone ID."), true);
36
+	} elseif (preg_match ('/^0$/i', $_POST['zoneId'])) {
37
+		$Result->show ("danger", _ ("Invalid zone ID."), true);
38 38
 	}
39 39
 	# check the device ID. valid value: integer
40
-	if(!preg_match('/^[0-9]+$/i',$_POST['deviceId'])) {
41
-		$Result->show("danger", _("Invalid device ID."), true);
42
-	} elseif (preg_match('/^0$/i',$_POST['deviceId'])) {
43
-		$Result->show("danger", _("Please select a device."), true);
40
+	if (!preg_match ('/^[0-9]+$/i', $_POST['deviceId'])) {
41
+		$Result->show ("danger", _ ("Invalid device ID."), true);
42
+	} elseif (preg_match ('/^0$/i', $_POST['deviceId'])) {
43
+		$Result->show ("danger", _ ("Please select a device."), true);
44 44
 	}
45 45
 	# check the mapping ID. valid value: integer
46
-	if($_POST['id'] && !preg_match('/^[0-9]+$/i',$_POST['id'])) {
47
-		$Result->show("danger", _("Invalid mapping ID."), true);
46
+	if ($_POST['id'] && !preg_match ('/^[0-9]+$/i', $_POST['id'])) {
47
+		$Result->show ("danger", _ ("Invalid mapping ID."), true);
48 48
 	}
49 49
 }
50 50
 
51 51
 
52 52
 # build the query parameter arrary
53
-$values = array('id' => $_POST['id'],
53
+$values = array ('id' => $_POST['id'],
54 54
 				'zoneId' => $_POST['zoneId'],
55 55
 				'alias' => $_POST['alias'],
56 56
 				'deviceId' => $_POST['deviceId'],
57 57
 				'interface' => $_POST['interface']
58 58
 				);
59 59
 # modify
60
-if(!$Zones->modify_mapping($_POST['action'],$values)) 	{ $Result->show("danger",  _("Cannot add mapping"), true); }
61
-else 													{ $Result->show("success", _("Mapping modified successfully"), true);  }
60
+if (!$Zones->modify_mapping ($_POST['action'], $values)) { $Result->show ("danger", _ ("Cannot add mapping"), true); }
61
+else { $Result->show ("success", _ ("Mapping modified successfully"), true); }
62 62
 ?>
63 63
\ No newline at end of file
Please login to merge, or discard this patch.