Project

General

Profile

« Previous | Next » 

Revision 6c07db48

Added by Phil Davis about 10 years ago

Code spacing

and other random stuff I noticed.
I think this finishes messing with code style. The codebase should match
the developer style guide closely enough that 99.9% of changes will not
feel the need to also massage the formatting.

View differences:

usr/local/www/status_dhcp_leases.php
47 47
require("guiconfig.inc");
48 48
require_once("config.inc");
49 49

  
50
$pgtitle = array(gettext("Status"),gettext("DHCP leases"));
50
$pgtitle = array(gettext("Status"), gettext("DHCP leases"));
51 51
$shortcut_section = "dhcp";
52 52

  
53 53
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
......
60 60
	/* $leases_contents has the lines of the file, including the newline char at the end of each line. */
61 61
	$leases_contents = file($leasesfile);
62 62
	$newleases_contents = array();
63
	$i=0;
63
	$i = 0;
64 64
	while ($i < count($leases_contents)) {
65 65
		/* Find the lease(s) we want to delete */
66 66
		if ($leases_contents[$i] == "lease {$_GET['deleteip']} {\n") {
......
116 116
	return $dt;
117 117
}
118 118

  
119
function remove_duplicate($array, $field)
120
{
119
function remove_duplicate($array, $field) {
121 120
	foreach ($array as $sub) {
122 121
		$cmp[] = $sub[$field];
123 122
	}
124
	$unique = array_unique(array_reverse($cmp,true));
123
	$unique = array_unique(array_reverse($cmp, true));
125 124
	foreach ($unique as $k => $rien) {
126 125
		$new[] = $array[$k];
127 126
	}
......
141 140
$arpdata_ip = array();
142 141
$arpdata_mac = array();
143 142
foreach ($rawdata as $line) {
144
	$elements = explode(' ',$line);
143
	$elements = explode(' ', $line);
145 144
	if ($elements[3] != "(incomplete)") {
146 145
		$arpent = array();
147
		$arpdata_ip[] = trim(str_replace(array('(',')'),'',$elements[1]));
146
		$arpdata_ip[] = trim(str_replace(array('(', ')'), '', $elements[1]));
148 147
		$arpdata_mac[] = strtolower(trim($elements[3]));
149 148
	}
150 149
}
......
167 166
		$i++;
168 167
		continue;
169 168
	}
170
	while($f < $fcount) {
169
	while ($f < $fcount) {
171 170
		switch ($data[$f]) {
172 171
			case "failover":
173 172
				$pools[$p]['name'] = trim($data[$f+2], '"');
......
251 250
				break;
252 251
			case "client-hostname":
253 252
				if ($data[$f+1] <> "") {
254
					$leases[$l]['hostname'] = preg_replace('/"/','',$data[$f+1]);
253
					$leases[$l]['hostname'] = preg_replace('/"/', '', $data[$f+1]);
255 254
				} else {
256 255
					$hostname = gethostbyaddr($leases[$l]['ip']);
257 256
					if ($hostname <> "") {
......
276 275

  
277 276
/* remove duplicate items by mac address */
278 277
if (count($leases) > 0) {
279
	$leases = remove_duplicate($leases,"ip");
278
	$leases = remove_duplicate($leases, "ip");
280 279
}
281 280

  
282 281
if (count($pools) > 0) {
283
	$pools = remove_duplicate($pools,"name");
282
	$pools = remove_duplicate($pools, "name");
284 283
	asort($pools);
285 284
}
286 285

  
......
405 404
				echo "<td class=\"listr\">{$fspans}{$data['mac']}{$fspane}</td>\n";
406 405
			}
407 406
		}
408
		echo "<td class=\"listr\">{$fspans}"  . htmlentities($data['hostname']) . "{$fspane}</td>\n";
407
		echo "<td class=\"listr\">{$fspans}" . htmlentities($data['hostname']) . "{$fspane}</td>\n";
409 408
		if ($data['type'] != "static") {
410 409
			echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n";
411 410
			echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n";

Also available in: Unified diff