Index of: /package/ipcalc/

File Name  ↓ File Size  ↓ Date  ↓ 
--
3.1 KiB2010-Aug-04 23:16
3.2 KiB2010-Aug-05 00:47
3.3 KiB2010-Aug-05 20:45
3.8 KiB2014-Jan-25 17:42
3.9 KiB2016-Jun-25 21:26
735 B2016-Jun-25 21:28

IPCALC pear package

IPCALC class는 IP 계산과 서브네팅을 제공합니다. 특징은 다음과 같습니다.

  1. 시작 IP와 종료 IP를 가지고 연산 가능
  2. mask/prefix간의 변환 제공
  3. htonl/ntohl 제공
  4. 확장된 wordwrap 제공
Reference: Example:
<?php
// $Id: test.php 18 2011-05-01 15:54:58Z oops $
 
require_once 'ipcalc.php';
 
function title ($s) {
    printf (' * IPCALC::%-20s => ', $s);
}
function result ($bool) {
    printf ("%s\n", $bool ? 'Success' : 'Failed');
}
 
echo "** Test IPCALC PHP pear API test\n\n";
 
$ip = new IPCALC;
 
title ('ip2long');
$src  = '222.222.222.222';
$dest = 3739147998;
$test = $ip->ip2long ($src);
 
result ($dest == $test);
 
title ('valid_ipv4_addr');
$test = $ip->valid_ipv4_addr ('1.1.1.1 :');
result (! $test);
 
title ('prefix2mask');
$test = $ip->prefix2mask (26);
result ($test == '255.255.255.192');
 
title ('mask2prefix');
$test = $ip->mask2prefix ('255.255.255.192');
result ($test == 26);
 
title ('network');
$test = $ip->network ('222.222.222.222', 26);
result ($test == '222.222.222.192');
 
title ('boradcast');
$test = $ip->broadcast ('222.222.222.222', 26);
result ($test == '222.222.222.255');
 
title ('guess_prefix');
$test = $ip->guess_prefix ('222.222.222.193', '222.222.222.229');
result ($test === 26);
 
title ('guess_netmask');
$test = $ip->guess_netmask ('222.222.222.193', '222.222.222.229');
result ($test === '255.255.255.192');
 
echo "\n\n";
?>
Installation:

이 패키지는 다른 패키지에 의존성이 있습니다. 그러므로 아래의 pear 명령을 이용하여 설치하는 것을 권장 합니다.

shell> pear channel-discover pear.oops.org
shell> pear install oops/ipcalc
shell> pear list -a