Niouzes

< Décembre 2018 >
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.

2018-12-06 à 02:12:30

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) (06/12/2018)
  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)

LSUrl.functions.php

Generated by The Vae Soli! Documentor: Guide v. 1.3.0018 on 01-04-2015 16:19:56 (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/LSUrl.functions.phpC:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSUrl.functions.phpapplication/force-downloadC:\websites\vaesoli.org\www\httpdocs\vaesoli\include18803 bytes03/08/2013 23:27:5324/07/2014 17:16:1324/07/2014 17:16:13

Compliance

Assertions count: 15

Assertions successful: 13

Assertion failures: 2

0001 ... <?php
0002 ... /**************************************************************************/
0003 ... /** {{{*fheader
0004 ...     {*file                  LSUrl.functions.php *}
0005 ...     {*purpose               URL 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 ...                             http://www.latosensu.be[br]
0012 ...                             Vae Soli! : http://www.vaesoli.org *}
0013 ...     {*cdate                 03/11/2006 - 18:26 *}
0014 ...     {*mdate                 auto *}
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 : 
0031 ...                             vaesoli-5.0.0002.zip *}
0032 ...     *}
0033 ... 
0034 ...     {*chist
0035 ...         {*mdate 02/07/2012 *}
0036 ...         {*v 5.4.0010 *}
0037 ...         {*desc              1)  URL_URItoRoot(): new function
0038 ...         *}
0039 ...     *}
0040 ... 
0041 ... 
0042 ...     *}}} */
0043 ... /**************************************************************************/
0044 ... if ( ! defined( 'VAESOLI_PATH' ) )                                  /* If the path is not defined yet */
0045 ... {
0046 ...     /* {*define (VAESOLI_PATH)  Define the path where Vae Soli! is installed *} */
0047 ...     define( 'VAESOLI_PATH',__DIR__ );
0048 ... }   /* if ( ! defined( 'VAESOLI_PATH' ) ) */
0049 ... 
0050 ... if ( ! defined( 'VAESOLI_PLUGINS' ) )                               /* If the path is not defined yet */
0051 ... {
0052 ...     /* {*define (VAESOLI_PLUGINS)  Define the path where plugins are located *} */
0053 ...     define( 'VAESOLI_PLUGINS',VAESOLI_PATH . '/../plugins' );
0054 ... }   /* if ( ! defined( 'VAESOLI_PLUGINS' ) ) */
0055 ... 
0056 ... if ( ! defined( 'LS_URL' ) )                                        /* If PWH var not defined yet */
0057 ... {
0058 ...     /* {*define (LS_URL)  Remember that THESE functions have been declared *} */
0059 ...     define( 'LS_URL',__DIR__ );
0060 ... }   /* if ( ! defined( 'LS_URL' ) ) */
0061 ... 
0062 ... function URL_IsValid( $szURL )
0063 ... /*--------------------------*/
0064 ... {
0065 ...     return ( filter_var( $szURL,FILTER_VALIDATE_URL,FILTER_FLAG_PATH_REQUIRED ) === false ? false : true );
0066 ... }
0067 ... 
0068 ... /* ========================================================================== */
0069 ... /** {{*URL_QueryString()=
0070 ... 
0071 ...     Determines the query string passed in the url
0072 ... 
0073 ...     {*params
0074 ...     *}
0075 ... 
0076 ...     {*return
0077 ...         (string)    a [c]"<key>=<value>&amp;<key>=<value>"[/c] string
0078 ...     *}
0079 ... 
0080 ...     {*alias
0081 ...         GetQueryString()
0082 ...     *}
0083 ... 
0084 ...     {*warning
0085 ...         Not quite identical to [c]$_SERVER['QUERY_STRING'][/c]
0086 ...     *}
0087 ... 
0088 ...     {*example
0089 ...         // If current page is http://www.latosensu.be?lang=fr&theme=summer
0090 ...         echo URL_QueryString(); // Prints 'lang=fr&amp;theme=summer'
0091 ...     *}
0092 ...     *}}
0093 ...  */
0094 ... /* ========================================================================== */
0095 ... function URL_QueryString()
0096 ... /*----------------------*/
0097 ... {
0098 ...     $szRetVal = '';
0099 ...     $sep      = '&amp;';
0100 ... 
0101 ...     foreach ( $_GET as $key => $val )
0102 ...     {
0103 ...         $szRetVal .= "$key=$val$sep";
0104 ...     }   /* foreach ( $_GET as $key => $val ) */
0105 ... 
0106 ...     if ( ! empty( $szRetVal ) )
0107 ...     {
0108 ...         $szRetVal = substr( $szRetVal,0,strlen( $szRetVal ) - strlen( $sep ) );
0109 ...     }   /* if ( ! empty( $szRetVal ) ) */
0110 ... 
0111 ...     return ( $szRetVal );
0112 ... }   /* End of function URL_QueryString() ==================================== */
0113 ... function GetQueryString() { return ( URL_QueryString() ); }
0114 ... 
0115 ... /* ========================================================================== */
0116 ... /** {{*URL_Parse( $szURL,$szPart )=
0117 ... 
0118 ...     Parses a URL into its respective protocol, domain and path
0119 ... 
0120 ...     {*params
0121 ...         $szURL  (string)    The URL to parse
0122 ...         $szPart (string)    Part to receive. Optional. Can be [c]'protocol'[/c], [c]'domain'[/c] or [c]'path'[/c].
0123 ...     *}
0124 ... 
0125 ...     {*return
0126 ...         (mixed)     Associative array with the following keys:[br]
0127 ...                     - [c]protocol[/c][br]
0128 ...                     - [c]domain[/c][br]
0129 ...                     - [c]path[/c][br]
0130 ...                     If $szPart passed and 'protocol', 'domain' or 'path' the return value is a string
0131 ...     *}
0132 ... 
0133 ...     {*assert
0134 ...         URL_Parse( 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3','protocol' ) == 'http'
0135 ...     *}
0136 ... 
0137 ...     {*assert
0138 ...         URL_Parse( 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3','domain' ) == 'www.vaesoli.org'
0139 ...     *}
0140 ... 
0141 ...     {*assert
0142 ...         URL_Parse( 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3','path' ) == '/documentation/documentation-vaesoli-code-source.php'
0143 ...     *}
0144 ... 
0145 ...     {*assert
0146 ...         URL_Parse( 'http://api.soccer.openlabels.net/source.php?page=3','path' ) == array( 'api','soccer' )
0147 ...     *}
0148 ... 
0149 ... 
0150 ...     {*example
0151 ...         $szURL  = 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3';
0152 ...         $aURL   = URL_Parse( $szURL );
0153 ...         echo $aURL['protocol'];     // Prints 'http'
0154 ...         echo $aURL['domain'];       // Prints 'www.vaesoli.org'
0155 ...         echo $aURL['path'];         // documentation/documentation-vaesoli-code-source.php'
0156 ...     *}
0157 ...     *}}
0158 ...  */
0159 ... /* ========================================================================== */
0160 ... function URL_Parse( $szURL = null,$szPart = null )
0161 ... /*----------------------------------------------*/
0162 ... {
0163 ...     $aURL               = array();
0164 ... 
0165 ...     $aURL['path']       =
0166 ...     $aURL['domain']     =
0167 ...     $aURL['protocol']   = '';
0168 ...     $aURL['subdomains'] = array();
0169 ... 
0170 ...     if ( ! STR_Empty( $szURL ) && preg_match( '/\b((?P<protocol>https?|ftp):\/\/)?(?P<domain>[-A-Z0-9.]+)(?P<path>\/[-A-Z0-9+&@#\/%=~_|!:,.;]*)?/i',$szURL,$aMatch ) )
0171 ...     {
0172 ...         $aURL['protocol']   = isset( $aMatch['protocol'] ) ? $aMatch['protocol'] : '';
0173 ...         $aURL['domain']     = isset( $aMatch['domain']   ) ? $aMatch['domain']   : '';
0174 ...         $aURL['path']       = isset( $aMatch['path']     ) ? $aMatch['path']     : '';
0175 ... 
0176 ...         $iSubDomains = count( $aDomains = explode( '.',$aURL['domain'] ) );
0177 ... 
0178 ...         for ( $i = 0;$i < $iSubDomains - 2;$i++ )
0179 ...         {
0180 ...             $aURL['subdomains'][] = $aDomains[$i];
0181 ...         }   /* for ( $i = 0;$i < $iSubDomains - 3;$i++ ) */
0182 ...     }   /* if ( preg_match( ...,$szURL,$aMatch ) ) */
0183 ... 
0184 ...     if ( ! is_null( $szPart ) && isset( $aURL[$szPart] ) )
0185 ...     {
0186 ...         return ( $aURL[$szPart] );
0187 ...     }
0188 ...     else
0189 ...     {
0190 ...         return ( $aURL );
0191 ...     }
0192 ... }   /* End of function URL_Parse() ========================================== */
0193 ... 
0194 ... /* ========================================================================== */
0195 ... /** {{*URL_ParseDomain( $szDomain,$szPart )=
0196 ... 
0197 ...     Parses a domain
0198 ... 
0199 ...     {*params
0200 ...         $szDomain   (string)    Domain to parse
0201 ...         $szPart     (string)    Optional. Part to receive.
0202 ...                                 Can be:[br]
0203 ...                                 - [c]'tld'[/c][br]
0204 ...                                 - [c]'domain'[/c][br]
0205 ...                                 - [c]'subdomain'[/c][br]
0206 ...     *}
0207 ... 
0208 ...     {*return
0209 ...         (mixed)     Associative array with the following keys:[br]
0210 ...                         - [c]tld[/c][br]
0211 ...                         - [c]domain[/c][br]
0212 ...                         - [c]subdomain[/c][br]
0213 ...                     If $szPart passed ([c]'tld'[/c], [c]'domain'[/c] or [c]'subdomain'[/c]) the return value is a string
0214 ...     *}
0215 ... 
0216 ...     {*assert
0217 ...         URL_ParseDomain( 'www.vaesoli.org','subdomain' ) == 'www'
0218 ...     *}
0219 ... 
0220 ...     {*assert
0221 ...         URL_ParseDomain( 'www.vaesoli.org','domain'    ) == 'vaesoli'
0222 ...     *}
0223 ... 
0224 ...     {*assert
0225 ...         URL_ParseDomain( 'www.vaesoli.org','tld'       ) == 'org'
0226 ...     *}
0227 ... 
0228 ...     {*example
0229 ...         $szURL      = 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3';
0230 ...         $szDomain   = URL_Parse( $szURL,'domain' );
0231 ...         echo $szDomain;                                 // Prints 'www.vaesoli.org'
0232 ...         echo URL_ParseDomain( $szDomain,'subdomain' );  // Prints 'www'
0233 ...         echo URL_ParseDomain( $szDomain,'domain'    );  // Prints 'vaesoli'
0234 ...         echo URL_ParseDomain( $szDomain,'tld'       );  // Prints 'org'
0235 ...     *}
0236 ... 
0237 ...     {*exec
0238 ...         $szDomain = "ui.tl";
0239 ...         $aParts   = URL_ParseDomain( $szDomain );
0240 ...         var_dump( $aParts );
0241 ...     *}
0242 ...     *}}
0243 ...  */
0244 ... /* ========================================================================== */
0245 ... function URL_ParseDomain( $szDomain,$szPart = null )
0246 ... /*------------------------------------------------*/
0247 ... {
0248 ...     $aURL               = array();
0249 ... 
0250 ...     $aURL['tld']        =
0251 ...     $aURL['domain']     =
0252 ...     $aURL['subdomain']  = '';
0253 ... 
0254 ...     if ( preg_match( '/(?P<subdomain>[[:alnum:]]+?\.)?(?P<domain>.+?)\.(?P<tld>.{2,})/i',$szDomain,$aMatch ) )
0255 ...     {
0256 ...         $aURL['subdomain']  = isset( $aMatch['subdomain'] ) ? $aMatch['subdomain']  : '';
0257 ...         $aURL['domain']     = isset( $aMatch['domain']    ) ? $aMatch['domain']     : '';
0258 ...         $aURL['tld']        = isset( $aMatch['tld']       ) ? $aMatch['tld']        : '';
0259 ... 
0260 ...         if ( ( $iPos = STR_Pos( $aURL['tld'],'/' ) ) != -1 )
0261 ...         {
0262 ...             $aURL['tld'] = STR_Left( $aURL['tld'],$iPos );
0263 ...         }
0264 ...     }
0265 ... 
0266 ...     if ( ! is_null( $szPart ) && isset( $aURL[$szPart] ) )
0267 ...     {
0268 ...         return ( $aURL[$szPart] );
0269 ...     }
0270 ...     else
0271 ...     {
0272 ...         return ( $aURL );
0273 ...     }
0274 ... 
0275 ...     return ( $aURL );
0276 ... }   /* End of function URL_ParseDomain() ==================================== */
0277 ... 
0278 ... /* ========================================================================== */
0279 ... /** {{*URL_IsExtern( $szURL,$szDomain )=
0280 ... 
0281 ...     Determines whether $szURL is extern to $szDomain
0282 ... 
0283 ...     {*params
0284 ...         $szURL      (string)    URL to test
0285 ...         $szDomain   (string)    Domain to consider. Optional. If not passed
0286 ...                                 $_SERVER['SERVER_NAME'] is used instead.
0287 ...     *}
0288 ... 
0289 ...     {*warning
0290 ...         Only http and https URLs can be compared safely
0291 ...     *}
0292 ... 
0293 ...     {*return
0294 ...         (bool)      true to indicate that $szURL is extern to $szDomain. false otherwise.
0295 ...                     In case of technical problem, false is returned.
0296 ...     *}
0297 ... 
0298 ...     {*assert
0299 ...         MISC_CastString( URL_IsExtern( '/contact.html','http://www.latosensu.be' ) ) == 'false'
0300 ...     *}
0301 ... 
0302 ...     {*assert
0303 ...         MISC_CastString( URL_IsExtern( '','http://www.latosensu.be' ) ) == 'false'
0304 ...     *}
0305 ... 
0306 ...     {*assert
0307 ...         MISC_CastString( URL_IsExtern( 'http://www.latosensu.be/contact.html','http://www.latosensu.be' ) ) == 'false'
0308 ...     *}
0309 ... 
0310 ...     {*assert
0311 ...         MISC_CastString( URL_IsExtern( 'http://www.microsoft.com','http://www.latosensu.be' ) ) == 'true'
0312 ...     *}
0313 ... 
0314 ...     {*example
0315 ...         echo MISC_CastString( URL_IsExtern( '/contact.html','http://www.latosensu.be' ) ); // prints 'false'
0316 ...     *}
0317 ... 
0318 ...     {*seealso
0319 ...         URL_IsIntern()
0320 ...     *}
0321 ... 
0322 ...     *}}
0323 ...  */
0324 ... /* ========================================================================== */
0325 ... function URL_IsExtern( $szURL,$szDomain = null )
0326 ... /*---------------------------------------------*/
0327 ... {
0328 ...     $bRetVal = false;                                               /* Default return value of the function */
0329 ... 
0330 ...     if ( STR_Empty( $szDomain ) )                                   /* If no domain given */
0331 ...     {
0332 ...         $szDomain = 'http://' . $_SERVER['SERVER_NAME'];
0333 ...     }   /* if ( STR_Empty( $szDomain ) ) */
0334 ... 
0335 ...     if ( ! preg_match( '/http:\/\/|https:\/\//si',$szDomain ) )     /* If no protocol/scheme found */
0336 ...     {
0337 ...         $szDomain = 'http://' . $szDomain;                          /* Add http in front */
0338 ...     }   /* if ( ! preg_match( '/http:\/\/|https:... */
0339 ... 
0340 ...     if ( ! STR_Empty( $szURL ) )                                    /* If URL provided */
0341 ...     {
0342 ...         if ( preg_match( '/http:\/\/|https:\/\//si',$szURL ) )      /* Check whether HTTP or HTTPS protocol */
0343 ...         {
0344 ...             $aParsedURL     = parse_url( $szURL     );              /* Parse URL */
0345 ...             $aParsedDomain  = parse_url( $szDomain  );              /* Parse domain */
0346 ... 
0347 ...             if ( isset( $aParsedURL[   'host'] ) &&                 /* If both URL and domain parsed successfully */
0348 ...                  isset( $aParsedDomain['host'] ) &&
0349 ...                  $aParsedURL['host'] == $aParsedDomain['host'] )    /* ... and domain is identical */
0350 ...             {
0351 ...                 $bRetVal = false;
0352 ...             }   /* if ( isset( $aParsedURL[   'host'] ) && ... */
0353 ...             else   /* Else of ... if ( isset( $aParsedURL[   'host'] ) && ... */
0354 ...             {
0355 ...                 $bRetVal = true;
0356 ...             }   /* End of ... Else of ... if ( isset( $aParsedURL[   'host'] ) && ... */
0357 ...         }   /* if ( preg_match( '/http:\/\/|https:\/\//si',$szURL ) ) */
0358 ...     }   /* if ( ! STR_Empty( $szURL ) ) */
0359 ... 
0360 ...     return ( $bRetVal );                                            /* Return result to caller */
0361 ... }   /* End of URL_IsExtern() ================================================ */
0362 ... 
0363 ... /* ========================================================================== */
0364 ... /** {{*URL_IsIntern( $szURL,$szDomain )=
0365 ... 
0366 ...     Determines whether $szURL is intern to $szDomain
0367 ... 
0368 ...     {*params
0369 ...         $szURL      (string)    URL to test
0370 ...         $szDomain   (string)    Domain to consider. Optional. If not passed
0371 ...                                 $_SERVER['SERVER_NAME'] is used instead.
0372 ...     *}
0373 ... 
0374 ...     {*warning
0375 ...         Only http and https URLs can be compared safely
0376 ...     *}
0377 ... 
0378 ...     {*return
0379 ...         (bool)      [c]true[/c] to indicate that $szURL is intern to $szDomain. 
0380 ...                     [c]false[/c] otherwise. In case of technical problem, 
0381 ...                     [c]true[/c] is returned.
0382 ...     *}
0383 ... 
0384 ...     {*assert
0385 ...         MISC_CastString( URL_IsIntern( '/contact.html','http://www.latosensu.be' ) ) == 'true'
0386 ...     *}
0387 ... 
0388 ...     {*assert
0389 ...         MISC_CastString( URL_IsIntern( '','http://www.latosensu.be' ) ) == 'true'
0390 ...     *}
0391 ... 
0392 ...     {*assert
0393 ...         MISC_CastString( URL_IsIntern( 'http://www.latosensu.be/contact.html','http://www.latosensu.be' ) ) == 'true'
0394 ...     *}
0395 ... 
0396 ...     {*assert
0397 ...         MISC_CastString( URL_IsIntern( 'http://www.microsoft.com','http://www.latosensu.be' ) ) == 'false'
0398 ...     *}
0399 ... 
0400 ...     {*example
0401 ...         echo MISC_CastString( URL_IsIntern( '/contact.html','http://www.latosensu.be' ) ); // prints 'true'
0402 ...     *}
0403 ... 
0404 ...     {*seealso
0405 ...         URL_IsExtern()
0406 ...     *}
0407 ... 
0408 ...     *}}
0409 ...  */
0410 ... /* ========================================================================== */
0411 ... function URL_IsIntern( $szURL,$szDomain = null )
0412 ... {
0413 ...     return ( ! URL_IsExtern( $szURL,$szDomain ) );
0414 ... }   /* End of URL_IsIntern() ================================================ */
0415 ... 
0416 ... /* ========================================================================== */
0417 ... /** {{*URL_URItoRoot( $aURLParts[,$szURI] )=
0418 ... 
0419 ...     Resolves a relative URI to a fully qualified URI that takes the
0420 ...     domain into account
0421 ... 
0422 ...     {*params
0423 ...         &aURLParts      (array)     URL parts array. By reference.
0424 ...                                     Updated upon return
0425 ...         $szURI          (string)    Optional URI. If not passed, the
0426 ...                                     current URI is considered
0427 ...                                     ([c]$_SERVER['REQUEST_URI'][/c])
0428 ...     *}
0429 ... 
0430 ...     {*return
0431 ...         (string)    the fully qualified URI (absolute path)
0432 ...     *}
0433 ... 
0434 ...     {*exec
0435 ...         // 1st run
0436 ...         $aURLParts = array();
0437 ...         $szURL = URL_URItoRoot( $aURLParts );
0438 ...         echo $szURL;
0439 ...         var_dump( $aURLParts );
0440 ... 
0441 ...         // 2nd run
0442 ...         $szURL = URL_URItoRoot( $aURLParts,$szURL );
0443 ...         echo $szURL;
0444 ...         var_dump( $aURLParts );
0445 ... 
0446 ...     *}
0447 ...     *}}
0448 ...  */
0449 ... /* ========================================================================== */
0450 ... function URL_URItoRoot( &$aURLParts,$szURI = null )
0451 ... /*-----------------------------------------------*/
0452 ... {
0453 ...     $szRetVal   = null;                                             /* Return value of the function */
0454 ... 
0455 ...     $szHost     = isset( $_SERVER['HTTP_HOST']       ) ? $_SERVER['HTTP_HOST']       : null;    // e.g. 'api.openlabels.poc'
0456 ...     $szProtocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : null;    // e.g. 'HTTP/1.1'
0457 ... 
0458 ...     if ( ! is_null( $szHost ) && ! is_null( $szProtocol ) )         /* If we got a host AND a protocol */
0459 ...     {
0460 ...         /* {*todo: take care of additional protocols such as https, ... *} */
0461 ...         if ( $szProtocol === 'HTTP/1.1' )                           /* If protocol is something we know */
0462 ...         {
0463 ...             $szQueryString  = $_SERVER['QUERY_STRING'];             /* This is the query string */
0464 ... 
0465 ...             if ( STR_Empty( $szURI ) )                              /* If URI not mentioned */
0466 ...             {
0467 ...                 $szURI  = $_SERVER['REQUEST_URI'];                  /* Use current URI */
0468 ...             }   /* if ( STR_Empty( $szURI ) ) */
0469 ... 
0470 ...             if ( ! STR_Empty( $szQueryString ) )                    /* If query string found */
0471 ...             {
0472 ...                 /* Get rid of the query string from the $szURI */
0473 ...                 $szURI      = str_replace( "?{$szQueryString}",'',$szURI );
0474 ...                 $szRetVal   = 'http://' . $szHost . $szURI . '?' . $szQueryString;
0475 ...             }   /* if ( ! STR_Empty( $szQueryString ) ) */
0476 ...             else   /* Else of ... if ( ! STR_Empty( $szQueryString ) ) */
0477 ...             {
0478 ...                 $szRetVal = 'http://' . $szHost . $szURI;
0479 ...             }   /* End of ... Else of ... if ( ! STR_Empty( $szQueryString ) ) */
0480 ... 
0481 ...             /* {*todo: should also take care of additional parts
0482 ...                        such as username, password, port *} */
0483 ...             $aURLParts['scheme']    = 'http://';                    /* Store the scheme part */
0484 ...             $aURLParts['host']      = $szHost;                      /* Store the host part */
0485 ...             $aURLParts['uri']       = $szURI;                       /* Store the URI part */
0486 ...             $aURLParts['query']     = $szQueryString;               /* Store the query string part */
0487 ...         }   /* if ( $szProtocol === 'HTTP/1.1' ) */
0488 ...     }   /* if ( ! is_null( $szHost ) && ! is_null( $szProtocol ) ) */
0489 ... 
0490 ...     return ( $szRetVal );                                           /* Return result to caller */
0491 ... }   /* End of function URL_URItoRoot() ====================================== */
0492 ... 

Manifest Constants

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

LS_URL: Remember that THESE functions have been declared

UltraEdit Syntax files

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

Function List (TOC)

  1. URL_IsExtern(): Determines whether $szURL is extern to $szDomain
  2. URL_IsIntern(): Determines whether $szURL is intern to $szDomain
  3. URL_Parse(): Parses a URL into its respective protocol, domain and path
  4. URL_ParseDomain(): Parses a domain
  5. URL_QueryString(): Determines the query string passed in the url No assertion found for URL_QueryString() (0 - 0)
  6. URL_URItoRoot(): Resolves a relative URI to a fully qualified URI that takes the domain into account No assertion found for URL_URItoRoot() (0 - 0)

Functions of LSUrl.functions.php

URL_IsExtern(): Determines whether $szURL is extern to $szDomain

[ back to function list ]

Warning

Only http and https URLs can be compared safely

Syntax

URL_IsExtern( $szURL,$szDomain )

Parameters
NameTypeDescription
$szURL string URL to test
$szDomain string Domain to consider. Optional. If not passed $_SERVER['SERVER_NAME'] is used instead.
Return

(bool) true to indicate that $szURL is extern to $szDomain. false otherwise. In case of technical problem, false is returned.

Example(s)
echo MISC_CastString( URL_IsExtern( '/contact.html','http://www.latosensu.be' ) ); // prints 'false'
Assertions

MISC_CastString( URL_IsExtern( '/contact.html','http://www.latosensu.be' ) ) == 'false' successful

MISC_CastString( URL_IsExtern( '','http://www.latosensu.be' ) ) == 'false' successful

MISC_CastString( URL_IsExtern( 'http://www.latosensu.be/contact.html','http://www.latosensu.be' ) ) == 'false' successful

MISC_CastString( URL_IsExtern( 'http://www.microsoft.com','http://www.latosensu.be' ) ) == 'true' successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

URL_IsIntern()

URL_IsIntern(): Determines whether $szURL is intern to $szDomain

[ back to function list ]

Warning

Only http and https URLs can be compared safely

Syntax

URL_IsIntern( $szURL,$szDomain )

Parameters
NameTypeDescription
$szURL string URL to test
$szDomain string Domain to consider. Optional. If not passed $_SERVER['SERVER_NAME'] is used instead.
Return

(bool) true to indicate that $szURL is intern to $szDomain. false otherwise. In case of technical problem, true is returned.

Example(s)
echo MISC_CastString( URL_IsIntern( '/contact.html','http://www.latosensu.be' ) ); // prints 'true'
Assertions

MISC_CastString( URL_IsIntern( '/contact.html','http://www.latosensu.be' ) ) == 'true' successful

MISC_CastString( URL_IsIntern( '','http://www.latosensu.be' ) ) == 'true' successful

MISC_CastString( URL_IsIntern( 'http://www.latosensu.be/contact.html','http://www.latosensu.be' ) ) == 'true' successful

MISC_CastString( URL_IsIntern( 'http://www.microsoft.com','http://www.latosensu.be' ) ) == 'false' successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

URL_IsExtern()

URL_Parse(): Parses a URL into its respective protocol, domain and path

[ back to function list ]

Syntax

URL_Parse( $szURL,$szPart )

Parameters
NameTypeDescription
$szURL string The URL to parse
$szPart string Part to receive. Optional. Can be 'protocol', 'domain' or 'path'.
Return

(mixed) Associative array with the following keys:
- protocol
- domain
- path
If $szPart passed and 'protocol', 'domain' or 'path' the return value is a string

Example(s)
$szURL  = 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3';
$aURL   = URL_Parse( $szURL );
echo $aURL['protocol'];     // Prints 'http'
echo $aURL['domain'];       // Prints 'www.vaesoli.org'
echo $aURL['path'];         // documentation/documentation-vaesoli-code-source.php'
Assertions

URL_Parse( 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3','protocol' ) == 'http' successful

URL_Parse( 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3','domain' ) == 'www.vaesoli.org' successful

URL_Parse( 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3','path' ) == '/documentation/documentation-vaesoli-code-source.php' successful

URL_Parse( 'http://api.soccer.openlabels.net/source.php?page=3','path' ) == array( 'api','soccer' ) failure

Unit Testing

4 assertions: 3 successful; 1 failed

URL_ParseDomain(): Parses a domain

[ back to function list ]

Syntax

URL_ParseDomain( $szDomain,$szPart )

Parameters
NameTypeDescription
$szDomain string Domain to parse
$szPart string Optional. Part to receive. Can be:
- 'tld'
- 'domain'
- 'subdomain'
Return

(mixed) Associative array with the following keys:
- tld
- domain
- subdomain
If $szPart passed ('tld', 'domain' or 'subdomain') the return value is a string

Example(s)
$szURL      = 'http://www.vaesoli.org/documentation/documentation-vaesoli-code-source.php?page=3';
$szDomain   = URL_Parse( $szURL,'domain' );
echo $szDomain;                                 // Prints 'www.vaesoli.org'
echo URL_ParseDomain( $szDomain,'subdomain' );  // Prints 'www'
echo URL_ParseDomain( $szDomain,'domain'    );  // Prints 'vaesoli'
echo URL_ParseDomain( $szDomain,'tld'       );  // Prints 'org'
Example Executed
$szDomain = "ui.tl";
$aParts   = URL_ParseDomain( $szDomain );
var_dump( $aParts );

array (size=3)
  'subdomain' => string '' (length=0)
  'domain' => string 'ui' (length=2)
  'tld' => string 'tl' (length=2)
Assertions

URL_ParseDomain( 'www.vaesoli.org','subdomain' ) == 'www' failure

URL_ParseDomain( 'www.vaesoli.org','domain' ) == 'vaesoli' successful

URL_ParseDomain( 'www.vaesoli.org','tld' ) == 'org' successful

Unit Testing

3 assertions: 2 successful; 1 failed

URL_QueryString(): Determines the query string passed in the url

[ back to function list ]

Warning

Not quite identical to $_SERVER['QUERY_STRING']

Syntax

URL_QueryString()

Alias

GetQueryString()

Parameters

None

Return

(string) a "=&=" string

Example(s)
// If current page is http://www.latosensu.be?lang=fr&theme=summer
echo URL_QueryString(); // Prints 'lang=fr&amp;theme=summer'
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

URL_URItoRoot(): Resolves a relative URI to a fully qualified URI that takes the domain into account

[ back to function list ]

Syntax

URL_URItoRoot( $aURLParts,$szURI )

Parameters
NameTypeDescription
$aURLParts array URL parts array. By reference. Updated upon return
$szURI string Optional URI. If not passed, the current URI is considered ($_SERVER['REQUEST_URI'])
Return

(string) the fully qualified URI (absolute path)

Example Executed
// 1st run
$aURLParts = array();
$szURL = URL_URItoRoot( $aURLParts );
echo $szURL;
var_dump( $aURLParts );

// 2nd run
$szURL = URL_URItoRoot( $aURLParts,$szURL );
echo $szURL;
var_dump( $aURLParts );

array (size=0)
  empty
array (size=0)
  empty
Unit Testing

WARNING: No Unit Testing found. Please provide assertions with assertion constructs ({*assert ... *}) or with GuideAssert() function calls in exec constructs ({*exec LSUnitTesting::assert(...); *}).

Précédent Suivant