Completed
Pull Request — master (#532)
06:37
created
app/admin/import-export/import-recompute-logic.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -5,42 +5,42 @@  discard block
 block discarded – undo
5 5
  ******************************************/
6 6
 
7 7
 # include required scripts
8
-require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
9
-require_once( dirname(__FILE__) . '/../../../functions/PEAR/Net/IPv4.php' );
10
-require_once( dirname(__FILE__) . '/../../../functions/PEAR/Net/IPv6.php' );
8
+require_once(dirname (__FILE__).'/../../../functions/functions.php');
9
+require_once(dirname (__FILE__).'/../../../functions/PEAR/Net/IPv4.php');
10
+require_once(dirname (__FILE__).'/../../../functions/PEAR/Net/IPv6.php');
11 11
 
12 12
 # initialize user object, if not already set
13
-if (!isset($Database)) { $Database 	= new Database_PDO; }
13
+if (!isset($Database)) { $Database = new Database_PDO; }
14 14
 if (!isset($User)) { $User = new User ($Database); }
15 15
 if (!isset($Admin)) { $Admin = new Admin ($Database); }
16 16
 if (!isset($Tools)) { $Tools = new Tools ($Database); }
17
-if (!isset($Sections)) { $Sections	= new Sections ($Database); }
18
-if (!isset($Subnets)) { $Subnets	= new Subnets ($Database); }
17
+if (!isset($Sections)) { $Sections = new Sections ($Database); }
18
+if (!isset($Subnets)) { $Subnets = new Subnets ($Database); }
19 19
 
20 20
 # Load colors and icons
21 21
 include 'import-constants.php';
22 22
 
23
-$p=array();
24
-$pi4 = new Net_IPv4();	# Pear IPv4
25
-$pi6 = new Net_IPv6();	# Pear IPv6
23
+$p = array ();
24
+$pi4 = new Net_IPv4 (); # Pear IPv4
25
+$pi6 = new Net_IPv6 (); # Pear IPv6
26 26
 
27
-$rlist = array();
27
+$rlist = array ();
28 28
 $pass_inputs = ""; # Pass fields from one page to another
29 29
 
30 30
 # Pear IPv6 ip2Bin, local copy
31
-function my_ip2Bin($pi6,$ip)
31
+function my_ip2Bin ($pi6, $ip)
32 32
 {
33 33
 	$binstr = '';
34 34
 
35
-	$ip = $pi6->removeNetmaskSpec($ip);
36
-	$ip = $pi6->Uncompress($ip);
35
+	$ip = $pi6->removeNetmaskSpec ($ip);
36
+	$ip = $pi6->Uncompress ($ip);
37 37
 
38
-	$parts = explode(':', $ip);
38
+	$parts = explode (':', $ip);
39 39
 
40
-	foreach ( $parts as $v ) {
40
+	foreach ($parts as $v) {
41 41
 
42
-		$str     = base_convert($v, 16, 2);
43
-		$binstr .= str_pad($str, 16, '0', STR_PAD_LEFT);
42
+		$str     = base_convert ($v, 16, 2);
43
+		$binstr .= str_pad ($str, 16, '0', STR_PAD_LEFT);
44 44
 
45 45
 	}
46 46
 
@@ -48,59 +48,59 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 # Read selected fields and pass them to the save form
51
-foreach($_GET as $key => $value) {
52
-	if (preg_match("/recomputeSection_(\d+)$/",$key,$matches) && ($value == "on")) {
51
+foreach ($_GET as $key => $value) {
52
+	if (preg_match ("/recomputeSection_(\d+)$/", $key, $matches) && ($value == "on")) {
53 53
 		# Grab provided values
54 54
 		$rlist[$matches[1]]["IPv4"] = ($_GET['recomputeSectionIPv4_'.$matches[1]] == "on" ? true : false);
55 55
 		$rlist[$matches[1]]["IPv6"] = ($_GET['recomputeSectionIPv6_'.$matches[1]] == "on" ? true : false);
56 56
 		$rlist[$matches[1]]["CVRF"] = ($_GET['recomputeSectionCVRF_'.$matches[1]] == "on" ? true : false);
57 57
 		# Build hidden form inputs
58
-		$pass_inputs.="<input name='".$key."' type='hidden' value='".$value."' style='display:none;'>";
59
-		$pass_inputs.="<input name='recomputeSectionIPv4_".$matches[1]."' type='hidden' value='".$_GET['recomputeSectionIPv4_'.$matches[1]]."' style='display:none;'>";
60
-		$pass_inputs.="<input name='recomputeSectionIPv6_".$matches[1]."' type='hidden' value='".$_GET['recomputeSectionIPv6_'.$matches[1]]."' style='display:none;'>";
61
-		$pass_inputs.="<input name='recomputeSectionCVRF_".$matches[1]."' type='hidden' value='".$_GET['recomputeSectionCVRF_'.$matches[1]]."' style='display:none;'>";
58
+		$pass_inputs .= "<input name='".$key."' type='hidden' value='".$value."' style='display:none;'>";
59
+		$pass_inputs .= "<input name='recomputeSectionIPv4_".$matches[1]."' type='hidden' value='".$_GET['recomputeSectionIPv4_'.$matches[1]]."' style='display:none;'>";
60
+		$pass_inputs .= "<input name='recomputeSectionIPv6_".$matches[1]."' type='hidden' value='".$_GET['recomputeSectionIPv6_'.$matches[1]]."' style='display:none;'>";
61
+		$pass_inputs .= "<input name='recomputeSectionCVRF_".$matches[1]."' type='hidden' value='".$_GET['recomputeSectionCVRF_'.$matches[1]]."' style='display:none;'>";
62 62
 	}
63 63
 }
64 64
 
65 65
 #print "<pre>";print_r($rlist);print "</pre>";
66 66
 
67 67
 # fetch all sections and store their names
68
-$all_sections = $Sections->fetch_all_sections(); $sect_names = array();
69
-foreach($all_sections as $section) { $section = (array) $section; $sect_names[$section['id']] = $section['name']; }
68
+$all_sections = $Sections->fetch_all_sections (); $sect_names = array ();
69
+foreach ($all_sections as $section) { $section = (array) $section; $sect_names[$section['id']] = $section['name']; }
70 70
 
71 71
 # fetch all VRFs
72
-$all_vrfs = $Admin->fetch_all_objects("vrf", "vrfId"); $vrf_name = array();
73
-if (!$all_vrfs) { $all_vrfs = array(); }
72
+$all_vrfs = $Admin->fetch_all_objects ("vrf", "vrfId"); $vrf_name = array ();
73
+if (!$all_vrfs) { $all_vrfs = array (); }
74 74
 # insert default VRF in the list
75
-array_splice($all_vrfs,0,0,(object) array(array('vrfId' => '0', 'name' => 'default', 'rd' => '0:0')));
75
+array_splice ($all_vrfs, 0, 0, (object) array (array ('vrfId' => '0', 'name' => 'default', 'rd' => '0:0')));
76 76
 foreach ($all_vrfs as $vrf) { $vrf = (array) $vrf; $vrf_name[$vrf['vrfId']] = $vrf['name']; }
77 77
 
78 78
 # Precompute masks values, to avoid too much CPU load
79
-$masks = array();
79
+$masks = array ();
80 80
 for ($i = 0; $i <= 32; $i++) { $masks["IPv4"][$i] = 0xffffffff >> (32 - $i) << (32 - $i); }				# IPv4 masks, long
81
-for ($i = 0; $i <= 128; $i++) { $masks["IPv6"][$i] = str_repeat('1', $i).str_repeat('0', 128 - $i); }	# IPv6 masks, bin str
81
+for ($i = 0; $i <= 128; $i++) { $masks["IPv6"][$i] = str_repeat ('1', $i).str_repeat ('0', 128 - $i); }	# IPv6 masks, bin str
82 82
 
83 83
 # Read IPs for the sections we need to order
84 84
 foreach ($rlist as $sect_id => $sect_check) {
85
-	$section_subnets = $Subnets->fetch_section_subnets($sect_id);
85
+	$section_subnets = $Subnets->fetch_section_subnets ($sect_id);
86 86
 	# skip empty sections
87
-	if (sizeof($section_subnets)==0) { continue; }
87
+	if (sizeof ($section_subnets) == 0) { continue; }
88 88
 
89
-	$isFolder[$sect_id] = array();
89
+	$isFolder[$sect_id] = array ();
90 90
 	
91 91
 	foreach ($section_subnets as &$subnet) {
92 92
 		$subnet = (array) $subnet;
93
-		$subnet['ip'] = $Subnets->transform_to_dotted($subnet['subnet']);
94
-		$subnet['type'] = $Subnets->identify_address($subnet['ip']);
93
+		$subnet['ip'] = $Subnets->transform_to_dotted ($subnet['subnet']);
94
+		$subnet['type'] = $Subnets->identify_address ($subnet['ip']);
95 95
 		# Precompute subnet in AND format (long for IPv4 and bin str for IPv6)
96
-		$subnet['andip'] = ($subnet['type'] == "IPv4") ? $subnet['subnet'] : my_ip2Bin($pi6,$subnet['ip']);
96
+		$subnet['andip'] = ($subnet['type'] == "IPv4") ? $subnet['subnet'] : my_ip2Bin ($pi6, $subnet['ip']);
97 97
 		# Add to array
98 98
 		$edata[$sect_id][] = $subnet;
99 99
 		$isFolder[$sect_id][$subnet['id']] = $subnet['isFolder'];
100 100
 	}
101 101
 }
102 102
 
103
-$rows = ""; $counters = array();
103
+$rows = ""; $counters = array ();
104 104
 
105 105
 # Recompute master/nested relations for the selected sections and address families
106 106
 foreach ($rlist as $sect_id => $sect_check) {
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 
130 130
 		# At the end, save the new master
131 131
 		$c_subnet['new_masterSubnetId'] = $c_master_id;
132
-		$c_subnet['new_master'] = (($c_master_id === "0") ? _("Root") : $c_master_ip."/".$c_master_mask);
132
+		$c_subnet['new_master'] = (($c_master_id === "0") ? _ ("Root") : $c_master_ip."/".$c_master_mask);
133 133
 		$c_subnet['action'] = ($c_subnet['masterSubnetId'] == $c_subnet['new_masterSubnetId'] ? "skip" : "edit");
134
-		$c_subnet['msg'] = ($c_subnet['masterSubnetId'] == $c_subnet['new_masterSubnetId'] ? _("No change, skip") : _("New master, update"));
134
+		$c_subnet['msg'] = ($c_subnet['masterSubnetId'] == $c_subnet['new_masterSubnetId'] ? _ ("No change, skip") : _ ("New master, update"));
135 135
 
136
-		$rows.="<tr class='".$colors[$c_subnet['action']]."'><td><i class='fa ".$icons[$c_subnet['action']]."' rel='tooltip' data-placement='bottom' title='"._($c_subnet['msg'])."'></i></td>";
137
-		$rows.="<td>".$sect_names[$sect_id]."</td><td>".$c_subnet['ip']."/".$c_subnet['mask']."</td>";
138
-		$rows.="<td>".$c_subnet['description']."</td><td>".$vrf_name[$c_subnet['vrfId']]."</td><td>";
139
-		$rows.=$c_subnet['new_master']."</td><td>".$c_subnet['msg']."</td></tr>\n";
136
+		$rows .= "<tr class='".$colors[$c_subnet['action']]."'><td><i class='fa ".$icons[$c_subnet['action']]."' rel='tooltip' data-placement='bottom' title='"._ ($c_subnet['msg'])."'></i></td>";
137
+		$rows .= "<td>".$sect_names[$sect_id]."</td><td>".$c_subnet['ip']."/".$c_subnet['mask']."</td>";
138
+		$rows .= "<td>".$c_subnet['description']."</td><td>".$vrf_name[$c_subnet['vrfId']]."</td><td>";
139
+		$rows .= $c_subnet['new_master']."</td><td>".$c_subnet['msg']."</td></tr>\n";
140 140
 
141 141
 		$counters[$c_subnet['action']]++;
142 142
 	}
Please login to merge, or discard this patch.
app/admin/import-export/export-l2dom.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,51 +5,51 @@  discard block
 block discarded – undo
5 5
  *********************************/
6 6
 
7 7
 # include required scripts
8
-require( dirname(__FILE__) . '/../../../functions/functions.php' );
9
-require( dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php');
8
+require(dirname (__FILE__).'/../../../functions/functions.php');
9
+require(dirname (__FILE__).'/../../../functions/PEAR/Spreadsheet/Excel/Writer.php');
10 10
 
11 11
 # initialize required objects
12
-$Database	= new Database_PDO;
13
-$Result		= new Result;
14
-$User		= new User ($Database);
12
+$Database = new Database_PDO;
13
+$Result = new Result;
14
+$User = new User ($Database);
15 15
 $Admin		= new Admin ($Database);
16 16
 $Tools		= new Tools ($Database);
17 17
 
18 18
 # verify that user is logged in
19
-$User->check_user_session();
19
+$User->check_user_session ();
20 20
 
21 21
 # fetch all l2 domains
22
-$vlan_domains = $Admin->fetch_all_objects("vlanDomains", "id");
22
+$vlan_domains = $Admin->fetch_all_objects ("vlanDomains", "id");
23 23
 
24 24
 # Create a workbook
25
-$today = date("Ymd");
25
+$today = date ("Ymd");
26 26
 $filename = $today."_phpipam_L2-Domains_export.xls";
27
-$workbook = new Spreadsheet_Excel_Writer();
27
+$workbook = new Spreadsheet_Excel_Writer ();
28 28
 
29 29
 //formatting headers
30
-$format_header =& $workbook->addFormat();
31
-$format_header->setBold();
32
-$format_header->setColor('black');
33
-$format_header->setSize(12);
34
-$format_header->setAlign('left');
30
+$format_header = & $workbook->addFormat ();
31
+$format_header->setBold ();
32
+$format_header->setColor ('black');
33
+$format_header->setSize (12);
34
+$format_header->setAlign ('left');
35 35
 
36 36
 //formatting content
37
-$format_text =& $workbook->addFormat();
37
+$format_text = & $workbook->addFormat ();
38 38
 
39 39
 // Create a worksheet
40 40
 $worksheet_name = "L2 domains";
41
-$worksheet =& $workbook->addWorksheet($worksheet_name);
41
+$worksheet = & $workbook->addWorksheet ($worksheet_name);
42 42
 
43 43
 $lineCount = 0;
44 44
 $rowCount = 0;
45 45
 
46 46
 //write headers
47
-if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) {
48
-	$worksheet->write($lineCount, $rowCount, _('Name') ,$format_header);
47
+if ((isset($_GET['name'])) && ($_GET['name'] == "on")) {
48
+	$worksheet->write ($lineCount, $rowCount, _ ('Name'), $format_header);
49 49
 	$rowCount++;
50 50
 }
51
-if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) {
52
-	$worksheet->write($lineCount, $rowCount, _('Description') ,$format_header);
51
+if ((isset($_GET['description'])) && ($_GET['description'] == "on")) {
52
+	$worksheet->write ($lineCount, $rowCount, _ ('Description'), $format_header);
53 53
 	$rowCount++;
54 54
 }
55 55
 
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	//cast
61 61
 	$vlan_domain = (array) $vlan_domain;
62 62
 
63
-	if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) {
64
-		$worksheet->write($lineCount, $rowCount, $vlan_domain['name'], $format_text);
63
+	if ((isset($_GET['name'])) && ($_GET['name'] == "on")) {
64
+		$worksheet->write ($lineCount, $rowCount, $vlan_domain['name'], $format_text);
65 65
 		$rowCount++;
66 66
 	}
67
-	if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) {
68
-		$worksheet->write($lineCount, $rowCount, $vlan_domain['description'], $format_text);
67
+	if ((isset($_GET['description'])) && ($_GET['description'] == "on")) {
68
+		$worksheet->write ($lineCount, $rowCount, $vlan_domain['description'], $format_text);
69 69
 		$rowCount++;
70 70
 	}
71 71
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
 
77 77
 // sending HTTP headers
78
-$workbook->send($filename);
78
+$workbook->send ($filename);
79 79
 
80 80
 // Let's send the file
81
-$workbook->close();
81
+$workbook->close ();
82 82
 
83 83
 ?>
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/import-export/export-vlan.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -5,73 +5,73 @@  discard block
 block discarded – undo
5 5
  *********************************/
6 6
 
7 7
 # include required scripts
8
-require( dirname(__FILE__) . '/../../../functions/functions.php' );
9
-require( dirname(__FILE__) . '/../../../functions/PEAR/Spreadsheet/Excel/Writer.php');
8
+require(dirname (__FILE__).'/../../../functions/functions.php');
9
+require(dirname (__FILE__).'/../../../functions/PEAR/Spreadsheet/Excel/Writer.php');
10 10
 
11 11
 # initialize required objects
12
-$Database 	= new Database_PDO;
12
+$Database = new Database_PDO;
13 13
 $Result		= new Result;
14
-$User		= new User ($Database);
14
+$User = new User ($Database);
15 15
 $Admin	 	= new Admin ($Database);
16
-$Tools	    = new Tools ($Database);
16
+$Tools = new Tools ($Database);
17 17
 
18 18
 # verify that user is logged in
19
-$User->check_user_session();
19
+$User->check_user_session ();
20 20
 
21 21
 # fetch all l2 domains
22
-$vlan_domains = $Admin->fetch_all_objects("vlanDomains", "id");
22
+$vlan_domains = $Admin->fetch_all_objects ("vlanDomains", "id");
23 23
 
24 24
 # get all custom fields
25
-$custom_fields = $Tools->fetch_custom_fields('vlans');
25
+$custom_fields = $Tools->fetch_custom_fields ('vlans');
26 26
 
27 27
 # Create a workbook
28
-$today = date("Ymd");
28
+$today = date ("Ymd");
29 29
 $filename = $today."_phpipam_VLAN_export.xls";
30
-$workbook = new Spreadsheet_Excel_Writer();
30
+$workbook = new Spreadsheet_Excel_Writer ();
31 31
 
32 32
 //formatting headers
33
-$format_header =& $workbook->addFormat();
34
-$format_header->setBold();
35
-$format_header->setColor('black');
36
-$format_header->setSize(12);
37
-$format_header->setAlign('left');
33
+$format_header = & $workbook->addFormat ();
34
+$format_header->setBold ();
35
+$format_header->setColor ('black');
36
+$format_header->setSize (12);
37
+$format_header->setAlign ('left');
38 38
 
39 39
 //formatting content
40
-$format_text =& $workbook->addFormat();
40
+$format_text = & $workbook->addFormat ();
41 41
 
42 42
 // Create a worksheet
43 43
 $worksheet_name = "VLANs";
44
-$worksheet =& $workbook->addWorksheet($worksheet_name);
44
+$worksheet = & $workbook->addWorksheet ($worksheet_name);
45 45
 
46 46
 $lineCount = 0;
47 47
 $rowCount = 0;
48 48
 
49 49
 //write headers
50
-if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) {
51
-	$worksheet->write($lineCount, $rowCount, _('Name') ,$format_header);
50
+if ((isset($_GET['name'])) && ($_GET['name'] == "on")) {
51
+	$worksheet->write ($lineCount, $rowCount, _ ('Name'), $format_header);
52 52
 	$rowCount++;
53 53
 }
54
-if( (isset($_GET['number'])) && ($_GET['number'] == "on") ) {
55
-	$worksheet->write($lineCount, $rowCount, _('Number') ,$format_header);
54
+if ((isset($_GET['number'])) && ($_GET['number'] == "on")) {
55
+	$worksheet->write ($lineCount, $rowCount, _ ('Number'), $format_header);
56 56
 	$rowCount++;
57 57
 }
58
-if( (isset($_GET['domain'])) && ($_GET['domain'] == "on") ) {
59
-	$worksheet->write($lineCount, $rowCount, _('Domain') ,$format_header);
58
+if ((isset($_GET['domain'])) && ($_GET['domain'] == "on")) {
59
+	$worksheet->write ($lineCount, $rowCount, _ ('Domain'), $format_header);
60 60
 	$rowCount++;
61 61
 }
62
-if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) {
63
-	$worksheet->write($lineCount, $rowCount, _('Description') ,$format_header);
62
+if ((isset($_GET['description'])) && ($_GET['description'] == "on")) {
63
+	$worksheet->write ($lineCount, $rowCount, _ ('Description'), $format_header);
64 64
 	$rowCount++;
65 65
 }
66 66
 
67 67
 //custom fields
68
-if(sizeof($custom_fields) > 0) {
69
-	foreach($custom_fields as $myField) {
68
+if (sizeof ($custom_fields) > 0) {
69
+	foreach ($custom_fields as $myField) {
70 70
 		//set temp name - replace space with three ___
71
-		$myField['nameTemp'] = str_replace(" ", "___", $myField['name']);
71
+		$myField['nameTemp'] = str_replace (" ", "___", $myField['name']);
72 72
 
73
-		if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) {
74
-			$worksheet->write($lineCount, $rowCount, $myField['name'] ,$format_header);
73
+		if ((isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on")) {
74
+			$worksheet->write ($lineCount, $rowCount, $myField['name'], $format_header);
75 75
 			$rowCount++;
76 76
 		}
77 77
 	}
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	//cast
86 86
 	$vlan_domain = (array) $vlan_domain;
87 87
 
88
-	if( (isset($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])] == "on") ) {
88
+	if ((isset($_GET['exportDomain__'.str_replace (" ", "_", $vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace (" ", "_", $vlan_domain['name'])] == "on")) {
89 89
 		// get all VLANs in VLAN domain
90
-		$all_vlans = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain['id'], "number");
90
+		$all_vlans = $Admin->fetch_multiple_objects ("vlans", "domainId", $vlan_domain['id'], "number");
91 91
 		$all_vlans = (array) $all_vlans;
92 92
 		// skip empty domains
93
-		if (sizeof($all_vlans)==0) { continue; }
93
+		if (sizeof ($all_vlans) == 0) { continue; }
94 94
 		//write all VLAN entries
95 95
 		foreach ($all_vlans as $vlan) {
96 96
 			//cast
@@ -99,31 +99,31 @@  discard block
 block discarded – undo
99 99
 			//reset row count
100 100
 			$rowCount = 0;
101 101
 
102
-			if( (isset($_GET['name'])) && ($_GET['name'] == "on") ) {
103
-				$worksheet->write($lineCount, $rowCount, $vlan['name'], $format_text);
102
+			if ((isset($_GET['name'])) && ($_GET['name'] == "on")) {
103
+				$worksheet->write ($lineCount, $rowCount, $vlan['name'], $format_text);
104 104
 				$rowCount++;
105 105
 			}
106
-			if( (isset($_GET['number'])) && ($_GET['number'] == "on") ) {
107
-				$worksheet->write($lineCount, $rowCount, $vlan['number'], $format_text);
106
+			if ((isset($_GET['number'])) && ($_GET['number'] == "on")) {
107
+				$worksheet->write ($lineCount, $rowCount, $vlan['number'], $format_text);
108 108
 				$rowCount++;
109 109
 			}
110
-			if( (isset($_GET['domain'])) && ($_GET['domain'] == "on") ) {
111
-				$worksheet->write($lineCount, $rowCount, $vlan_domain['name'], $format_text);
110
+			if ((isset($_GET['domain'])) && ($_GET['domain'] == "on")) {
111
+				$worksheet->write ($lineCount, $rowCount, $vlan_domain['name'], $format_text);
112 112
 				$rowCount++;
113 113
 			}
114
-			if( (isset($_GET['description'])) && ($_GET['description'] == "on") ) {
115
-				$worksheet->write($lineCount, $rowCount, $vlan['description'], $format_text);
114
+			if ((isset($_GET['description'])) && ($_GET['description'] == "on")) {
115
+				$worksheet->write ($lineCount, $rowCount, $vlan['description'], $format_text);
116 116
 				$rowCount++;
117 117
 			}
118 118
 
119 119
 			//custom fields, per VLAN
120
-			if(sizeof($custom_fields) > 0) {
121
-				foreach($custom_fields as $myField) {
120
+			if (sizeof ($custom_fields) > 0) {
121
+				foreach ($custom_fields as $myField) {
122 122
 					//set temp name - replace space with three ___
123
-					$myField['nameTemp'] = str_replace(" ", "___", $myField['name']);
123
+					$myField['nameTemp'] = str_replace (" ", "___", $myField['name']);
124 124
 
125
-					if( (isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on") ) {
126
-						$worksheet->write($lineCount, $rowCount, $vlan[$myField['name']], $format_text);
125
+					if ((isset($_GET[$myField['nameTemp']])) && ($_GET[$myField['nameTemp']] == "on")) {
126
+						$worksheet->write ($lineCount, $rowCount, $vlan[$myField['name']], $format_text);
127 127
 						$rowCount++;
128 128
 					}
129 129
 				}
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 $lineCount++;
139 139
 
140 140
 //write domain sheet
141
-if( (isset($_GET['exportVLANDomains'])) && ($_GET['exportVLANDomains'] == "on") ) {
141
+if ((isset($_GET['exportVLANDomains'])) && ($_GET['exportVLANDomains'] == "on")) {
142 142
 	// Create a worksheet
143
-	$worksheet_domains =& $workbook->addWorksheet('Domains');
143
+	$worksheet_domains = & $workbook->addWorksheet ('Domains');
144 144
 
145 145
 	$lineCount = 0;
146 146
 	$rowCount = 0;
147 147
 
148 148
 	//write headers
149
-	$worksheet_domains->write($lineCount, $rowCount, _('Name') ,$format_header);
149
+	$worksheet_domains->write ($lineCount, $rowCount, _ ('Name'), $format_header);
150 150
 	$rowCount++;
151
-	$worksheet_domains->write($lineCount, $rowCount, _('Description') ,$format_header);
151
+	$worksheet_domains->write ($lineCount, $rowCount, _ ('Description'), $format_header);
152 152
 	$rowCount++;
153 153
 
154 154
 	$lineCount++;
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 		//cast
159 159
 		$vlan_domain = (array) $vlan_domain;
160 160
 
161
-		if( (isset($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace(" ", "_",$vlan_domain['name'])] == "on") ) {
162
-			$worksheet_domains->write($lineCount, $rowCount, $vlan_domain['name'], $format_text);
161
+		if ((isset($_GET['exportDomain__'.str_replace (" ", "_", $vlan_domain['name'])])) && ($_GET['exportDomain__'.str_replace (" ", "_", $vlan_domain['name'])] == "on")) {
162
+			$worksheet_domains->write ($lineCount, $rowCount, $vlan_domain['name'], $format_text);
163 163
 			$rowCount++;
164
-			$worksheet_domains->write($lineCount, $rowCount, $vlan_domain['description'], $format_text);
164
+			$worksheet_domains->write ($lineCount, $rowCount, $vlan_domain['description'], $format_text);
165 165
 			$rowCount++;
166 166
 		}
167 167
 
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 }
172 172
 
173 173
 // sending HTTP headers
174
-$workbook->send($filename);
174
+$workbook->send ($filename);
175 175
 
176 176
 // Let's send the file
177
-$workbook->close();
177
+$workbook->close ();
178 178
 
179 179
 ?>
180 180
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/import-export/generate-hosts.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,65 +6,65 @@
 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 user object
12
-$Database 	= new Database_PDO;
13
-$User 		= new User ($Database);
14
-$Sections	= new Sections ($Database);
12
+$Database = new Database_PDO;
13
+$User = new User ($Database);
14
+$Sections = new Sections ($Database);
15 15
 $Subnets	= new Subnets ($Database);
16
-$Addresses	= new Addresses ($Database);
17
-$Tools		= new Tools ($Database);
16
+$Addresses = new Addresses ($Database);
17
+$Tools = new Tools ($Database);
18 18
 $Result 	= new Result ();
19 19
 
20 20
 # verify that user is logged in
21
-$User->check_user_session();
21
+$User->check_user_session ();
22 22
 
23 23
 
24 24
 //set filename
25
-$filename = "phpipam_hosts_". date("Y-m-d");
25
+$filename = "phpipam_hosts_".date ("Y-m-d");
26 26
 
27 27
 //fetch all addresses with hostname set
28
-$hosts = $Tools->fetch_addresses_for_export();
28
+$hosts = $Tools->fetch_addresses_for_export ();
29 29
 
30 30
 //loop
31
-if(sizeof($hosts)>0) {
31
+if (sizeof ($hosts) > 0) {
32 32
 	//details
33
-	$m=0;
34
-	foreach($hosts as $host) {
33
+	$m = 0;
34
+	foreach ($hosts as $host) {
35 35
 		//fetch subnet and section details on change!
36
-		if(@$hosts[$m-1]->subnetId!=$hosts[$m]->subnetId) {
37
-			$subnet  = (array) $Subnets->fetch_subnet(null, $host->subnetId);
38
-			$section = (array) $Sections->fetch_section(null, $subnet['sectionId']);
36
+		if (@$hosts[$m - 1]->subnetId != $hosts[$m]->subnetId) {
37
+			$subnet  = (array) $Subnets->fetch_subnet (null, $host->subnetId);
38
+			$section = (array) $Sections->fetch_section (null, $subnet['sectionId']);
39 39
 
40 40
 			//first print subnet and section details
41
-			$res[] = "# $subnet[description] (".$Subnets->transform_to_dotted($subnet['subnet'])."/$subnet[mask]) - $section[description]";
41
+			$res[] = "# $subnet[description] (".$Subnets->transform_to_dotted ($subnet['subnet'])."/$subnet[mask]) - $section[description]";
42 42
 		}
43 43
 
44 44
 		//than address details
45
-		$diff = 17 - strlen($Subnets->transform_to_dotted($host->ip_addr));	//for print offset
46
-		$diff>0 ? : $diff = 3;												//IPv6 print offset
45
+		$diff = 17 - strlen ($Subnets->transform_to_dotted ($host->ip_addr)); //for print offset
46
+		$diff > 0 ? : $diff = 3; //IPv6 print offset
47 47
 
48
-		$res[] = $Subnets->transform_to_dotted($host->ip_addr).str_repeat(" ", $diff)."$host->dns_name";
48
+		$res[] = $Subnets->transform_to_dotted ($host->ip_addr).str_repeat (" ", $diff)."$host->dns_name";
49 49
 
50 50
 		//break
51
-		if($hosts[$m]->subnetId!=@$hosts[$m+1]->subnetId) {
51
+		if ($hosts[$m]->subnetId != @$hosts[$m + 1]->subnetId) {
52 52
 		$res[] = "";
53 53
 		}
54 54
 
55
-		$m++;		//next index
55
+		$m++; //next index
56 56
 	}
57 57
 }
58 58
 
59 59
 # join content
60
-$content = implode("\n", $res);
60
+$content = implode ("\n", $res);
61 61
 
62 62
 
63 63
 # headers
64
-header("Cache-Control: private");
65
-header("Content-Description: File Transfer");
66
-header('Content-type: application/octet-stream');
67
-header('Content-Disposition: attachment; filename="'. $filename .'"');
64
+header ("Cache-Control: private");
65
+header ("Content-Description: File Transfer");
66
+header ('Content-type: application/octet-stream');
67
+header ('Content-Disposition: attachment; filename="'.$filename.'"');
68 68
 
69 69
 print($content);
70 70
 ?>
71 71
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/users/edit.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -5,45 +5,45 @@  discard block
 block discarded – undo
5 5
  *************************************************/
6 6
 
7 7
 /* functions */
8
-require( dirname(__FILE__) . '/../../../functions/functions.php');
8
+require(dirname (__FILE__).'/../../../functions/functions.php');
9 9
 
10 10
 # initialize user object
11
-$Database 	= new Database_PDO;
12
-$User 		= new User ($Database);
11
+$Database = new Database_PDO;
12
+$User = new User ($Database);
13 13
 $Admin	 	= new Admin ($Database);
14 14
 $Tools	 	= new Tools ($Database);
15 15
 $Result 	= new Result ();
16 16
 
17 17
 # verify that user is logged in
18
-$User->check_user_session();
18
+$User->check_user_session ();
19 19
 
20 20
 # create csrf token
21 21
 $csrf = $User->csrf_cookie ("create", "user");
22 22
 
23 23
 
24 24
 # fetch custom fields
25
-$custom 	= $Tools->fetch_custom_fields('users');
25
+$custom 	= $Tools->fetch_custom_fields ('users');
26 26
 # fetch all languages
27 27
 $langs 		= $Admin->fetch_all_objects ("lang", "l_id");
28 28
 # fetch all auth types
29 29
 $auth_types = $Admin->fetch_all_objects ("usersAuthMethod", "id");
30 30
 # fetch all groups
31
-$groups		= $Admin->fetch_all_objects ("userGroups", "g_id");
31
+$groups = $Admin->fetch_all_objects ("userGroups", "g_id");
32 32
 
33 33
 
34 34
 # set header parameters and fetch user
35
-if($_POST['action']!="add") {
35
+if ($_POST['action'] != "add") {
36 36
 	$user = $Admin->fetch_object ("users", "id", $_POST['id']);
37 37
 	//false
38
-	if($user===false)		{ $Result->show("danger", _("Invalid ID"), true, true); }
38
+	if ($user === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); }
39 39
 	else {
40 40
 		$user = (array) $user;
41 41
 	}
42 42
 }
43 43
 else {
44
-	$user = array();
44
+	$user = array ();
45 45
 	//set default lang
46
-	$user['lang']=$User->settings->defaultLang;
46
+	$user['lang'] = $User->settings->defaultLang;
47 47
 }
48 48
 ?>
49 49
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
 <!-- header -->
68
-<div class="pHeader"><?php print ucwords($_POST['action'])." "._('user'); ?></div>
68
+<div class="pHeader"><?php print ucwords ($_POST['action'])." "._ ('user'); ?></div>
69 69
 
70 70
 
71 71
 <!-- content -->
@@ -77,35 +77,35 @@  discard block
 block discarded – undo
77 77
 	<tbody>
78 78
 	<!-- real name -->
79 79
 	<tr>
80
-	    <td><?php print _('Real name'); ?></td>
80
+	    <td><?php print _ ('Real name'); ?></td>
81 81
 	    <td><input type="text" class="form-control input-sm" name="real_name" value="<?php print @$user['real_name']; ?>"></td>
82
-       	<td class="info2"><?php print _('Enter users real name'); ?></td>
82
+       	<td class="info2"><?php print _ ('Enter users real name'); ?></td>
83 83
     </tr>
84 84
 
85 85
     <!-- username -->
86 86
     <tr>
87
-    	<td><?php print _('Username'); ?></td>
88
-    	<td><input type="text" class="form-control input-sm" name="username" value="<?php print @$user['username']; ?>" <?php if($_POST['action']=="edit"||$_POST['action']=="delete") print 'readonly'; ?>></td>
87
+    	<td><?php print _ ('Username'); ?></td>
88
+    	<td><input type="text" class="form-control input-sm" name="username" value="<?php print @$user['username']; ?>" <?php if ($_POST['action'] == "edit" || $_POST['action'] == "delete") print 'readonly'; ?>></td>
89 89
     	<td class="info2">
90 90
     		<a class='btn btn-xs btn-default adsearchuser' rel='tooltip' title='Search AD for user details'><i class='fa fa-search'></i></a>
91
-			<?php print _('Enter username'); ?>
91
+			<?php print _ ('Enter username'); ?>
92 92
 		</td>
93 93
     </tr>
94 94
 
95 95
     <!-- email -->
96 96
     <tr>
97
-    	<td><?php print _('e-mail'); ?></td>
97
+    	<td><?php print _ ('e-mail'); ?></td>
98 98
     	<td><input type="text" class="form-control input-sm input-w-250" name="email" value="<?php print @$user['email']; ?>"></td>
99
-    	<td class="info2"><?php print _('Enter users email address'); ?></td>
99
+    	<td class="info2"><?php print _ ('Enter users email address'); ?></td>
100 100
     </tr>
101 101
 
102 102
     <!-- role -->
103 103
     <tr>
104
-    	<td><?php print _('User role'); ?></td>
104
+    	<td><?php print _ ('User role'); ?></td>
105 105
     	<td>
106 106
         <select name="role" class="form-control input-sm input-w-auto">
107
-            <option value="Administrator"   <?php if (@$user['role'] == "Administrator") print "selected"; ?>><?php print _('Administrator'); ?></option>
108
-            <option value="User" 			<?php if (@$user['role'] == "User" || $_POST['action'] == "add") print "selected"; ?>><?php print _('Normal User'); ?></option>
107
+            <option value="Administrator"   <?php if (@$user['role'] == "Administrator") print "selected"; ?>><?php print _ ('Administrator'); ?></option>
108
+            <option value="User" 			<?php if (@$user['role'] == "User" || $_POST['action'] == "add") print "selected"; ?>><?php print _ ('Normal User'); ?></option>
109 109
         </select>
110 110
 
111 111
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
         <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>">
115 115
 
116 116
         </td>
117
-        <td class="info2"><?php print _('Select user role'); ?>
117
+        <td class="info2"><?php print _ ('Select user role'); ?>
118 118
 	    	<ul>
119
-		    	<li><?php print _('Administrator is almighty'); ?></li>
120
-		    	<li><?php print _('Users have access defined based on groups'); ?></li>
119
+		    	<li><?php print _ ('Administrator is almighty'); ?></li>
120
+		    	<li><?php print _ ('Users have access defined based on groups'); ?></li>
121 121
 		    </ul>
122 122
 		</td>
123 123
 	</tr>
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 
126 126
 	<!-- auth type -->
127 127
 	<tr>
128
-		<td><?php print _("Authentication method"); ?></td>
128
+		<td><?php print _ ("Authentication method"); ?></td>
129 129
 		<td>
130 130
 			<select name="authMethod" id="authMethod" class="form-control input-sm input-w-auto">
131 131
 			<?php
132
-			foreach($auth_types as $type) {
132
+			foreach ($auth_types as $type) {
133 133
 				# match
134
-				if($type->id==@$user['authMethod'])	{ print "<option value='$type->id' selected>$type->type ($type->description)</option>"; }
135
-				else								{ print "<option value='$type->id'         >$type->type ($type->description)</option>"; }
134
+				if ($type->id == @$user['authMethod']) { print "<option value='$type->id' selected>$type->type ($type->description)</option>"; }
135
+				else { print "<option value='$type->id'         >$type->type ($type->description)</option>"; }
136 136
 			}
137 137
 			?>
138 138
 			</select>
139 139
 		</td>
140
-		<td class="info2"><?php print _("Select authentication method for user"); ?></td>
140
+		<td class="info2"><?php print _ ("Select authentication method for user"); ?></td>
141 141
 	</tr>
142 142
 
143 143
 	<tr>
@@ -147,28 +147,28 @@  discard block
 block discarded – undo
147 147
 	</tbody>
148 148
 
149 149
     <!-- password -->
150
-	<tbody id="user_password" <?php if(@$user['authMethod']!="1" && isset($user['authMethod'])) print "style='display:none'"; ?>>
150
+	<tbody id="user_password" <?php if (@$user['authMethod'] != "1" && isset($user['authMethod'])) print "style='display:none'"; ?>>
151 151
 
152 152
     <tr class="password">
153
-    	<td><?php print _('Password'); ?></td>
153
+    	<td><?php print _ ('Password'); ?></td>
154 154
     	<td><input type="password" class="userPass form-control input-sm" name="password1"></td>
155
-    	<td class="info2"><?php print _("User's password"); ?> (<a href="#" id="randomPass"><?php print _('click to generate random'); ?>!</a>)</td>
155
+    	<td class="info2"><?php print _ ("User's password"); ?> (<a href="#" id="randomPass"><?php print _ ('click to generate random'); ?>!</a>)</td>
156 156
     </tr>
157 157
 
158 158
     <!-- password repeat -->
159 159
     <tr class="password">
160
-    	<td><?php print _('Password'); ?></td>
160
+    	<td><?php print _ ('Password'); ?></td>
161 161
     	<td><input type="password" class="userPass form-control input-sm" name="password2"></td>
162
-    	<td class="info2"><?php print _('Re-type password'); ?></td>
162
+    	<td class="info2"><?php print _ ('Re-type password'); ?></td>
163 163
     </tr>
164 164
 
165 165
     <!-- password change request -->
166
-    <?php if($_POST['action']=="add") { ?>
166
+    <?php if ($_POST['action'] == "add") { ?>
167 167
     <tr class="password">
168 168
     	<td></td>
169 169
     	<td class="info2" colspan="2">
170 170
     		<input type="checkbox" name="passChange" value="On" checked>
171
-			<?php print _('Require user to change password after initial login'); ?>
171
+			<?php print _ ('Require user to change password after initial login'); ?>
172 172
 		</td>
173 173
     </tr>
174 174
     <?php } ?>
@@ -180,55 +180,55 @@  discard block
 block discarded – undo
180 180
 	<tbody>
181 181
 	<!-- Language -->
182 182
 	<tr>
183
-		<td><?php print _('Language'); ?></td>
183
+		<td><?php print _ ('Language'); ?></td>
184 184
 		<td>
185 185
 			<select name="lang" class="form-control input-sm input-w-auto">
186 186
 				<?php
187
-				foreach($langs as $lang) {
188
-					if($lang->l_id==$user['lang'])	{ print "<option value='$lang->l_id' selected>$lang->l_name ($lang->l_code)</option>"; }
189
-					else							{ print "<option value='$lang->l_id'		 >$lang->l_name ($lang->l_code)</option>"; }
187
+				foreach ($langs as $lang) {
188
+					if ($lang->l_id == $user['lang']) { print "<option value='$lang->l_id' selected>$lang->l_name ($lang->l_code)</option>"; }
189
+					else { print "<option value='$lang->l_id'		 >$lang->l_name ($lang->l_code)</option>"; }
190 190
 				}
191 191
 				?>
192 192
 			</select>
193 193
 		</td>
194
-		<td class="info2"><?php print _('Select language'); ?></td>
194
+		<td class="info2"><?php print _ ('Select language'); ?></td>
195 195
 	</tr>
196 196
 
197 197
     <!-- send notification mail -->
198 198
     <tr>
199
-    	<td><?php print _('Notification'); ?></td>
200
-    	<td><input type="checkbox" name="notifyUser" value="on" <?php if($_POST['action'] == "add") { print 'checked'; } else if($_POST['action'] == "delete") { print 'disabled="disabled"';} ?>></td>
201
-    	<td class="info2"><?php print _('Send notification email to user with account details'); ?></td>
199
+    	<td><?php print _ ('Notification'); ?></td>
200
+    	<td><input type="checkbox" name="notifyUser" value="on" <?php if ($_POST['action'] == "add") { print 'checked'; } else if ($_POST['action'] == "delete") { print 'disabled="disabled"'; } ?>></td>
201
+    	<td class="info2"><?php print _ ('Send notification email to user with account details'); ?></td>
202 202
     </tr>
203 203
 	</tbody>
204 204
 
205 205
 	<!-- mailNotify -->
206
-	<tbody id="user_notifications" <?php if(@$user['role']!="Administrator") print "style='display:none'"; ?>>
206
+	<tbody id="user_notifications" <?php if (@$user['role'] != "Administrator") print "style='display:none'"; ?>>
207 207
 	<tr>
208
-    	<td><?php print _('Mail State changes'); ?></td>
208
+    	<td><?php print _ ('Mail State changes'); ?></td>
209 209
     	<td>
210 210
         <select name="mailNotify" class="form-control input-sm input-w-auto">
211
-            <option value="No"><?php print _('No'); ?></option>
212
-            <option value="Yes"  <?php if (@$user['mailNotify'] == "Yes") print "selected='selected'"; ?>><?php print _('Yes'); ?></option>
211
+            <option value="No"><?php print _ ('No'); ?></option>
212
+            <option value="Yes"  <?php if (@$user['mailNotify'] == "Yes") print "selected='selected'"; ?>><?php print _ ('Yes'); ?></option>
213 213
         </select>
214 214
 
215 215
 
216 216
         </td>
217
-        <td class="info2"><?php print _('Select yes to receive notification change mail for State change'); ?></td>
217
+        <td class="info2"><?php print _ ('Select yes to receive notification change mail for State change'); ?></td>
218 218
 	</tr>
219 219
 
220 220
 	<!-- mailNotifyChangelog -->
221 221
 	<tr>
222
-    	<td><?php print _('Mail Changelog'); ?></td>
222
+    	<td><?php print _ ('Mail Changelog'); ?></td>
223 223
     	<td>
224 224
         <select name="mailChangelog" class="form-control input-sm input-w-auto">
225
-            <option value="No"><?php print _('No'); ?></option>
226
-            <option value="Yes" <?php if (@$user['mailChangelog'] == "Yes") print "selected='selected'"; ?>><?php print _('Yes'); ?></option>
225
+            <option value="No"><?php print _ ('No'); ?></option>
226
+            <option value="Yes" <?php if (@$user['mailChangelog'] == "Yes") print "selected='selected'"; ?>><?php print _ ('Yes'); ?></option>
227 227
         </select>
228 228
 
229 229
 
230 230
         </td>
231
-        <td class="info2"><?php print _('Select yes to receive notification change mail for changelog'); ?></td>
231
+        <td class="info2"><?php print _ ('Select yes to receive notification change mail for changelog'); ?></td>
232 232
 	</tr>
233 233
 	</tbody>
234 234
 
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
 		<td colspan="3"><hr></td>
239 239
 	</tr>
240 240
 	<tr>
241
-		<td><?php print _('Groups'); ?></td>
241
+		<td><?php print _ ('Groups'); ?></td>
242 242
 		<td class="groups">
243 243
 		<?php
244 244
 		//print groups
245
-		if($groups!==false) {
245
+		if ($groups !== false) {
246 246
 			//set groups
247
-			$ugroups = json_decode(@$user['groups'], true);
248
-			$ugroups = $Admin->groups_parse_ids($ugroups);
247
+			$ugroups = json_decode (@$user['groups'], true);
248
+			$ugroups = $Admin->groups_parse_ids ($ugroups);
249 249
 
250
-			foreach($groups as $g) {
250
+			foreach ($groups as $g) {
251 251
 				# empty fix
252
-				if(sizeof($ugroups) > 0) {
253
-					if(in_array($g->g_id, $ugroups)) 	{ print "<input type='checkbox' name='group$g->g_id' checked>$g->g_name<br>"; }
254
-					else 								{ print "<input type='checkbox' name='group$g->g_id'		>$g->g_name<br>"; }
252
+				if (sizeof ($ugroups) > 0) {
253
+					if (in_array ($g->g_id, $ugroups)) { print "<input type='checkbox' name='group$g->g_id' checked>$g->g_name<br>"; }
254
+					else { print "<input type='checkbox' name='group$g->g_id'		>$g->g_name<br>"; }
255 255
 				}
256 256
 				else {
257 257
 														{ print "<input type='checkbox' name='group$g->g_id'>$g->g_name<br>"; }
@@ -259,32 +259,32 @@  discard block
 block discarded – undo
259 259
 			}
260 260
 		}
261 261
 		else {
262
-			$Result->show("danger", _("No groups configured"), false);
262
+			$Result->show ("danger", _ ("No groups configured"), false);
263 263
 		}
264 264
 
265 265
 		?>
266 266
 		</td>
267
-		<td class="info2"><?php print _('Select to which groups the user belongs to'); ?></td>
267
+		<td class="info2"><?php print _ ('Select to which groups the user belongs to'); ?></td>
268 268
 	</tr>
269 269
 
270 270
 	<!-- pdns -->
271
-    <?php if ($User->settings->enablePowerDNS==1) { ?>
271
+    <?php if ($User->settings->enablePowerDNS == 1) { ?>
272 272
 	<tbody>
273 273
 	<tr>
274 274
 		<td colspan="3"><hr></td>
275 275
 	</tr>
276 276
 	<tr>
277
-    	<td><?php print _("PowerDNS"); ?></td>
277
+    	<td><?php print _ ("PowerDNS"); ?></td>
278 278
     	<td>
279
-            <input type="checkbox" class="input-switch" value="Yes" name="pdns" <?php if(@$user->pdns == "Yes") print 'checked'; ?>>
279
+            <input type="checkbox" class="input-switch" value="Yes" name="pdns" <?php if (@$user->pdns == "Yes") print 'checked'; ?>>
280 280
     	</td>
281
-		<td class="info2"><?php print _('Select to allow user to create DNS records'); ?></td>
281
+		<td class="info2"><?php print _ ('Select to allow user to create DNS records'); ?></td>
282 282
 	</tr>
283 283
     <?php } ?>
284 284
 
285 285
 	<!-- Custom -->
286 286
 	<?php
287
-	if(sizeof($custom) > 0) {
287
+	if (sizeof ($custom) > 0) {
288 288
 		print '<tr>';
289 289
 		print '	<td colspan="3"><hr></td>';
290 290
 		print '</tr>';
@@ -293,39 +293,39 @@  discard block
 block discarded – undo
293 293
 		$timeP = 0;
294 294
 
295 295
 		# all my fields
296
-		foreach($custom as $field) {
296
+		foreach ($custom as $field) {
297 297
 			# replace spaces with |
298
-			$field['nameNew'] = str_replace(" ", "___", $field['name']);
298
+			$field['nameNew'] = str_replace (" ", "___", $field['name']);
299 299
 
300 300
 			# required
301
-			if($field['Null']=="NO")	{ $required = "*"; }
302
-			else						{ $required = ""; }
301
+			if ($field['Null'] == "NO") { $required = "*"; }
302
+			else { $required = ""; }
303 303
 
304 304
 			# set default value !
305
-			if ($_POST['action']=="add")	{ $user[$field['name']] = $field['Default']; }
305
+			if ($_POST['action'] == "add") { $user[$field['name']] = $field['Default']; }
306 306
 
307
-			print '<tr>'. "\n";
308
-			print '	<td>'. $field['name'] .' '.$required.'</td>'. "\n";
309
-			print '	<td>'. "\n";
307
+			print '<tr>'."\n";
308
+			print '	<td>'.$field['name'].' '.$required.'</td>'."\n";
309
+			print '	<td>'."\n";
310 310
 
311 311
 			//set type
312
-			if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") {
312
+			if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") {
313 313
 				//parse values
314
-				$tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type']));
314
+				$tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type']));
315 315
 				//null
316
-				if($field['Null']!="NO") { array_unshift($tmp, ""); }
316
+				if ($field['Null'] != "NO") { array_unshift ($tmp, ""); }
317 317
 
318 318
 				print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
319
-				foreach($tmp as $v) {
320
-					if($v==$user[$field['name']])	{ print "<option value='$v' selected='selected'>$v</option>"; }
321
-					else								{ print "<option value='$v'>$v</option>"; }
319
+				foreach ($tmp as $v) {
320
+					if ($v == $user[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; }
321
+					else { print "<option value='$v'>$v</option>"; }
322 322
 				}
323 323
 				print "</select>";
324 324
 			}
325 325
 			//date and time picker
326
-			elseif($field['type'] == "date" || $field['type'] == "datetime") {
326
+			elseif ($field['type'] == "date" || $field['type'] == "datetime") {
327 327
 				// just for first
328
-				if($timeP==0) {
328
+				if ($timeP == 0) {
329 329
 					print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">';
330 330
 					print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>';
331 331
 					print '<script type="text/javascript">';
@@ -341,39 +341,39 @@  discard block
 block discarded – undo
341 341
 				$timeP++;
342 342
 
343 343
 				//set size
344
-				if($field['type'] == "date")	{ $size = 10; $class='datepicker';		$format = "yyyy-MM-dd"; }
345
-				else							{ $size = 19; $class='datetimepicker';	$format = "yyyy-MM-dd"; }
344
+				if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; }
345
+				else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; }
346 346
 
347 347
 				//field
348
-				if(!isset($user[$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"; }
349
-				else								{ print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $user[$field['name']]. '" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; }
348
+				if (!isset($user[$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"; }
349
+				else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" value="'.$user[$field['name']].'" rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; }
350 350
 			}
351 351
 			//boolean
352
-			elseif($field['type'] == "tinyint(1)") {
352
+			elseif ($field['type'] == "tinyint(1)") {
353 353
 				print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>";
354
-				$tmp = array(0=>"No",1=>"Yes");
354
+				$tmp = array (0=>"No", 1=>"Yes");
355 355
 				//null
356
-				if($field['Null']!="NO") { $tmp[2] = ""; }
356
+				if ($field['Null'] != "NO") { $tmp[2] = ""; }
357 357
 
358
-				foreach($tmp as $k=>$v) {
359
-					if(strlen($user[$field['name']])==0 && $k==2)	{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
360
-					elseif($k==$user[$field['name']])				{ print "<option value='$k' selected='selected'>"._($v)."</option>"; }
361
-					else											{ print "<option value='$k'>"._($v)."</option>"; }
358
+				foreach ($tmp as $k=>$v) {
359
+					if (strlen ($user[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; }
360
+					elseif ($k == $user[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; }
361
+					else { print "<option value='$k'>"._ ($v)."</option>"; }
362 362
 				}
363 363
 				print "</select>";
364 364
 			}
365 365
 			//text
366
-			elseif($field['type'] == "text") {
367
-				print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" rowspan=3>'. $user[$field['name']]. '</textarea>'. "\n";
366
+			elseif ($field['type'] == "text") {
367
+				print ' <textarea class="form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" rowspan=3>'.$user[$field['name']].'</textarea>'."\n";
368 368
 			}
369 369
 			//default - input field
370 370
 			else {
371
-				print ' <input type="text" class="ip_addr form-control input-sm" name="'. @$field['nameNew'] .'" placeholder="'. @$field['name'] .'" value="'. @$user[$field['name']]. '" size="30">'. "\n";
371
+				print ' <input type="text" class="ip_addr form-control input-sm" name="'.@$field['nameNew'].'" placeholder="'.@$field['name'].'" value="'.@$user[$field['name']].'" size="30">'."\n";
372 372
 			}
373 373
 
374 374
 			print "	<td class='info2'>".$field['Comment']."</td>";
375
-			print '	</td>'. "\n";
376
-			print '</tr>'. "\n";
375
+			print '	</td>'."\n";
376
+			print '</tr>'."\n";
377 377
 		}
378 378
 	}
379 379
 	?>
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 <!-- footer -->
390 390
 <div class="pFooter">
391 391
 	<div class="btn-group">
392
-		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
393
-		<button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editUserSubmit"><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>
392
+		<button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button>
393
+		<button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editUserSubmit"><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>
394 394
 	</div>
395 395
 
396 396
 	<!-- Result -->
Please login to merge, or discard this patch.
app/admin/users/print-user.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -5,46 +5,46 @@  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 user details
11
-$user 		  = $Admin->fetch_object("users", "id", $_GET['subnetId']);
11
+$user = $Admin->fetch_object ("users", "id", $_GET['subnetId']);
12 12
 
13 13
 # invalid?
14
-if($user===false)		{ $Result->show("danger", _("Invalid ID"), true); }
14
+if ($user === false) { $Result->show ("danger", _ ("Invalid ID"), true); }
15 15
 
16 16
 # fetch user lang
17
-$language 	  = $Admin->fetch_object("lang", "l_id", $user->lang);
17
+$language = $Admin->fetch_object ("lang", "l_id", $user->lang);
18 18
 # check users auth method
19
-$auth_details = $Admin->fetch_object("usersAuthMethod", "id", $user->authMethod);
19
+$auth_details = $Admin->fetch_object ("usersAuthMethod", "id", $user->authMethod);
20 20
 # fetch custom fields
21
-$custom_fields = $Tools->fetch_custom_fields('users');
21
+$custom_fields = $Tools->fetch_custom_fields ('users');
22 22
 ?>
23 23
 
24 24
 <!-- display existing users -->
25
-<h4><?php print _('User details'); ?></h4>
25
+<h4><?php print _ ('User details'); ?></h4>
26 26
 <hr><br>
27 27
 
28 28
 <!-- Add new -->
29
-<a class='btn btn-sm btn-default' href="<?php print create_link("administration","users"); ?>" style="margin-bottom:10px;"><i class='fa fa-angle-left'></i> <?php print _('All users'); ?></a>
29
+<a class='btn btn-sm btn-default' href="<?php print create_link ("administration", "users"); ?>" style="margin-bottom:10px;"><i class='fa fa-angle-left'></i> <?php print _ ('All users'); ?></a>
30 30
 
31 31
 <!-- table -->
32 32
 <table id="userPrint" class="table table-hover table-auto table-condensed">
33 33
 
34 34
 <tr>
35
-	<td><?php print _('Real Name'); ?></td>
35
+	<td><?php print _ ('Real Name'); ?></td>
36 36
 	<td><strong><?php print $user->real_name; ?></strong></td>
37 37
 </tr>
38 38
 <tr>
39
-	<td><?php print _('Username'); ?></td>
39
+	<td><?php print _ ('Username'); ?></td>
40 40
 	<td><?php print $user->username; ?></td>
41 41
 </tr>
42 42
 <tr>
43
-	<td><?php print _('E-mail'); ?></td>
43
+	<td><?php print _ ('E-mail'); ?></td>
44 44
 	<td><?php print $user->email; ?></td>
45 45
 </tr>
46 46
 <tr>
47
-	<td><?php print _('Language'); ?></td>
47
+	<td><?php print _ ('Language'); ?></td>
48 48
 	<td><?php print $language->l_name; ?></td>
49 49
 </tr>
50 50
 <tr>
@@ -59,42 +59,42 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
 <tr>
62
-	<td colspan="2"><h4><?php print _('Authentication settings'); ?></h4><hr></td>
62
+	<td colspan="2"><h4><?php print _ ('Authentication settings'); ?></h4><hr></td>
63 63
 </tr>
64 64
 
65 65
 <tr>
66
-	<td><?php print _('Role'); ?></td>
66
+	<td><?php print _ ('Role'); ?></td>
67 67
 	<td><?php print $user->role; ?></td>
68 68
 </tr>
69 69
 <tr>
70
-	<td><?php print _('Authentication'); ?></td>
70
+	<td><?php print _ ('Authentication'); ?></td>
71 71
 	<td>
72 72
 	<?php
73
-	if($auth_details===false) 	{ print "<span class='text-muted'>No auth method</span>"; }
74
-	else 					 	{ print $auth_details->type." <span class='text-muted'>(".$auth_details->description.")</span>"; }
73
+	if ($auth_details === false) { print "<span class='text-muted'>No auth method</span>"; }
74
+	else { print $auth_details->type." <span class='text-muted'>(".$auth_details->description.")</span>"; }
75 75
 	?>
76 76
 	</td>
77 77
 </tr>
78 78
 <tr>
79
-	<td><?php print _('Last login'); ?></td>
80
-	<td><?php print strlen($user->lastLogin)>0 ? $user->lastLogin : "<span class='text-muted'>"._("Never")."</span>"; ?></td>
79
+	<td><?php print _ ('Last login'); ?></td>
80
+	<td><?php print strlen ($user->lastLogin) > 0 ? $user->lastLogin : "<span class='text-muted'>"._ ("Never")."</span>"; ?></td>
81 81
 </tr>
82 82
 <tr>
83
-	<td><?php print _('Last activity'); ?></td>
84
-	<td><?php print strlen($user->lastActivity)>0 ? $user->lastActivity : "<span class='text-muted'>"._("Never")."</span>"; ?></td>
83
+	<td><?php print _ ('Last activity'); ?></td>
84
+	<td><?php print strlen ($user->lastActivity) > 0 ? $user->lastActivity : "<span class='text-muted'>"._ ("Never")."</span>"; ?></td>
85 85
 </tr>
86 86
 <tr>
87
-	<td><?php print _('Groups'); ?></td>
87
+	<td><?php print _ ('Groups'); ?></td>
88 88
 	<td>
89 89
 	<?php
90
-	if($user->role == "Administrator") {
91
-	print _('All groups');
90
+	if ($user->role == "Administrator") {
91
+	print _ ('All groups');
92 92
 	}
93 93
 	else {
94
-		$groups = json_decode($user->groups, true);
95
-		$gr = $Admin->groups_parse($groups);
96
-		if(sizeof($gr)>0) {
97
-			foreach($gr as $group) {
94
+		$groups = json_decode ($user->groups, true);
95
+		$gr = $Admin->groups_parse ($groups);
96
+		if (sizeof ($gr) > 0) {
97
+			foreach ($gr as $group) {
98 98
 				print $group['g_name']."<br>";
99 99
 			}
100 100
 		}
@@ -106,64 +106,64 @@  discard block
 block discarded – undo
106 106
 	</td>
107 107
 </tr>
108 108
 <tr>
109
-	<td><?php print _('Password change required'); ?></td>
109
+	<td><?php print _ ('Password change required'); ?></td>
110 110
 	<td><?php print $user->passChange; ?></td>
111 111
 </tr>
112 112
 
113 113
 
114 114
 
115 115
 <tr>
116
-	<td colspan="2"><h4><?php print _('Display settings'); ?></h4><hr></td>
116
+	<td colspan="2"><h4><?php print _ ('Display settings'); ?></h4><hr></td>
117 117
 </tr>
118 118
 <tr>
119
-	<td><?php print _('compress override'); ?></td>
120
-	<td><?php print $user->compressOverride==1 ? _("Yes") : _("No") ?></td>
119
+	<td><?php print _ ('compress override'); ?></td>
120
+	<td><?php print $user->compressOverride == 1 ? _ ("Yes") : _ ("No") ?></td>
121 121
 </tr>
122 122
 <tr>
123
-	<td><?php print _('Hide free range'); ?></td>
124
-	<td><?php print $user->hideFreeRange==1 ? _("Yes") : _("No") ?></td>
123
+	<td><?php print _ ('Hide free range'); ?></td>
124
+	<td><?php print $user->hideFreeRange == 1 ? _ ("Yes") : _ ("No") ?></td>
125 125
 </tr>
126 126
 <tr>
127
-	<td><?php print _('IP address print limit'); ?></td>
127
+	<td><?php print _ ('IP address print limit'); ?></td>
128 128
 	<td><?php print $user->printLimit; ?></td>
129 129
 </tr>
130 130
 
131 131
 
132 132
 
133 133
 <tr>
134
-	<td colspan="2"><h4><?php print _('Mail settings'); ?></h4><hr></td>
134
+	<td colspan="2"><h4><?php print _ ('Mail settings'); ?></h4><hr></td>
135 135
 </tr>
136 136
 <tr>
137
-	<td><?php print _('Mail notifications'); ?></td>
138
-	<td><?php print $user->role == "Administrator" ? _($user->mailNotify) : _("No"); ?></td>
137
+	<td><?php print _ ('Mail notifications'); ?></td>
138
+	<td><?php print $user->role == "Administrator" ? _ ($user->mailNotify) : _ ("No"); ?></td>
139 139
 </tr>
140 140
 <tr>
141
-	<td><?php print _('Changelog notifications'); ?></td>
142
-	<td><?php print $user->role == "Administrator" ? _($user->mailChangelog) : _("No"); ?></td>
141
+	<td><?php print _ ('Changelog notifications'); ?></td>
142
+	<td><?php print $user->role == "Administrator" ? _ ($user->mailChangelog) : _ ("No"); ?></td>
143 143
 </tr>
144 144
 
145 145
 
146 146
 
147 147
 <tr>
148
-	<td colspan="2"><h4><?php print _('Custom fields'); ?></h4><hr></td>
148
+	<td colspan="2"><h4><?php print _ ('Custom fields'); ?></h4><hr></td>
149 149
 </tr>
150 150
 
151 151
 <?php
152 152
 # custom subnet fields
153
-if(sizeof($custom_fields) > 0) {
154
-	foreach($custom_fields as $key=>$field) {
155
-		$user->$key = str_replace("\n", "<br>",$user->$key);
153
+if (sizeof ($custom_fields) > 0) {
154
+	foreach ($custom_fields as $key=>$field) {
155
+		$user->$key = str_replace ("\n", "<br>", $user->$key);
156 156
 		print "<tr>";
157 157
 		print "	<td>$key</td>";
158 158
 		print "	<td>";
159 159
 		//no length
160
-		if(strlen($user->$key)==0) {
160
+		if (strlen ($user->$key) == 0) {
161 161
 			print "/";
162 162
 		}
163 163
 		//booleans
164
-		elseif($field['type']=="tinyint(1)")	{
165
-			if($user->$key == "0")		{ print _("No"); }
166
-			elseif($user->$key == "1")	{ print _("Yes"); }
164
+		elseif ($field['type'] == "tinyint(1)") {
165
+			if ($user->$key == "0") { print _ ("No"); }
166
+			elseif ($user->$key == "1") { print _ ("Yes"); }
167 167
 		}
168 168
 		else {
169 169
 			print $user->$key;
Please login to merge, or discard this patch.
app/admin/users/index.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,16 +5,16 @@
 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
 // switch user
11
-if(@$_GET['subnetId']=="switch"){
11
+if (@$_GET['subnetId'] == "switch") {
12 12
 	$_SESSION['realipamusername'] = $_SESSION['ipamusername'];
13 13
 	$_SESSION['ipamusername'] = $_GET['sPage'];
14
-	print '<script>window.location.href = "'.create_link(null).'";</script>';
14
+	print '<script>window.location.href = "'.create_link (null).'";</script>';
15 15
 }
16 16
 
17 17
 # print all or specific user?
18
-if(isset($_GET['subnetId']))	{ include("print-user.php"); }
19
-else							{ include("print-all.php"); }
18
+if (isset($_GET['subnetId'])) { include("print-user.php"); }
19
+else { include("print-all.php"); }
20 20
 ?>
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
app/admin/users/ad-search-result.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,84 +5,84 @@  discard block
 block discarded – undo
5 5
  *************************************/
6 6
 
7 7
 /* functions */
8
-require( dirname(__FILE__) . '/../../../functions/functions.php');
9
-require( dirname(__FILE__) . "/../../../functions/adLDAP/src/adLDAP.php");
8
+require(dirname (__FILE__).'/../../../functions/functions.php');
9
+require(dirname (__FILE__)."/../../../functions/adLDAP/src/adLDAP.php");
10 10
 
11 11
 # initialize user object
12
-$Database 	= new Database_PDO;
13
-$User 		= new User ($Database);
12
+$Database = new Database_PDO;
13
+$User = new User ($Database);
14 14
 $Admin	 	= new Admin ($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
 # fetch server
21
-$server = $Admin->fetch_object("usersAuthMethod", "id", $_POST['server']);
22
-$server!==false ? : $Result->show("danger", _("Invalid server ID"), true);
21
+$server = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['server']);
22
+$server !== false ? : $Result->show ("danger", _ ("Invalid server ID"), true);
23 23
 
24 24
 //parse parameters
25
-$params = json_decode($server->params);
25
+$params = json_decode ($server->params);
26 26
 
27 27
 //no login parameters
28
-if(strlen(@$params->adminUsername)==0 || strlen(@$params->adminPassword)==0)	{ $Result->show("danger", _("Missing credentials"), true); }
28
+if (strlen (@$params->adminUsername) == 0 || strlen (@$params->adminPassword) == 0) { $Result->show ("danger", _ ("Missing credentials"), true); }
29 29
 //at least 2 chars
30
-if(strlen($_POST['dname'])<2) 													{ $Result->show("danger", _('Please enter at least 2 characters'), true); }
30
+if (strlen ($_POST['dname']) < 2) { $Result->show ("danger", _ ('Please enter at least 2 characters'), true); }
31 31
 
32 32
 
33 33
 //open connection
34 34
 try {
35
-	if($server->type == "NetIQ") { $params->account_suffix = ""; }
35
+	if ($server->type == "NetIQ") { $params->account_suffix = ""; }
36 36
 	//set options
37
-	$options = array(
37
+	$options = array (
38 38
 			'base_dn'=>$params->base_dn,
39 39
 			'account_suffix'=>$params->account_suffix,
40
-			'domain_controllers'=>explode(";",$params->domain_controllers),
40
+			'domain_controllers'=>explode (";", $params->domain_controllers),
41 41
 			'use_ssl'=>$params->use_ssl,
42 42
 			'use_tls'=>$params->use_tls,
43 43
 			'ad_port'=>$params->ad_port
44 44
 			);
45 45
 	//AD
46
-	$adldap = new adLDAP($options);
46
+	$adldap = new adLDAP ($options);
47 47
 
48 48
 	//try to login with higher credentials for search
49
-	$authUser = $adldap->authenticate($params->adminUsername, $params->adminPassword);
49
+	$authUser = $adldap->authenticate ($params->adminUsername, $params->adminPassword);
50 50
 	if ($authUser == false) {
51
-		$Result->show("danger", _("Invalid credentials"), true);
51
+		$Result->show ("danger", _ ("Invalid credentials"), true);
52 52
 	}
53 53
 
54 54
 	// set OpenLDAP flag
55
-	if($server->type == "LDAP") { $adldap->setUseOpenLDAP(true); }
55
+	if ($server->type == "LDAP") { $adldap->setUseOpenLDAP (true); }
56 56
 
57 57
 	//search for domain user!
58
-	$userinfo = $adldap->user()->info("$_POST[dname]*", array("*"),false,$server->type);
58
+	$userinfo = $adldap->user ()->info ("$_POST[dname]*", array ("*"), false, $server->type);
59 59
 
60 60
 	//echo $adldap->getLastError();
61 61
 }
62 62
 catch (adLDAPException $e) {
63
-	$Result->show("danger", $e->getMessage(), true);
63
+	$Result->show ("danger", $e->getMessage (), true);
64 64
 }
65 65
 
66 66
 
67 67
 //check for found
68
-if(!isset($userinfo['count'])) {
68
+if (!isset($userinfo['count'])) {
69 69
 	print "<div class='alert alert-info'>";
70
-	print _('No users found')."!<hr>";
71
-	print _('Possible reasons').":";
70
+	print _ ('No users found')."!<hr>";
71
+	print _ ('Possible reasons').":";
72 72
 	print "<ul>";
73
-	print "<li>"._('Username not existing')."</li>";
74
-	print "<li>"._('Invalid baseDN setting for AD')."</li>";
75
-	print "<li>"._('AD account does not have enough privileges for search')."</li>";
73
+	print "<li>"._ ('Username not existing')."</li>";
74
+	print "<li>"._ ('Invalid baseDN setting for AD')."</li>";
75
+	print "<li>"._ ('AD account does not have enough privileges for search')."</li>";
76 76
 	print "</div>";
77 77
 } else {
78
-	print _(" Following users were found").": ($userinfo[count]):<hr>";
78
+	print _ (" Following users were found").": ($userinfo[count]):<hr>";
79 79
 
80 80
 	print "<table class='table table-striped'>";
81 81
 
82 82
 	unset($userinfo['count']);
83
-	if(sizeof(@$userinfo)>0 && isset($userinfo)) {
83
+	if (sizeof (@$userinfo) > 0 && isset($userinfo)) {
84 84
 		// loop
85
-		foreach($userinfo as $u) {
85
+		foreach ($userinfo as $u) {
86 86
 			print "<tr>";
87 87
 			print "	<td>".$u['displayname'][0];
88 88
 			print "</td>";
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			print "	<td>".$u['mail'][0]."</td>";
91 91
 			//actions
92 92
 			print " <td style='width:10px;'>";
93
-			print "		<a href='' class='btn btn-sm btn-default btn-success userselect' data-uname='".$u['displayname'][0]."' data-username='".$u['samaccountname'][0]."' data-email='".$u['mail'][0]."' data-server='".$_POST['server']."' data-server-type='".$server->type."'>"._('Select')."</a>";
93
+			print "		<a href='' class='btn btn-sm btn-default btn-success userselect' data-uname='".$u['displayname'][0]."' data-username='".$u['samaccountname'][0]."' data-email='".$u['mail'][0]."' data-server='".$_POST['server']."' data-server-type='".$server->type."'>"._ ('Select')."</a>";
94 94
 			print "	</td>";
95 95
 			print "</tr>";
96 96
 		}
Please login to merge, or discard this patch.
app/admin/users/ad-search-form.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,32 +5,32 @@  discard block
 block discarded – undo
5 5
  *************************************/
6 6
 
7 7
 /* functions */
8
-require( dirname(__FILE__) . '/../../../functions/functions.php');
8
+require(dirname (__FILE__).'/../../../functions/functions.php');
9 9
 
10 10
 # initialize user object
11
-$Database 	= new Database_PDO;
12
-$User 		= new User ($Database);
11
+$Database = new Database_PDO;
12
+$User = new User ($Database);
13 13
 $Admin	 	= new Admin ($Database);
14 14
 $Result 	= new Result ();
15 15
 
16 16
 # verify that user is logged in
17
-$User->check_user_session();
17
+$User->check_user_session ();
18 18
 
19 19
 # fetch all available LDAP servers
20 20
 $servers = $Admin->fetch_all_objects ("usersAuthMethod");
21
-foreach($servers as $k=>$s) {
22
-	if($s->type!="AD" && $s->type!="LDAP" && $s->type!="NetIQ") {
21
+foreach ($servers as $k=>$s) {
22
+	if ($s->type != "AD" && $s->type != "LDAP" && $s->type != "NetIQ") {
23 23
 		unset($servers[$k]);
24 24
 	}
25 25
 }
26 26
 
27 27
 # die if no servers
28
-if(sizeof($servers)==0) 	{ $Result->show("danger", _("No servers available"), true, true); }
28
+if (sizeof ($servers) == 0) { $Result->show ("danger", _ ("No servers available"), true, true); }
29 29
 ?>
30 30
 
31 31
 
32 32
 <!-- header -->
33
-<div class="pHeader"><?php print _('Search user in AD'); ?></div>
33
+<div class="pHeader"><?php print _ ('Search user in AD'); ?></div>
34 34
 
35 35
 <!-- content -->
36 36
 <div class="pContent">
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 	<tr>
41 41
 		<td style="width:150px;">Enter username</td>
42
-		<td><input type="text" class="form-control input-sm" id='dusername' name="dusername" placeholder="<?php print _('Username'); ?>"></td>
42
+		<td><input type="text" class="form-control input-sm" id='dusername' name="dusername" placeholder="<?php print _ ('Username'); ?>"></td>
43 43
 	</tr>
44 44
 
45 45
 	<tr>
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		<td>
48 48
 			<select name="server" id="adserver" class="form-control input-w-auto">
49 49
 			<?php
50
-			foreach($servers as $s) {
50
+			foreach ($servers as $s) {
51 51
 				print "<option value='$s->id'>$s->description</option>";
52 52
 			}
53 53
 			?>
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 	<tr>
63 63
 		<td></td>
64
-		<td><button class='btn btn-sm btn-default pull-right' class="form-control input-sm" id="adsearchusersubmit"><?php print _('Search'); ?></button></td>
64
+		<td><button class='btn btn-sm btn-default pull-right' class="form-control input-sm" id="adsearchusersubmit"><?php print _ ('Search'); ?></button></td>
65 65
 	</tr>
66 66
 
67 67
 	</table>
@@ -72,6 +72,6 @@  discard block
 block discarded – undo
72 72
 <!-- footer -->
73 73
 <div class="pFooter">
74 74
 	<div class="btn-group">
75
-		<button class="btn btn-sm btn-default hidePopup2"><?php print _('Cancel'); ?></button>
75
+		<button class="btn btn-sm btn-default hidePopup2"><?php print _ ('Cancel'); ?></button>
76 76
 	</div>
77 77
 </div>
78 78
\ No newline at end of file
Please login to merge, or discard this patch.