phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Procedural File: _url.funcs.php

Source Location: /qp_inc/_core/_url.funcs.php

Page Details

URL manipulation functions

This file is part of the Quam Plures project - http://quamplures.net/. See also https://launchpad.net/quam-plures.

Author:  blueyed: Daniel HAHLER
Author:  Danny Ferguson
Copyright:  (c)2003-2009 by Francois PLANQUE - http://fplanque.net/. Parts of this file are copyright (c)2006 by Daniel HAHLER - http://daniel.hahler.de/.
Copyright:  (c) 2009 - 2011 by the Quam Plures developers - http://quamplures.net/
Filesource:  Source Code for this file
License:  GNU General Public License (GPL)
Functions
disp_url  [line 635]

void disp_url( string $url, [integer $max_length = NULL]  )

Display an URL, constrained to a max length

Parameters:
string   $url: 
integer   $max_length: 


[ Top ]
fetch_remote_page  [line 277]

string|false fetch_remote_page( string $url, array &$info, [integer $timeout = 15]  )

Fetch remote page

Attempt to retrieve a remote page using a HTTP GET request, first with cURL, then fsockopen, then fopen.

Parameters:
string   $url:  URL
array   &$info:  Info (by reference) 'error': holds error message, if any 'status': HTTP status (e.g. 200 or 404) 'used_method': Used method ("curl", "fopen", "fsockopen" or null if no method is available)
integer   $timeout:  Timeout

API Tags:
Return:  The remote page as a string; false in case of error

Information Tags:
Todo:  dh> Should we try remaining methods, if the previous one(s) failed?
Todo:  Tblue> Also allow HTTP POST.

[ Top ]
get_allowed_uri_schemes  [line 192]

array get_allowed_uri_schemes( [string $context = 'posting']  )

Get allowed URI schemes for a given context.

Parameters:
string   $context:  Context ("posting", "commenting")


[ Top ]
idna_decode  [line 707]

string idna_decode( string $url  )

Decode IDNA puny-code ("xn--..") to UTF-8 name.

Parameters:
string   $url: 

API Tags:
Return:  The decoded puny-code ("xn--..") (UTF8!)


[ Top ]
idna_encode  [line 682]

string idna_encode( string $url  )

IDNA-Encode URL to Punycode.

Parameters:
string   $url:  URL

API Tags:
Return:  Encoded URL (ASCII)


[ Top ]
is_absolute_url  [line 656]

boolean is_absolute_url( string $url  )

Is a given URL absolute? Note: "//foo/bar" is absolute - leaving the protocol out.

Parameters:
string   $url:  URL


[ Top ]
is_same_url  [line 669]

boolean is_same_url( $a, $b  )

Compare two given URLs, if they are the same.

This converts all urlencoded chars (e.g. "%AA") to lowercase. It appears that some webservers use lowercase for the chars (Apache), while others use uppercase (lighttpd).

Parameters:
   $a: 
   $b: 


[ Top ]
make_rel_links_abs  [line 615]

string make_rel_links_abs( string $s, [string $host = NULL]  )

Make links in $s absolute.

It searches for "src" and "href" HTML tag attributes and makes the absolute.

Parameters:
string   $s:  content
string   $host:  Hostname including scheme, e.g. http://example.com; defaults to $ReqHost

API Tags:
Uses:  url_absolute()


[ Top ]
url_absolute  [line 589]

string url_absolute( string $url, [string $host = NULL]  )

Make an $url absolute according to $host, if it is not absolute yet.

Parameters:
string   $url:  URL
string   $host:  Host (including protocol, e.g. 'http://example.com'); defaults to $ReqHost

API Tags:
Usedby:  make_rel_links_abs()


[ Top ]
url_add_param  [line 467]

void url_add_param( string $url, string $param, [string $glue = '&']  )

Add param(s) at the end of an URL, using either "?" or "&" depending on existing url

Parameters:
string   $url:  existing url
string   $param:  params to add
string   $glue:  delimiter to use for more params


[ Top ]
url_add_tail  [line 505]

void url_add_tail( string $url, string $tail  )

Add a tail (starting with "/") at the end of an URL before any params (starting with "?")

Parameters:
string   $url:  existing url
string   $tail:  tail to add


[ Top ]
url_rel_to_same_host  [line 533]

string url_rel_to_same_host( string $url, string $target_url  )

Try to make $url relative to $target_url, if scheme, host, user and pass matches.

This is useful for redirect_to params, to keep them short and avoid mod_security rejecting the request as "Not Acceptable" (whole URL as param).

NOTE: parse_url cannot handle URLs without scheme (e.g. "//example.com/foo").

Parameters:
string   $url:  URL to handle
string   $target_url:  URL where we want to make $url relative to


[ Top ]
url_same_protocol  [line 431]

string url_same_protocol( string $url, [string $other_url = NULL]  )

Get $url with the same protocol (http/https) as $other_url.

Parameters:
string   $url:  URL
string   $other_url:  other URL (defaults to $ReqHost)


[ Top ]
validate_url  [line 44]

mixed validate_url( string $url, [string $context = 'posting'], [boolean $antispam_check = true]  )

Check the validity of a given URL

Checks allowed URI schemes and URL ban list. URL can be empty.

Note: We have a problem when trying to "antispam" a keyword which is already blacklisted If that keyword appears in the URL... then the next page has a bad referer! :/

Parameters:
string   $url:  Url to validate
string   $context:  Context ("posting", "commenting")
boolean   $antispam_check:  also do an antispam check on the url

API Tags:
Return:  false (which means OK) or error message


[ Top ]
_http_wrapper_last_status  [line 245]

integer|boolean _http_wrapper_last_status( array &$headers  )

Get the last HTTP status code received by the HTTP/HTTPS wrapper of PHP.

Parameters:
array   &$headers:  The $http_response_header array (by reference).

API Tags:
Return:  False if no HTTP status header could be found, the HTTP status code otherwise.


[ Top ]