b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Procedural File: _url.funcs.php

Source Location: /blogs/inc/_core/_url.funcs.php

Page Details

URL manipulation functions

This file is part of the b2evolution/evocms project - http://b2evolution.net/. See also http://sourceforge.net/projects/evocms/.

Author:  blueyed: Daniel HAHLER
Author:  Danny Ferguson
Version:  $Id: _url.funcs.php,v 1.49 2010/02/08 17:51:38 efy-yury Exp $
Copyright:  (c)2003-2010 by Francois PLANQUE - http://fplanque.net/. Parts of this file are copyright (c)2006 by Daniel HAHLER - http://daniel.hahler.de/.
Filesource:  Source Code for this file
License:  GNU General Public License (GPL)
Functions
disp_url  [line 714]

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 284]

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

Fetch remote page

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

cURL gets skipped, if $max_size_kb is requested, since there appears to be no method to control this.

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 (default: 15 seconds)
integer   $max_size_kb:  Maximum size in kB

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 193]

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 796]

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 761]

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 735]

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 748]

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 694]

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 668]

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 514]

void url_add_param( string $url, string|array $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|array   $param:  Params to add (string as-is) or array, which gets urlencoded.
string   $glue:  delimiter to use for more params


[ Top ]
url_add_tail  [line 563]

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_crumb  [line 584]

void url_crumb( string $crumb_name  )

Create a crumb param to be passed in action urls...

Parameters:
string   $crumb_name:  crumb_name


[ Top ]
url_rel_to_same_host  [line 603]

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).

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


[ Top ]
url_same_protocol  [line 478]

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 45]

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 246]

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 ]


Documentation generated on Sat, 06 Mar 2010 04:25:51 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).