25mordad
Member
سلام
چطور می توانم آدرس مک بازدید کننده سایت را پیدا کنم ؟
البته نکات زیر را هم در نظر بگیرید ..
1 - باید ببینیم که اصلا در پروتکل tcp/ip آدرس مک کامپیوتر کاربر در هدر ها ارسال می شود یا خیر ؟ که البته فکر می کنم که ارسال نمی شود.
2 - فرض کنیم که یک دستوری وجود دارد که می توانیم فوری این مک را بگیریم آیا مک کاربر را می دهد یا سروری که کاربر با آن به اینترنت وصل است و یا شایدم یکی از روتر ها
3 - طی بررسی هایی که داشتم و گوگلیدم به هیچ نتیجه ی راضی کننده ای نرسیدم زیرا کد زیر را پیدا کردم ولی آیا این کد در روی همه سرور ها کار می کند یا خیر ..
اگر برو بچ توضیحی در ورد این کد ارائه بدن .. لطف کردن .. در ضمن این تابع از دستور arp استفاده می کنه و خودش هم توضیح می ده که باید جایگذاری بشه ولی چه جوری ؟
چطور می توانم آدرس مک بازدید کننده سایت را پیدا کنم ؟
البته نکات زیر را هم در نظر بگیرید ..
1 - باید ببینیم که اصلا در پروتکل tcp/ip آدرس مک کامپیوتر کاربر در هدر ها ارسال می شود یا خیر ؟ که البته فکر می کنم که ارسال نمی شود.
2 - فرض کنیم که یک دستوری وجود دارد که می توانیم فوری این مک را بگیریم آیا مک کاربر را می دهد یا سروری که کاربر با آن به اینترنت وصل است و یا شایدم یکی از روتر ها
3 - طی بررسی هایی که داشتم و گوگلیدم به هیچ نتیجه ی راضی کننده ای نرسیدم زیرا کد زیر را پیدا کردم ولی آیا این کد در روی همه سرور ها کار می کند یا خیر ..
PHP:
<?php
function returnmacaddress() {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
// Tested only on linux, please report bugs
// WARNinG: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine
// Get the arp executable path
$location = `which arp`;
$location = rtrim($location);
// Execute the arp command and store the output in $arpTable
$arpTable = `$location -n`;
// Split the output so every line is an entry of the $arpSplitted array
$arpSplitted = split("\n",$arpTable);
// Get the remote ip address (the ip address of the client, the browser)
$remoteIp = $GLOBALS['REMOTE_ADDR'];
$remoteIp = str_replace(".", "\\.", $remoteIp);
// Cicle the array to find the match with the remote ip address
foreach ($arpSplitted as $value) {
// Split every arp line, this is done in case the format of the arp
// command output is a bit different than expected
$valueSplitted = split(" ",$value);
foreach ($valueSplitted as $spLine) {
if (preg_match("/$remoteIp/",$spLine)) {
$ipFound = true;
}
// The ip address has been found, now rescan all the string
// to get the mac address
if ($ipFound) {
// Rescan all the string, in case the mac address, in the string
// returned by arp, comes before the ip address
// (you know, Murphy's laws)
reset($valueSplitted);
foreach ($valueSplitted as $spLine) {
if (preg_match("/[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f]/i",$spLine)) {
return $spLine;
}
}
}
$ipFound = false;
}
}
return false;
}
?>