PHP: H�l�zatkezel�si F�ggv�nyek - Manual
PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links 
search for in the  
<muscat_setupcheckdnsrr>
Last updated: Wed, 15 Jan 2003
view the printer friendly version or the printer friendly version with notes or change language to English | Brazilian Portuguese | Chinese (Simplified) | Chinese (Traditional) | Czech | Dutch | Finnish | French | German | Hebrew | Italian | Japanese | Korean | Polish | Romanian | Russian | Slovak | Slovenian | Spanish | Swedish | Turkish

LXVI. H�l�zatkezel�si F�ggv�nyek

Bevezet�s

K�vetelm�nyek

Az itt le�rt f�ggv�nyek a standard modulban tal�lhat�ak, ami mindig rendelkez�sre �ll.

Telep�t�s

Semmilyen telep�t�s nem sz�ks�ges ezen f�ggv�nyek haszn�lat�hoz, a PHP alapelemei.

Fut�sidej� be�ll�t�sok

The behaviour of these functions is affected by settings in php.ini.

T�bl�zat 1. Network Configuration Options

NameDefaultChangeable
define_syslog_variables"0"PHP_INI_ALL
For further details and definition of the PHP_INI_* constants see ini_set().

Here is a short explanation of the configuration directives.

define_syslog_variables boolean

Whether or not to define the various syslog variables (e.g. $LOG_PID, $LOG_CRON, etc.). Turning it off is a good idea performance-wise. At runtime, you can define these variables by calling define_syslog_variables().

Er�forr�s t�pusok

Ez a kiterjeszt�s semmilyen er�forr�s t�pust nem defini�l.

El�re defini�lt �lland�k

Az itt felsorolt konstansok minden el�rthet�ek mivel r�szei a PHP alaptelep�t�s�nek.

T�bl�zat 2. openlog() Options

ConstantDescription
LOG_CONS if there is an error while sending data to the system logger, write directly to the system console
LOG_NDELAY open the connection to the logger immediately
LOG_ODELAY (default) delay opening the connection until the first message is logged
LOG_PERRORprint log message also to standard error
LOG_PIDinclude PID with each message

T�bl�zat 3. syslog() Priorities (in descending order)

ConstantDescription
LOG_EMERGsystem is unusable
LOG_ALERTaction must be taken immediately
LOG_CRITcritical conditions
LOG_ERRerror conditions
LOG_WARNINGwarning conditions
LOG_NOTICEnormal, but significant, condition
LOG_INFOinformational message
LOG_DEBUGdebug-level message

T�bl�zat 4. dns_get_record() Options

ConstantDescription
DNS_AIPv4 Address Resource
DNS_MXMail Exchanger Resource
DNS_CNAMEAlias (Canonical Name) Resource
DNS_NSAuthoritative Name Server Resource
DNS_PTRPointer Resource
DNS_HINFOHost Info Resource (See for the meaning of these values)
DNS_SOAStart of Authority Resource
DNS_TXTText Resource
DNS_ANYAny Resource Record. On most systems this returns all resource records, however it should not be counted upon for critical uses. Try DNS_ALL instead.
DNS_AAAAIPv6 Address Resource
DNS_ALLItteratively query the name server for each available record type.
Tartalom
checkdnsrr --  Adott Internet domainn�v vagy IP c�mnek megfelel� bejegyz�s l�t�nek vizsg�lata a DNS rekordokban
closelog -- Syslog (rendszer napl�) kapcsolat z�r�sa
debugger_off -- A be�p�tett PHP debugger letilt�sa
debugger_on -- A be�p�tett PHP debugger enged�lyez�se
define_syslog_variables -- A rendszer napl�z�val kapcsolatos konstansok inicializ�l�sa
dns_check_record -- Synonym for checkdnsrr()
dns_get_mx -- Synonym for getmxrr()
dns_get_record --  Fetch DNS Resource Records associated with a hostname
fsockopen --  Internet vagy Unix domain socket megnyit�sa
gethostbyaddr --  Adott IP c�mnek megfelel� hostn�v kinyer�se
gethostbyname --  Kinyeri a megadott Internet hostnak megfelel� IP c�met
gethostbynamel --  Adott hostn�vnek megfelel� �sszes IP c�m list�j�nak kinyer�se
getmxrr --  Adott Internet hostn�vhez tartoz� MX rekordok kigy�jt�se
getprotobyname --  N�vvel megadott protokol sz�m�t adja vissza
getprotobynumber --  Sz�mmal megadott protokol nev�t adja vissza
getservbyname --  Adott szolg�ltat�st�pus portsz�m�nak megallap�t�sa n�v alapj�n
getservbyport --  Adott porton lev� szolg�ltat�s nev�nek meg�llap�t�sa
ip2long --  Pontozott IP c�met tartalmaz� karakterl�ncot val�di IP cimm� alak�t
long2ip --  N�gy byteon t�rolt (IPv4) h�l�zatc�met alak�t az Internet szabv�nynak megfelel� pontozott form�ra
openlog -- A rendszer napl�z�val val� kapcsolat nyit�sa
pfsockopen --  Tart�s Internet vagy Unix domain socket-kapcsolat megnyit�sa
socket_get_status --  Egy m�r megl�v� socket adatainak kinyer�se
socket_set_blocking -- Adott socketen a blokkol�/nem blokkol� m�d kapcsolgat�sa
socket_set_timeout -- Adott socket id�t�ll�p�si peri�dus�nak �ll�t�sa
syslog -- Syslog �zenet l�trehoz�sa
User Contributed Notes
H�l�zatkezel�si F�ggv�nyek
add a note about notes
oliviert at videotron dot ca
18-Feb-1999 09:31

If u wanna do one of these function on windows95, u have to install the lastest winsock before , if else php will crash with a message of wsock32.dll

()

philip at cornado dot c()m
04-Jul-2001 09:18

View a few Networking PHP PEAR classes here :

philip at cornado dot c()m
04-Jul-2001 09:20

More socket functions can be seen here :

philippe-at-cyberabuse.org
15-Dec-2001 02:46

PHP miss CIDR functions.

This one will convert a CIDR like this:
0.0.0.0/16 -> 0.0.0.0 - 0.0.255.255
127.0/16 -> 127.0.0.0 - 127.0.255.255
etc...

function cidrconv($net) {
$start=strtok($net,"/");
$n=3-substr_count($net, ".");
if ($n>0) { for ($i=$n;$i>0;$i--) $start.=".0"; }
$bits1=str_pad(decbin(ip2long($start)),32,"0","STR_PAD_LEFT");
$net=pow(2,(32-substr(strstr($net,"/"),1)))-1;
$bits2=str_pad(decbin($net),32,"0","STR_PAD_LEFT");
for ($i=0;$i<32;$i++) {
if ($bits1[$i]==$bits2[$i]) $final.=$bits1[$i];
if ($bits1[$i]==1 and $bits2[$i]==0) $final.=$bits1[$i];
if ($bits1[$i]==0 and $bits2[$i]==1) $final.=$bits2[$i];
}
return $start." - ".long2ip(bindec($final));
}

philippe-at-cyberabuse.org
12-Oct-2002 10:49

... and this one will do the opposite (o return NULL for invalid netblocks) :

1.0.0.0 1.0.255.255 -> 1.0.0.0/16
1.0.0.0 1.3.255.255 -> 1.0.0.0/14
192.168.0.0 192.168.0.255 -> 192.168.0.0/24

function ip2cidr($ip_start,$ip_end) {
if(long2ip(ip2long($ip_start))!=$ip_start or long2ip(ip2long($ip_end))!=$ip_end) return NULL;
$ipl_start=(int)ip2long($ip_start);
$ipl_end=(int)ip2long($ip_end);
if($ipl_start>0 && $ipl_end<0) $delta=($ipl_end+4294967296)-$ipl_start;
else $delta=$ipl_end-$ipl_start;
$netmask=str_pad(decbin($delta),32,"0","STR_PAD_LEFT");
if(ip2long($ip_start)==0 && substr_count($netmask,"1")==32) return "0.0.0.0/0";
if($delta<0 or ($delta>0 && $delta%2==0)) return NULL;
for($mask=0;$mask<32;$mask++) if($netmask[$mask]==1) break;
if(substr_count($netmask,"0")!=$mask) return NULL;
return "$ip_start/$mask";
}

trevor-hemsley at nospam dot dial dot pipex dot com
16-Oct-2002 06:53

Previous example of IP range to CIDR list does not cope with ranges as well as the perl Net::Netmask range2cidrlist() function. In PHP this looks like

<?
function imask($this)
{
// use base_convert not dechex because dechex is broken and returns 0x80000000 instead of 0xffffffff
return base_convert((pow(2,32) - pow(2, (32-$this)))), 10, 16);
}

function imaxblock($ibase, $tbit)
{
while ($tbit > 0)
{
$im = hexdec(imask($tbit-1));
$imand = $ibase & $im;
if ($imand != $ibase)
{
break;
}
$tbit--;
}
return $tbit;
}

function range2cidrlist($istart, $iend)
{
// this function returns an array of cidr lists that map the range given
$s = explode(".", $istart);
// PHP ip2long does not handle leading zeros on IP addresses! 172.016 comes back as 172.14, seems to be treated as octal!
$start = "";
$dot = "";
while (list($key,$val) = each($s))
{
$start = sprintf("%s%s%d",$start,$dot,$val);
$dot = ".";
}
$end = "";
$dot = "";
$e = explode(".",$iend);
while (list($key,$val) = each($e))
{
$end = sprintf("%s%s%d",$end,$dot,$val);
$dot = ".";
}
$start = ip2long($start);
$end = ip2long($end);
$result = array();
while ($end > $start)
{
$maxsize = imaxblock($start,32);
$x = log($end - $start + 1)/log(2);
$maxdiff = floor(32 - floor($x));
$ip = long2ip($start);
if ($maxsize < $maxdiff)
{
$maxsize = $maxdiff;
}
array_push($result,"$ip/$maxsize");
$start += pow(2, (32-$maxsize));
}
return $result;
}
?>

add a note about notes
<muscat_setupcheckdnsrr>
Last updated: Wed, 15 Jan 2003
show source | credits | mirror sites
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Thu Jan 16 08:12:52 2003 CET