c0ldfyr3 Posted August 28, 2008 Share Posted August 28, 2008 i am new to PhP... i have this scripts however i get no out put just a parse error. $mac = &new NtMacAddress(); echo 'SERVER MAC: '.$mac->getMac( 'server' ).'<br />CLIENT MAC: '.$mac->getMac( 'client' ); class NtMacAddress { NtMacAddress->getMac( $what:String ):String function getMac( $what ) { $what = &strtolower( $what ); if( $what == 'server' ) { return $this->__server_macaddress(); } elseif( $what == 'client' ) { return $this->__client_macaddress(); } else { return '\'client\' or \'server\' ?'; } } Private method __server_macaddress. Returns server mac-address if is readable. NtMacAddress->__server_macaddress():String function __server_macaddress() { $output = Array(); exec( 'netstat -r', $output ); for( $a = 0, $b = &count( $output ); $a < $b; $a++ ) { if( preg_match( "/(?i)([a-z0-9]{2} ){6}/", $output[$a] ) == true ) { $macaddress = &$output[$a]; $uniquekey = &md5( $macaddress ); $output[$a] = &preg_replace( "/(?i)([^a-z0-9]?)([a-z0-9]{2} ){6}/i", "\\1 {$uniquekey} ", $output[$a] ); $output[$a] = &explode( " {$uniquekey} ", $output[$a] ); $uniquekey = Array( trim( $output[$a][0] ), trim( $output[$a][1] ) ); $macaddress = &str_replace( $uniquekey, "", $macaddress ); return trim( $macaddress ); } } return 'not found'; } NtMacAddress->__client_macaddress():String 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'; } } Link to comment https://forums.phpfreaks.com/topic/121640-how-to-display-a-mac-address/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 28, 2008 Share Posted August 28, 2008 Several of the lines of that code are syntax examples and comments. Perhaps go back to the original source of that code and compare it with what you have. Link to comment https://forums.phpfreaks.com/topic/121640-how-to-display-a-mac-address/#findComment-627515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.