rootpackage
[ class tree: rootpackage ] [ index: rootpackage ] [ all elements ]

Class: URLs

Source Location: /URLs.php

Class Overview


Created on 5 janv. 07


Author(s):

Version:

  • 2.1

Variables

Methods



Class Details

[line 19]
Created on 5 janv. 07

This class manages URLs objects. Many functions are available: ValidURL(), ParseURL(), etc.

Changes: 2.1 to 2.2: 01 may 09 OpenOverIP() timeout definition 2.0 to 2.1: 28 apr 09 Parse() modification when array values are not defined 1.0 to 2.0: phpdoc compatible in the way to generate documentation




Tags:

author:  Pierre-Dominique Vienne <pvienne@me.com>
version:  2.1
license:  GNU Public License


[ Top ]


Class Variables

$ahttp_codes_2follow = array(301,302)

[line 150]

Variable that contains HTTP code to follow when $this->followlinks==true



Tags:

access:  public

Type:   array


[ Top ]

$aVars =

[line 75]

Variable that contains sent variables and their values ( array("varname"=>"value") )



Tags:

access:  public

Type:   array


[ Top ]

$connection_close_regex =  '/^Connection:\s+close/si'

[line 181]

Variable that contains regular expression used to detect end of connection



Tags:

access:  public

Type:   string


[ Top ]

$content_length =

[line 170]

Variable that contains length of content extracted from headers



Tags:

access:  public

Type:   int


[ Top ]

$content_length_max =  20971520

[line 176]

Variable that contains content length maximum to be retrieved. This limitation has been added to avoid downloading too large files.

Limitation default is 20MB (20971529 bytes)




Tags:

access:  public

Type:   int


[ Top ]

$content_type =  "application/x-www-form-urlencoded"

[line 60]

Variable that contains default content type



Tags:

access:  public

Type:   string


[ Top ]

$error =

[line 125]

Variable that contains error number and error message specific to the URLs() class



Tags:

access:  public

Type:   array


[ Top ]

$errorno =

[line 120]

Variable that contains error number when error occurred in socket opening



Tags:

access:  public

Type:   int


[ Top ]

$followlinks =  false

[line 130]

Variable that contains boolean defining if the opening functions need to follow links



Tags:

access:  public

Type:   bool


[ Top ]

$fragment =

[line 110]

Variable that contains fragment stored in URL (ie.: test for URL=> http://foo.bar.com/#test )



Tags:

access:  public

Type:   string


[ Top ]

$headers =

[line 100]

Variable that contains sent / returned headers



Tags:

access:  public

Type:   array


[ Top ]

$host =

[line 35]

Variable that contains hostname of the specified URL with scheme (ie.: http://foo.bar.com)



Tags:

access:  public

Type:   string


[ Top ]

$host_noscheme =

[line 40]

Variable that contains hostname of the specified URL without scheme (ie.: foo.bar.com)



Tags:

access:  public

Type:   string


[ Top ]

$http_code =

[line 140]

Variable that contains HTTP code



Tags:

access:  public

Type:   int


[ Top ]

$http_response =

[line 145]

Variable that contains HTTP response



Tags:

access:  public

Type:   string


[ Top ]

$http_version =  "1.0"

[line 55]

Variable that contains http version to be used when manipulating headers



Tags:

access:  public

Type:   string


[ Top ]

$infile =

[line 186]

Variable that contains boolean defining if the file needs to be locally stored or not



Tags:

access:  public

Type:   bool


[ Top ]

$location =

[line 160]

Variable that contains location extracted from headers



Tags:

access:  public

Type:   string


[ Top ]

$method =  "GET"

[line 50]

Variable that contains default method



Tags:

access:  public

Type:   string


[ Top ]

$password =

[line 85]

Variable that contains password string to be sent when URL is password protected



Tags:

access:  public

Type:   string


[ Top ]

$path =

[line 105]

Variable that contains path stored in URL (ie.: test/abc for URL=> http://foo.bar.com/test/abc )



Tags:

access:  public

Type:   string


[ Top ]

$port =

[line 90]

Variable that contains port to be used



Tags:

access:  public

Type:   int


[ Top ]

$query =

[line 95]

Variable that contains query stored in URL (ie.: test=abc for URL=> http://foo.bar.com?test=abc )



Tags:

access:  public

Type:   string


[ Top ]

$showstatus =  false

[line 201]

Variable that contains boolean defining if a current status is needed to be displayed



Tags:

access:  public

Type:   bool


[ Top ]

$tmpfile =  null

[line 196]

Variable that contains filename used to store temporary file



Tags:

access:  public

Type:   string


[ Top ]

$tmppath =  "/tmp/"

[line 191]

Variable that contains path where to store temporary files



Tags:

access:  public

Type:   string


[ Top ]

$url =

[line 30]

Variable that contains treated URL



Tags:

access:  public

Type:   string


[ Top ]

$username =

[line 80]

Variable that contains username string to be sent when URL is password protected



Tags:

access:  public

Type:   string


[ Top ]

$user_agent =

[line 115]

Variable that contains user agent to be used for getting headers



Tags:

access:  public

Type:   string


[ Top ]

$user_agent_send =  "PHP-HTTP-Opener"

[line 45]

Variable that contains user agent string used when sending headers



Tags:

access:  public

Type:   string


[ Top ]

$value =

[line 25]

Variable that contains value to be treated



Tags:

access:  public

Type:   string


[ Top ]



Class Methods


constructor __construct [line 227]

URLs __construct( [string $value = null])

Construction function

This function is used when object is generated. It places variable in $this->value

  1.  <?php
  2.  $oURLs    new URLs("http://foo.bar.com");
  3.  echo $oURLs->value;
  4.  // http://foo.bar.com
  5.  ?>




Tags:

since:  Version 1.0


Parameters:

string   $value   string containing url to be treated

[ Top ]

method CompareDomains [line 327]

int CompareDomains( string $actual, string $tocompare)

URL on same domain detection function

This function is used to detect if the URL is on same domain as another provided Result is stored in $this->value and returned

  1.  <?php
  2.  $oURLs        new URLs();
  3.  $actual        "http://www.bar.com/test.php";
  4.  $tocompare    "http://foo.bar.com/example/index.php";
  5.  echo $oURLs->CompareDomains($actual,$tocompare);
  6.  // 4
  7.  ?>




Tags:

return:  code corresponding to specific result (0 = External URL, 1 = Exact domain, 2 = Subdomain ($tocompare is subdomain), 3 = Parent domain ($tocompare is parent), 4 = Same TLD and first domain name (abc.foo.bar.com and def.bar.com), 5 = Link is a mailto: link, 6 = Link is a ftp:// link, 7 = Link is a ssh:// link)
since:  Version 1.0


Parameters:

string   $actual   url to be checked (required)
string   $tocompare   url with which comparing (required)

[ Top ]

method FileType [line 545]

bool|string FileType( string $this->value)

Content type obtention function

This function is used to get the content type of a distant file Result is stored in $this->content_type and returned

  1.  <?php
  2.  $oURLs        new URLs("http://www.bar.com/image.png");
  3.  echo $oURLs->FileType();
  4.  // image/png
  5.  ?>




Tags:

return:  content type of the distant file
since:  Version 1.0
uses:  URLs::GetHeaders()


Parameters:

string   $this->value   url to be checked (required)

[ Top ]

method GetHeaders [line 478]

array GetHeaders( string $this->value)

Headers obtention function

This function is used to get HTTP headers Result is stored in $this->headers and returned

  1.  <?php
  2.  $oURLs        new URLs("http://www.bar.com/test.php");
  3.  echo implode("",$oURLs->GetHeaders());
  4.  // displays headers of the page
  5.  ?>




Tags:

return:  result headers
since:  Version 1.0
usedby:  URLs::FileType()
usedby:  URLs::ValidURL()


Parameters:

string   $this->value   url to be checked (required)

[ Top ]

method OpenOverIP [line 595]

bool|string OpenOverIP( string $this->value, int $this->port, string $this->username, string $this->password, string $this->user_agent_send, bool $this->followlinks, string $this->method, array $this->aVars)

Distant file opening function

This function is used to open files over IP protocol using fsockopen() function The file can be a generated file from a server like PHP-file or POP response. Result is returned

  1.  <?php
  2.  $oURLs        new URLs("http://www.bar.com/test.html");
  3.  echo $oURLs->OpenOverIP();
  4.  // content of test.html
  5.  ?>




Tags:

return:  content of the distant file
since:  Version 1.0
uses:  URLs::Parse()
uses:  STRpasswords::makeRandom()


Parameters:

string   $this->value   url to be checked (required)
int   $this->port   port of the url to be checked
string   $this->username   username of the url if password protected
string   $this->password   password of the url if password protected
string   $this->user_agent_send   string to send to the server to override useragent string
bool   $this->followlinks   follow links on specifics http codes
string   $this->method   method to pass variables
array   $this->aVars   array containing variables to be passed for a post (variablename => variablevalue)

[ Top ]

method Parse [line 417]

string Parse( string $this->value)

Special URL parsing function

This function is used to parse URL Result is stored in $this->host, $this->host_noscheme, $this->port, $this->username, $this->password, $this->path, $this->query, $this->fragment and returned

  1.  <?php
  2.  $oURLs        new URLs("http://foo.bar.com/test/index.php?var1=abc#anchor");
  3.  $oURLs->Parse();
  4.  echo $oURLs->query;
  5.  // var1=abc
  6.  ?>




Tags:

return:  host name
since:  Version 1.0
usedby:  URLs::OpenOverIP()


Parameters:

string   $this->value   url to be checked (required)

[ Top ]

method ValidURL [line 257]

bool ValidURL( [bool $completevalid = false], [bool $nullable = false], string $this->value)

Special URL validation function

This function is used to check state of URL: valid, forbidden, etc. Result is returned

  1.  <?php
  2.  $oURLs        new URLs();
  3.  $actual        "http://www.bar.com/test.php";
  4.  echo $oURLs->ValidURL();
  5.  // 1 (if http://www.bar.com exists)
  6.  ?>




Tags:

return:  true or false weither the URL is valid or not
since:  Version 1.0
uses:  URLs::GetHeaders()


Parameters:

string   $this->value   url to be checked (required)
bool   $completevalid   defines if the URL must be completely valid (HTTP 200, 30x) or can be an error on a valid server (HTTP 404)
bool   $nullable   defines if the URL value can be null

[ Top ]


Documentation generated on Wed, 26 Aug 2009 12:30:58 +0200 by phpDocumentor 1.4.1