Форум: Форум PHPФорум ApacheФорум Регулярные ВыраженияФорум MySQLHTML+CSS+JavaScriptФорум FlashРазное
Новые темы: 0000000
Самоучитель PHP 5 / 6 (3 издание). Авторы: Кузнецов М.В., Симдянов И.В. Программирование. Ступени успешной карьеры. Авторы: Кузнецов М.В., Симдянов И.В. Самоучитель MySQL 5. Авторы: Кузнецов М.В., Симдянов И.В. PHP 5/6. В подлиннике. Авторы: Кузнецов М.В., Симдянов И.В. C++. Мастер-класс в задачах и примерах. Авторы: Кузнецов М.В., Симдянов И.В.
ВСЕ НАШИ КНИГИ
Консультационный центр SoftTime

Форум PHP

Выбрать другой форум

 

Здравствуйте, Посетитель!

вид форума:
Линейный форум (новые сообщения вниз) Структурный форум

тема: Detecting MAC address with PHP

Сообщения:  [1-4] 

 
 автор: cheops   (06.12.2005 в 20:09)   письмо автору
 
   для: maxy   (06.12.2005 в 16:01)
 

При помощи exec() можно сделать всё, что может делать операционная система - хоть ядро перекомпилировать. Однако на 99% хостингов выполнение этой функции запрещено в целях безопасности.

   
 
 автор: maxy   (06.12.2005 в 16:01)   письмо автору
 
   для: DDK   (04.12.2005 в 08:50)
 

на www.phpclub.ru
говорят что можно. вот от туда кусок:

/**
* get_mac_address
*
* Used to get the MAC address of the host server. It works with Linux,
* Darwin (Mac OS X), and Win XP. It may work with others as some other
* os's have similar ifconfigs to Darwin but they haven't been tested
*
* @access private
* @return string Mac address if found
* @return string ERROR_OPEN means config can't be found and thus not opened
* @return string MAC_404 means mac adress doesn't exist in the config file
* @return string SAFE_MODE means server is in safe mode so config can't be read
**/
function get_mac_address() {
if(ini_get('safe_mode')) {
# returns invalid because server is in safe mode thus not allowing
# sbin reads but will still allow it to open. a bit weird that one.
return 'SAFE_MODE';
}

# if anyone has any clues for windows environments
# or other server types let me know
$os = strtolower(PHP_OS);
if(substr($os, 0, 3)=='win') {
# this windows version works on xp running apache
# based server. it has not been tested with anything
# else, however it should work with NT, and 2000 also

# execute the ipconfig
exec('ipconfig/all', $lines);
# seperate the lines
foreach ($lines as $key=>$line) {
# check for the mac signature in the line
if(strpos(strtolower($line), 'physical address')) {
$trimmed_line = trim($line);
# take of the mac addres and return
return trim(substr($trimmed_line, strrpos($trimmed_line, " ")));
}
}
} else {
# switch between the os's
switch($os) {
# not sure if the string is correct for FreeBSD
# not tested
case 'freebsd' :
# not sure if the string is correct for NetBSD
# not tested
case 'netbsd' :
# not sure if the string is correct for Solaris
# not tested
case 'solaris' :
# not sure if the string is correct for SunOS
# not tested
case 'sunos' :
# darwin is mac os x
# tested only on the client os
case 'darwin' :
$os_var = 'ether';
$os_file = '/sbin/ifconfig';
break;
# linux variation
# tested on server
case 'linux' :
$os_var = 'HWaddr';
$os_file = '/sbin/ifconfig';
break;
default :
break;
}

# open the ipconfig
$fp = @popen($os_file, "rb");
if (!$fp) {
# returns invalid, cannot open ifconfig
return 'ERROR_OPEN';
}

# read the config
$conf = @fread($fp, 4096);
@pclose($fp);

# get the pos of the os_var to look for
$pos = strpos($conf, $os_var);
if($pos) {
# seperate out the mac address
$str1 = trim(substr($conf, ($pos+strlen($os_var))));
return trim(substr($str1, 0, strpos($str1, "\n")));
}
}
# failed to find the mac address
return 'MAC_404';
}


-~{}~ 28.11.05 15:24:

Запускается на сервере.

   
 
 автор: DDK   (04.12.2005 в 08:50)   письмо автору
 
   для: behrad   (04.12.2005 в 02:59)
 

Много раз обсуждали - это невозможно.

   
 
 автор: behrad   (04.12.2005 в 02:59)   письмо автору
 
 

Privet vsem
u mniya takaya problema :
1. mne nado opredelit MAC address polzovatelya kotory zashel na site???
etot web site budet ispolzovatsa po lokalnoe seti.
i eshe mojna li v php ispolzovat winapi ???
P.S. zaranee sposibo)

   

Сообщения:  [1-4] 

Форум разработан IT-студией SoftTime
Rambler's Top100
вверх

Rambler's Top100 Яндекс.Метрика Яндекс цитирования