Only in admin/: README.metrix
Only in /home/rob/pebble/src/wifiadmin-0.0.4/: confirm_account.php
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/create-update-rrds.php admin/create-update-rrds.php
--- /home/rob/pebble/src/wifiadmin-0.0.4/create-update-rrds.php 2004-12-05 01:16:50.000000000 -0800
+++ admin/create-update-rrds.php 2005-02-03 23:50:53.000000000 -0800
@@ -38,7 +38,7 @@
if (!is_dir( $rrd_database_path))
mkdir( $rrd_database_path, 0777);
-// For each wireless if get wif name, signal and noise, quality, etc into rrds
+// For each wireless if get wif name, signal and noise, and rate into rrds
foreach ( $status as $device => $device_status)
{
//if device in master mode, create-update number of connected users rrd
@@ -49,7 +49,7 @@
print "creating nusers database for $device\n";
$rrd_create_cmd = $rrdtool_bin." create ".$nusers_rrd_filename."\
--step 300\
- DS:nusers:GAUGE:600:0:30\
+ DS:nusers:GAUGE:600:U:U\
RRA:AVERAGE:0.5:1:600\
RRA:AVERAGE:0.5:6:700\
RRA:AVERAGE:0.5:24:775\
@@ -64,8 +64,7 @@
}
//insert nusers into rrd
$nusers = get_connected_users_num( $device );
- $rrd_update_cmd = $rrdtool_bin." update ".$nusers_rrd_filename."\
- --template nusers N:".$nusers;
+ $rrd_update_cmd = $rrdupdate_bin."-gauge ".$device;
echo "Updating nusers rrd for ".$device."\n".$rrd_update_cmd."\n";
$out = `$rrd_update_cmd`;
echo $out;
@@ -73,16 +72,15 @@
}
//if device not in master mode, create signal-noise graphs
- $rrd_filename = $rrd_database_path.$device.".rrd";
+ $rrd_filename = $rrd_database_path.$device."-radio.rrd";
//check whether the coresponding rrd exists, if not, create
if (!file_exists($rrd_filename)) {
- print "creating signal-noise database for $device\n";
+ print "creating signal-noise database $rrd_filename for $device\n";
$rrd_create_cmd = $rrdtool_bin." create ".$rrd_filename."\
--step 300\
- DS:signal:GAUGE:600:-150:0\
- DS:noise:GAUGE:600:-150:0\
- DS:quality:GAUGE:600:0:100\
- DS:rate:GAUGE:600:0:100\
+ DS:signal:GAUGE:600:U:U\
+ DS:noise:GAUGE:600:U:U\
+ DS:rate:GAUGE:600:U:U\
RRA:AVERAGE:0.5:1:600\
RRA:AVERAGE:0.5:6:700\
RRA:AVERAGE:0.5:24:775\
@@ -96,14 +94,8 @@
echo $out."\n";
}
- //strip trailing /92 out of quality string
- $pos = strpos($device_status["quality"], '/');
- if ($pos)
- $device_status["quality"] = substr($device_status["quality"],0,$pos);
-
//insert signal, noise into rrd
- $rrd_update_cmd = $rrdtool_bin." update ".$rrd_filename."\
- --template signal:noise:quality:rate N:".$device_status["signal"].":".$device_status["noise"].":".$device_status["quality"].":".$device_status["rate"];
+ $rrd_update_cmd = $rrdupdate_bin."-radio ".$device;
echo "Updating rrd for ".$device."\n".$rrd_update_cmd."\n";
$out = `$rrd_update_cmd`;
echo $out;
@@ -123,8 +115,8 @@
print "creating traffic database for $device\n";
$rrd_create_cmd = $rrdtool_bin." create ".$traffic_rrd_filename."\
--step 300 \
- DS:in:COUNTER:600:0:100000000 \
- DS:out:COUNTER:600:0:100000000 \
+ DS:in:COUNTER:600:U:U \
+ DS:out:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
@@ -139,8 +131,7 @@
}
//insert tx,rx into rrd
- $rrd_update_cmd = $rrdtool_bin." update ".$traffic_rrd_filename."\
- --template in:out N:".$device_status["rx"].":".$device_status["tx"];
+ $rrd_update_cmd = $rrdupdate_bin." ".$device;
echo "Updating rrd for ".$device."\n".$rrd_update_cmd."\n";
$out = `$rrd_update_cmd`;
echo $out;
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/create_graphs.php admin/create_graphs.php
--- /home/rob/pebble/src/wifiadmin-0.0.4/create_graphs.php 2004-12-06 02:46:52.000000000 -0800
+++ admin/create_graphs.php 2005-01-19 14:17:01.000000000 -0800
@@ -88,6 +88,7 @@
# generate signal/noise graph
$graph_create_cmd = $rrdtool_bin." graph ".
$graphs_path."$device-signal-$interval.png\
+ --lazy\
--imgformat=PNG \
--start=$magic_number\
--title=\"$interval $device signal-noise\"\
@@ -117,6 +118,7 @@
//generate rate graph
$graph_create_cmd = $rrdtool_bin." graph ".
$graphs_path."$device-rate-$interval.png\
+ --lazy\
--imgformat=PNG\
--start=$magic_number\
--title=\" $device rate $interval graph\"\
@@ -157,6 +159,7 @@
# generate nusers graph
$graph_create_cmd = $rrdtool_bin." graph ".
$graphs_path."$device-nusers-$interval.png\
+ --lazy\
--imgformat=PNG\
--start=$magic_number\
--title=\"$interval associations on device $device\"\
@@ -186,6 +189,7 @@
{
$graph_create_cmd = $rrdtool_bin." graph ".
$graphs_path."$device-traffic-$interval.png\
+ --lazy\
--imgformat=PNG \
--start=$magic_number\
--title=\"$device $interval traffic\" \
Only in /home/rob/pebble/src/wifiadmin-0.0.4/: forgotpassword.php
Only in admin/: graphs
Only in admin/: help
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/ifsettings.php admin/ifsettings.php
--- /home/rob/pebble/src/wifiadmin-0.0.4/ifsettings.php 2004-12-21 13:57:50.000000000 -0800
+++ admin/ifsettings.php 2005-02-10 15:16:08.000000000 -0800
@@ -25,80 +25,13 @@
***********************************************/
include("./include/header.php"); //echo the default Header entries
+include("./include/if_functions.php");
+include("./include/ip_functions.php");
-//returns a 32char string
-function dectobin($dectobin) {
- $cadtemp="";
- $dectobin = decbin($dectobin);
- $numins = 8 - strlen($dectobin);
-
- for ($i = 0; $i < $numins; $i++) {
- $cadtemp = $cadtemp."0";
- }
-return $cadtemp.$dectobin;
-}
-
-function broadcast_address($decimal_netmask_octet,$decimal_ip_octet) {
- $tempchar="";
- $bin_bcast="";
- $cadres="";
- $bin_netmask=dectobin($decimal_netmask_octet);
- $bin_ip=dectobin($decimal_ip_octet);
-
- for ($i=0;$i<8;$i++) {
- $tempchar = substr($bin_netmask,$i,1);
- if ($tempchar=="1") {
- $cadres=$cadres.substr($bin_ip,$i,1);
- } else {
- $cadres=$cadres."1";
- }
- }
- return bindec($cadres);
-}
-
-function ipmask($in_ip,$in_mask){
- /* Check netmask */
- if (4 != sscanf($in_mask,"%d.%d.%d.%d", $mask_octets[0], $mask_octets[1], $mask_octets[2], $mask_octets[3])) {
- echo "
Invalid netmask \"$in_mask\".
";
- return false;
- }
- foreach ($mask_octets as $mask_octet) {
- if ($mask_octet < 0 || $mask_octet > 255) {
- echo "Invalid octet $mask_octet in \"$in_mask\".
";
- return false;
- }
- }
-
- /* Check IP address */
- if (4 != sscanf($in_ip,"%d.%d.%d.%d", $ip_octets[0],$ip_octets[1],$ip_octets[2],$ip_octets[3])) {
- echo "Invalid ip address \"$in_ip\".
";
- return false;
- }
- foreach ($ip_octets as $ip_octet) {
- if ($ip_octet < 0 || $ip_octet > 255) {
- echo "Invalid octet $ip_octet in \"$in_ip\".
";
- return false;
- }
- }
-
- for($n_octet = 0; $n_octet < 4; $n_octet++)
- {
- $bcast_octets[$n_octet] = broadcast_address($mask_octets[$n_octet], $ip_octets[$n_octet]);
- $netaddr_octets[$n_octet] = $ip_octets[$n_octet] & $mask_octets[$n_octet];
- }
-
-
- $string_netaddr = sprintf ("%d.%d.%d.%d",$netaddr_octets[0], $netaddr_octets[1], $netaddr_octets[2], $netaddr_octets[3]);
- $string_bcast = sprintf ("%d.%d.%d.%d",$bcast_octets[0], $bcast_octets[1], $bcast_octets[2], $bcast_octets[3]);
-
- $array["bcast"]= $string_bcast;
- $array["netaddr"]= $string_netaddr;
-
- return $array;
-}
?>
-Ethernet Settings
+
+Network Settings
//check privileges
@@ -132,109 +65,101 @@
else
echo "".$ifs[$i]." \n";
}
-if ($_GET['action'] == "show_routing_table")
- echo "Router \n";
-else
- echo "Router \n";
echo "";
switch ($_GET["action"]){
- case "edit_new_route":
- $devices = array_keys($ethernet_statuses);?>
-
- break;
- case "save_new_route":
- echo "Saving new route ";
- $routes = get_routing_table();
- $route_cmd = $route_bin." add -net ".escapeshellarg($_GET["target"])." netmask ".escapeshellarg($_GET["netmask"]);
- if ($_GET["gateway"] != "")
- $route_cmd = $route_cmd." gw ".escapeshellarg($_GET["gateway"]);
- if ($_GET["device"] != "Determined by Gateway")
- $route_cmd = $route_cmd." dev ".escapeshellarg($_GET["device"]);
- $route_output = `$route_cmd`;
- echo "$route_cmd $route_output ";
- echo "view new routing table ";
- break;
- case "delete_route":
- echo "deleting route ";
- $routes = get_routing_table();
- $route_cmd = $route_bin." del -net ".$routes[ $_GET["route_id"] ]["destination"]." netmask ".$routes[ $_GET["route_id"] ]["netmask"]." dev ".$routes[ $_GET["route_id"] ]["iface"];
- $route_output = `$route_cmd`;
- echo "$route_cmd $route_output ";
- //don't delte another route in case of refresh
- $_GET["action"] = "show_routing_table";
- //don't break, go on and show the new routing table
- case "show_routing_table":
- $routes = get_routing_table();
- echo "Current routing table ";?>
- ";
- break;
case "save_device_changes":
+ $changes = 0;
$selected_device = $_GET["device"];
$device_status = $ethernet_statuses[$selected_device];
- if($_GET["mtu"] != $device_status["mtu"]){
- $new_mtu = $_GET["mtu"];
- echo "Changing mtu to " .$new_mtu. "
";
- $command = $ifconfig_bin." ".$selected_device." mtu ".$new_mtu ;
- $output = `$command`;
- echo "
".$output." ";
+
+ echo "
";
+ if(isset($_GET["disableme"])) {
+ if(!get_disabled($selected_device)) {
+ echo "Disabling DHCP server on $selected_device ";
+ set_dhcpd($selected_device,false);
+ echo "Disabling $selected_device ";
+ set_disabled($selected_device,true);
+ $changes = 1;
+ }
+ }
+ else {
+ if(get_disabled($selected_device)) {
+ set_disabled($selected_device,false);
+ echo "Enabling $selected_device ";
+ $changes = 1;
+ }
+ }
+
+ // We're not disabled. Are we changing IP or DHCP?
+ if(!get_disabled($selected_device)) {
+ if(isset($_GET["dhcp"]) && (!get_dhcp($selected_device))) {
+ echo "Enabling DHCP client on $selected_device ";
+ set_iface($selected_device,"dhcp",null,null,null,null);
+ $changes = 1;
+ }
+ else {
+ foreach(array("ipaddr","mask","bcast","mtu","gateway") as $setting) {
+ // If one changes, set everything
+ if(isset($_GET[$setting]) && ($device_status[$setting] != $_GET[$setting])) {
+ echo "Configuring IP settings for $selected_device ";
+ set_iface($selected_device,$_GET["ipaddr"],$_GET["mask"],$_GET["bcast"],$_GET["mtu"],$_GET["gateway"]);
+ $changes = 1;
+ break;
+ }
+ }
+ }
+
+ if(isset($_GET["dhcpd"]) && (!get_dhcpd($selected_device))) {
+ echo "Enabling DHCP server on $selected_device ";
+ set_dhcpd($selected_device,true);
+ $changes = 1;
+ }
+ elseif(!isset($_GET["dhcpd"]) && (get_dhcpd($selected_device))) {
+ echo "Disabling DHCP server on $selected_device ";
+ set_dhcpd($selected_device,false);
+ $changes = 1;
+ }
+
+ // Any changes to the dhcpd conf?
+ if(isset($_GET["dhcpd"])) {
+ $dhchanges = 0;
+ if(!(isset($_GET["dhstart"]) && (isset($_GET["dhend"])) )) {
+ // error: need start and end
+ }
+ $dhcpd_conf = get_dhcpdconf($selected_device);
+ foreach(array_keys($dhcpd_conf) as $prop) {
+ if(!isset($_GET[$prop])) {
+ $dhchanges = 1;
+ break;
+ }
+ if($dhcpd_conf[$prop] != $_GET[$prop]) {
+ $dhchanges = 1;
+ break;
+ }
+ }
+ if($dhchanges) {
+ $dhcpd_conf = "";
+ foreach(array("dhstart","dhend","dhtime","dhgateway","dhdomain","dhsubnet","dhdns") as $prop) {
+ if(isset($_GET[$prop]))
+ $dhcpd_conf[$prop] = $_GET[$prop];
+ }
+ set_dhcpdconf($selected_device,$dhcpd_conf);
+ $changes = 1;
+ }
+ }
+ } # if(!disabled)
+
+ echo " ";
+
+ if($changes) {
+ echo "Back to Network Settings ";
+ break;
}
- else
- echo "Leaving mtu unchanged
";
-
- if ($_GET["ipaddr"]!=$device_status["ipaddr"] || $_GET["mask"] != $device_status["mask"]){
- //check if supplied ip and mask are valid
- $array = ipmask($_GET["ipaddr"],$_GET["mask"]);
- if ($array == false)
- break;
- $bcast = $array["bcast"];
- $ipaddr = $_GET["ipaddr"];
- $mask = $_GET["mask"];
- echo "
Changing $selected_device to ip: ". $ipaddr." netmask: ".$mask. "
";
- $command = $ifconfig_bin." ".$selected_device." ".$ipaddr." broadcast ".$bcast." netmask ". $mask;
- $output = `$command`;
- echo "
".$output." ";
+ else {
+ $ethernet_statuses = get_ethernet_status();
}
- else
- echo "Leaving ip and netmask unchanged
";
- //get possibly updated ethernet_status to show
- $ethernet_statuses = get_ethernet_status();
- //don't break here, go on and show the new status
+
case "show_device_status":
// Print Device information
$selected_device = $_GET["device"];
@@ -245,26 +170,86 @@
if ($array == false)
exit();
$device_status["bcast"] = $array["bcast"];
- $device_status["netaddr"] = $array["netaddr"];
}
else
{
$device_status["bcast"] = "";
- $device_status["netaddr"] = "";
+ $device_status["mask"] = "";
+ $device_status["mtu"] = "";
+ $device_status["gateway"] = "";
+ }
+ $device_status["disabled"] = get_disabled($selected_device);
+ $device_status["dhcp"] = get_dhcp($selected_device);
+ $device_status["dhcpd"] = get_dhcpd($selected_device);
+
+ $dhcpd_conf = get_dhcpdconf($selected_device);
+ foreach(array("dhstart","dhend","dhtime","dhgateway","dhdomain","dhsubnet","dhdns") as $prop) {
+ if(isset($dhcpd_conf[$prop]))
+ $device_status[$prop] = $dhcpd_conf[$prop];
+ else
+ $device_status[$prop] = "";
}
- echo "
Current setting for device $selected_device ";
?>
+
+
+
+
-
+
}
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/include/config.php admin/include/config.php
--- /home/rob/pebble/src/wifiadmin-0.0.4/include/config.php 2004-12-21 14:45:00.000000000 -0800
+++ admin/include/config.php 2005-02-04 21:17:28.000000000 -0800
@@ -29,32 +29,33 @@
//page iwstatus can refresh every some seconds
//so that that its information is up-to-date
//leave blank for NO refresh
-$status_refresh = "120";
+$status_refresh = "360";
-$resolve = true; //should iwstatus resolve the assosiated clients IPs to DNS names?Might be a little slower, but its nicer
+$resolve = false; //should iwstatus resolve the associated clients IPs to DNS names?Might be a little slower, but its nicer
$resolve_timeout = 1; //in sec, the timeout for reverce DNS lookups
//you probably don't have to mess with these two:
$hostap_device_path = "/proc/net/hostap/";
$wireless_filename = "/proc/net/wireless";
//Paths to binaries
-$iwconfig_bin = 'sudo iwconfig';
-$iwlist_bin = 'sudo iwlist';
-$iwpriv_bin = 'sudo iwpriv';
+$iwconfig_bin = 'iwconfig';
+$iwlist_bin = 'iwlist';
+$iwpriv_bin = 'iwpriv';
$rrdtool_bin = 'rrdtool';
-$ifconfig_bin = 'sudo ifconfig';
-$route_bin = 'sudo route';
-$host_bin = 'sudo host';
-$arp_bin = 'sudo arp';
+$rrdupdate_bin = 'rrd-update';
+$ifconfig_bin = 'ifconfig -a';
+$route_bin = 'route';
+$host_bin = 'host';
+$arp_bin = 'arp';
//set true to authenticate users and give each specific privileges,
//or false to treat everyone as admin
-$global_auth = true;
+$global_auth = false;
//Using mysql for authentication and user-community information management, gives wifiadmin
//a lot more funtionality. If you choose false, usernames, privileges and passords will be stored
//in a plain text file.
-$use_mysql = true;
+$use_mysql = false;
//set these if you chose true above.
@@ -64,7 +65,7 @@
$USERS_DBPASS = "wifiadmin"; //mysql password
//Where to save the passwd file (when $use_mysql is false)
-$passwd_filename = "./include/passwd";
+$passwd_filename = "/etc/wifiadmin.passwd";
//where will rrd tool store its database and the produced graph images
$rrd_database_path = "rrd_database/";
@@ -85,5 +86,5 @@
$WEB_MASTER_EMAIL = "root@localhost";
//do you want render time to be recorded and displayed at the bottom of the page?
-$count_time = true;
+$count_time = false;
?>
Only in admin/include: disabler.js
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/include/functions.php admin/include/functions.php
--- /home/rob/pebble/src/wifiadmin-0.0.4/include/functions.php 2004-12-21 14:45:00.000000000 -0800
+++ admin/include/functions.php 2005-02-10 15:29:54.000000000 -0800
@@ -100,7 +100,7 @@
if ($fp = fopen('/proc/sys/kernel/hostname', 'r')) {
$result = trim(fgets($fp, 4096));
fclose($fp);
- $result = gethostbyaddr(gethostbyname($result));
+ //$result = gethostbyaddr(gethostbyname($result));
} else {
$result = 'N.A.';
}
@@ -122,10 +122,10 @@
$tx_bytes[] = str_replace("tx_bytes=","",$list[$i]);
elseif (!(strpos($list[$i],"silence=")=== FALSE))
- $noise[] = str_replace("silence=","",$list[$i])-256;
+ $noise[] = str_replace("silence=","",$list[$i]);
elseif (!(strpos($list[$i],"signal=")=== FALSE))
- $signal[] = str_replace("signal=","",$list[$i])-256;
+ $signal[] = str_replace("signal=","",$list[$i]);
}
for($i=0;$i /var/tmp/hostname`;
+ privcmd("cp /var/tmp/hostname /ro/etc/hostname",true);
+ `rm -f /var/tmp/hostname`;
+ return true;
+}
+
+/************************************************
+* get_sshkeys()
+* Return root's authorized_keys2
+*************************************************/
+function get_sshkeys() {
+ $filename = '/root/.ssh/authorized_keys2';
+ if(file_exists($filename) && (filesize($filename) > 0)) {
+ $fd = fopen($filename, 'r');
+ $file_contents=fread($fd,filesize($filename));
+ fclose($fd);
+ return $file_contents;
+ }
+ else {
+ return "";
+ }
+}
+
+/************************************************
+* set_sshkeys()
+* Install new ssh keys for root
+*************************************************/
+function set_sshkeys($sshkeys) {
+ $sshkeys = "$sshkeys\n";
+ $rootkeys = "/root/.ssh/authorized_keys2";
+ if(file_exists($rootkeys)) {
+ $fd = fopen($rootkeys,"r");
+ $contents = fread($fd,filesize($rootkeys));
+ fclose($fd);
+ if($contents == $sshkeys) {
+ // Nothing has changed, so no need to update
+ return false;
+ }
+ }
+ $fd = fopen("/var/tmp/tmpkeys","w");
+ fwrite($fd,"$sshkeys");
+ fclose($fd);
+ privcmd("cp /var/tmp/tmpkeys /ro/$rootkeys",true);
+ privcmd("cp /var/tmp/tmpkeys $rootkeys",false);
+ `rm -f /var/tmp/tmpkeys`;
+ return true;
+}
+
/************************************************
* get_wif()
* returns an array in the following format
@@ -320,6 +448,15 @@
return trim($out);
}
+function get_flag($input_string, $attribute) {
+ if(strstr($input_string, $attribute)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
function get_all_values($input_string, $attribute){
$values = array();
$count = 0;
@@ -336,14 +473,18 @@
//returns the following attributes of a wifi device
//given its "iwconfig wlanX" output
-function parse_iwconfig($output)
+function parse_iwconfig($wif)
{
+ $output = `iwconfig $wif`;
//IWCONFIG OUTPUT PARSING!!
$data['type'] = getnext($output,"IEEE");
$data['nick'] = getnext($output,"Nickname");
- $data['essid'] = getnext($output,"ESSID");
+// $data['essid'] = getnext($output,"ESSID");
+ ereg('ESSID:"(.*)"',$output,$regs);
+ $data['essid'] = $regs[1];
$data['mode'] = getnext($output,"Mode");
- $data['channel'] = freq2channel(str_replace("GHz","",getnext($output,"Frequency")));
+// $data['channel'] = freq2channel(str_replace("GHz","",getnext($output,"Frequency")));
+ $data['channel'] = get_channel($wif);
$data['ap'] = getnext($output,"Access Point");
$data['cell'] = getnext($output,"Cell");
$data['quality'] = getnext($output,"Link Quality");
@@ -351,22 +492,30 @@
$data['noise'] = getnext($output,"Noise level");
$data['rate'] = getnext($output,"Rate");
$data['sens'] = getnext($output,"Sensitivity");
- $data['retry'] = getnext($output,"limit");//fix "retry min limit" and "retry limit" that exist in different versions of hostap/witools
+// $data['retry'] = getnext($output,"limit");//fix "retry min limit" and "retry limit" that exist in different versions of hostap/witools
+ ereg("Retry( min)?( limit)?:([[:alnum:]]+) ",$output,$regs);
+ $data['retry'] = $regs[3];
$data['rts'] = getnext($output,"RTS thr");
+ if($data['rts'] >= 65534)
+ $data['rts'] = "off";
$data['frag'] = getnext($output,"Fragment thr");
+ if($data['frag'] >= 65534)
+ $data['frag'] = "off";
$data['power'] = getnext($output,"Power Management");
return $data;
}
/*iwconfig output in an array with device names as keys*/
function get_wireless_status(){
- global $iwconfig_bin;
- $iwconfig_output = trim(`$iwconfig_bin`);
+ $iwconfig_output = trim(`iwconfig`);
$device_status_strings = explode("\n\n", $iwconfig_output);
foreach($device_status_strings as $device_status_string){
sscanf($device_status_string,"%s ",$device);
if (strstr($device_status_string, "no wireless extensions") !== false)
continue;
- $devices_data[$device] = parse_iwconfig($device_status_string);
+ // don't return wifi0 et al; it's a pseudo-device from hostap
+ if (strstr($device, "wifi") !== false)
+ continue;
+ $devices_data[$device] = parse_iwconfig($device);
$devices_data[$device]["name"] = $device;
}
return $devices_data;
@@ -384,6 +533,9 @@
//skip loopback interface
if ($device == "lo")
continue;
+ // Ignore wifi0 et al; they're pseudo-devices for hostap
+ if (strstr($device,"wifi"))
+ continue;
$device_status["Link encap"] = get_value($device_status_string,"Link encap:");
$device_status["hwaddr"] = get_value($device_status_string,"HWaddr");
$device_status["ipaddr"] = get_value($device_status_string,"inet addr:");
@@ -393,6 +545,9 @@
$device_status["Metric"] = get_value($device_status_string,"Metric:");
$device_status["tx"] = get_value($device_status_string,"TX bytes:");
$device_status["rx"] = get_value($device_status_string,"RX bytes:");
+ $device_status["UP"] = get_flag($device_status_string,"UP");
+
+ $device_status["gateway"] = get_gateway($device);
$device_statuses[$device] = $device_status;
}
return $device_statuses;
@@ -425,8 +580,9 @@
*/
function get_scan_results($device){
global $iwlist_bin;
- $iwlist_cmd = $iwlist_bin." ".$device." scan";
- $iwlist_output = rtrim(`$iwlist_cmd`, " \n");
+
+ $iwlist_output = rtrim(do_scan($device), " \n");
+
if (!(stristr( $iwlist_output, "Operation not supported") === false))
return false;
//remove first line
@@ -437,7 +593,9 @@
$cell_infos = array();
foreach( $cell_strings as $cell_index => $cell_string){
$cell_info["address"] = get_value($cell_string,"Address:");
- $cell_info["essid"] = get_value($cell_string,"ESSID:");
+// $cell_info["essid"] = get_value($cell_string,"ESSID:");
+ ereg('ESSID:"(.*)"',$cell_string,$regs);
+ $cell_info["essid"] = $regs[1];
$cell_info["mode"] = get_value($cell_string,"Mode:");
$cell_info["frequency"] = get_value($cell_string,"Frequency:");
$cell_info["channel"] = freq2channel($cell_info["frequency"]);
@@ -445,6 +603,8 @@
$cell_info["signal"] = get_value($cell_string,"Signal level:");
$cell_info["noise"] = get_value($cell_string,"Noise level:");
$cell_info["encryption"] = get_value($cell_string,"Encryption key:");
+ if($cell_info["encryption"] == "on")
+ $cell_info["encryption"] = "on ";
$rates = get_all_values($cell_string,"Bit Rate:");
$cell_info["rates"] = array_shift($rates);
foreach ($rates as $rate)
@@ -459,4 +619,216 @@
return($cell_infos);
}
+/*******************************
+* get_channels($iface)
+* Find all available channels
+* for the given interface
+*******************************/
+function get_channels($iface){
+ $reply = array();
+ $whole_lines = explode("\n",`iwlist $iface freq`);
+ foreach ($whole_lines as $whole_line) {
+ if(strstr($whole_line,"Channel")) {
+ array_push($reply,trim($whole_line));
+ }
+ }
+ return $reply;
+}
+
+/*******************************
+* get_channel($iface)
+* What channel are we on?
+*******************************/
+function get_channel($iface){
+ if(ereg("\(channel ([[:digit:]]+)\)",`iwlist $iface freq`,$regs))
+ return $regs[1];
+ else
+ return false;
+}
+
+/*******************************
+* get_rates($iface)
+* Find all available rates
+* for the given interface
+*******************************/
+function get_rates($iface){
+ $reply = array();
+ $whole_lines = explode("\n",`iwlist $iface rate`);
+ foreach ($whole_lines as $whole_line) {
+// if(ereg("Current Bit Rate:(.*)",$whole_line,$regs)) {
+ if(strstr($whole_line,"Current Bit Rate"))
+ break;
+ if(strstr($whole_line,"/s"))
+ array_push($reply,trim($whole_line));
+ }
+ return $reply;
+}
+
+/*******************************
+* get_networks($iface)
+* Do a quick network scan
+*******************************/
+function get_networks($iface){
+ $reply = array();
+
+ $whole_lines = explode("\n",do_scan($iface));
+
+ foreach ($whole_lines as $whole_line) {
+ if(!ereg("ESSID:\"(.*)\"",$whole_line,$regs))
+ continue;
+ $net = $regs[1];
+ if(!$net)
+ continue;
+ if(!in_array($net,$reply))
+ array_push($reply,$net);
+ }
+
+ return $reply;
+}
+
+/*******************************
+* get_mode($iface)
+* What STA mode is $iface in?
+*******************************/
+function get_mode($iface) {
+ if(ereg("Mode:([[:alnum:]]+) ",`iwconfig $iface`,$regs))
+ return $regs[1];
+ else
+ return false;
+}
+
+/*******************************
+* do_scan($iface)
+* Perform an 'iwlist scanning'
+* on an interface. Safely.
+*******************************/
+function do_scan($iface) {
+
+ $mode = get_mode($iface);
+
+ // Don't even try if we don't recognize the current mode.
+ if(!ereg("Master|Managed|Ad-Hoc|Monitor|Repeater",$mode))
+ return false;
+
+ if($mode != "Managed")
+ privcmd("iwconfig $iface mode managed",false);
+
+ $reply = `iwlist $iface scanning`;
+
+ if($mode != "Managed")
+ privcmd("iwconfig $iface mode $mode",false);
+
+ return $reply;
+}
+
+/************************************
+* get_gateway($iface)
+* Return default gateway for $iface
+*************************************/
+function get_gateway($iface) {
+ $filename = '/etc/network/interfaces';
+ $fp = fopen($filename,"r");
+
+ if(!$fp)
+ return false;
+
+ $file_contents=fread($fp,filesize($filename));
+ fclose($fp);
+
+ $thisif = 0;
+ $whole_lines=explode("\n",$file_contents);
+ foreach ($whole_lines as $whole_line) {
+ // Is this where we get off?
+ if(ereg("^(auto|iface) $iface",$whole_line)) {
+ $thisif = 1;
+ continue;
+ }
+
+ // Is this where we get back on?
+ if(ereg("^(auto|iface)",$whole_line)) {
+ $thisif = 0;
+ continue;
+ }
+
+ if($thisif && ereg(" gateway (.*)",$whole_line,$regs))
+ return $regs[1];
+ }
+
+ return false;
+}
+
+/*********************************
+* get_auto_rate($iface)
+* Is this radio in auto rate mode?
+*********************************/
+function get_auto_rate($iface) {
+ $filename = '/etc/network/interfaces';
+ $fp = fopen($filename,"r");
+
+ if(!$fp)
+ return false;
+
+ $file_contents=fread($fp,filesize($filename));
+ fclose($fp);
+ $whole_lines=explode("\n",$file_contents);
+
+ foreach ($whole_lines as $whole_line) {
+ // rate line for our if with optional rate and auto? True.
+ if(ereg(" pre-up.*$iface.*rate ?[[:digit:]]?\.?[[:digit:]]?[[:digit:]]?M? auto",$whole_line))
+ return true;
+ // rate line for our if with an explicit rate only? False.
+ if(ereg(" pre-up.*$iface.*rate.*M ",$whole_line))
+ return false;
+ }
+
+ // No rate line at all? True.
+ return true;
+}
+
+/*********************************
+* get_numeric_rate($iface)
+* How fast should this radio go?
+*********************************/
+function get_numeric_rate($iface) {
+ $filename = '/etc/network/interfaces';
+ $fp = fopen($filename,"r");
+
+ if(!$fp)
+ return false;
+
+ $file_contents=fread($fp,filesize($filename));
+ fclose($fp);
+ $whole_lines=explode("\n",$file_contents);
+
+ foreach ($whole_lines as $whole_line) {
+ if(ereg(" pre-up.*$iface.*rate ([[:digit:]]?\.?[[:digit:]]?[[:digit:]]?M)",$whole_line,$regs))
+ return $regs[1];
+ }
+
+ return "best";
+}
+
+/************************************
+* get_athctrl($iface)
+* Return athctrl distance for $iface
+*************************************/
+function get_athctrl($iface) {
+ $filename = '/etc/network/interfaces';
+ $fp = fopen($filename,"r");
+
+ if(!$fp)
+ return false;
+
+ $file_contents=fread($fp,filesize($filename));
+ fclose($fp);
+ $whole_lines=explode("\n",$file_contents);
+
+ foreach ($whole_lines as $whole_line) {
+ if(ereg(" pre-up athctrl -i $iface -d ([[:digit:]]+)",$whole_line,$regs))
+ return $regs[1];
+ }
+
+ return false;
+}
+
?>
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/include/global.css admin/include/global.css
--- /home/rob/pebble/src/wifiadmin-0.0.4/include/global.css 2004-12-12 17:00:06.000000000 -0800
+++ admin/include/global.css 2005-01-25 00:04:40.000000000 -0800
@@ -155,7 +155,8 @@
background-color: #fff;
}
ul#tabnav li#active-tab
-{background-color: #F1F1F1;}
+{background-color: #F1F1F1;
+border-bottom: 0px;}
#tabnav a {
float: left;
@@ -168,3 +169,4 @@
#tabnav a:hover {
background: #fff;
}
+
diff -ru /home/rob/pebble/src/wifiadmin-0.0.4/include/header.php admin/include/header.php
--- /home/rob/pebble/src/wifiadmin-0.0.4/include/header.php 2004-12-21 13:57:50.000000000 -0800
+++ admin/include/header.php 2005-02-10 16:20:44.000000000 -0800
@@ -38,31 +38,32 @@
echo '
- WiFiAdmin
+ WiFiAdmin: '.chostname().'
';
-if(isset($_POST['logout']) && $_SESSION['username'] != "guest" )
- echo ' ';
+if(isset($_POST['logout']) && $_SESSION['username'] != "guest" ) {
+ echo ' ';
+ echo "Logging out...
";
+ exit;
+}
+
echo ' ';
-echo '