Most Referenced Functions
  » google_pagerank()
  » preg_replace()
  » imagecreatefrompng()
  » site_pageranks()
  » imagepng()
  » imagedestroy()
  » imagestring()
  » imagecolorallocate()
  » htmlentities()
  » preg_match()
  » fopen()
  » header()
  » getimagesize()
  » preg_match_all()
  » session_start()
  » htmlspecialchars()
  » ob_start()
  » ob_flush()
  » strstr()
  » flush()
  » strpos()
  » setcookie()
  » str_replace()
  » array2vars()
  » nl2br()
  » preg_split()
  » ereg()
  » ereg_replace()
  » urlencode()
  » readgzfile()

Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m.

PHP Functions

Function: gopher_parsedir

(PECL)

gopher_parsedir -- Translate a gopher formatted directory entry into an associative array.

Description

array gopher_parsedir ( string dirent )

While gopher returns text/plain documents for actual document requests. A request to a directory (such as /) will return specially encoded series of lines with each line being one directory entry or information line.

Examples

Example 1. Hypothetical output from gopher://gopher.example.com/

0All about my gopher site.	/allabout.txt	gopher.example.com	70
9A picture of my cat.	/pics/cat.png	gopher.example.com	70
1A collection of my writings.	/stories	gopher.example.com	70
hThe HTTP version of this site.	URL:http://www.example.com	gopher.example.com	70
1Mirror of this site in Spain.	/	gopher.ejemplo.co.es	70
iWelcome to my gopher site.		error.host	1
iPlease select one of the options above		error.host	1
iSend complaints to /dev/null		error.host	1
iLong live gopher!		error.host	1

In the example above, the root directory at gopher.example.com knows about one DOCUMENT identified by 0 located at gopher://gopher.example.com:70/allabout.txt . It also knows about two other directory (which have their own listing files) at gopher://gopher.exmaple.com:70/stories and at gopher://gopher.ejemplo.co.es:70/ . In addition there is a binary file, a link to an HTTP url, and several informative lines.

By passing each line of the directory listing into gopher_parsedir() , an associative array is formed containing a parsed out version of the data.

Example 2. Using gopher_parsedir()

<?php
dl("gopher.so");

$directory = file("gopher://gopher.example.com");

foreach($directory as $dirent) {
    print_r(gopher_parsedir($dirent));
}

/* Expected Output
   ---------------

Array (
  [type] => 0
  [title] => All about my gopher site.
  [path] => /allabout.txt
  [host] => gopher.example.com
  [port] => 70
)
Array (
  [type] => 9
  [title] => A picture of my cat.
  [path] => /pics/cat.png
  [host] => gopher.example.com
  [port] => 70
)
Array (
  [type] => 1
  [title] => A collection of my writings.
  [path] => /stories
  [host] => gopher.example.com
  [port] => 70
)
Array (
  [type] => 254
  [title] => The HTTP version of this site.
  [path] => URL:http://www.example.com
  [host] => gopher.example.com
  [port] => 70
)
Array (
  [type] => 1
  [title] => Mirror of this site in Spain.
  [path] => /
  [host] => gopher.ejemplo.co.es
  [port] => 70
)
Array (
  [type] => 255
  [title] => Welcome to my gopher site.
  [path] =>
  [host] => error.host
  [port] => 1
)
Array (
  [type] => 255
  [title] => Please select one of the options above.
  [path] =>
  [host] => error.host
  [port] => 1
)
Array (
  [type] => 255
  [title] => Send complaints to /dev/null
  [path] =>
  [host] => error.host
  [port] => 1
)
Array (
  [type] => 255
  [title] => Long live gopher!
  [path] =>
  [host] => error.host
  [port] => 1
)
*/
?>

The values given by type are associated with the following constants.

Table 1. Gopher Constants

Constant Definition GOPHER_DOCUMENT Standard text/plain document. GOPHER_DIRECTORY A resource containing a gopher formatted directory listing. GOPHER_BINHEX A BinHex encoded binary file. GOPHER_DOSBINARY A DOS formatted binary archive. GOPHER_UUENCODED A UUEncoded file. GOPHER_BINARY A generic binary file. GOPHER_INFO An Informational entry GOPHER_HTTP A reference to an HTTP resource. GOPHER_UNKNOWN An unrecognized entry, the line will be returned in data . LXXXVI. Network Functions

Introduction

Requirements

No external libraries are needed to build this extension.

Installation

There is no installation needed to use these functions; they are part of the PHP core.

Runtime Configuration

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

Table 1. Network Configuration Options

Name Default Changeable Changelog define_syslog_variables "0" PHP_INI_ALL   For further details and definitions of the PHP_INI_* constants, see the Appendix H .

Here's 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() .

Resource Types

This extension has no resource types defined.

Predefined Constants

The constants below are always available as part of the PHP core.

Table 2. openlog() Options

Constant Description 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_NOWAIT   LOG_PERROR print log message also to standard error LOG_PID include PID with each message

Table 3. openlog() Facilities

Constant Description LOG_AUTH security/authorization messages (use LOG_AUTHPRIV instead in systems where that constant is defined) LOG_AUTHPRIV security/authorization messages (private) LOG_CRON clock daemon (cron and at) LOG_DAEMON other system daemons LOG_KERN kernel messages LOG_LOCAL0 ... LOG_LOCAL7 reserved for local use, these are not available in Windows LOG_LPR line printer subsystem LOG_MAIL mail subsystem LOG_NEWS USENET news subsystem LOG_SYSLOG messages generated internally by syslogd LOG_USER generic user-level messages LOG_UUCP UUCP subsystem

Table 4. syslog() Priorities (in descending order)

Constant Description LOG_EMERG system is unusable LOG_ALERT action must be taken immediately LOG_CRIT critical conditions LOG_ERR error conditions LOG_WARNING warning conditions LOG_NOTICE normal, but significant, condition LOG_INFO informational message LOG_DEBUG debug-level message

Table 5. dns_get_record() Options

Constant Description DNS_A IPv4 Address Resource DNS_MX Mail Exchanger Resource DNS_CNAME Alias (Canonical Name) Resource DNS_NS Authoritative Name Server Resource DNS_PTR Pointer Resource DNS_HINFO Host Info Resource (See IANA's Operating System Names for the meaning of these values) DNS_SOA Start of Authority Resource DNS_TXT Text Resource DNS_ANY Any 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_AAAA IPv6 Address Resource DNS_ALL Iteratively query the name server for each available record type. Table of Contents checkdnsrr  --  Check DNS records corresponding to a given Internet host name or IP address closelog  -- Close connection to system logger debugger_off  -- Disable internal PHP debugger (PHP 3) debugger_on  -- Enable internal PHP debugger (PHP 3) define_syslog_variables  -- Initializes all syslog related constants dns_check_record  -- Synonym for checkdnsrr() dns_get_mx  -- Synonym for getmxrr() dns_get_record  --  Fetch DNS Resource Records associated with a hostname fsockopen  --  Open Internet or Unix domain socket connection gethostbyaddr  --  Get the Internet host name corresponding to a given IP address gethostbyname  --  Get the IP address corresponding to a given Internet host name gethostbynamel  --  Get a list of IP addresses corresponding to a given Internet host name getmxrr  --  Get MX records corresponding to a given Internet host name getprotobyname  --  Get protocol number associated with protocol name getprotobynumber  --  Get protocol name associated with protocol number getservbyname  --  Get port number associated with an Internet service and protocol getservbyport  --  Get Internet service which corresponds to port and protocol inet_ntop  --  Converts a packed internet address to a human readable representation inet_pton  --  Converts a human readable IP address to its packed in_addr representation ip2long  --  Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address long2ip  --  Converts an (IPv4) Internet network address into a string in Internet standard dotted format openlog  -- Open connection to system logger pfsockopen  --  Open persistent Internet or Unix domain socket connection socket_get_status  -- Alias of stream_get_meta_data() socket_set_blocking  -- Alias of stream_set_blocking() socket_set_timeout  -- Alias of stream_set_timeout() syslog  -- Generate a system log message

Related Function(s)

  • define_syslog_variables()
  • openlog()
  • syslog()
  • dns_get_record()
  • checkdnsrr()
  • closelog()
  • debugger_off()
  • debugger_on()
  • dns_check_record()
  • dns_get_mx()
  • getmxrr()
  • fsockopen()
  • gethostbyaddr()
  • gethostbyname()
  • gethostbynamel()
  • getprotobyname()
  • getprotobynumber()
  • getservbyname()
  • getservbyport()
  • inet_ntop()
  • inet_pton()
  • ip2long()
  • long2ip()
  • pfsockopen()
  • socket_get_status()
  • stream_get_meta_data()
  • socket_set_blocking()
  • stream_set_blocking()
  • socket_set_timeout()
  • stream_set_timeout()
  • Icemelon -- PHP, CSS, Javascript Tutorials, & More!
      © 2005-2010 Icemelon.com   Email: dave[AT]icemelon[D0T]c0m