Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Funkcja ip2mac, Zamiana ip na mac karty sieciowej.
Nightwalker
post 13.02.2007, 23:55:04
Post #1





Grupa: Zarejestrowani
Postów: 180
Pomógł: 0
Dołączył: 5.02.2006
Skąd: Bytom

Ostrzeżenie: (10%)
X----


Dzięki tej funkcji możemy zamienić numer IP na numer karty sieciowej mac, oczywiscie dziala to tylko, na komputery , ktore są w sieci LAN.
Funkcja przeznaczona dla systemów POSIX (Unix, Linux, *BSD itp), wymaga programu arping

  1. <?php
  2.  
  3. /*
  4.  $id: ip2mac.php, v 0.1 2006/02/13 23:32 Nightwalker <nightwalker@rootnode.eu> Exp $
  5.  
  6.  Relased on BSD License
  7.  
  8.  Copyright (c) 2007, Nightwalker
  9.  All rights reserved.
  10.  
  11.  Redistribution and use in source and binary forms, with or without
  12.  modification, are permitted provided that the following conditions are met:
  13.  
  14. * Redistributions of source code must retain the above copyright notice,
  15. this list of conditions and the following disclaimer.
  16. * Redistributions in binary form must reproduce the above copyright notice,
  17. this list of conditions and the following disclaimer in the documentation
  18. and/or other materials provided with the distribution.
  19. * Neither the name of the <ORGANIZATION> nor the names of its contributors
  20. may be used to endorse or promote products derived from this software
  21. without specific prior written permission.
  22.  
  23. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. POSSIBILITY OF SUCH DAMAGE.
  35.  
  36.  Usage example:
  37.  
  38. ip2mac( "192.168.4.128", "eth1" );
  39. */
  40.  
  41. function ip2mac( $ip, $ifc )
  42. {
  43. # path to arping.
  44. $arping = "/sbin/arping";
  45.  
  46. # arguments for arping.
  47. $args  = " -c 1 -I {$ifc} {$ip} -f";
  48.  
  49. exec( $arping . $args . " | grep -o ..:..:..:..:..:..", $response );
  50.  
  51. return $response[0];
  52. }
  53.  
  54. ?>


--------------------
Go to the top of the page
+Quote Post
ActivePlayer
post 14.02.2007, 00:03:07
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 224
Pomógł: 40
Dołączył: 6.07.2004
Skąd: Wuppertal

Ostrzeżenie: (0%)
-----


hm to jakas skomplikowana powłoka do funkcji exec?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 24.07.2025 - 19:56