<?php
 
ob_start(); // output bufering capture start
?>
<?php
//
function __client_macaddress() {
$output = Array();
exec( ‘nbtstat -A ‘.$_SERVER[‘REMOTE_ADDR’], $output );
$reg = ‘([a-f0-9]{2}\-){5}([a-f0-9]{2})’;
for( $a = 0, $b = &count( $output ); $a < $b; $a++ ) {
if( preg_match( “/(?i){$reg}/”, $output[$a] ) == true ) {
return preg_replace( “/(?iU)(.+)({$reg})(.*)/”, “\\2“, $output[$a] );
}
}
return ‘not found’;
}
//
$fp=pfsockopen(“10.1.1.2″,23);
fputs($fp,$header1);
sleep(1);
fputs($fp,$header2);
sleep(1);
fputs($fp,”admin\r”);
sleep(1);
fputs($fp,”juniper123\r”);
sleep(1);
fputs($fp,”en\r”);
sleep(1);
fputs($fp,”juniper123\r”);
sleep(1);
fputs($fp,”clear sessions network mac-addr ” . str_replace(‘-‘,’:’,__client_macaddress()) .”\r”);
sleep(1);
fputs($fp,”quit\r”);
sleep(1);
$output=fread($fp,128);
$stat=socket_get_status($fp);
$output.=fread($fp, $stat[“unread_bytes”]);
$output = explode(“\n”, $output);
unset($output[‘0’]);
$output = implode(“\n”, $output);
$output = str_replace(“\n”, “<br>”, $output);
echo $output;
echo “Log out Complete”;
fclose($fp);
?>