fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

MACAddress Class Reference
Inheritance diagram for MACAddress:
Collaboration diagram for MACAddress:

Public Member Functions

 __construct ($mac)
 getMACPrefix ()
 __toString ()
 isValid ()
 isPending ()
 isClientIgnored ()
 isPrimary ()
 isImageIgnored ()
 getHost ()
 wake ($ip, $port=9)
- Public Member Functions inherited from FOGBase
 __construct ()
 orderBy (&$orderBy)

Protected Member Functions

 setMAC ()
- Protected Member Functions inherited from FOGBase
 isLoaded ($key)
 setRequest ()
 sendData ( $datatosend, $service=true, $array=array())

Static Protected Member Functions

static normalizeMAC ($mac)
- Static Protected Member Functions inherited from FOGBase
static getActivePlugins ()
static fatalError ($txt, $data=array())
static error ($txt, $data=array())
static debug ($txt, $data=array())
static info ($txt, $data=array())
static setMessage ($txt, $data=array())
static getMessages ()
static redirect ($url='')
static arrayInsertBefore ( $key, array &$array, $new_key, $new_value)
static arrayInsertAfter ( $key, array &$array, $new_key, $new_value)
static arrayRemove ($key, array &$array)
static arrayFind ( $needle, array $haystack, $ignorecase=false)
static resetRequest ()
static formatByteSize ($size)
static getGlobalModuleStatus ($names=false, $keys=false)
static validDate ($date, $format='')
static pluralize ($count, $text, $space=false)
static diff ($start, $end, $ago=false)
static humanify ($diff, $unit)
static arrayChangeKey (array &$array, $old_key, $new_key)
static byteconvert ($kilobytes)
static hex2bin ($hex)
static certEncrypt ($data)
static certDecrypt ($dataArr, $padding=true)
static arrayStrpos ($haystack, $needles, $case=true)
static log ( $txt, $curlog, $logfile, $logbrow, $obj, $level=1)
static logHistory ($string)
static getIPAddress ($force=false)

Protected Attributes

- Protected Attributes inherited from FOGBase
 $isLoaded = array()

Private Attributes

 $_msg = ''
 $_Host = null
 $_MAC = null

Static Private Attributes

static $_pattern = ''

Additional Inherited Members

- Static Public Member Functions inherited from FOGBase
static getClass ($class, $data='', $props=false)
static getHostItem ( $service=true, $encoded=false, $hostnotrequired=false, $returnmacs=false, $override=false, $mac=false)
static getAllBlamedNodes ($Host)
static niceDate ($date='now', $utc=false)
static formatTime ($time, $format=false, $utc=false)
static createSecToken ()
static aesencrypt ( $data, $key=false, $enctype='aes-256-cbc')
static aesdecrypt ( $encdata, $key=false, $enctype='aes-128-cbc')
static parseMacList ( $stringlist, $image=false, $client=false)
static getSubObjectIDs ( $object='Host', $findWhere=array(), $getField='id', $not=false, $operator='AND', $orderBy='name', $groupBy=false, $filter='array_unique')
static getSetting ($key)
static setSetting ($key, $value)
static getQueuedStates ()
static getQueuedState ()
static getCheckedInState ()
static getProgressState ()
static getCompleteState ()
static getCancelledState ()
static stringBetween ($string, $start, $end)
static stripAndDecode (&$item)
static getMasterInterface ($ip_find)
static lasterror ()
static getFilesize ($path)
static wakeUp ($macs)
static fastmerge ($array1)
static getHash ($file)
static attemptLogin ($username, $password)
static clearMACLookupTable ()
static getMACLookupCount ()
static resolveHostname ($host)
static getBroadcast ()
static randWait ()
- Static Public Attributes inherited from FOGBase
static $locale = ''
static $fogpingactive = false
static $fogdeleteactive = false
static $fogexportactive = false
static $pendingMACs = 0
static $pendingHosts = 0
static $defaultscreen = ''
static $pluginsinstalled = array()
static $useragent
static $foglang
static $ajax = false
static $post = false
static $service = false
static $json = false
static $newService = false
static $scriptname
static $querystring
static $httpreqwith
static $reqmethod
static $remoteaddr
static $httpreferer
static $mySchema = 0
static $showhtml = true
static $httpproto = false
static $httphost = ''
static $Host = null
- Static Protected Attributes inherited from FOGBase
static $strlen
static $debug = false
static $info = false
static $buildSelectBox
static $selected
static $DB
static $FOGFTP
static $FOGCore
static $EventManager
static $HookManager
static $TimeZone
static $FOGUser
static $FOGPageManager
static $FOGURLRequests
static $FOGSubMenu
static $ips = array()
static $interface = array()
static $searchPages

Detailed Description

Definition at line 22 of file macaddress.class.php.

Constructor & Destructor Documentation

◆ __construct()

MACAddress::__construct (   $mac)

Initializes the mac address class.

string$macthe mac item(s)

Defines our grep/search patterns for validating a MAC Address.

Pull in our base initialized items.

Temp storage of our passed mac address.

Makes our required changes to the mac.


If the mac is already registered, sets our MAC Variable to the instance of the db item.

Definition at line 65 of file macaddress.class.php.

References $mac, __toString(), FOGBase\getClass(), and setMAC().

Member Function Documentation

◆ __toString()

MACAddress::__toString ( )

How to present the mac as a string.


Splits the mac to be an array for joining together easier. For example, mac 012345abcdef will become: ['01','23','45','ab','cd','ef'].

Joins the array with colons so our mac will be like: 01:23:45:ab:cd:ef

Returns our string

Reimplemented from FOGBase.

Definition at line 243 of file macaddress.class.php.

Referenced by __construct().

◆ getHost()

MACAddress::getHost ( )

Gets mac's associated host.


Definition at line 322 of file macaddress.class.php.

◆ getMACPrefix()

MACAddress::getMACPrefix ( )

Gets the first 6 characters of the mac.


Gets the prefix of the mac address.

Splits into the segments for easier joining. For example, 012345 will become: ['01','23','45']

OUI text is in format xx-xx-xx, This puts the string together properly so string will become: 01-23-45

Returns our string.

Definition at line 207 of file macaddress.class.php.

◆ isClientIgnored()

MACAddress::isClientIgnored ( )

Tests if mac is to be ignored for client.


Definition at line 295 of file macaddress.class.php.

◆ isImageIgnored()

MACAddress::isImageIgnored ( )

Tests if mac is to be ignored for imaging.


Definition at line 313 of file macaddress.class.php.

◆ isPending()

MACAddress::isPending ( )

Tests if mac is a pending mac.


Definition at line 286 of file macaddress.class.php.

◆ isPrimary()

MACAddress::isPrimary ( )

Tests if mac is primary mac.


Definition at line 304 of file macaddress.class.php.

◆ isValid()

MACAddress::isValid ( )

Tests if the mac is valid.


Tests the pattern to see if we are safe. Returns as bool.

Definition at line 270 of file macaddress.class.php.

Referenced by setMAC().

◆ normalizeMAC()

static MACAddress::normalizeMAC (   $mac)

Normalizes the mac address for us and lowers the case.

string$macThe mac to normalize

Pull out the valid mac addresses in an array format.

Remove the :, -, and/or . and lowercase the characters. Return the string.

Definition at line 175 of file macaddress.class.php.

References $mac.

Referenced by setMAC().

◆ setMAC()

MACAddress::setMAC ( )

Sets the mac.


If the mac is already an instance of MACAddress, MACAddressAssociation, or plain string, normalize our protected MAC as lowercase without ., -, or :.

If the mac is an array, take the first mac address and perform the same as above.

If the mac address is not valid throw Invalid MAC message.

Split the normalized mac into an array using 2 characters as the split. For example: 012345abcdef would become ['01','23,'45','ab','cd','ef']

This creates a portion of the message string for WOL requests.

This creates and combines the message string. Message string is: 6 times inline 0xff 16 times hwAddr

Definition at line 106 of file macaddress.class.php.

References $tmpMAC, isValid(), and normalizeMAC().

Referenced by __construct().

◆ wake()

MACAddress::wake (   $ip,
  $port = 9 

Wakes this MAC address.

string$ipthe ip to send to
int$portthe port to sent from

Assume return will be true for now.

Create our socket resource

If failed, immediately return.

Set our coket options

If invalid close socket and return immediately.

Send our wake up packet.

If failed set return to false;

Close the socket.

Return value

Definition at line 334 of file macaddress.class.php.

References $ip, and $ret.

Member Data Documentation

◆ $_Host

MACAddress::$_Host = null

Definition at line 41 of file macaddress.class.php.

◆ $_MAC

MACAddress::$_MAC = null

Definition at line 47 of file macaddress.class.php.

◆ $_msg

MACAddress::$_msg = ''

Definition at line 35 of file macaddress.class.php.

◆ $_pattern

MACAddress::$_pattern = ''

Definition at line 29 of file macaddress.class.php.

◆ $MAC


Definition at line 53 of file macaddress.class.php.

◆ $tmpMAC


Definition at line 59 of file macaddress.class.php.

Referenced by setMAC().

The documentation for this class was generated from the following file: