PHP MAC Address validation script

Pentru vlaidarea unui mac in PHP putem folosi:
Pentru adresele mac de tip UNIX (exemplu: 00:15:17:1D:73:5F)

$input_string = "00:15:17:1D:73:5F";
if (preg_match('/^[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}$/i',$input_string))
{
     echo "Yes, the mac address is valid.";
} else
{
     echo "No, the mac address is wrong";
}

Pentru adresele mac de tip WINDOWS (exemplu: 00-25-9c-4b-1e-2b)

$input_string = "00-25-9c-4b-1e-2b";
if (preg_match('/^[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}$/i',$input_string))
{
     echo "Yes, the mac address is valid.";
} else
{
     echo "No, the mac address is wrong";
}

Pentru adresele mac de tip Cisco (exemplu: 0018.f352.d31c)

$input_string = "0018.f352.d31c";
if (preg_match('/^[a-f0-9]{4}\.[a-f0-9]{4}\.[a-f0-9]{4}$/i',$input_string))
{
     echo "Yes, the mac address is valid.";
} else
{
     echo "No, the mac address is wrong";
}
http://www.usermadetutorials.com/2010/07/php-validate-mac-address-using-regex/

Chmod pentru directoare si subdirectoare

Se executa urmatoarea comanda:

find [directorul] -type d -exec chmod 777 {} \;

[directory] < este calea catre directorul mama ; ex:/home/user

-type d < acest parametru specifica faptul ca o cautam directoare

-exec chmod 777 {} \; < acest parametru specifica faptul ca o sa rulam comanda chmod 777 pe toate sub directoarele pe care le gaseste

linux kill all processes owned by a user

kill -9 `ps -u <username> -o ”pid=”`

 

sursa