Niouzes

< Janvier 2021 >
Lu Ma Me Je Ve Sa Di
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Citation

Attention

The documentation is incomplete. The Vae Soli! team works hard to make it as exhaustive as possible with tons of useful examples and easy to understand explanations.

On top of that, we have decided to use our own tool to generate the documentation you read. This also takes time to fine-tune. Our goal is have better documentation, easier to read, easier to use, completely integrated with our site.

Even though NOT finalized, you can now link back to our documentation pages as we have decided once and for all about the structure of our documents and where they all reside on our server.

Thank you very much
The Vae Soli! team.

2020-01-18 à 01:24:43

Table Of Contents

  1. FOUNDATION (functions) (01/04/2015)
  2. LSAction (class) (01/04/2015)
  3. LSAddress (class) (01/04/2015)
  4. LSAdministrativeArea (class) (01/04/2015)
  5. LSApplication (class) (14/10/2013)
  6. LSArray (class) (14/10/2013)
  7. LSArticle (class) (18/02/2014)
  8. LSAssertion (class) (14/10/2013)
  9. LSAudience (class) (18/02/2014)
  10. AUTOLOAD (function) (21/04/2014)
  11. LSAutoReference (class) (14/10/2013)
  12. LSBag (class) (14/10/2013)
  13. LSBBCodes (class) (10/06/2014)
  14. LSBrowser (class) (14/10/2013)
  15. LSCache (class) (14/10/2013)
  16. LSCalculator (class) (14/10/2013)
  17. LSCalendar (class) (14/10/2013)
  18. LSCameraSnapshot (class) (14/10/2013)
  19. LSCitation (class) (14/10/2013)
  20. LSClass (class) (14/10/2013)
  21. LSCode (class) ()
  22. Colors (functions) (18/01/2020)
  23. LSContactForm (class) (14/10/2013)
  24. LSContainer (class) (14/10/2013)
  25. LSContents (class) (14/10/2013)
  26. LSContentsAccounts (class) (14/10/2013)
  27. LSContentsArticles (class) (14/10/2013)
  28. LSContentsAtomicClock (class) (14/10/2013)
  29. LSContentsBusinessCoordinates (class) (14/10/2013)
  30. LSContentsBusinessOff (class) (14/10/2013)
  31. LSContentsBusinessOpeningHours (class) (14/10/2013)
  32. LSContentsBreadcrumb (class) (14/10/2013)
  33. LSContentsCalendar (class) (14/10/2013)
  34. LSContentsCatalogue (class) (14/10/2013)
  35. LSContentsCharter (class) (18/02/2014)
  36. LSContentsCitation (class) (14/10/2013)
  37. LSContentsClock (class) (14/10/2013)
  38. LSContentsComments (class) (14/10/2013)
  39. LSContentsCookieUsage (class) (14/10/2013)
  40. LSContentsCountdown (class) (14/10/2013)
  41. LSContentsDatetime (class) (14/10/2013)
  42. LSContentsHeartbeat (class) (14/10/2013)
  43. LSContentsIFrame (class) (14/10/2013)
  44. LSContentsImageGallery (class) (14/10/2013)
  45. LSContentsLanguageSwitchers (class) (14/10/2013)
  46. LSContentsLegal (class) (18/02/2014)
  47. LSContentsMicronews (class) (14/10/2013)
  48. LSContentsMyAccount (class) (14/10/2013)
  49. LSContentsPaymentOptions (class) (14/10/2013)
  50. LSContentsPinboard (class) (14/10/2013)
  51. LSContentsRememberPassword (class) (14/10/2013)
  52. LSContentsRSS (class) (14/10/2013)
  53. LSContentsSiteManager (class) (14/10/2013)
  54. LSContentsSitemap (class) (14/10/2013)
  55. LSContentsShare (class) (14/10/2013)
  56. LSContentsStopwatch (class) (14/10/2013)
  57. LSContentsTagCloud (class) (14/10/2013)
  58. LSContentsTodosOnPage (class) (14/10/2013)
  59. LSContentsW3C (class) (14/10/2013)
  60. LSContentsWeather (class) (14/10/2013)
  61. LSControl (class) (14/10/2013)
  62. LSCreativeWork (class) (18/02/2014)
  63. LSCursor (class) (09/03/2015)
  64. LSCustomer (class) (14/10/2013)
  65. LSDataEnvironment (class) (14/10/2013)
  66. Dates (functions) (01/04/2015)
  67. LSDate (class) (14/10/2013)
  68. LSDictionary (class) (14/10/2013)
  69. LSDom, LSDomNode and LSXPath (class) (30/04/2014)
  70. LSErrors and LSError (classes) (14/10/2013)
  71. LSException (class) (16/10/2013)
  72. LSExplorer (class) (14/10/2013)
  73. LSFieldset (class) (14/10/2013)
  74. LSFile (class) (14/10/2013)
  75. LSFileProperties (class) (14/10/2013)
  76. Files (functions) (01/04/2015)
  77. Finance (functions) (01/04/2015)
  78. LSFootnotes (class) (22/02/2014)
  79. LSForm (class) (09/06/2014)
  80. LSFunction (class) (14/10/2013)
  81. LSGeorama (class) (24/10/2013)
  82. LSGeoramaVar (class) (24/10/2013)
  83. LSGlossary (class) (09/03/2015)
  84. LSGroup (class) (14/10/2013)
  85. HTML (functions) (01/04/2015)
  86. LSHttp (class) (14/10/2013)
  87. HTTP (functions) (01/04/2015)
  88. LSImageGallery (class) (14/10/2013)
  89. Images (functions) (01/04/2015)
  90. LSInput (class) (26/04/2014)
  91. IP (functions) (01/04/2015)
  92. LSIslandAbstract (14/10/2013)
  93. LSIslandFormAbstract (class) (14/10/2013)
  94. LSLabel (class) (14/10/2013)
  95. LSLanguageSwitchers (class) (14/10/2013)
  96. LSLatin (class) (14/10/2013)
  97. LSLegalPerson (class) (14/10/2013)
  98. LSLinkedList (class) (14/10/2013)
  99. LSList (class) (14/10/2013)
  100. Mails (functions) (01/04/2015)
  101. LSMap (class) (14/10/2013)
  102. Math (functions) (01/04/2015)
  103. LSMicronews (class) (18/02/2014)
  104. Miscellaneous (functions) (01/04/2015)
  105. LSModuleAbstract (class) (14/10/2013)
  106. LSNaturalPerson (class) (14/10/2013)
  107. LSNewsArticle (class) (18/02/2014)
  108. LSNote (class) (14/10/2013)
  109. LSMotherNature (class) (16/10/2013)
  110. LSPage (class) (18/02/2014)
  111. LSParameter (class) (14/10/2013)
  112. LSPaymentOptions (class) (14/10/2013)
  113. LSPeopleAudience (class) (18/02/2014)
  114. LSPerson (class) (14/10/2013)
  115. LSPlace (class) (18/02/2014)
  116. LSProperty (class) (14/10/2013)
  117. LSPublication (class) (14/10/2013)
  118. LSRequirement (class) (14/10/2013)
  119. LSReturn (class) (24/10/2013)
  120. LSRisk (class) (14/10/2013)
  121. LSSentanaiAbstract (14/10/2013)
  122. LSServiceMessage (class) (14/10/2013)
  123. LSSession (class) (14/10/2013)
  124. LSSiteManager (class) (14/10/2013)
  125. LSSitemap (class) (14/10/2013)
  126. LSSockets (class) (14/10/2013)
  127. LSSoftwareApplication (class) (18/02/2014)
  128. LSSource (class) (14/10/2013)
  129. Strings (functions) (31/07/2016)
  130. LSSupplier (class) (14/10/2013)
  131. System (functions) (01/04/2015)
  132. LSTag (class) (21/04/2014)
  133. LSTagCloud (class) (14/10/2013)
  134. LSTechArticle (class) (18/02/2014)
  135. LSThing (class) (18/02/2014)
  136. LSTimeline (class) (14/10/2013)
  137. LSTimer (class) (16/10/2013)
  138. LSTracer (class) (09/03/2015)
  139. LSUnitTesting (class) (14/10/2013)
  140. URL (functions) (01/04/2015)
  141. LSUser (class) (09/03/2015)
  142. LSUserMgr (class) (14/10/2013)
  143. LSVaesoli (class) (09/06/2014)
  144. LSVersion (class) (14/10/2013)
  145. LSWebSite (class) (14/10/2013)
  146. LSWidget (class) (14/10/2013)
  147. LSWireTransferForm (class) (14/10/2013)
  148. LSXMLSitemap (class) (14/10/2013)
  149. XML (functions) (01/04/2015)

LSHttp.functions.php

Generated by The Vae Soli! Documentor: Guide v. 1.3.0018 on 01-04-2015 16:19:49 (DD-MM-YYYY HH:mm:SS). This documentation is built with Vae Soli! functions and classes!

The download page of Vae Soli! contains all sources of the framework.

Additional samples are available on the samples page of Vae Soli!.

File Properties

C:\websites\vaesoli.org\www\httpdocs/vaesoli/include/LSHttp.functions.phpC:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSHttp.functions.phpapplication/force-downloadC:\websites\vaesoli.org\www\httpdocs\vaesoli\include40114 bytes03/08/2013 23:27:5212/03/2015 15:03:2412/03/2015 15:03:24

Compliance

Assertions count: 10

Assertions successful: 10

Assertion failures: 0

0001 ... <?php
0002 ... /**************************************************************************/
0003 ... /** {{{*fheader
0004 ...     {*file                  LSHttp.functions.php *}
0005 ...     {*purpose               HTTP protocol oriented functions *}
0006 ...     {*author                 *}
0007 ...     {*company               Lato Sensu Management[br]
0008 ...                             Rue Bois des Mazuis, 47[br]
0009 ...                             5070 Vitrival[br]
0010 ...                             Belgium (BE)[br]
0011 ...                             [url]http://www.latosensu.be[/url][br]
0012 ...                             Vae Soli! : [url]http://www.vaesoli.org[/url] *}
0013 ...     {*cdate                 05/06/2012 - 11:44 *}
0014 ...     {*mdate                 27/06/2012 - 06:45 *}
0015 ...     {*license               [url]http://creativecommons.org/licenses/by-sa/2.0/be/[/url][br]
0016 ... 
0017 ...                             To obtain detailed information about the license
0018 ...                             terms, please head to the full license text
0019 ...                             available in the [file]LSCopyright.php[/file] file *}
0020 ... 
0021 ...     ------------------------------------------------------------------------
0022 ...     Changes History:
0023 ...     ------------------------------------------------------------------------
0024 ... 
0025 ...     {*chist
0026 ...         {*mdate 21/06/2012 *}
0027 ...         {*v 5.0.0003 *}
0028 ...         {*desc              All comments before this release have been
0029 ...                             eliminated (for tracking purposes, please
0030 ...                             head to the Vae Soli! archive : vaesoli-5.0.0002.zip *}
0031 ...     *}
0032 ... 
0033 ...     {*chist
0034 ...         {*mdate 26/06/2012 *}
0035 ...         {*v 5.0.0003 *}
0036 ...         {*desc              Changed the default name of the VaeSoliBot to
0037 ...                             Mozilla/5.0 (compatible; VaesoliBot Version/1.0; http://www.vaesoli.org)
0038 ...         *}
0039 ...     *}
0040 ... 
0041 ...     {*chist
0042 ...         {*mdate 27/06/2012 *}
0043 ...         {*v 5.0.0003 *}
0044 ...         {*desc              Tiny changes in HTTP_GetURL()
0045 ...         *}
0046 ...     *}
0047 ... 
0048 ...     *}}} */
0049 ... /**************************************************************************/
0050 ... if ( ! defined( 'VAESOLI_PATH' ) )                                  /* If the path is not defined yet */
0051 ... {
0052 ...     /* {*define (VAESOLI_PATH)  Define the path where Vae Soli! is installed *} */
0053 ...     define( 'VAESOLI_PATH',__DIR__ );
0054 ... }   /* if ( ! defined( 'VAESOLI_PATH' ) ) */
0055 ... 
0056 ... if ( ! defined( 'VAESOLI_PLUGINS' ) )                               /* If the path is not defined yet */
0057 ... {
0058 ...     /* {*define (VAESOLI_PLUGINS)  Define the path where plugins are located *} */
0059 ...     define( 'VAESOLI_PLUGINS',VAESOLI_PATH . '/../plugins' );
0060 ... }   /* if ( ! defined( 'VAESOLI_PLUGINS' ) ) */
0061 ... 
0062 ... /* {*define (RET_CODES)  Defines whether return codes are defined or not *} */
0063 ... if ( ! defined( 'RET_CODES' ) )                                     /* If the path is not defined yet */
0064 ... {
0065 ...     define( 'RET_CODES'                                 ,0  );
0066 ... 
0067 ...     define( 'RET_CODE_CONTINUE'                         ,100 );     /* {*define (RET_CODES)                             Defines whether return codes are defined or not *} */
0068 ... 
0069 ...     define( 'RET_CODE_OK'                               ,200 );     /* {*define (RET_CODE_OK)                              200 *} */
0070 ...     define( 'RET_CODE_CREATED'                          ,201 );     /* {*define (RET_CODE_CREATED)                         201 *} */
0071 ...     define( 'RET_CODE_ACCEPTED'                         ,202 );     /* {*define (RET_CODE_ACCEPTED)                        202 *} */
0072 ...     define( 'RET_CODE_NON_AUTHORITATIVE'                ,203 );     /* {*define (RET_CODE_NON_AUTHORITATIVE)               203 *} */
0073 ...     define( 'RET_CODE_NO_CONTENT'                       ,204 );     /* {*define (RET_CODE_NO_CONTENT)                      204 *} */
0074 ...     define( 'RET_CODE_RESET_CONTENT'                    ,205 );     /* {*define (RET_CODE_RESET_CONTENT)                   205 *} */
0075 ...     define( 'RET_CODE_PARTIAL_CONTENT'                  ,206 );     /* {*define (RET_CODE_PARTIAL_CONTENT)                 206 *} */
0076 ... 
0077 ...     define( 'RET_CODE_MULTIPLE_CHOICES'                 ,300 );     /* {*define (RET_CODE_MULTIPLE_CHOICES)                300 *} */
0078 ...     define( 'RET_CODE_MOVED_PERMANENTLY'                ,301 );     /* {*define (RET_CODE_MOVED_PERMANENTLY)               301 *} */
0079 ...     define( 'RET_CODE_FOUND'                            ,302 );     /* {*define (RET_CODE_FOUND)                           302 *} */
0080 ...     define( 'RET_CODE_SEE_OTHER'                        ,303 );     /* {*define (RET_CODE_SEE_OTHER)                       303 *} */
0081 ...     define( 'RET_CODE_NOT_MODIFIED'                     ,304 );     /* {*define (RET_CODE_NOT_MODIFIED)                    304 *} */
0082 ...     define( 'RET_CODE_USE_PROXY'                        ,305 );     /* {*define (RET_CODE_USE_PROXY)                       305 *} */
0083 ...     define( 'RET_CODE_RESERVED'                         ,306 );     /* {*define (RET_CODE_RESERVED)                        306 *} */
0084 ...     define( 'RET_CODE_TEMPORARY_REDIRECT'               ,307 );     /* {*define (RET_CODE_TEMPORARY_REDIRECT)              307 *} */
0085 ... 
0086 ...     define( 'RET_CODE_BAD_REQUEST'                      ,400 );     /* {*define (RET_CODE_BAD_REQUEST)                     400 *} */
0087 ...     define( 'RET_CODE_UNAUTHORIZED'                     ,401 );     /* {*define (RET_CODE_UNAUTHORIZED)                    401 *} */
0088 ...     define( 'RET_CODE_PAYMENT_REQUIRED'                 ,402 );     /* {*define (RET_CODE_PAYMENT_REQUIRED)                402 *} */
0089 ...     define( 'RET_CODE_FORBIDDEN'                        ,403 );     /* {*define (RET_CODE_FORBIDDEN)                       403 *} */
0090 ...     define( 'RET_CODE_NOT_FOUND'                        ,404 );     /* {*define (RET_CODE_NOT_FOUND)                       404 *} */
0091 ...     define( 'RET_CODE_METHOD_NOT_ALLOWED'               ,405 );     /* {*define (RET_CODE_METHOD_NOT_ALLOWED)              405 *} */
0092 ...     define( 'RET_CODE_NOT_ACCEPTABLE'                   ,406 );     /* {*define (RET_CODE_NOT_ACCEPTABLE)                  406 *} */
0093 ...     define( 'RET_CODE_PROXY_AUTHENTIFICATION_REQUIRED'  ,407 );     /* {*define (RET_CODE_PROXY_AUTHENTIFICATION_REQUIRED) 407 *} */
0094 ...     define( 'RET_CODE_REQUEST_TIMEOUT'                  ,408 );     /* {*define (RET_CODE_REQUEST_TIMEOUT)                 408 *} */
0095 ...     define( 'RET_CODE_CONFLICT'                         ,409 );     /* {*define (RET_CODE_CONFLICT)                        409 *} */
0096 ...     define( 'RET_CODE_GONE'                             ,410 );     /* {*define (RET_CODE_GONE)                            410 *} */
0097 ...     define( 'RET_CODE_LENGTH_REQUIRED'                  ,411 );     /* {*define (RET_CODE_LENGTH_REQUIRED)                 411 *} */
0098 ...     define( 'RET_CODE_PRECONDITION_FAILED'              ,412 );     /* {*define (RET_CODE_PRECONDITION_FAILED)             412 *} */
0099 ...     define( 'RET_CODE_REQUEST_ENTITY_TOO_LARGE'         ,413 );     /* {*define (RET_CODE_REQUEST_ENTITY_TOO_LARGE)        413 *} */
0100 ...     define( 'RET_CODE_REQUEST_URI_TOO_LONG'             ,414 );     /* {*define (RET_CODE_REQUEST_URI_TOO_LONG)            414 *} */
0101 ...     define( 'RET_CODE_UNSUPPORTED_MEDIA_TYPE'           ,415 );     /* {*define (RET_CODE_UNSUPPORTED_MEDIA_TYPE)          415 *} */
0102 ...     define( 'RET_CODE_REQUESTED_RANGE_NOT_SATISFIABLE'  ,416 );     /* {*define (RET_CODE_REQUESTED_RANGE_NOT_SATISFIABLE) 416 *} */
0103 ...     define( 'RET_CODE_EXPECTATION_FAILED'               ,417 );     /* {*define (RET_CODE_EXPECTATION_FAILED)              417 *} */
0104 ... 
0105 ...     define( 'RET_CODE_INTERNAL_SERVER_ERROR'            ,500 );     /* {*define (RET_CODE_INTERNAL_SERVER_ERROR)           500 *} */
0106 ...     define( 'RET_CODE_NOT_IMPLEMENTED'                  ,501 );     /* {*define (RET_CODE_NOT_IMPLEMENTED)                 501 *} */
0107 ...     define( 'RET_CODE_BAD_GATEWAY'                      ,502 );     /* {*define (RET_CODE_BAD_GATEWAY)                     502 *} */
0108 ...     define( 'RET_CODE_SERVICE_UNAVAILABLE'              ,503 );     /* {*define (RET_CODE_SERVICE_UNAVAILABLE)             503 *} */
0109 ...     define( 'RET_CODE_GATEWAY_TIMEOUT'                  ,504 );     /* {*define (RET_CODE_GATEWAY_TIMEOUT)                 504 *} */
0110 ...     define( 'RET_CODE_HTTP_VERSION_NOT_SUPPORTED'       ,505 );     /* {*define (RET_CODE_HTTP_VERSION_NOT_SUPPORTED)      505 *} */
0111 ... }
0112 ... 
0113 ... global $iLSVTimeout;
0114 ... global $szLSVUserAgent;
0115 ... 
0116 ... $iLSVTimeout    = 25000;
0117 ... $szLSVUserAgent = 'Mozilla/5.0 (compatible; VaesoliBot Version/1.1; http://www.vaesoli.org/vaesolibot/)';
0118 ... 
0119 ... /* ====================================================================== */
0120 ... /** {{*HTTP_GetURL( $szURL,$szUser,$szPwd,$iErrCode,$aOptions,$szHeader,$iSecs )=
0121 ... 
0122 ...     Retrieves URL as a string
0123 ...     (uppercase and lowercase) into their respective equivalents
0124 ... 
0125 ...     {*params
0126 ...         $szURL      (string)    URL to access.
0127 ...         $szUser     (string)    User account. Optional. [c]null[/c] by default.
0128 ...         $szPwd      (string)    User password. Optional. [c]null[/c] by default.
0129 ...         $iErrCode   (int)       Optional return code. Updated upon exit.
0130 ...                                 [c]0[/c] by default.
0131 ...         $aOptions   (array)     Optional array of CURL options. Not used
0132 ...                                 so far (1/05/2013 14:50:32). [c]null[/c]
0133 ...                                 by default.
0134 ...         $szHeader   (string)    Optional header that we got back. [c]null[/c]
0135 ...                                 by default. Updated upon return.
0136 ...         $iSecs      (int)       Optional. The number of seconds to wait while
0137 ...                                 trying to connect. Use 0 to wait indefinitely.
0138 ...                                 By default, this value is set to 5.
0139 ...     *}
0140 ... 
0141 ...     {*warning
0142 ...         This set of functions is designed to be internals of
0143 ...         Vae Soli! at this stage (09-03-15 10:50:16). Do not use
0144 ...         these functions or use them at your own risk.[br]
0145 ...         Consider the use of [c]HTTP_SetTimeout()[/c]
0146 ... 
0147 ...     *}
0148 ... 
0149 ...     {*remark
0150 ... 
0151 ...         Proxies and firewalls are not supported for the time being.
0152 ...         HTTP_GetURL() features a server timeout of 60 seconds: if the server
0153 ...         does not respond within 60 seconds, the request is aborted. The same
0154 ...         applies when the server does not send any more information within
0155 ...         the same period.
0156 ...     *}
0157 ... 
0158 ...     {*return
0159 ...         (string)            The resource identified by $szURL as a string
0160 ...     *}
0161 ... 
0162 ...     {*assert
0163 ...         strstr( HTTP_GetURL( 'http://www.google.com' ),'google.com' ) != false
0164 ...     *}
0165 ... 
0166 ...     {*example
0167 ...         echo HTTP_GetURL( 'http://www.latosensu.be' );  // Outputs the homepage of Lato Sensu Management
0168 ...     *}
0169 ... 
0170 ...     *}}
0171 ...  */
0172 ... /* ====================================================================== */
0173 ... function HTTP_GetURL( $szURL,$szUser = null,$szPwd = null,&$iErrCode = 0,$aOptions = null,&$szHeader = null,$iSecs = 5 )
0174 ... /*--------------------------------------------------------------------------------------------------------------------*/
0175 ... {
0176 ...     //echo "GET URL avec " . $GLOBALS['szLSVUserAgent'];
0177 ...     $szRetVal   = null;                                             /* Default return value of the function */
0178 ...     $WithHeader = true;                                             /* With response header */
0179 ... 
0180 ...     if ( function_exists( 'curl_init' ) )                           /* If function is defined */
0181 ...     {
0182 ...         if ( ( $xHandle = curl_init() ) )                           /* Create a handle */
0183 ...         {
0184 ...             if ( ! is_null( $aOptions ) )                           /* If array of options passed */
0185 ...             {
0186 ...                 if ( isset( $aOptions[CURLOPT_HEADER] ) )           /* If response header requested */
0187 ...                 {
0188 ...                     $WithHeader = $aOptions[CURLOPT_HEADER];        /* With response header ? */
0189 ...                 }   /* if ( isset( $aOptions[CURLOPT_HEADER] ) ) */
0190 ...                 curl_setopt_array ( $xHandle,$aOptions );           /* Use this array */
0191 ...             }   /* if ( ! is_null( $aOptions ) ) */
0192 ...             else   /* Else of ... if ( ! is_null( $aOptions ) ) */
0193 ...             {
0194 ...                 $iMS = isset( $GLOBALS['iLSVTimeout'] ) ? $GLOBALS['iLSVTimeout'] : $iSecs * 1000;
0195 ... 
0196 ...                 set_time_limit( 30 + $iSecs );                      /* To cater for connection timeout and execution timeout */
0197 ...                 curl_setopt( $xHandle,CURLOPT_RETURNTRANSFER    ,true       );  /* TRUE to return the transfer as a string */
0198 ...                 curl_setopt( $xHandle,CURLOPT_CONNECTTIMEOUT    ,$iSecs     );  /* The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. */
0199 ...                 curl_setopt( $xHandle,CURLOPT_CONNECTTIMEOUT_MS ,$iMS       );  /* The number of milliseconds to wait while trying to connect. Use 0 to wait indefinitely. */
0200 ...                 curl_setopt( $xHandle,CURLOPT_TIMEOUT           ,25         );  /* The maximum number of seconds to allow cURL functions to execute */
0201 ...                 curl_setopt( $xHandle,CURLOPT_USERAGENT         ,$GLOBALS['szLSVUserAgent'] );
0202 ...                 curl_setopt( $xHandle,CURLOPT_ENCODING          ,''         );  /* Set all encodings possible */
0203 ...                 curl_setopt( $xHandle,CURLOPT_FOLLOWLOCATION    ,true       );  /* Follow Location: */
0204 ...                 curl_setopt( $xHandle,CURLOPT_FRESH_CONNECT     ,true       );  /* Fresh connection */
0205 ...                 curl_setopt( $xHandle,CURLINFO_HEADER_OUT       ,true       );
0206 ...                 curl_setopt( $xHandle,CURLOPT_HEADER            ,$WithHeader ); /* Response Header info */
0207 ...                 curl_setopt( $xHandle,CURLOPT_AUTOREFERER       ,true       );
0208 ...                 curl_setopt( $xHandle,CURLOPT_MAXREDIRS         ,3          );
0209 ...             }   /* End of ... Else of ... if ( ! is_null( $aOptions ) ) */
0210 ... 
0211 ...             curl_setopt( $xHandle,CURLOPT_URL,$szURL );             /* URL passed to CURL */
0212 ... 
0213 ...             if ( ! is_null( $szUser ) )                             /* If user passed */
0214 ...             {
0215 ...                 curl_setopt( $xHandle,CURLOPT_USERPWD   ,"{$szUser}:{$szPwd}"   );
0216 ...             }   /* if ( ! is_null( $szUser ) ) */
0217 ... 
0218 ...             $szData     = curl_exec( $xHandle );                    /* Get data now */
0219 ...             $aInfo      = curl_getinfo( $xHandle );                 /* Get info from the connection */
0220 ... 
0221 ...             $iErrCode   = (int) $aInfo['http_code'];                /* Error code (if any) */
0222 ... 
0223 ...             if ( $iErrCode == 200 )                                 /* If success */
0224 ...             {
0225 ...                 if ( $WithHeader )                                  /* If response header sent back */
0226 ...                 {
0227 ...                     /********************************************************************/
0228 ...                     /* OK ... $szData contains both the response header AND the payload */
0229 ...                     /* What we need to do now is to parse this response as to be able   */
0230 ...                     /* to distinguish the response header from the body. The header is  */
0231 ...                     /* sent first, then we have a double \r\n, then we have the body.   */
0232 ...                     /*                                                                  */
0233 ...                     /* We shall use list(..) to do this together with explode(..) with  */
0234 ...                     /* only 2 parts.                                                    */
0235 ...                     /********************************************************************/
0236 ...                     list( $header,$body ) = explode("\r\n\r\n",$szData,2 );
0237 ... 
0238 ...                     if ( ! is_null( $szHeader ) )                   /* If header requested (CURLINFO_HEADER_OUT option must be set) */
0239 ...                     {
0240 ...                         $szHeader = $header;                        /* Store header back in parameter sent by reference */
0241 ...                     }   /* if ( ! is_null( $szHeader ) ) */
0242 ... 
0243 ...                     $szRetVal = $body;                              /* Place the return buffer in the return slot */
0244 ...                 }   /* if ( $WithHeader ) */
0245 ...                 else   /* Else of ... if ( $WithHeader ) */
0246 ...                 {
0247 ...                     $szRetVal = $szData;                            /* Place the return buffer in the return slot */
0248 ...                 }   /* End of ... Else of ... if ( $WithHeader ) */
0249 ...             }   /* if ( $iErrCode == 200 ) */
0250 ...             else   /* Else of ... if ( $iErrCode == 200 ) */
0251 ...             {
0252 ...                 if ( $WithHeader )                                  /* If response header sent back */
0253 ...                 {
0254 ...                     /********************************************************************/
0255 ...                     /* OK ... $szData contains both the response header AND the payload */
0256 ...                     /* What we need to do now is to parse this response as to be able   */
0257 ...                     /* to distinguish the response header from the body. The header is  */
0258 ...                     /* sent first, then we have a double \r\n, then we have the body.   */
0259 ...                     /*                                                                  */
0260 ...                     /* We shall use list(..) to do this together with explode(..) with  */
0261 ...                     /* 2 parts only.                                                    */
0262 ...                     /********************************************************************/
0263 ...                     $szNeedle = "\r\n\r\n";
0264 ...                     if ( ! STR_Empty( $szData ) && strstr( $szData,$szNeedle ) )
0265 ...                     {
0266 ...                         list( $header,$body ) = explode( $szNeedle,$szData,2 );
0267 ... 
0268 ...                         if ( ! is_null( $szHeader ) )               /* If header requested (CURLINFO_HEADER_OUT option must be set) */
0269 ...                         {
0270 ...                             $szHeader = $header;                    /* Store header back in parameter sent by reference */
0271 ...                         }   /* if ( ! is_null( $szHeader ) ) */
0272 ...                     }   /* if ( ! STR_Empty( $szData ) && strstr( $szData,$szNeedle = "\r\n\r\n" ) ) */
0273 ...                     else   /* Else of ... if ( ! STR_Empty( $szData ) && strstr( $szData,$szNeedle = "\r\n\r\n" ) ) */
0274 ...                     {
0275 ...                         $szHeader = null;
0276 ...                     }   /* End of ... Else of ... if ( ! STR_Empty( $szData ) && strstr( $szData,$szNeedle = "\r\n\r\n" ) ) */
0277 ...                 }   /* if ( $WithHeader ) */
0278 ...                 $szRetVal = null;                                   /* Got nothing */
0279 ...             }   /* End of ... Else of ... if ( $iErrCode == 200 ) */
0280 ... 
0281 ...             curl_close( $xHandle );                                 /* Close connection */
0282 ...         }   /* if ( ( $xHandle = curl_init() ) ) */
0283 ...     }   /* if ( function_exists( 'curl_init' ) ) */
0284 ...     else   /* Else of ... if ( function_exists( 'curl_init' ) ) */
0285 ...     {
0286 ...         $szRetVal = file_get_contents( $szURL );
0287 ...     }   /* End of ... Else of ... if ( function_exists( 'curl_init' ) ) */
0288 ... 
0289 ...     return ( $szRetVal );                                           /* Return result to caller */
0290 ... }   /* End of HTTP_GetURL() ============================================= */
0291 ... function HTTP_Get( $szURL,$szUser = null,$szPwd = null,&$iErrCode = 0,$aOptions = null,&$szHeader = null )
0292 ... {
0293 ...     return ( HTTP_GetURL( $szURL,$szUser,$szPwd,$iErrCode,$aOptions,$szHeader ) );
0294 ... }
0295 ... 
0296 ... 
0297 ... /* ====================================================================== */
0298 ... /** {{*HTTP_CanConnect( [$szURL] )=
0299 ... 
0300 ...     Determines if we can connect to a given URL.
0301 ... 
0302 ...     {*params
0303 ...         $szURL  (string)    Optional URL to access. 'http://www.google.com'
0304 ...                             by default
0305 ...     *}
0306 ... 
0307 ...     {*return
0308 ...         (bool)      [c]true[/c] if $szURL could be contacted; [c]false[/c]
0309 ...                     if not.
0310 ...     *}
0311 ... 
0312 ...     {*assert
0313 ...         HTTP_CanConnect( 'http://www.google.com' ) === true
0314 ...     *}
0315 ... 
0316 ...     {*assert
0317 ...         HTTP_CanConnect() === true
0318 ...     *}
0319 ... 
0320 ...     {*assert
0321 ...         HTTP_CanConnect( 'noexist' ) === false
0322 ...     *}
0323 ... 
0324 ...     {*assert
0325 ...         HTTP_CanConnect( 'http://this-domain-does-not-exist.tl' ) === false
0326 ...     *}
0327 ... 
0328 ...     *}}
0329 ...  */
0330 ... /* ====================================================================== */
0331 ... function HTTP_CanConnect( $szURL = 'http://www.google.com' )
0332 ... /*--------------------------------------------------------*/
0333 ... {
0334 ...     $bRetVal = false;                                               /* Cannot connect by default */
0335 ... 
0336 ...     if ( ! STR_Empty( $szURL ) )                                    /* If URL OK */
0337 ...     {
0338 ...         $szHost = 'www.google.com';                                 /* Default host to test */
0339 ... 
0340 ...         $aParsedURL = parse_url( $szURL );                          /* Parse URL now */
0341 ... 
0342 ...         if ( isset( $aParsedURL['host'] ) )                         /* If host found */
0343 ...         {
0344 ...             $szHost = $aParsedURL['host'];                          /* Get host */
0345 ...         }   /* if ( isset( $aParsedURL['host'] ) ) */
0346 ... 
0347 ...         if ( isset( $aParsedURL['scheme'] ) && ! STR_Empty( $aParsedURL['scheme'] ) ) /* We need a scheme ... otherwise we're on something else */
0348 ...         {
0349 ...             if ( @fsockopen( $szHost,80 ) )                         /* Open socket on port 80 */
0350 ...             {
0351 ...                 $bRetVal = true;                                    /* Ready to return a logical true */
0352 ...             }   /* if ( @fsockopen( $szHost,80 ) ) */
0353 ...         }
0354 ...     }   /* if ( ! STR_Empty( $szURL ) ) */
0355 ... 
0356 ...     return ( $bRetVal );                                            /* Return result to caller */
0357 ... }   /* End of HTTP_CanConnect() ========================================= */
0358 ... 
0359 ... /* ====================================================================== */
0360 ... /** {{*HTTP_IsURL( $szURL )=
0361 ... 
0362 ...     Returns status information about a URL
0363 ... 
0364 ...     {*params
0365 ...         $szURL  (string)   the URL to access.
0366 ...     *}
0367 ... 
0368 ...     {*return
0369 ...         (int)       The return code
0370 ... 
0371 ...         HTTP Status Codes[br]
0372 ...         Constant                        Value   Description[br]
0373 ...         HTTP_STATUS_OK                  200    The request completed successfully.[br]
0374 ...         HTTP_STATUS_CREATED             201    The request has been fulfilled and resulted in the creation of a new resource.[br]
0375 ...         HTTP_STATUS_ACCEPTED            202    The request has been accepted for processing , but the processing has not been completed.[br]
0376 ...         HTTP_STATUS_PARTIAL             203    The returned meta information in the entity-header is not the definitive set available from the origin server.[br]
0377 ...         HTTP_STATUS_NO_CONTENT          204    The server has fulfilled the request, but there is no new information to send back.[br]
0378 ...         HTTP_STATUS_RESET_CONTENT       205    The request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action.[br]
0379 ...         HTTP_STATUS_PARTIAL_CONTENT     206    The server has fulfilled the partial GET request for the resource.[br]
0380 ...         HTTP_STATUS_AMBIGUOUS           300    The server couldn't decide what to return.[br]
0381 ...         HTTP_STATUS_MOVED               301    The requested resource has been assigned to a new permanent URI, and any future references to this resource should be done using one of the returned URIs.[br]
0382 ...         HTTP_STATUS_REDIRECT            302    The requested resource resides temporarily under a different URI.[br]
0383 ...         HTTP_STATUS_REDIRECT_METHOD     303    The response to the request can be found under a different URI and should be retrieved using a GET method on that resource.[br]
0384 ...         HTTP_STATUS_NOT_MODIFIED        304    The requested resource has not been modified.[br]
0385 ...         HTTP_STATUS_USE_PROXY           305    The requested resource must be accessed through the proxy given by the location field.[br]
0386 ...         HTTP_STATUS_REDIRECT_KEEP_VERB  307    The redirected request keeps the same verb. HTTP/1.1 behavior.[br]
0387 ...         HTTP_STATUS_BAD_REQUEST         400    The request could not be processed by the server due to invalid syntax.[br]
0388 ...         HTTP_STATUS_DENIED              401    The requested resource requires user authentication.[br]
0389 ...         HTTP_STATUS_PAYMENT_REQ         402    Not currently implemented in the HTTP protocol.[br]
0390 ...         HTTP_STATUS_FORBIDDEN           403    The server understood the request, but is refusing to fulfill it.[br]
0391 ...         HTTP_STATUS_NOT_FOUND           404    The server has not found anything matching the requested URI.[br]
0392 ...         HTTP_STATUS_BAD_METHOD          405    The method used is not allowed.[br]
0393 ...         HTTP_STATUS_NONE_ACCEPTABLE     406    No responses acceptable to the client were found.[br]
0394 ...         HTTP_STATUS_PROXY_AUTH_REQ      407    Proxy authentication required.[br]
0395 ...         HTTP_STATUS_REQUEST_TIMEOUT     408    The server timed out waiting for the request.[br]
0396 ...         HTTP_STATUS_CONFLICT            409    The request could not be completed due to a conflict with the current state of the resource. The user should resubmit with more information.[br]
0397 ...         HTTP_STATUS_GONE                410    The requested resource is no longer available at the server, and no forwarding address is known.[br]
0398 ...         HTTP_STATUS_LENGTH_REQUIRED     411    The server refuses to accept the request without a defined content length.[br]
0399 ...         HTTP_STATUS_PRECOND_FAILED      412    The precondition given in one or more of the request header fields evaluated to false when it was tested on the server.[br]
0400 ...         HTTP_STATUS_REQUEST_TOO_LARGE   413    The server is refusing to process a request because the request entity is larger than the server is willing or able to process.[br]
0401 ...         HTTP_STATUS_URI_TOO_LONG        414    The server is refusing to service the request because the request URI is longer than the server is willing to interpret.[br]
0402 ...         HTTP_STATUS_UNSUPPORTED_MEDIA   415    The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.[br]
0403 ...         HTTP_STATUS_SERVER_ERROR        500    The server encountered an unexpected condition that prevented it from fulfilling the request.[br]
0404 ...         HTTP_STATUS_NOT_SUPPORTED       501    The server does not support the functionality required to fulfill the request.[br]
0405 ...         HTTP_STATUS_BAD_GATEWAY         502    The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.[br]
0406 ...         HTTP_STATUS_SERVICE_UNAVAIL     503    The service is temporarily overloaded.[br]
0407 ...         HTTP_STATUS_GATEWAY_TIMEOUT     504    The request was timed out waiting for a gateway.[br]
0408 ...         HTTP_STATUS_VERSION_NOT_SUP     505    The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.[br]
0409 ... 
0410 ...     *}
0411 ... 
0412 ...     {*assert
0413 ...         HTTP_IsURL( 'http://www.latosensu.be' ) === 200
0414 ...     *}
0415 ...     *}}
0416 ...  */
0417 ... /* ====================================================================== */
0418 ... function HTTP_IsURL( $szURL )
0419 ... /*-------------------------*/
0420 ... {
0421 ...     $iRetCode = -1;                                                 /* Default return value of the function */
0422 ... 
0423 ...     if ( $ch = curl_init( $szURL ) )                                /* cURL initialization / create cURL handle */
0424 ...     {
0425 ...         curl_setopt( $ch,CURLOPT_NOBODY,true );                     /* true = exclude body from output (request method set to HEAD) */
0426 ...         curl_exec( $ch );                                           /* Execute HTTP query */
0427 ...         $iRetCode = curl_getinfo( $ch,CURLINFO_HTTP_CODE );         /* Get return code */
0428 ... 
0429 ...         curl_close( $ch );                                          /* Close cURL handle */
0430 ...     }   /* if ( $ch = curl_init( $szURL ) ) */
0431 ... 
0432 ...     return ( $iRetCode );                                           /* Return result to caller */
0433 ... }   /* End of HTTP_IsURL() ============================================== */
0434 ... 
0435 ... /* ====================================================================== */
0436 ... /** {{*HTTP_EffectiveURL( $szURL )=
0437 ... 
0438 ...     Get effective URL of a URL (<strong>redirections considered</strong>)
0439 ... 
0440 ...     {*params
0441 ...         $szURL  (string)   the URL to access.
0442 ...     *}
0443 ... 
0444 ...     {*return
0445 ...         (string)            The effective URL corresponding to $szURL
0446 ...     *}
0447 ... 
0448 ...     {*assert
0449 ...         HTTP_EffectiveURL( 'http://www.latosensu.be' ) == 'http://www.latosensu.be'
0450 ...     *}
0451 ... 
0452 ...     {*example
0453 ...         echo HTTP_EffectiveURL( 'http://www.latosensu.be' );  // Outputs 'http://www.latosensu.be'
0454 ...     *}
0455 ...     *}}
0456 ...  */
0457 ... /* ====================================================================== */
0458 ... function HTTP_EffectiveURL( $szURL )
0459 ... /*--------------------------------*/
0460 ... {
0461 ...     $szRetVal = $szURL;                                             /* Default return value of the function */
0462 ... 
0463 ...     if ( $ch = curl_init( $szURL ) )                                /* cURL initialization / create cURL handle */
0464 ...     {
0465 ...         curl_setopt( $ch,CURLOPT_NOBODY,true );                     /* true = exclude body from output (request method set to HEAD) */
0466 ...         curl_exec( $ch );                                           /* Execute HTTP query */
0467 ...         $szRetVal = curl_getinfo( $ch,CURLINFO_EFFECTIVE_URL );     /* Get effective URL */
0468 ... 
0469 ...         curl_close( $ch );                                          /* Close cURL handle */
0470 ...     }   /* if ( $ch = curl_init( $szURL ) ) */
0471 ... 
0472 ...     return ( $szRetVal );                                           /* Return result to caller */
0473 ... }   /* End of HTTP_EffectiveURL() ======================================= */
0474 ... 
0475 ... /* ====================================================================== */
0476 ... /** {{*HTTP_SetTimeout( $iMilli )=
0477 ... 
0478 ...      Gets/Sets the timeout value used in HTTP functions.
0479 ... 
0480 ...     {*params
0481 ...         $iMilli (int)   the new timeout in milliseconds. This parameter is
0482 ...                         optional in which case the current value is returned.
0483 ...     *}
0484 ... 
0485 ...     {*remark
0486 ...         [c]HTTP_SetTimeout()[/c] implements the Set/Get paradigm
0487 ...     *}
0488 ... 
0489 ...     {*return
0490 ...         (int)            The old setting.
0491 ...     *}
0492 ... 
0493 ...     {*exec
0494 ...         $nMilli = HTTP_SetTimeout( 30000 );                 // Set new setting and save old setting
0495 ...         $szHTML = HTTP_GetURL( 'http://www.latosensu.be' ); // Get the content of a page now
0496 ... 
0497 ...         if ( STR_Empty( $szHTML ) )                         // If we got something
0498 ...         {
0499 ...             echo 'No response';                             // Warning
0500 ...         }
0501 ... 
0502 ...         echo LSUnitTesting::assert( HTTP_SetTimeout() === 30000                     ,
0503 ...                                     'ASSERTION SUCCESSFUL: Timeout set correctly'   ,
0504 ...                                     'ASSERTION FAILURE: invalid timeout'            ,
0505 ...                                     'GuideAssert' );
0506 ...         HTTP_SetTimeout( $nMilli );                         // Restore old setting
0507 ...     *}
0508 ...     *}}
0509 ...  */
0510 ... /* ====================================================================== */
0511 ... function HTTP_SetTimeout( $iMilli = null )
0512 ... /*--------------------------------------*/
0513 ... {
0514 ...     $iOldTimeout = $GLOBALS['iLSVTimeout'];
0515 ... 
0516 ...     if ( ! is_null( $iMilli ) )
0517 ...     {
0518 ...         $GLOBALS['iLSVTimeout'] = $iMilli;
0519 ...     }
0520 ... 
0521 ...     return ( $iOldTimeout );
0522 ... }   /* End of HTTP_SetTimeout() ========================================= */
0523 ... 
0524 ... /* ====================================================================== */
0525 ... /** {{*HTTP_SetUserAgent( $szUA )=
0526 ... 
0527 ...      Gets/Sets the User Agent value used in HTTP functions.
0528 ... 
0529 ...     {*params
0530 ...         $szUA   (string)    the new User Agent. This parameter is optional.
0531 ...     *}
0532 ... 
0533 ...     {*alias
0534 ...         HTTP_SetAgent(), HTTP_SetUA()
0535 ...     *}
0536 ... 
0537 ...     {*remark
0538 ...         HTTP_SetUserAgent() implements the Set/Get paradigm
0539 ...     *}
0540 ... 
0541 ...     {*return
0542 ...         (string)            the old setting.
0543 ...     *}
0544 ... 
0545 ...     {*exec
0546 ...         $szUA   = HTTP_SetUserAgent( 'MyOwnBot' );          // Set new setting and save old setting
0547 ...         $szHTML = HTTP_GetURL( 'http://www.latosensu.be' ); // Get the content of a page using the User Agent specified earlier
0548 ... 
0549 ...         if ( STR_Empty( $szHTML ) )                         // If we got something
0550 ...         {
0551 ...             echo 'No response';                             // Warning
0552 ...         }
0553 ... 
0554 ...         echo LSUnitTesting::assert( HTTP_SetUserAgent() === 'MyOwnBot'      ,
0555 ...                                     'ASSERTION SUCCESSFUL: UA set correctly',
0556 ...                                     'ASSERTION FAILURE: invalid UA'         ,
0557 ...                                     'GuideAssert' );
0558 ... 
0559 ...         HTTP_SetUserAgent( $szUA );                         // Restore old setting
0560 ...     *}
0561 ...     *}}
0562 ...  */
0563 ... /* ====================================================================== */
0564 ... function HTTP_SetUserAgent( $szUA = null )
0565 ... /*--------------------------------------*/
0566 ... {
0567 ...     $szOldUA = $GLOBALS['szLSVUserAgent'];
0568 ... 
0569 ...     if ( ! is_null( $szUA ) )
0570 ...     {
0571 ...         $GLOBALS['szLSVUserAgent'] = $szUA;
0572 ...     }
0573 ... 
0574 ...     return ( $szOldUA );
0575 ... }   /* End of HTTP_SetUserAgent() *************************************** */
0576 ... function HTTP_SetAgent( $szUA ) { return ( HTTP_SetUserAgent( $szUA ) ); }
0577 ... function HTTP_SetUA( $szUA    ) { return ( HTTP_SetUserAgent( $szUA ) ); }
0578 ... /* ====================================================================== */
0579 ... 
0580 ... function HTTP_IsDomain( $szDomain )
0581 ... /*-------------------------------*/
0582 ... {
0583 ...     // Aussi voir http://php.net/manual/en/book.curl.php qui semble avoir un exemple
0584 ...     // de vérification de domaine
0585 ...     $aURL = URL_parse( $szDomain );
0586 ...     var_dump( $aURL );
0587 ... 
0588 ... // *-* function domain_check($domain) {
0589 ... // *-*
0590 ... // *-* $data = 'http://'.$domain;
0591 ... // *-*
0592 ... // *-* // Create a curl handle to a non-existing location
0593 ... // *-* $ch = curl_init($data);
0594 ... // *-*
0595 ... // *-* // Execute
0596 ... // *-* curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
0597 ... // *-* curl_exec($ch);
0598 ... // *-*
0599 ... // *-* // Check if any error occured
0600 ... // *-* if(curl_errno($ch))
0601 ... // *-*  {
0602 ... // *-*      return '<span style="color:#22c922">The domain is available!</span>';
0603 ... // *-*  } else {
0604 ... // *-*      return '<span style="color:#c92222">The domain is not available</span>';
0605 ... // *-*  }
0606 ... // *-*
0607 ... // *-* // Close handle
0608 ... // *-* curl_close($ch);
0609 ... // *-*  }
0610 ... 
0611 ... }
0612 ... 
0613 ... /* ====================================================================== */
0614 ... /** {{*HTTP_WhoIs( $szURL )=
0615 ... 
0616 ...      Returns WHO IS information about the $szURL
0617 ... 
0618 ...     {*params
0619 ...         $szURL      (string)    The URL for which "Who Is" info is to be returned
0620 ...     *}
0621 ... 
0622 ...     {*caution
0623 ...         Experimental function. Do not use in a production environment!
0624 ...     *}
0625 ... 
0626 ...     {*return
0627 ...         (string)    the WHO IS info
0628 ...     *}
0629 ... 
0630 ...     {*exec
0631 ...         echo $szWhoIs = HTTP_WhoIs( "http://www.vaesoli.org" );
0632 ... 
0633 ... 
0634 ...         echo LSUnitTesting::assert( stristr( $szWhoIs,'Registrant Name: Patrick Boens' ) != false   ,
0635 ...                                     'ASSERTION SUCCESSFUL: WHOIS seems to be correct'               ,
0636 ...                                     'ASSERTION FAILURE: invalid WHOIS'                              ,
0637 ...                                     'GuideAssert' );
0638 ...     *}
0639 ... 
0640 ...     *}}
0641 ...  */
0642 ... /* ====================================================================== */
0643 ... function HTTP_WhoIs( $szURL )
0644 ... /*-------------------------*/
0645 ... {
0646 ...     $szRetVal   = '';                                               /* Default return value of the function */
0647 ...     $aURL       = URL_Parse( $szURL );                              /* Imagine that URL is http://www.latosensu.be/articles:core/pm/steering.php */
0648 ... 
0649 ...     //echo "<p>" . __METHOD__ . " at line " . __LINE__ . ": URL to whois = '{$szURL}'</p>\n";
0650 ... 
0651 ...     if ( ! STR_Empty( $aURL['domain'] ) )                           /* This should now be something like 'www.latosensu.be' */
0652 ...     {
0653 ...         //var_dump( $aURL );
0654 ...         //echo "<p>" . __METHOD__ . " at line " . __LINE__ . ": domain of '{$szURL}' is '{$aURL['domain']}'</p>\n";
0655 ... 
0656 ...         $aURL = URL_ParseDomain( $aURL['domain'] );                 /* Parse domain */
0657 ... 
0658 ... 
0659 ...         // Autres stratégies de whois
0660 ...         //  - whois.dns.be
0661 ...         //  - http://www.whois.net/whois/fastwrite.com (domaine est ajouté à l'URL)
0662 ... 
0663 ... 
0664 ... 
0665 ...         if ( isset( $aURL['domain'] ) && isset( $aURL['tld'] ) )    /* If domain and TLD found ('latosensu' and 'be') */
0666 ...         {
0667 ...             $szMainDomain   = $aURL['domain'] . '.'. $aURL['tld'];  /* szMainDomain is now 'latosensu.be' */
0668 ...             //echo "<p>" . __METHOD__ . " at line " . __LINE__ . ": Main domain of '{$szURL}' is '{$szMainDomain}'</p>\n";
0669 ...             $szQueryURL     = "https://www.gandi.net/whois/details?search={$szMainDomain}";
0670 ...             //echo "<p>" . __METHOD__ . " at line " . __LINE__ . ": Whois URL is '{$szQueryURL}'</p>\n";
0671 ... 
0672 ...             $ch = curl_init();
0673 ...             curl_setopt( $ch,CURLOPT_URL            ,$szQueryURL                );  // set the url to fetch (une des URLS de serveur whois)
0674 ...             curl_setopt( $ch,CURLOPT_HEADER         , 0                         );  // set headers (0 = no headers in result)
0675 ...             curl_setopt( $ch,CURLOPT_RETURNTRANSFER , 1                         );  // type of transfer (1 = to string)
0676 ...             curl_setopt( $ch,CURLOPT_TIMEOUT        , 10                        );  // time to wait in seconds
0677 ...             curl_setopt( $ch,CURLOPT_USERAGENT      ,$GLOBALS['szLSVUserAgent'] );
0678 ...             curl_setopt( $ch,CURLOPT_HTTPAUTH       , CURLAUTH_ANY              );
0679 ...             curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER ,false                      );
0680 ...             curl_setopt( $ch,CURLOPT_SSL_VERIFYHOST ,false                      );
0681 ... 
0682 ...             $szHTML = curl_exec( $ch );                             /* Make the call now */
0683 ... 
0684 ...             curl_close( $ch );                                      /* Close cURL handle */
0685 ... 
0686 ...             $szCharset = '';                                        /* The charset of the return */
0687 ... 
0688 ...             if ( ! STR_Empty( $szHTML ) )                           /* If we got something */
0689 ...             {
0690 ...                 //echo "<p>" . __METHOD__ . " at line " . __LINE__ . ": We have received some HTML back from the whois server'</p>\n";
0691 ...                 if ( preg_match( '%<meta +http-equiv=["\']content-type["\'] +content=["\'](.+?)["\'].*?>|' .
0692 ...                                   '<meta +content=["\'](.+?)["\'] +http-equiv=["\']content-type["\'].*?>%si',$szHTML,$aMatch ) )
0693 ...                 {
0694 ...                     $szCharset = $aMatch[1];
0695 ... 
0696 ...                     if ( preg_match( '/utf-8/si',$szCharset ) )
0697 ...                     {
0698 ...                         $szHTML = utf8_decode( $szHTML );
0699 ... 
0700 ...                         //echo $szHTML;
0701 ...                         //echo htmlentities( $szHTML );
0702 ... 
0703 ...                         if ( preg_match( '/Your IP has been restricted due to excessive access/si',$szHTML ) )
0704 ...                         {
0705 ...                             $szRetVal = (string) RET_CODE_UNAUTHORIZED;
0706 ...                         }
0707 ...                         elseif ( preg_match( '/<pre>(.*?)<\/pre>/si',$szHTML,$aMatch ) )
0708 ...                         {
0709 ...                             $szRetVal = $aMatch[1];
0710 ...                         }
0711 ...                         elseif ( preg_match( '/<h1>Ce domaine est disponible !<\/h1>/si',$szHTML ) )
0712 ...                         {
0713 ...                             $szRetVal = (string) RET_CODE_NOT_FOUND;
0714 ...                         }
0715 ...                         else
0716 ...                         {
0717 ...                             $szRetVal = (string) RET_CODE_NO_CONTENT;
0718 ...                             //echo $szHTML;
0719 ...                         }
0720 ...                     }
0721 ...                 }   /* if ( preg_match( '%<meta +http-equiv="content-type" ...  */
0722 ...             }
0723 ...         }
0724 ...     }
0725 ... 
0726 ...     // Whois servers : voir aussi les fonctions WHOIS de FOCUS.FLL
0727 ...     // "whois.verisign-grs.com";
0728 ...     // "http://www.whois.net/whois/hotmail.com" où le hotmail.com semble être le domaine à vérifier
0729 ... 
0730 ...     return ( $szRetVal );                                           /* Return result to caller */
0731 ... }
0732 ... ?>

Manifest Constants

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

RET_CODES: Defines whether return codes are defined or not

RET_CODE_OK: 200

RET_CODE_CREATED: 201

RET_CODE_ACCEPTED: 202

RET_CODE_NON_AUTHORITATIVE: 203

RET_CODE_NO_CONTENT: 204

RET_CODE_RESET_CONTENT: 205

RET_CODE_PARTIAL_CONTENT: 206

RET_CODE_MULTIPLE_CHOICES: 300

RET_CODE_MOVED_PERMANENTLY: 301

RET_CODE_FOUND: 302

RET_CODE_SEE_OTHER: 303

RET_CODE_NOT_MODIFIED: 304

RET_CODE_USE_PROXY: 305

RET_CODE_RESERVED: 306

RET_CODE_TEMPORARY_REDIRECT: 307

RET_CODE_BAD_REQUEST: 400

RET_CODE_UNAUTHORIZED: 401

RET_CODE_PAYMENT_REQUIRED: 402

RET_CODE_FORBIDDEN: 403

RET_CODE_NOT_FOUND: 404

RET_CODE_METHOD_NOT_ALLOWED: 405

RET_CODE_NOT_ACCEPTABLE: 406

RET_CODE_PROXY_AUTHENTIFICATION_REQUIRED: 407

RET_CODE_REQUEST_TIMEOUT: 408

RET_CODE_CONFLICT: 409

RET_CODE_GONE: 410

RET_CODE_LENGTH_REQUIRED: 411

RET_CODE_PRECONDITION_FAILED: 412

RET_CODE_REQUEST_ENTITY_TOO_LARGE: 413

RET_CODE_REQUEST_URI_TOO_LONG: 414

RET_CODE_UNSUPPORTED_MEDIA_TYPE: 415

RET_CODE_REQUESTED_RANGE_NOT_SATISFIABLE: 416

RET_CODE_EXPECTATION_FAILED: 417

RET_CODE_INTERNAL_SERVER_ERROR: 500

RET_CODE_NOT_IMPLEMENTED: 501

RET_CODE_BAD_GATEWAY: 502

RET_CODE_SERVICE_UNAVAILABLE: 503

RET_CODE_GATEWAY_TIMEOUT: 504

RET_CODE_HTTP_VERSION_NOT_SUPPORTED: 505

UltraEdit Syntax files

  1. UltraEdit keywords of LSHttp.functions.php
  2. UltraEdit Syntax of LSHttp.functions.php

Function List (TOC)

  1. HTTP_CanConnect(): Determines if we can connect to a given URL.
  2. HTTP_EffectiveURL(): Get effective URL of a URL (redirections considered)
  3. HTTP_GetURL(): Retrieves URL as a string (uppercase and lowercase) into their respective equivalents
  4. HTTP_IsURL(): Returns status information about a URL
  5. HTTP_SetTimeout(): Gets/Sets the timeout value used in HTTP functions.
  6. HTTP_SetUserAgent(): Gets/Sets the User Agent value used in HTTP functions.
  7. HTTP_WhoIs(): Returns WHO IS information about the $szURL

Functions of LSHttp.functions.php

HTTP_CanConnect(): Determines if we can connect to a given URL.

[ back to function list ]

Syntax

HTTP_CanConnect( $szURL )

Parameters
NameTypeDescription
$szURL string Optional URL to access. 'http://www.google.com' by default
Return

(bool) true if $szURL could be contacted; false if not.

Assertions

HTTP_CanConnect( 'http://www.google.com' ) === true successful

HTTP_CanConnect() === true successful

HTTP_CanConnect( 'noexist' ) === false successful

HTTP_CanConnect( 'http://this-domain-does-not-exist.tl' ) === false successful

Unit Testing

4 assertions: 4 successful; 0 failed

HTTP_EffectiveURL(): Get effective URL of a URL (redirections considered)

[ back to function list ]

Syntax

HTTP_EffectiveURL( $szURL )

Parameters
NameTypeDescription
$szURL string the URL to access.
Return

(string) The effective URL corresponding to $szURL

Example(s)
echo HTTP_EffectiveURL( 'http://www.latosensu.be' );  // Outputs 'http://www.latosensu.be'
Assertions

HTTP_EffectiveURL( 'http://www.latosensu.be' ) == 'http://www.latosensu.be' successful

Unit Testing

1 assertions: 1 successful; 0 failed

HTTP_GetURL(): Retrieves URL as a string (uppercase and lowercase) into their respective equivalents

[ back to function list ]

Warning

This set of functions is designed to be internals of Vae Soli! at this stage (09-03-15 10:50:16). Do not use these functions or use them at your own risk.
Consider the use of HTTP_SetTimeout()

Remark

Proxies and firewalls are not supported for the time being. HTTP_GetURL() features a server timeout of 60 seconds: if the server does not respond within 60 seconds, the request is aborted. The same applies when the server does not send any more information within the same period.

Syntax

HTTP_GetURL( $szURL,$szUser,$szPwd,$iErrCode,$aOptions,$szHeader,$iSecs )

Parameters
NameTypeDescription
$szURL string URL to access.
$szUser string User account. Optional. null by default.
$szPwd string User password. Optional. null by default.
$iErrCode int Optional return code. Updated upon exit. 0 by default.
$aOptions array Optional array of CURL options. Not used so far (1/05/2013 14:50:32). null by default.
$szHeader string Optional header that we got back. null by default. Updated upon return.
$iSecs int Optional. The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. By default, this value is set to 5.
Parameters Warning

HTTP_GetURL() uses 7 parameters whereas the suggested limit is 3.

Return

(string) The resource identified by $szURL as a string

Example(s)
echo HTTP_GetURL( 'http://www.latosensu.be' );  // Outputs the homepage of Lato Sensu Management
Assertions

strstr( HTTP_GetURL( 'http://www.google.com' ),'google.com' ) != false successful

Unit Testing

1 assertions: 1 successful; 0 failed

HTTP_IsURL(): Returns status information about a URL

[ back to function list ]

Syntax

HTTP_IsURL( $szURL )

Parameters
NameTypeDescription
$szURL string the URL to access.
Return

(int) The return code HTTP Status Codes
Constant Value Description
HTTP_STATUS_OK 200 The request completed successfully.
HTTP_STATUS_CREATED 201 The request has been fulfilled and resulted in the creation of a new resource.
HTTP_STATUS_ACCEPTED 202 The request has been accepted for processing , but the processing has not been completed.
HTTP_STATUS_PARTIAL 203 The returned meta information in the entity-header is not the definitive set available from the origin server.
HTTP_STATUS_NO_CONTENT 204 The server has fulfilled the request, but there is no new information to send back.
HTTP_STATUS_RESET_CONTENT 205 The request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action.
HTTP_STATUS_PARTIAL_CONTENT 206 The server has fulfilled the partial GET request for the resource.
HTTP_STATUS_AMBIGUOUS 300 The server couldn't decide what to return.
HTTP_STATUS_MOVED 301 The requested resource has been assigned to a new permanent URI, and any future references to this resource should be done using one of the returned URIs.
HTTP_STATUS_REDIRECT 302 The requested resource resides temporarily under a different URI.
HTTP_STATUS_REDIRECT_METHOD 303 The response to the request can be found under a different URI and should be retrieved using a GET method on that resource.
HTTP_STATUS_NOT_MODIFIED 304 The requested resource has not been modified.
HTTP_STATUS_USE_PROXY 305 The requested resource must be accessed through the proxy given by the location field.
HTTP_STATUS_REDIRECT_KEEP_VERB 307 The redirected request keeps the same verb. HTTP/1.1 behavior.
HTTP_STATUS_BAD_REQUEST 400 The request could not be processed by the server due to invalid syntax.
HTTP_STATUS_DENIED 401 The requested resource requires user authentication.
HTTP_STATUS_PAYMENT_REQ 402 Not currently implemented in the HTTP protocol.
HTTP_STATUS_FORBIDDEN 403 The server understood the request, but is refusing to fulfill it.
HTTP_STATUS_NOT_FOUND 404 The server has not found anything matching the requested URI.
HTTP_STATUS_BAD_METHOD 405 The method used is not allowed.
HTTP_STATUS_NONE_ACCEPTABLE 406 No responses acceptable to the client were found.
HTTP_STATUS_PROXY_AUTH_REQ 407 Proxy authentication required.
HTTP_STATUS_REQUEST_TIMEOUT 408 The server timed out waiting for the request.
HTTP_STATUS_CONFLICT 409 The request could not be completed due to a conflict with the current state of the resource. The user should resubmit with more information.
HTTP_STATUS_GONE 410 The requested resource is no longer available at the server, and no forwarding address is known.
HTTP_STATUS_LENGTH_REQUIRED 411 The server refuses to accept the request without a defined content length.
HTTP_STATUS_PRECOND_FAILED 412 The precondition given in one or more of the request header fields evaluated to false when it was tested on the server.
HTTP_STATUS_REQUEST_TOO_LARGE 413 The server is refusing to process a request because the request entity is larger than the server is willing or able to process.
HTTP_STATUS_URI_TOO_LONG 414 The server is refusing to service the request because the request URI is longer than the server is willing to interpret.
HTTP_STATUS_UNSUPPORTED_MEDIA 415 The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
HTTP_STATUS_SERVER_ERROR 500 The server encountered an unexpected condition that prevented it from fulfilling the request.
HTTP_STATUS_NOT_SUPPORTED 501 The server does not support the functionality required to fulfill the request.
HTTP_STATUS_BAD_GATEWAY 502 The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
HTTP_STATUS_SERVICE_UNAVAIL 503 The service is temporarily overloaded.
HTTP_STATUS_GATEWAY_TIMEOUT 504 The request was timed out waiting for a gateway.
HTTP_STATUS_VERSION_NOT_SUP 505 The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.

Assertions

HTTP_IsURL( 'http://www.latosensu.be' ) === 200 successful

Unit Testing

1 assertions: 1 successful; 0 failed

HTTP_SetTimeout(): Gets/Sets the timeout value used in HTTP functions.

[ back to function list ]

Remark

HTTP_SetTimeout() implements the Set/Get paradigm

Syntax

HTTP_SetTimeout( $iMilli )

Parameters
NameTypeDescription
$iMilli int the new timeout in milliseconds. This parameter is optional in which case the current value is returned.
Return

(int) The old setting.

Example Executed
$nMilli = HTTP_SetTimeout( 30000 );                 // Set new setting and save old setting
$szHTML = HTTP_GetURL( 'http://www.latosensu.be' ); // Get the content of a page now

if ( STR_Empty( $szHTML ) )                         // If we got something
{
    echo 'No response';                             // Warning
}

echo LSUnitTesting::assert( HTTP_SetTimeout() === 30000                     ,
                            'ASSERTION SUCCESSFUL: Timeout set correctly'   ,
                            'ASSERTION FAILURE: invalid timeout'            ,
                            'GuideAssert' );
HTTP_SetTimeout( $nMilli );                         // Restore old setting

GuideAssert() ... ASSERTION SUCCESSFUL: Timeout set correctly

Unit Testing

1 assertions: 1 successful; 0 failed

HTTP_SetUserAgent(): Gets/Sets the User Agent value used in HTTP functions.

[ back to function list ]

Remark

HTTP_SetUserAgent() implements the Set/Get paradigm

Syntax

HTTP_SetUserAgent( $szUA )

Alias

HTTP_SetAgent(), HTTP_SetUA()

Parameters
NameTypeDescription
$szUA string the new User Agent. This parameter is optional.
Return

(string) the old setting.

Example Executed
$szUA   = HTTP_SetUserAgent( 'MyOwnBot' );          // Set new setting and save old setting
$szHTML = HTTP_GetURL( 'http://www.latosensu.be' ); // Get the content of a page using the User Agent specified earlier

if ( STR_Empty( $szHTML ) )                         // If we got something
{
    echo 'No response';                             // Warning
}

echo LSUnitTesting::assert( HTTP_SetUserAgent() === 'MyOwnBot'      ,
                            'ASSERTION SUCCESSFUL: UA set correctly',
                            'ASSERTION FAILURE: invalid UA'         ,
                            'GuideAssert' );

HTTP_SetUserAgent( $szUA );                         // Restore old setting

GuideAssert() ... ASSERTION SUCCESSFUL: UA set correctly

Unit Testing

1 assertions: 1 successful; 0 failed

HTTP_WhoIs(): Returns WHO IS information about the $szURL

[ back to function list ]

Caution

Experimental function. Do not use in a production environment!

Syntax

HTTP_WhoIs( $szURL )

Parameters
NameTypeDescription
$szURL string The URL for which "Who Is" info is to be returned
Return

(string) the WHO IS info

Example Executed
echo $szWhoIs = HTTP_WhoIs( "http://www.vaesoli.org" );


echo LSUnitTesting::assert( stristr( $szWhoIs,'Registrant Name: Patrick Boens' ) != false   ,
                            'ASSERTION SUCCESSFUL: WHOIS seems to be correct'               ,
                            'ASSERTION FAILURE: invalid WHOIS'                              ,
                            'GuideAssert' );

Domain Name: vaesoli.org
Registry Domain ID: D98382021-LROR
Registrar WHOIS Server: whois.gandi.net
Registrar URL: http://www.gandi.net
Updated Date: 2014-12-22T18:00:49Z
Creation Date: 2003-07-13T17:18:46Z
Registrar Registration Expiration Date: 2015-07-13T17:18:46Z
Registrar: GANDI SAS
Registrar IANA ID: 81
Registrar Abuse Contact Email: abuse@support.gandi.net
Registrar Abuse Contact Phone: +33.170377661
Reseller: FastWrite
Domain Status: clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited
Domain Status: 
Domain Status: 
Domain Status: 
Domain Status: 
Registry Registrant ID: 0-1363763-GANDI
Registrant Name: Patrick Boens
Registrant Organization: FastWrite
Registrant Street: Rue A. Bracke, 9
Registrant City: Kraainem
Registrant State/Province: 
Registrant Postal Code: 1950
Registrant Country: BE
Registrant Phone: +32.3227208228
Registrant Phone Ext:
Registrant Fax: 
Registrant Fax Ext:
Registrant Email: c0da36f83fa06b787926bbd1b747f7d6-900652@contact.gandi.net
Registry Admin ID: PB7257-GANDI
Admin Name: Patrick Boens
Admin Organization: Lato Sensu Management
Admin Street: Rue Bois des Mazuis, 47
Admin City: Vitrival
Admin State/Province: 
Admin Postal Code: 5070
Admin Country: BE
Admin Phone: +32.71711743
Admin Phone Ext:
Admin Fax: 
Admin Fax Ext:
Admin Email: 7e539fb482aeefed00bd76b82f765cc9-1361549@contact.gandi.net
Registry Tech ID: PB7257-GANDI
Tech Name: Patrick Boens
Tech Organization: Lato Sensu Management
Tech Street: Rue Bois des Mazuis, 47
Tech City: Vitrival
Tech State/Province: 
Tech Postal Code: 5070
Tech Country: BE
Tech Phone: +32.71711743
Tech Phone Ext:
Tech Fax: 
Tech Fax Ext:
Tech Email: 7e539fb482aeefed00bd76b82f765cc9-1361549@contact.gandi.net
Name Server: A.DNS.GANDI.NET
Name Server: B.DNS.GANDI.NET
Name Server: C.DNS.GANDI.NET
Name Server: 
Name Server: 
Name Server: 
Name Server: 
Name Server: 
Name Server: 
Name Server: 
DNSSEC: Unsigned
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
>>> Last update of WHOIS database: 2015-04-01T16:19:57Z <<<

For more information on Whois status codes, please visit
https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en

Reseller Email: 
Reseller URL: 

GuideAssert() ... ASSERTION SUCCESSFUL: WHOIS seems to be correct

Unit Testing

1 assertions: 1 successful; 0 failed

Précédent Suivant