<?php
/*
* Created on Sep 5, 2005
*
* released under the GPL
* Copyright Carl H. Peterson 2005, 2006
* Copyright Port Networks LLC. 2005, 2006
*
* This file is used to display the clients
* connected to an Access Point
*
*
*/
$id = $_SESSION['locID'];
if (isset($_POST['APID'])) $apid=$_POST['APID'];
if (isset($_POST['LocationID'])) $locid=$_POST['LocationID'];
include('show_ap.php');
if ($buttonID=="show_users_ap" ) {
include('show_users.php');
}
if ($buttonID=="show_snmp_ap" ) {
$ap=$oreon->database->getapconfiguration($_SESSION['locID']);
if(isset($_POST['APID'])){
if($ap['conf_usg'] == 1){ // if we are pulling results from a USG
$usgUsers=get_usg("$usg_url", "$usg_user", "$usg_pass");
} // end of if usg
if($ap['conf_maclist']==1){
include('get_maclist.php');
exec("cat ".$ap['maclist_tmp_file'], $maclist_output);
} // end of if maclist
$ID=$_POST['APID'];
$LocationID=$_POST['LocationID'];
$query="SELECT dnsname,IPAddress, comunity, version, mib FROM AP WHERE ID = '$ID' AND LocationID='$LocationID'";
$result = $oreon->database->database->query($query) or die("Query database error !");
while ($row = $oreon->database->database->fetch_object($result)) { // while row
$array[] = $row;
$dnsname = ($row->dnsname);
$hostname = ($row->IPAddress);
$comunity = ($row->comunity);
$version = ($row->version);
$mib = ($row->mib);
$macpat="/[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f]/i";
$CID_pat="/[A-F][0-9][0-9][0-9][0-9]/i";
if ($ap["disp_snmp"]) include ('snmp_default.php');
echo '<br><tr><td colspan=2><big style="font-family: Aircut"><span
style="font-weight: bold; text-decoration: italic;">';
echo "Try to find connected users :</big></td></tr><br><br>";
exec($ap['snmpwalk']." -v $version -Cc -c $comunity $hostname $mib", $output);
foreach($output as $key=>$value){
// If it is an interepoch ap, then the mac comes after 'Hex-STRING: ' so we find it.
$findme = 'Hex-STRING:'; //
$pos = strpos($value, $findme);
if($pos){
$value= substr(stristr($value, 'Hex-STRING: '), 12);
// now we add a few : to make it into a mac address
$old=" ";
$new=":";
$value = str_replace($old, $new, $value);
}
// get MAC from value
preg_match($macpat, $value, $matches);
$client = $matches[0];
$clients[] = $client;
}
$colspan=3;
if($ap['conf_maclist']==1){$colspan=($colspan+2); }
echo"<table border=\"1\">"; // start the table
echo("<tr><td><img class=\"leftImage\" src=\"images/ap_connect.png\" ></td>
<td colspan=\"$colspan\"><b>$dnsname/$hostname</b></td></tr>");
echo('<tr><td>MAC</td><td>User Name</td><td>IP Address</td>');
if($ap['conf_maclist']==1){
echo('<td>C Num</td><td>Note</td></tr>');
} // EO if conf maclist
if ($k2 !=NULL)
foreach($clients as $k2=>$mac){
$mac = strtoupper($mac);
if($ap['conf_usg'] == 1){
if($usgUsers!="error"){
foreach($usgUsers as $user=>$data){
// echo("user- $user <br>"); // TESTING
// print_r ($data); // TESTING
// echo("<br>"); //TESTING
if(isset($key)) { unset($key); }
$key = array_search($mac, $data);
if($key === false){
}else{
$MAC = ($data[$key]);
$IP = ($data[1]);
$NAME = ($data[3]);
$uname="$NAME";
if($uname=="."){
$uname="n/logged in";
}else{ // we don't need to do this
if($remove_domain==1){
$user_array=split_relm($uname);
foreach($user_array as $relm=>$User){
$Relm=$relm;
$uname=$User;
} // end of foreach($user_array
} // end of if uname else
}
}
} // end of foreach usgUsers
}else{ // if $usgUsers is "error"
$uname="USG ERROR";
$IP="USG ERROR";
}
} // end of if conf_usg == 1
if(($ap['conf_maclist']==1)&&(!isset($uname))){ // if we are checking the maclist
foreach($maclist_output as $key=>$line){
$pos=strpos($line, $mac);
if($pos=== false){ // do nothing
}else{
preg_match($CID_pat, $line, $cid_matches);
$cust_ID = $cid_matches[0];
$line_pieces = explode("$cust_ID", $line);
$notes = trim($line_pieces[1]);
$notes=substr($notes, 0, 10);
}
}
}// end of if conf maclist
echo("<tr><td>$mac</td>");
echo("<td>$uname</td>");
echo("<td>$IP</td>");
if($ap['conf_maclist']==1){
echo("<td>$cust_ID</td>");
echo("<td>$notes</td>");
} // end of if conf maclist
echo("</tr>");
// unset some vars so they dont corrupt the next loop
if(isset($MAC)) { unset($MAC); }
if(isset($IP)) { unset($IP); }
if(isset($cust_ID)) { unset($cust_ID); }
if(isset($notes)) { unset($notes); }
if(isset($uname)) { unset($uname); }
if(isset($mac)) { unset($mac); }
} // end of foreach clients
echo('</table>');
} // end of while row
}
}
if ($oreon->user->get_status()=="3" or $oreon->user->get_status()=="2")
{
echo "<hr><table border=\"0\"><tr><td>";
printf('<form action="phpmyprepaid.php" method="post">');
echo('<input type="hidden" name="buttonID" value="mod_ap">');
echo("<input type=\"hidden\" name=\"APID\" value=\"$apid\">");
echo("<input type=\"submit\" class=\"smallButton\" name=\"submit\" value=\"Modify nas\">");
printf('</form></td><td style="text-align: right;">');
echo '<script type="text/javascript">
function confirmDelete() {
if(confirm("Are you sure you want to delete this nas ?" )) document.location.href = phpmyprepaid.php;
return false; //pour ne pas revenir au début de la page
}
</script>
<form action="phpmyprepaid.php" method="post" onsubmit="return confirmDelete();">';
echo('<input type="hidden" name="buttonID" value="del_ap">');
echo("<input type=\"hidden\" name=\"APID\" value=\"$apid\">");
echo('<input type="hidden" name="LocationID" value='.$locid.'>');
echo("<input type=\"submit\" class=\"smallButton\" name=\"submit\" value=\"Delete nas\">");
printf('</form></td></tr></table>');
} // end of if isset APID
?>