Niouzes

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php:3658:
object(LogicException)[63]
  protected 'message' => string 'Class LSContentsCalendar could not be loaded' (length=44)
  private 'string' (Exception) => string '' (length=0)
  protected 'code' => int 0
  protected 'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
  protected 'line' => int 3587
  private 'trace' (Exception) => 
    array (size=15)
      0 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 3587
          'function' => string 'spl_autoload' (length=12)
          'args' => 
            array (size=1)
              ...
      1 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 3262
          'function' => string 'EmergeIsland' (length=12)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=6)
              ...
      2 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 2756
          'function' => string 'EmergeIslands' (length=13)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=5)
              ...
      3 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 2994
          'function' => string 'EmergeArchipelagosFromParent' (length=28)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=3)
              ...
      4 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5928
          'function' => string 'EmergeArchipelagos' (length=18)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=2)
              ...
      5 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\template\vaesoli.html' (length=58)
          'line' => int 89
          'function' => string 'Land' (length=4)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      6 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 6110
          'args' => 
            array (size=1)
              ...
          'function' => string 'include' (length=7)
      7 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 6053
          'function' => string 'XInclude' (length=8)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      8 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5828
          'function' => string 'IncludeTemplate' (length=15)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      9 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5580
          'function' => string 'UseTemplate' (length=11)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      10 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 3282
          'function' => string 'RenderXML' (length=9)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      11 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 2082
          'function' => string 'StartPage' (length=9)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      12 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSApplication.class.php' (length=76)
          'line' => int 814
          'function' => string 'Render' (length=6)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=0)
              ...
      13 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\master.php' (length=47)
          'line' => int 8
          'function' => string 'Run' (length=3)
          'class' => string 'LSApplication' (length=13)
          'type' => string '->' (length=2)
          'args' => 
            array (size=0)
              ...
      14 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\documentation\documentation-vaesoli-code-source.php' (length=88)
          'line' => int 1
          'args' => 
            array (size=1)
              ...
          'function' => string 'include' (length=7)
  private 'previous' (Exception) => null
  public 'xdebug_message' => string '<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> LogicException: Class LSContentsCalendar could not be loaded in D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php on line <i>3587</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory'... (length=6279)
D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php:3658:
object(LogicException)[81]
  protected 'message' => string 'Class LSContentsCitation could not be loaded' (length=44)
  private 'string' (Exception) => string '' (length=0)
  protected 'code' => int 0
  protected 'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
  protected 'line' => int 3587
  private 'trace' (Exception) => 
    array (size=15)
      0 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 3587
          'function' => string 'spl_autoload' (length=12)
          'args' => 
            array (size=1)
              ...
      1 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 3262
          'function' => string 'EmergeIsland' (length=12)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=6)
              ...
      2 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 2756
          'function' => string 'EmergeIslands' (length=13)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=5)
              ...
      3 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 2994
          'function' => string 'EmergeArchipelagosFromParent' (length=28)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=3)
              ...
      4 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5928
          'function' => string 'EmergeArchipelagos' (length=18)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=2)
              ...
      5 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\template\vaesoli.html' (length=58)
          'line' => int 89
          'function' => string 'Land' (length=4)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      6 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 6110
          'args' => 
            array (size=1)
              ...
          'function' => string 'include' (length=7)
      7 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 6053
          'function' => string 'XInclude' (length=8)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      8 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5828
          'function' => string 'IncludeTemplate' (length=15)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      9 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5580
          'function' => string 'UseTemplate' (length=11)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      10 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 3282
          'function' => string 'RenderXML' (length=9)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      11 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 2082
          'function' => string 'StartPage' (length=9)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      12 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSApplication.class.php' (length=76)
          'line' => int 814
          'function' => string 'Render' (length=6)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=0)
              ...
      13 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\master.php' (length=47)
          'line' => int 8
          'function' => string 'Run' (length=3)
          'class' => string 'LSApplication' (length=13)
          'type' => string '->' (length=2)
          'args' => 
            array (size=0)
              ...
      14 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\documentation\documentation-vaesoli-code-source.php' (length=88)
          'line' => int 1
          'args' => 
            array (size=1)
              ...
          'function' => string 'include' (length=7)
  private 'previous' (Exception) => null
  public 'xdebug_message' => string '<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> LogicException: Class LSContentsCitation could not be loaded in D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php on line <i>3587</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory'... (length=6279)

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.

2019-06-18 à 01:34:06

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/06/2019)
  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)

LSFiles.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/LSFiles.functions.phpC:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFiles.functions.phpapplication/force-downloadC:\websites\vaesoli.org\www\httpdocs\vaesoli\include129444 bytes03/08/2013 23:27:5203/03/2015 06:32:5003/03/2015 06:32:50

Compliance

Assertions count: 37

Assertions successful: 37

Assertion failures: 0

Early Warning

LSFiles.functions.php exceeds 51200 bytes. We suggest this file got broken down in smaller chunks!

LSFiles.functions.php contains 3375 lines of code, which exceeds the suggested limit of 1024 lines. We suggest this file got broken down in smaller chunks!

0001 ... <?php
0002 ... /**************************************************************************/
0003 ... /** {{{*fheader
0004 ...     {*file                  LSFiles.functions.php *}
0005 ...     {*purpose               File 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 ...                             [url]Vae Soli! : http://www.vaesoli.org[/url] *}
0013 ...     {*cdate                 26/05/2006 - 15:21 *}
0014 ...     {*mdate                 auto *}
0015 ...     {*uses                  LSStrings.functions.php *}
0016 ...     {*license               [url]http://creativecommons.org/licenses/by-sa/2.0/be/[url][br]
0017 ... 
0018 ...                             To obtain detailed information about the license
0019 ...                             terms, please head to the full license text
0020 ...                             available in the [file]LSCopyright.php[/file] file *}
0021 ... 
0022 ...     ------------------------------------------------------------------------
0023 ...     Changes History:
0024 ...     ------------------------------------------------------------------------
0025 ... 
0026 ...     {*chist
0027 ...         {*mdate 21/06/2012 *}
0028 ...         {*v 5.0.0003 *}
0029 ...         {*desc              All comments before this release have been
0030 ...                             eliminated (for tracking purposes, please
0031 ...                             head to the Vae Soli! archive : vaesoli-5.0.0002.zip *}
0032 ...     *}
0033 ... 
0034 ...     {*chist
0035 ...         {*mdate 27/06/2012 *}
0036 ...         {*v 5.0.0003 *}
0037 ...         {*desc              FIL_Size() new function
0038 ...     *}
0039 ... 
0040 ...     *}}} */
0041 ... /**************************************************************************/
0042 ... if ( ! defined( 'VAESOLI_PATH' ) )                                  /* If the path is not defined yet */
0043 ... {
0044 ...     /* {*define (VAESOLI_PATH)  Define the path where Vae Soli! is installed *} */
0045 ...     define( 'VAESOLI_PATH',__DIR__ );
0046 ... }   /* if ( ! defined( 'VAESOLI_PATH' ) ) */
0047 ... 
0048 ... if ( ! defined( 'VAESOLI_PLUGINS' ) )                               /* If the path is not defined yet */
0049 ... {
0050 ...     /* {*define (VAESOLI_PLUGINS)  Define the path where plugins are located *} */
0051 ...     define( 'VAESOLI_PLUGINS',VAESOLI_PATH . '/../plugins' );
0052 ... }   /* if ( ! defined( 'VAESOLI_PLUGINS' ) ) */
0053 ... 
0054 ... if ( ! defined( 'VAESOLI_SLASH' ) )                                 /* If VAESOLI_SLASH not defined */
0055 ... {
0056 ...     /* {*define (VAESOLI_SHASH)  Define the value of the slash character in the file system *} */
0057 ...     switch ( strtoupper( PHP_OS ) )                                 /* In function of the OS */
0058 ...     {
0059 ...         case 'WINNT'    :
0060 ...         case 'WINDOWS'  :
0061 ...         case 'WIN32'    :
0062 ...         case 'WIN'      :   /**
0063 ...                              *  Définition du slash en fonction du système d'exploitation
0064 ...                              */
0065 ...                             define( 'VAESOLI_SLASH','\\' );
0066 ...                             break;
0067 ...         case 'AIX'      :
0068 ...         case 'LINUX'    :
0069 ...         case 'OS400'    :
0070 ...         case 'MAC'      :
0071 ...         default         :   /**
0072 ...                              *  Définition du slash en fonction du système d'exploitation
0073 ...                              *  @ignore
0074 ...                              */
0075 ...                             define( 'VAESOLI_SLASH','/' );
0076 ...                             break;
0077 ...     }   /* switch ( strtoupper( PHP_OS ) ) */
0078 ... }   /* if ( ! defined( 'VAESOLI_SLASH' ) ) */
0079 ... 
0080 ... if ( ! defined( 'LS_FILES_FUNCTIONS' ) )                            /* If module var not defined */
0081 ... {
0082 ...     /* {*define (LS_FILES_FUNCTIONS)  Remember that THESE functions have been declared *} */
0083 ...     define( 'LS_FILES_FUNCTIONS','PWH' );
0084 ... }   /* if ( ! defined( 'LS_FILES_FUNCTIONS' ) ) */
0085 ... 
0086 ... if ( ! defined( 'LS_STRINGS_FUNCTIONS' ) )                          /* If string var not defined yet, load functions */
0087 ... {
0088 ...     /* {*require (LSStrings.functions.php) String functions *} */
0089 ...     require_once( VAESOLI_PATH . '/LSStrings.functions.php' );
0090 ... }   /* if ( ! defined( 'LS_STRINGS_FUNCTIONS' ) ) */
0091 ... 
0092 ... /* {*require (LSUnitTesting.class.php)              Vae Soli! Unit Testing *} */
0093 ... require_once( VAESOLI_PATH . '/LSUnitTesting.class.php'   );
0094 ... 
0095 ... /* ========================================================================== */
0096 ... /** {{*FIL_Seek( $rHandle,$iOffset,$iStrategy )=
0097 ... 
0098 ...     Seeks on a file pointer
0099 ... 
0100 ...     {*params
0101 ...         $rHandle    (resource)  Resource to file
0102 ...         $iOffset    (int)       Offset to consider for the move of the pointer
0103 ...         $iStrategy  (int)       Strategy to apply when moving the pointer:[br]
0104 ...                                 [ul]
0105 ...                                 [li][c]SEEK_SET[/c] - Set position equal to offset bytes[/li][br]
0106 ...                                 [li][c]SEEK_CUR[/c] - Set position to current location plus offset[/li][br]
0107 ...                                 [li][c]SEEK_END[/c] - Set position to end-of-file plus offset[/li][br]
0108 ...                                 [/ul]
0109 ...                                 Default is [c]SEEK_CUR[/c].
0110 ...     *}
0111 ... 
0112 ...     {*cdate 16/09/2013 - 06:31 *}
0113 ...     {*author  *}
0114 ... 
0115 ...     {*return
0116 ...         (int)  [c]true[/c] if pointer moved successfully. [c]false[/c] otherwise
0117 ...     *}
0118 ... 
0119 ...     {*remark
0120 ...         This function acts as a wrapper around [c]fseek()[/c]
0121 ...     *}
0122 ... 
0123 ...     {*example
0124 ...         if ( $rHandle = FIL_Open( $szFile,'r' ) )
0125 ...         {
0126 ...             echo '<p>POSITION AT OPENING: ',FIL_Tell( $rHandle ),'</p>';
0127 ...             FIL_Seek( $rHandle,-10,SEEK_END ); // Move 10 bytes before end
0128 ...             echo '<p>NEW POSITION: ',FIL_Tell( $rHandle ),'</p>';
0129 ...             FIL_Close( $rHandle );
0130 ...         }
0131 ...     *}
0132 ... 
0133 ...     {*exec
0134 ...         if ( $rHandle = FIL_Open( $szFile = 'C:\websites\latosensu.be\www\httpdocs\vaesoli\include\LSFiles.functions.php','r' ) )
0135 ...         {
0136 ...             $iPos = FIL_Tell( $rHandle );
0137 ...             echo LSUnitTesting::assert( is_resource( $rHandle )                 ,
0138 ...                                         'ASSERTION SUCCESS: resource valid!'    ,
0139 ...                                         'ASSERTION FAILURE: invalid resource'   ,
0140 ...                                         'GuideAssert' );
0141 ...             echo LSUnitTesting::assert( $iPos === 0                             ,
0142 ...                                         'ASSERTION SUCCESS: file pointer correct'   ,
0143 ...                                         'ASSERTION FAILURE: file pointer incorrect' ,
0144 ...                                         'GuideAssert' );
0145 ...             $iSize = FIL_Size( $szFile );
0146 ...             FIL_Seek( $rHandle,-10,SEEK_END );
0147 ...             echo LSUnitTesting::assert( FIL_Tell( $rHandle ) === ( $iSize - 10 )    ,
0148 ...                                         'ASSERTION SUCCESS: file pointer correct'   ,
0149 ...                                         'ASSERTION FAILURE: file pointer incorrect' ,
0150 ...                                         'GuideAssert' );
0151 ...             $bClosed = FIL_Close( $rHandle );
0152 ...             echo LSUnitTesting::assert( $bClosed                                        ,
0153 ...                                         'ASSERTION SUCCESS: file successfully closed!'  ,
0154 ...                                         'ASSERTION FAILURE: file CANNOT be closed'      ,
0155 ...                                         'GuideAssert' );
0156 ...         }
0157 ...     *}
0158 ... 
0159 ...     {*seealso
0160 ...         FIL_Tell()
0161 ...     *}
0162 ... 
0163 ...  *}}
0164 ...  */
0165 ... /* ========================================================================== */
0166 ... function FIL_Seek( $rHandle,$iOffset = 0,$iStrategy = SEEK_CUR )
0167 ... {
0168 ...     return ( fseek( $rHandle,$iOffset,$iStrategy ) === 0 ? true : false );
0169 ... }   /* End of function FIL_Seek() =========================================== */
0170 ... 
0171 ... /* ========================================================================== */
0172 ... /** {{*FIL_Tell( $rHandle )=
0173 ... 
0174 ...     Returns the current position of the file read/write pointer
0175 ... 
0176 ...     {*params
0177 ...         $rHandle    (resource)  Resource to file
0178 ...     *}
0179 ... 
0180 ...     {*cdate 16/09/2013 - 06:52 *}
0181 ...     {*author  *}
0182 ... 
0183 ...     {*remark
0184 ...         This function acts as a wrapper around [c]ftell()[/c]
0185 ...     *}
0186 ... 
0187 ...     {*return
0188 ...         (int)  Position of the file pointer referenced by $rHandle
0189 ...     *}
0190 ... 
0191 ...     {*example
0192 ...         if ( $rHandle = FIL_Open( $szFile,'r' ) )
0193 ...         {
0194 ...             echo '<p>POSITION AT OPENING: ',FIL_Tell( $rHandle ),'</p>';
0195 ...             FIL_Seek( $rHandle,-10,SEEK_END );
0196 ...             echo '<p>NEW POSITION: ',FIL_Tell( $rHandle ),'</p>';
0197 ...             FIL_Close( $rHandle );
0198 ...         }
0199 ...     *}
0200 ... 
0201 ...     {*exec
0202 ...         if ( $rHandle = FIL_Open( $szFile = 'C:\websites\latosensu.be\www\httpdocs\vaesoli\include\LSFiles.functions.php','r' ) )
0203 ...         {
0204 ...             $iPos = FIL_Tell( $rHandle );
0205 ...             echo LSUnitTesting::assert( is_resource( $rHandle )                 ,
0206 ...                                         'ASSERTION SUCCESS: resource valid!'    ,
0207 ...                                         'ASSERTION FAILURE: invalid resource'   ,
0208 ...                                         'GuideAssert' );
0209 ...             echo LSUnitTesting::assert( $iPos === 0                             ,
0210 ...                                         'ASSERTION SUCCESS: file pointer correct'   ,
0211 ...                                         'ASSERTION FAILURE: file pointer incorrect' ,
0212 ...                                         'GuideAssert' );
0213 ...             $iSize = FIL_Size( $szFile );
0214 ...             FIL_Seek( $rHandle,-10,SEEK_END );
0215 ...             echo LSUnitTesting::assert( FIL_Tell( $rHandle ) === ( $iSize - 10 )    ,
0216 ...                                         'ASSERTION SUCCESS: file pointer correct'   ,
0217 ...                                         'ASSERTION FAILURE: file pointer incorrect' ,
0218 ...                                         'GuideAssert' );
0219 ...             $bClosed = FIL_Close( $rHandle );
0220 ...             echo LSUnitTesting::assert( $bClosed                                        ,
0221 ...                                         'ASSERTION SUCCESS: file successfully closed!'  ,
0222 ...                                         'ASSERTION FAILURE: file CANNOT be closed'      ,
0223 ...                                         'GuideAssert' );
0224 ...         }
0225 ...     *}
0226 ... 
0227 ...     {*seealso
0228 ...         FIL_Seek()
0229 ...     *}
0230 ... 
0231 ...  *}}
0232 ...  */
0233 ... /* ========================================================================== */
0234 ... function FIL_Tell( $rHandle )
0235 ... {
0236 ...     return ( ftell( $rHandle ) );
0237 ... }   /* End of function FIL_Tell() =========================================== */
0238 ... 
0239 ... /* ========================================================================== */
0240 ... /** {{*FIL_IncludeOnce( $szFile )=
0241 ... 
0242 ...     Includes a file if it exists
0243 ... 
0244 ...     {*params
0245 ...         $szFile     (string)    File to include
0246 ...     *}
0247 ... 
0248 ...     {*cdate 02/03/2015 - 12:44 *}
0249 ...     {*author  *}
0250 ... 
0251 ...     {*return
0252 ...         (bool)  [c]true[/c] if $szFile exists; [c]false[/c] if not
0253 ...     *}
0254 ... 
0255 ...     {*example
0256 ...         THE EXAMPLE WILL NOT WORK
0257 ...         if ( $rHandle = FIL_Open( $szFile,'r' ) )
0258 ...         {
0259 ...             echo '<p>POSITION AT OPENING: ',FIL_Tell( $rHandle ),'</p>';
0260 ...             FIL_Seek( $rHandle,-10,SEEK_END );
0261 ...             echo '<p>NEW POSITION: ',FIL_Tell( $rHandle ),'</p>';
0262 ...             FIL_Close( $rHandle );
0263 ...         }
0264 ...     *}
0265 ... 
0266 ...     {*exec
0267 ...         THE EXAMPLE WILL NOT WORK
0268 ...         if ( $rHandle = FIL_Open( $szFile = 'C:\websites\latosensu.be\www\httpdocs\vaesoli\include\LSFiles.functions.php','r' ) )
0269 ...         {
0270 ...             $iPos = FIL_Tell( $rHandle );
0271 ...             echo LSUnitTesting::assert( is_resource( $rHandle )                 ,
0272 ...                                         'ASSERTION SUCCESS: resource valid!'    ,
0273 ...                                         'ASSERTION FAILURE: invalid resource'   ,
0274 ...                                         'GuideAssert' );
0275 ...             echo LSUnitTesting::assert( $iPos === 0                             ,
0276 ...                                         'ASSERTION SUCCESS: file pointer correct'   ,
0277 ...                                         'ASSERTION FAILURE: file pointer incorrect' ,
0278 ...                                         'GuideAssert' );
0279 ...             $iSize = FIL_Size( $szFile );
0280 ...             FIL_Seek( $rHandle,-10,SEEK_END );
0281 ...             echo LSUnitTesting::assert( FIL_Tell( $rHandle ) === ( $iSize - 10 )    ,
0282 ...                                         'ASSERTION SUCCESS: file pointer correct'   ,
0283 ...                                         'ASSERTION FAILURE: file pointer incorrect' ,
0284 ...                                         'GuideAssert' );
0285 ...             $bClosed = FIL_Close( $rHandle );
0286 ...             echo LSUnitTesting::assert( $bClosed                                        ,
0287 ...                                         'ASSERTION SUCCESS: file successfully closed!'  ,
0288 ...                                         'ASSERTION FAILURE: file CANNOT be closed'      ,
0289 ...                                         'GuideAssert' );
0290 ...         }
0291 ...     *}
0292 ...  *}}
0293 ...  */
0294 ... /* ========================================================================== */
0295 ... function FIL_IncludeOnce( $szFile )
0296 ... /*-------------------------------*/
0297 ... {
0298 ...     if ( $bRetVal = FIL_Exists( $szFile ) )
0299 ...     {
0300 ...         include_once( $szFile );
0301 ...     }
0302 ... 
0303 ...     return ( $bRetVal );
0304 ... }   /* End of function FIL_IncludeOnce() ==================================== */
0305 ... 
0306 ... /* ========================================================================== */
0307 ... /** {{*FIL_IsLink( $szFile )=
0308 ... 
0309 ...     Determines if a file/dir is a link or not
0310 ... 
0311 ...     {*params
0312 ...         $szFile (string)        File to check if link
0313 ...     *}
0314 ... 
0315 ...     {*warning
0316 ...         This function proved to be necessary after we have discovered
0317 ...         that the [c]is_link()[/c] function of PHP sometimes returned
0318 ...         true and sometimes false on EXACTLY the same directory
0319 ...         (byte per byte).
0320 ...     *}
0321 ... 
0322 ...     {*mdate
0323 ...         16/01/2013 - 21:11
0324 ...     *}
0325 ... 
0326 ...     {*uses
0327 ...         FIL_RealPath(), FIL_Normalize(), FIL_AddBS()
0328 ...     *}
0329 ... 
0330 ...     {*return
0331 ...         (bool)  [c]true[/c] if $szFile is a link; [c]false[/c] if not
0332 ...     }
0333 ...  *}}
0334 ...  */
0335 ... /* ====================================================================== */
0336 ... function FIL_IsLink( $szFile )
0337 ... /*--------------------------*/
0338 ... {
0339 ...     $bRetVal = false;                                           /* Default return value of the function */
0340 ... 
0341 ...     $szFile = FIL_Normalize( $szFile );                         /* Normalize $szFile */
0342 ... 
0343 ...     if ( $bRetVal = is_link( $szFile ) )                        /* If is_link() returns true ... we trust it */
0344 ...     {
0345 ...     }   /* if ( $bRetVal = is_link( $szFile ) ) */
0346 ...     else                                                        /* In all other cases ... we check ourselves */
0347 ...     {
0348 ...         if ( ( $szTarget = FIL_Normalize( FIL_AddBS( readlink( $szFile ) ) ) ) !== FIL_RealPath( $szFile ) )
0349 ...         {
0350 ...             $bRetVal = true;
0351 ...         }   /* if ( ( $szTarget = FIL_Normalize( ... */
0352 ...     }   /* End of ... Else of ... if ( $bRetVal = is_link( $szFile ) ) */
0353 ... 
0354 ...     //echo "<p>",__METHOD__,"() at line ",__LINE__,": szFile",$szFile,"</p>";
0355 ...     //echo "<p>",__METHOD__,"() at line ",__LINE__,": szTarget",FIL_Normalize( FIL_AddBS( readlink( $szFile ) ) ),"</p>";
0356 ... 
0357 ...     return ( $bRetVal );                                        /* Return result to caller */
0358 ... }   /* End of function FIL_IsLink() ========================================= */
0359 ... 
0360 ... /* ========================================================================== */
0361 ... /** {{*FIL_IsReadOnly( $szFile )=
0362 ... 
0363 ...     Is $szFile read only?
0364 ... 
0365 ...     {*params
0366 ...         $szFile (string)    File name
0367 ...     *}
0368 ... 
0369 ...     {*return
0370 ...         (bool)      [c]true[/c] if $szFile is in read only mode; [c]false[/c] otherwise.
0371 ...     *}
0372 ... 
0373 ...     {*example
0374 ...         if ( FIL_IsReadOnly( 'C:\\myfile.txt' ) )
0375 ...         {
0376 ...             echo e<p>Read-only file</p>';
0377 ...         }
0378 ...     *}
0379 ... 
0380 ...  *}}
0381 ...  */
0382 ... /* ====================================================================== */
0383 ... function FIL_IsReadOnly( $szFile )
0384 ... /*----------------------------*/
0385 ... {
0386 ...     return ( ! is_writable( $szFile ) );
0387 ... }   /* End of function FIL_IsReadOnly() ================================= */
0388 ... 
0389 ... /* ====================================================================== */
0390 ... /** {{*FIL_RealPath( $szPath )=
0391 ... 
0392 ...     Shorten a path by replacing all occurrences of [c]\..\[/c] or [c]/../[/c]
0393 ... 
0394 ...     {*params
0395 ...         $szPath (string)        Path to turn to a realpath
0396 ...     *}
0397 ... 
0398 ...     {*return
0399 ...         (string)                Real path
0400 ...     *}
0401 ... 
0402 ...     {*assert
0403 ...         FIL_RealPath( 'C:/webSEAL/resources/../images' ) === 'C:\webSEAL\images'
0404 ...     *}
0405 ... 
0406 ...     {*uses
0407 ...         FIL_Normalize()
0408 ...     *}
0409 ... 
0410 ...  *}}
0411 ...  */
0412 ... /* ====================================================================== */
0413 ... function FIL_RealPath( $szPath )
0414 ... /*----------------------------*/
0415 ... {
0416 ...     $iLimit = 30;                                               /* Recursion limit */
0417 ...     $i      = 0;                                                /* Current iteration */
0418 ... 
0419 ...     /* Turn slashes into backslashes */
0420 ...     $szPath = str_replace( array('/','\\.\\'),array('\\','\\'),$szPath );
0421 ...     /* TODO: treat \.\ and /./ */
0422 ...     while ( true )                                              /* While true */
0423 ...     {
0424 ...         /* Change path */
0425 ...         $szPath = str_replace( array('/..\\','/'),array('\\..\\','\\'),preg_replace('/\\\\[^\\\\]*\\\\\.\.\\\\/i','/',$szPath ) );
0426 ... 
0427 ...         /* If no parent dir found ... or recursion limit attained */
0428 ...         if ( ( STR_Pos( $szPath,'\\..' ) === -1   &&
0429 ...                STR_Pos( $szPath,'/..'  ) === -1 ) ||
0430 ...                $i++ > $iLimit )
0431 ...         {
0432 ...             break;
0433 ...         }
0434 ...     }   /* while ( true ) */
0435 ... 
0436 ...     /* Return result to caller */
0437 ...     return ( FIL_Normalize( str_replace( array( '//','\\\\' ),array( '/','\\' ),$szPath ) ) );
0438 ... }   /* End of function FIL_RealPath() */
0439 ... /* ====================================================================== */
0440 ... 
0441 ... /* ====================================================================== */
0442 ... /** {{*FIL_AddBS( $szStr,$cMark )=
0443 ... 
0444 ...     Adds a backslash at the end of a string if it does not have one already
0445 ... 
0446 ...     {*params
0447 ...         $szStr  (string)        String to which a backslash must be added
0448 ...         $cMark  (character)     Backslash character. Optional. [c]null[/c] by default
0449 ...     *}
0450 ... 
0451 ...     {*alias
0452 ...         ADDBS()
0453 ...     *}
0454 ... 
0455 ...     {*return
0456 ...         (string)    String with the added backslash
0457 ...     *}
0458 ... 
0459 ...     {*exec
0460 ...         $szFile = FIL_AddBS( "C:\\MYDIR" );
0461 ...         echo "<p>'{$szFile}' ends with '" . STR_Last( $szFile ),"'</p>";
0462 ...     *}
0463 ...  *}}
0464 ...  */
0465 ... /* ====================================================================== */
0466 ... function FIL_AddBS( $szStr,$cMark = null )
0467 ... /*--------------------------------------*/
0468 ... {
0469 ...     if ( is_null( $cMark ) )                                        /* If no char passed to us */
0470 ...     {
0471 ...         $szOS = strtolower( PHP_OS );                               /* OS */
0472 ... 
0473 ...         switch ( $szOS )                                            /* In function of the OS */
0474 ...         {
0475 ...             // The following two lines have been commented out on
0476 ...             // 1/01/2012 17:52
0477 ...             //case 'linux':   $cMark = '/';   break;
0478 ...             //default     :   $cMark = '\\';  break;
0479 ...             default     :   $cMark = VAESOLI_SLASH;
0480 ...                             break;
0481 ...         }   /* switch ( $szOS ) */
0482 ...     }   /* if ( is_null( $cMark ) ) */
0483 ... 
0484 ...     if ( substr( $szStr,strlen( $szStr ) - 1,1 ) != $cMark )        /* If there is NO trailing backslash ... add one */
0485 ...     {
0486 ...        $szStr .= $cMark;                                            /* Add it to the string */
0487 ...     }   /* if ( substr( $szStr,strlen( $szStr ) - 1,1 ) != $cMark ) */
0488 ... 
0489 ...     return ( strtran( $szStr,$cMark . $cMark,$cMark ) );            /* Make sure that double slashes are turned to single slashes */
0490 ... }   /* End of function FIL_AddBS() */
0491 ... /* ====================================================================== */
0492 ... function ADDBS( $szStr ) { return ( FIL_AddBS( $szStr ) ); }
0493 ... 
0494 ... /* ====================================================================== */
0495 ... /** {{*FIL_Exists( $szFile,$szPath,$szFileSpec )=
0496 ... 
0497 ...     Determines if a file exists. Uses paths mentioned in $szPath if passed.
0498 ... 
0499 ...     {*params
0500 ...         $szFile     (string)        File whose existence must be checked
0501 ...         $szPath     (string)        Tokenized paths (';'). Optional.
0502 ...         $szFileSpec (string)        File that was found. Optional. Updated
0503 ...                                     upon return if passed.
0504 ...     *}
0505 ... 
0506 ...     {*remark
0507 ...         This function will also search the $szPath path if mentioned
0508 ...     *}
0509 ... 
0510 ...     {*return
0511 ...         (bool)  returns true if the specified file is found on disk
0512 ...                 (either current dir or in $szPath )
0513 ...     *}
0514 ... 
0515 ...     {*mdate
0516 ...         02/07/2012 - 08:42
0517 ...     *}
0518 ... 
0519 ...     {*example
0520 ...         // Example #1
0521 ...         if ( FIL_Exists( 'LSStrings.functions.php' ) )
0522 ...         {
0523 ...             // Do something
0524 ...         }
0525 ... 
0526 ...         // Example #2
0527 ...         // VAESOLI_INCLUDE is a manifest constant pointing to
0528 ...         // the installation of Vae Soli!
0529 ...         if ( FIL_Exists( 'LSStrings.functions.php',get_include_path() . PATH_SEPARATOR . VAESOLI_INCLUDE ) )
0530 ...         {
0531 ...             // Do something
0532 ...         }
0533 ... 
0534 ...         // Example #3
0535 ...         // VAESOLI_INCLUDE is a manifest constant pointing to
0536 ...         // the installation of Vae Soli!
0537 ...         // $szTheFile will be updated upon return with the
0538 ...         // exact filename that was found
0539 ...         $szTheFile = '';
0540 ...         if ( FIL_Exists( 'LSStrings.functions.php'                              ,
0541 ...                          get_include_path() . PATH_SEPARATOR . VAESOLI_INCLUDE  ,
0542 ...                          $szTheFile
0543 ...                        )
0544 ...            )
0545 ...         {
0546 ...             echo "<p>File found: {$szTheFile}</p>";
0547 ...         }
0548 ...     *}
0549 ... 
0550 ...     {*exec
0551 ...         if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
0552 ...         {
0553 ...             echo LSUnitTesting::assert( FIL_Exists( $szFile )                   ,
0554 ...                                         'ASSERTION SUCCESS: file exists'        ,
0555 ...                                         'ASSERTION FAILURE: file does NOT exist',
0556 ...                                         'GuideAssert' );
0557 ...             FIL_Delete( $szFile );
0558 ...             echo LSUnitTesting::assertFalse( FIL_Exists( $szFile )              ,
0559 ...                                         'ASSERTION SUCCESS: file does NOT exist',
0560 ...                                         'ASSERTION FAILURE: file exists'        ,
0561 ...                                         'GuideAssert' );
0562 ...         }
0563 ...     *}
0564 ... 
0565 ... 
0566 ...     {*assert
0567 ...         FIL_Exists( null ) === false
0568 ...     *}
0569 ... 
0570 ...     {*assert
0571 ...         FIL_Exists( '' ) === false
0572 ...     *}
0573 ... 
0574 ...     {*assert
0575 ...         FIL_Exists( '%georama%' ) === false
0576 ...     *}
0577 ... 
0578 ...     {*uses
0579 ...         FIL_Normalize()
0580 ...     *}
0581 ...  *}}
0582 ...  */
0583 ... /* ====================================================================== */
0584 ... function FIL_Exists( $szFile,$szPath = null,&$szFileSpec = null )
0585 ... /*-------------------------------------------------------------*/
0586 ... {
0587 ...     $bRetVal = false;                                               /* Default return value */
0588 ... 
0589 ...     if ( file_exists( $szFile ) )                                   /* Go away from here if file exists in current dir */
0590 ...     {
0591 ...         if ( func_num_args() === 3 )                                /* If 3rd parameter passed */
0592 ...         {
0593 ...             $szFileSpec = $szFile;                                  /* Update parameter (sent by reference) */
0594 ...         }   /* if ( func_num_args() == 3 ) */
0595 ...         return ( true );                                            /* Return a logical true */
0596 ...     }   /* if ( file_exists( $szFile ) ) */
0597 ... 
0598 ...     if ( ! STR_Empty( $szPath ) )                                   /* If we got down here ... it means that we need to use a path (if any) */
0599 ...     {
0600 ...         $aDirs = explode( ';',$szPath );                            /* Explode the path in smaller chunks */
0601 ... 
0602 ...         foreach ( $aDirs as $szDir )                                /* For each directory */
0603 ...         {
0604 ...             $szTmp = FIL_Normalize( trim( $szDir ) . '/' . $szFile );
0605 ... 
0606 ...             if ( file_exists( $szTmp ) )                            /* If file found */
0607 ...             {
0608 ...                 if ( func_num_args() === 3 )                        /* If 3rd parameter passed */
0609 ...                 {
0610 ...                     $szFileSpec = $szTmp;                           /* Update parameter (sent by reference) */
0611 ...                 }   /* if ( func_num_args() == 3 ) */
0612 ...                 return ( true );                                    /* Return a logical true */
0613 ...             }   /* if ( is_file( $szTmp ) ) */
0614 ...         }   /* foreach ( $aDirs as $szDir ) */
0615 ...     }   /* if ( ! STR_Empty( $szPath ) ) */
0616 ... 
0617 ...     if ( func_num_args() === 3 )                                    /* If 3rd parameter passed */
0618 ...     {
0619 ...         $szFileSpec = null;                                         /* Update parameter (sent by reference) */
0620 ...     }   /* if ( func_num_args() == 3 ) */
0621 ... 
0622 ...     return ( false );                                               /* Return result to caller (logical false) */
0623 ... }   /* End of function FIL_Exists() ========================================= */
0624 ... 
0625 ... /* ====================================================================== */
0626 ... /** {{*FIL_LinesCount( $szFile )=
0627 ... 
0628 ...     Determines the number of lines in a text file
0629 ... 
0630 ...     {*params
0631 ...         $szFile     (string)        File to examine
0632 ...     *}
0633 ... 
0634 ...     {*remark
0635 ...         Use this function only with text files
0636 ...     *}
0637 ... 
0638 ...     {*return
0639 ...         (int)   Number of lines
0640 ...     *}
0641 ... 
0642 ...     {*cdate 04/10/2013 - 19:42 *}
0643 ... 
0644 ...     {*exec
0645 ...         $szFile = 'C:\\websites\\latosensu.be\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php';
0646 ...         $iLines = FIL_LinesCount( $szFile );
0647 ...         echo LSUnitTesting::assert( $iLines > 3000 && $iLines < 4000            ,
0648 ...                                     'ASSERTION SUCCESS: file seems OK'          ,
0649 ...                                     'ASSERTION FAILURE: file does NOT seem OK'  ,
0650 ...                                     'GuideAssert' );
0651 ...         $szFile = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources\\ut\\bonjour.txt';
0652 ...         $iLines = FIL_LinesCount( $szFile );
0653 ...         echo FIL_FileToStr( $szFile );
0654 ...         echo LSUnitTesting::assert( $iLines == 9                            ,
0655 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'     ,
0656 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK' ,
0657 ...                                     'GuideAssert' );
0658 ...     *}
0659 ...  *}}
0660 ...         calculator.png */
0661 ... /* ====================================================================== */
0662 ... function FIL_LinesCount( $szFile )
0663 ... /*-------------------------------*/
0664 ... {
0665 ...     $iLineCount = 0;
0666 ... 
0667 ...     if ( FIL_Exists( $szFile ) )
0668 ...     {
0669 ...         if ( $handle = fopen( $szFile,'r' ) )
0670 ...         {
0671 ...             while( ! feof( $handle ) )
0672 ...             {
0673 ...                 fgets( $handle );
0674 ...                 $iLineCount++;
0675 ...             }
0676 ...             fclose( $handle );
0677 ...         }
0678 ...     }
0679 ... 
0680 ...     return ( $iLineCount );
0681 ... }   /* End of function FIL_LinesOfCode() ==================================== */
0682 ... 
0683 ... /* ========================================================================== */
0684 ... /** {{*FIL_IsDir( $szDir )=
0685 ... 
0686 ...     Determines if $szDir is a directory
0687 ... 
0688 ...     {*params
0689 ...         $szDir      (string)    Directory to test
0690 ...     *}
0691 ... 
0692 ...     {*return
0693 ...         (bool)                  true if $szDir is a directory; false otherwise
0694 ...     *}
0695 ... 
0696 ...     {*example
0697 ...         $szDir = "C:\\websites";
0698 ...         if ( FIL_IsDir( $szDir ) )
0699 ...         {
0700 ...             echo "<p>{$szDir} is a directory</p>\n";
0701 ...         }
0702 ...     *}
0703 ... 
0704 ...     {*seealso
0705 ...         FIL_MkDir()
0706 ...     *}
0707 ... 
0708 ...     *}}
0709 ...  */
0710 ... /* ====================================================================== */
0711 ... function FIL_IsDir( $szDir )
0712 ... /*------------------------*/
0713 ... {
0714 ...     return ( is_dir( $szDir ) );
0715 ... }   /* End of function FIL_IsDir() */
0716 ... /* ====================================================================== */
0717 ... 
0718 ... /* ====================================================================== */
0719 ... /** {{*FIL_DateTime( $szFile,$iRetType )=
0720 ... 
0721 ...     Determines the last modification datetime of a file
0722 ... 
0723 ...     {*params
0724 ...         $szFile     (string)    File whose last update datetime must be determined
0725 ...         $iRetType   (int)       Optional return type. 1 by default = 'YYYYMMDDHHmmSS'
0726 ...                                 string; any other integer value will return an array
0727 ...     *}
0728 ... 
0729 ...     {*warning
0730 ...         This function is provided for backward compatibility. It is recommended
0731 ...         to use [c]FIL_mTime()[/c] instead.
0732 ...     *}
0733 ... 
0734 ...     {*return
0735 ...         (mixed)     if $iRetType == 1, a YYYYMMDDHHmmSS string is returned or null
0736 ...                     if date cannot be obtained. if $iRetType != 1, an associative
0737 ...                     array is returned if all goes well (otherwise it is also a null)
0738 ...     *}
0739 ... 
0740 ...     {*example
0741 ...         echo "<p>Last update: " . FIL_DateTime( "C:\\websites\\myfile.txt" ) . "</p>\n";
0742 ...     *}
0743 ... 
0744 ... 
0745 ...     {*exec
0746 ...         var_dump( FIL_DateTime( 'C:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFiles.functions.php',2 ) );
0747 ...     *}
0748 ... 
0749 ...     *}}
0750 ...  */
0751 ... /* ====================================================================== */
0752 ... function FIL_DateTime( $szFile,$iRetType = 1 )
0753 ... /*------------------------------------------*/
0754 ... {
0755 ...     $xRetVal = null;                                                 /* Return value of the function */
0756 ... 
0757 ...     if ( $iTime = @filemtime( $szFile ) )                            /* If time obtained */
0758 ...     {
0759 ...         $szYear     = date( "Y",$iTime );
0760 ...         $szMonth    = date( "m",$iTime );
0761 ...         $szDay      = date( "d",$iTime );
0762 ...         $szHour     = date( "H",$iTime );
0763 ...         $szMinute   = date( "i",$iTime );
0764 ...         $szSecond   = date( "s",$iTime );
0765 ... 
0766 ...         if ( is_int( $iRetType ) && $iRetType == 1 )
0767 ...         {
0768 ...             $xRetVal = "{$szYear}{$szMonth}{$szDay}{$szHour}{$szMinute}{$szSecond}";
0769 ...         }
0770 ...         else
0771 ...         {
0772 ...             $xRetVal['YYYY'] = $szYear;
0773 ...             $xRetVal['MM'  ] = $szMonth;
0774 ...             $xRetVal['DD'  ] = $szDay;
0775 ...             $xRetVal['HH'  ] = $szHour;
0776 ...             $xRetVal['mm'  ] = $szMinute;
0777 ...             $xRetVal['SS'  ] = $szSecond;
0778 ...         }
0779 ...     }   /* if ( $iTime = filemtime( $szFile ) ) */
0780 ... 
0781 ...     return ( $xRetVal );                                            /* Return result to caller */
0782 ... }   /* End of function FIL_DateTime() */
0783 ... /* ====================================================================== */
0784 ... 
0785 ... /* ====================================================================== */
0786 ... /** {{*FIL_Size( $szFile )=
0787 ... 
0788 ...     Gets file size
0789 ... 
0790 ...     {*params
0791 ...         $szFile     (string)    File whose size must be determined
0792 ...     *}
0793 ... 
0794 ...     {*version
0795 ...         5.0.0003
0796 ...     *}
0797 ... 
0798 ...     {*cdate
0799 ...         27/06/2012 - 07:37
0800 ...     *}
0801 ... 
0802 ...     {*caution
0803 ...         May return unexpected results for files which are larger than 2GB.
0804 ...     *}
0805 ... 
0806 ...     {*return
0807 ...         (int)       Size in bytes or -1 in case of problem
0808 ...     *}
0809 ... 
0810 ...     {*example
0811 ...         if ( ( $iSize = FIL_Size( "C:\\websites\\myfile.txt" ) ) != -1 )
0812 ...         {
0813 ...             // can treat the file
0814 ...         }
0815 ...     *}
0816 ... 
0817 ...     *}}
0818 ...  */
0819 ... /* ====================================================================== */
0820 ... function FIL_Size( $szFile )
0821 ... /*------------------------*/
0822 ... {
0823 ...     $iSize = @filesize( $szFile );
0824 ...     return ( is_bool( $iSize ) ? -1 : $iSize );
0825 ... }   /* End of function FIL_Size() */
0826 ... /* ====================================================================== */
0827 ... 
0828 ... /* ====================================================================== */
0829 ... /** {{*FIL_Split( $szFile,$i )=
0830 ... 
0831 ...     Splits a filename into basic components (drive, path, filename, extension)
0832 ... 
0833 ...     {*params
0834 ...         $szFile     (string)    File that must be split
0835 ...         $i          (int)       Component part (1 = drive; 2 = path; 3 = filename;
0836 ...                                 4 = extension; 5 = all parts (returned as array))
0837 ...     *}
0838 ... 
0839 ...     {*version
0840 ...         2.0.0009
0841 ...     *}
0842 ... 
0843 ...     {*mdate
0844 ...         27/06/2012 - 11:09
0845 ...     *}
0846 ... 
0847 ...     {*return
0848 ...         (mixed)                Part that is expected if $i is between 1 and 4 (string);
0849 ...                                if $i == 5, return value is an array of file parts
0850 ...     *}
0851 ... 
0852 ...     {*assert
0853 ...         MISC_CastString( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',4 ) == '.xml' ) == 'true'
0854 ...     *}
0855 ... 
0856 ...     {*assert
0857 ...         FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',3 ) == 'myfile'
0858 ...     *}
0859 ... 
0860 ...     {*assert
0861 ...         is_array( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',5 ) ) == true
0862 ...     *}
0863 ... 
0864 ...     {*exec
0865 ...         echo '<p>' . MISC_CastString( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',4 ) == '.klm' ) . '</p>';
0866 ...         echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',1 )                              . '</p>';
0867 ...         echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',2 )                              . '</p>';
0868 ...         echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',3 )                              . '</p>';
0869 ...         echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',4 )                              . '</p>';
0870 ...         var_dump( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',5 ) );
0871 ...     *}
0872 ... 
0873 ...     {*uses
0874 ...         FIL_Normalize(), STRTRAN()
0875 ...     *}
0876 ... 
0877 ...     *}}
0878 ...  */
0879 ... /* ====================================================================== */
0880 ... function FIL_Split( $szFile,$i )
0881 ... /*----------------------------*/
0882 ... {
0883 ...     $xRetVal    = null;                                             /* Default return value of the function */
0884 ... 
0885 ...     $aParts     = pathinfo( $szFile );
0886 ... 
0887 ...     switch ( $i )
0888 ...     {
0889 ...         case    2:  $iPos = strpos( $aParts['dirname'],':' );
0890 ...                     if ( $iPos === false )
0891 ...                     {
0892 ...                         $xRetVal = FIL_Normalize( FIL_AddBS( $aParts['dirname'] ) );
0893 ...                     }
0894 ...                     else
0895 ...                     {
0896 ...                         $xRetVal = FIL_Normalize( FIL_AddBS( substr( $aParts['dirname'],$iPos + 1 ) ) );
0897 ...                     }
0898 ...                     break;
0899 ...         case    3:  $xRetVal = $aParts['basename' ];
0900 ...                     if ( isset( $aParts['extension'] ) )
0901 ...                     {
0902 ...                         $szExt    = $aParts['extension'];
0903 ...                     }
0904 ...                     else
0905 ...                     {
0906 ...                         $szExt    = '';
0907 ...                     }
0908 ...                     $xRetVal = STRTRAN( $xRetVal,'.' . $szExt,'' );
0909 ...                     break;
0910 ...         case    4:  if ( isset( $aParts['extension'] ) )
0911 ...                     {
0912 ...                         $xRetVal = '.' . $aParts['extension'];
0913 ...                     }
0914 ...                     else
0915 ...                     {
0916 ...                         $xRetVal = '';
0917 ...                     }
0918 ...                     break;
0919 ...         case    5:  $xRetVal = $aParts;
0920 ...                     if ( isset( $xRetVal['extension'] ) )
0921 ...                     {
0922 ...                         $xRetVal['extension'] = '.' . $xRetVal['extension'];
0923 ...                     }
0924 ...                     break;
0925 ...         default  :  $iPos = strpos( $aParts['dirname'],':' );
0926 ...                     if ( $iPos === false )
0927 ...                     {
0928 ...                         $xRetVal = $aParts['dirname'];
0929 ...                     }
0930 ...                     else
0931 ...                     {
0932 ...                         $xRetVal = STR_Left( $aParts['dirname'],$iPos + 1);
0933 ...                     }
0934 ...     }   /* switch ( $i ) */
0935 ... 
0936 ...     return ( $xRetVal );                                            /* Return result to caller */
0937 ... }   /* End of function FIL_Split() */
0938 ... /* ====================================================================== */
0939 ... 
0940 ... /* ====================================================================== */
0941 ... /** {{*FIL_CreateTemp( $szFileSpec )=
0942 ... 
0943 ...     Creates a temporary file
0944 ... 
0945 ...     {*params
0946 ...         $szFileSpec (string)    Temporary filename. This variable is not used
0947 ...                                 to create the temporary file: it is updated
0948 ...                                 upon return. Sent by reference.
0949 ...     *}
0950 ... 
0951 ...     {*version
0952 ...         1.1.0001
0953 ...     *}
0954 ... 
0955 ...     {*mdate
0956 ...         27/06/2012 - 15:06
0957 ...     *}
0958 ... 
0959 ...     {*return
0960 ...         (bool)      [c]true[/c] if temporary file succesfully created; [c]false[/c] if not
0961 ...     *}
0962 ... 
0963 ...     {*example
0964 ...         $szFile = '';
0965 ...         if ( FIL_CreateTmp( $szFile ) )
0966 ...         {
0967 ...             echo '<p>' . $szFile . ' created</p>';
0968 ...         }
0969 ...     *}
0970 ...     *}}
0971 ...  */
0972 ... /* ====================================================================== */
0973 ... function FIL_CreateTemp( &$szFileSpec )
0974 ... /*-----------------------------------*/
0975 ... {
0976 ...     $bRetVal = false;                                               /* Ready to return a logical false */
0977 ... 
0978 ...     $szTmpFileName = tempnam( VAESOLI_PATH . '/../tmp','FOO' );     /* Create a temporary file */
0979 ... 
0980 ...     if ( $szTmpFileName )                                           /* If we got something worth it */
0981 ...     {
0982 ...         $szFileSpec = $szTmpFileName;                               /* Update parameter */
0983 ...         $bRetVal    = true;                                         /* Ready to return a logical true */
0984 ...     }   /* if ( $szTmpFileName ) */
0985 ... 
0986 ...     return ( $bRetVal );                                            /* Return result to caller */
0987 ... }   /* End of function FIL_CreateTemp() */
0988 ... /* ====================================================================== */
0989 ... 
0990 ... /* ====================================================================== */
0991 ... /** {{*FIL_Chunk( $szFile,$iLineLength,$iMaxSize )=
0992 ... 
0993 ...     Splits a [b]text[/b] file into multiple parts
0994 ... 
0995 ...     {*params
0996 ...         $szFile         (string)    The file to split apart
0997 ...         $iLineLength    (int)       Optional line length for reading (in bytes). Default = [c]2048[/c].
0998 ...         $iMaxSize       (int)       Optional maximum size of split (in bytes). Default = [c]100000[/c].
0999 ...     *}
1000 ... 
1001 ...     {*warning
1002 ...         Do not use FIL_Chunk() on other files than text files! Please be
1003 ...         aware of the fact that the function stops writing to a part when
1004 ...         $iMaxSize has been reached. Therefore the resulting file is often
1005 ...         slightly bigger than $iMaxSize.
1006 ...         This function is still [b]experimental[/b]!
1007 ...     *}
1008 ... 
1009 ...     {*caution
1010 ...         Large files can take some time to be split in smaller chunks. Please
1011 ...         set the maximum execution limit accordingly ([c]set_time_limit()[/c])
1012 ...     *}
1013 ... 
1014 ...     {*version
1015 ...         5.0.0003
1016 ...     *}
1017 ... 
1018 ...     {*cdate
1019 ...         29/06/2012 - 12:42
1020 ...     *}
1021 ... 
1022 ...     {*mdate
1023 ...         16/01/2013 - 21:15
1024 ...     *}
1025 ... 
1026 ...     {*return
1027 ...         (int)   Number of parts written. Each part ends with a [c]".split"[/c] extension.
1028 ...                 For example, if [c]"traces-LATO.log"[/c] is split in 3 parts, 3 resulting
1029 ...                 files will be generated:[br][br]
1030 ...                 [c]traces-LATO.log-0.split[/c][br]
1031 ...                 [c]traces-LATO.log-1.split[/c][br]
1032 ...                 [c]traces-LATO.log-2.split[/c]
1033 ...     *}
1034 ... 
1035 ...     {*example
1036 ...         $szFile = 'mybiglogfile.log';
1037 ...         if ( ( $iParts = FIL_Chunk( $szFile ) ) > 0 )
1038 ...         {
1039 ...             echo '<p>' . $szFile . ' has been split in ' . $iParts . ' parts</p>';
1040 ...         }
1041 ...     *}
1042 ... 
1043 ...     {*seealso
1044 ...         FIL_Combine()
1045 ...     *}
1046 ...     *}}
1047 ...  */
1048 ... /* ====================================================================== */
1049 ... function FIL_Chunk( $szFile,$iLineLength = 2048,$iMaxSize = 100000 )
1050 ... /*----------------------------------------------------------------*/
1051 ... {
1052 ...     $iCount = 0;                                                    /* Return value of the function */
1053 ... 
1054 ...     if ( $nHandle = FIL_open( $szFile,'r+' ) )                      /* Open source file */
1055 ...     {
1056 ...         $szBuffer       = '';                                       /* Empty buffer to start with */
1057 ...         $iTotalLength   = 0;                                        /* We have read 0 bytes so far */
1058 ... 
1059 ...         while ( ( $szLine = fgets( $nHandle,$iLineLength ) ) != false )
1060 ...         {
1061 ...             $iLength        = strlen( $szLine );                    /* Line length */
1062 ...             $szBuffer       .= $szLine;                             /* Concatenate in buffer */
1063 ...             $iTotalLength   += $iLength;                            /* We have read that many bytes up to now */
1064 ... 
1065 ...             if ( $iTotalLength > $iMaxSize )                        /* If max size reached */
1066 ...             {
1067 ...                 $szFileOutput = "{$szFile}-{$iCount}.split";        /* Output file name */
1068 ... 
1069 ...                 if ( $nHandleOutput = fopen( $szFileOutput,"w+" ) ) /* Create an output file */
1070 ...                 {
1071 ...                     fwrite( $nHandleOutput,$szBuffer );             /* Write to output file */
1072 ...                     fclose( $nHandleOutput );                       /* Close output file */
1073 ...                     $szBuffer       = '';                           /* Clean buffer */
1074 ...                     $iTotalLength   = 0;                            /* Reset length we have read so far */
1075 ...                 }
1076 ...                 else
1077 ...                 {
1078 ...                     break;
1079 ...                 }
1080 ...                 $iCount++;                                          /* Increment count */
1081 ...             }
1082 ...         }
1083 ... 
1084 ...         if ( $iTotalLength > 0 )                                    /* If there is still something to be written (last chunk) */
1085 ...         {
1086 ...             $szFileOutput = "{$szFile}-{$iCount}.split";            /* Output file name */
1087 ... 
1088 ...             if ( $nHandleOutput = fopen( $szFileOutput,"w+" ) )     /* Create an output file */
1089 ...             {
1090 ...                 fwrite( $nHandleOutput,$szBuffer );                 /* Write to output file */
1091 ...                 fclose( $nHandleOutput );                           /* Close output file */
1092 ...             }
1093 ...         }
1094 ... 
1095 ...         fclose( $nHandle );                                         /* Close source file */
1096 ...     }
1097 ... 
1098 ...     return ( $iCount );                                             /* Return count */
1099 ... 
1100 ... }   /* End of function FIL_Chunk() */
1101 ... /* ====================================================================== */
1102 ... 
1103 ... /* ====================================================================== */
1104 ... /** {{*FIL_Combine( $szFile,$aFiles )=
1105 ... 
1106 ...     Combines multiple files ($aFiles) into a single file
1107 ... 
1108 ...     {*params
1109 ...         $szFile         (string)    The resulting file
1110 ...         $aFiles         (array)     Array of physical files to combine into $szFile
1111 ...     *}
1112 ... 
1113 ...     {*version
1114 ...         5.0.0003
1115 ...     *}
1116 ... 
1117 ...     {*cdate
1118 ...         01/07/2012 - 13:58
1119 ...     *}
1120 ... 
1121 ...     {*mdate
1122 ...         16/01/2013 - 21:15
1123 ...     *}
1124 ... 
1125 ...     {*caution
1126 ...         If $szFile exists it is overwritten
1127 ...     *}
1128 ... 
1129 ...     {*return
1130 ...         (int)   Total number of bytes written or -1 if error
1131 ...     *}
1132 ... 
1133 ...     {*example
1134 ...         $szFile = 'mybiglogfile.log';
1135 ...         if ( ( $iParts = FIL_Chunk( $szFile ) ) > 0 )
1136 ...         {
1137 ...             echo '<p>' . $szFile . ' has been split in ' . $iParts . ' parts'</p>';
1138 ...         }
1139 ...     *}
1140 ... 
1141 ...     {*seealso
1142 ...         FIL_Chunk()
1143 ...     *}
1144 ... 
1145 ...     {*uses
1146 ...         FIL_Open(), FIL_Write(), FIL_Close()
1147 ...     *}
1148 ... 
1149 ...     *}}
1150 ...  */
1151 ... /* ====================================================================== */
1152 ... function FIL_Combine( $szFile,$aFiles )
1153 ... /*-----------------------------------*/
1154 ... {
1155 ...     $iBytes = -1;                                                   /* Return value of the function */
1156 ... 
1157 ...     if ( $rHandleOutput = FIL_Open( $szFile,'w+' ) )                /* Create an output file */
1158 ...     {
1159 ...         foreach( $aFiles as $szInputFile )                          /* For each file found in the array */
1160 ...         {
1161 ...             /* Write input file to output file */
1162 ...             if ( ( $iCount = FIL_Write( $rHandleOutput,FIL_FileToStr( $szInputFile ) ) ) == -1 )
1163 ...             {
1164 ...                 $iBytes = -1;                                       /* Indicates a failure */
1165 ...                 break;                                              /* Stop here in case of problem */
1166 ...             }   /* if ( ( $iCount = FIL_Write( $rHandleOutput,FIL_FileToStr( $szInputFile ) ) ) == -1 ) */
1167 ...             else   /* Else of ... if ( ( $iCount = FIL_Write( $rHandleOutput,FIL_FileToStr( $szInputFile ) ) ) == -1 ) */
1168 ...             {
1169 ...                 $iBytes += $iCount;
1170 ...             }   /* End of ... Else of ... if ( ( $iCount = FIL_Write( $rHandleOutput,FIL_FileToStr( $szInputFile ) ) ) == -1 ) */
1171 ...         }   /* foreach( $aFiles as $szInputFile ) */
1172 ...         FIL_Close( $rHandleOutput );                                /* Close the output handle */
1173 ...     }   /* if ( $rHandleOutput = FIL_Open( $szFile,'w+' ) ) */
1174 ... 
1175 ...     return ( $iBytes );                                            /* Return result to caller */
1176 ... 
1177 ... }   /* End of function FIL_Combine() */
1178 ... /* ====================================================================== */
1179 ... 
1180 ... /* ====================================================================== */
1181 ... /** {{*FIL_Delete( $szFile )=
1182 ... 
1183 ...     Erases a file from disk
1184 ... 
1185 ...     {*params
1186 ...         $szFile     (string)    Specifies the file to delete
1187 ...     *}
1188 ... 
1189 ...     {*version
1190 ...         5.0.0003
1191 ...     *}
1192 ... 
1193 ...     {*cdate
1194 ...         27/06/2012 - 18:40
1195 ...     *}
1196 ... 
1197 ...     {*alias
1198 ...         FIL_Del()
1199 ...     *}
1200 ... 
1201 ...     {*return
1202 ...         (bool)      [c]true[/c] if $szFile successfully deleted; [c]false[/c] otherwise
1203 ...     *}
1204 ... 
1205 ...     {*exemple
1206 ...         $szFile = '';
1207 ...         if ( FIL_CreateTmp( $szFile ) )
1208 ...         {
1209 ...             echo '<p>' . $szFile . ' created</p>';
1210 ...             if ( FIL_Del( $szFile ) )
1211 ...             {
1212 ...                 echo "<p>And now {$szFile} has been successfully deleted</p>";
1213 ...             }
1214 ...             else
1215 ...             {
1216 ...                 echo "<p>Cannot delete {$szFile}!</p>";
1217 ...             }
1218 ...         }
1219 ...     *}
1220 ... 
1221 ...     {*seealso
1222 ...         FIL_Rename(), FIL_Copy()
1223 ...     *}
1224 ...     *}}
1225 ...  */
1226 ... /* ========================================================================== */
1227 ... function FIL_Delete( $szFile )
1228 ... /*--------------------------*/
1229 ... {
1230 ...     if ( ! ( $bRetVal = @unlink( $szFile ) ) )                      /* If deletion NOT successful */
1231 ...     {
1232 ...         if ( FIL_IsDir( $szFile ) )                                 /* If a directory */
1233 ...         {
1234 ...             $bRetVal = @rmdir( $szFile );                           /* Remove directory (must be empty) */
1235 ...             //echo "DELETE DIR";
1236 ...         }   /* if ( FIL_IsDir( $szFile ) ) */
1237 ...     }   /* if ( ! ( $bRetVal = @unlink( $szFile ) ) ) */
1238 ... 
1239 ...     return ( $bRetVal );                                            /* Return result to caller */
1240 ... }   /* End of function FIL_Delete() ========================================= */
1241 ... function FIL_Del( $szFileSpec  ) { return FIL_Delete( $szFileSpec ); }
1242 ... 
1243 ... /* ========================================================================== */
1244 ... /** {{*FIL_Rename( $szSrc,$szDest )=
1245 ... 
1246 ...     Renames (moves) $szSrc to $szDest
1247 ... 
1248 ...     {*params
1249 ...         $szSrc      (string)    Old filename
1250 ...         $szDest     (string)    New filename
1251 ...     *}
1252 ... 
1253 ...     {*caution
1254 ...         Physical file name (fully qualified) must be mentioned. Use
1255 ...         [c]FIL_ResolveRoot()[/c] to transform a logical filename into a physical
1256 ...         filename.
1257 ...     *}
1258 ... 
1259 ...     {*version
1260 ...         2.1.0000
1261 ...     *}
1262 ... 
1263 ...     {*alias
1264 ...         FIL_Move()
1265 ...     *}
1266 ... 
1267 ...     {*return
1268 ...         (bool)      true if $szSrc successfully renamed to $szDest; false otherwise
1269 ...     *}
1270 ... 
1271 ...     {*exemple
1272 ...         if ( FIL_Rename( FIL_ResolveRoot( '/images/img001.jpg' ),
1273 ...                          FIL_ResolveRoot( '/images/img001.bak' ),
1274 ...                        )
1275 ...            )
1276 ...         {
1277 ...             echo '<p>File successfully renamed</p>';
1278 ...         }
1279 ...     *}
1280 ... 
1281 ...     {*seealso
1282 ...         FIL_Delete(), FIL_Copy()
1283 ...     *}
1284 ... 
1285 ...     *}}
1286 ...  */
1287 ... /* ====================================================================== */
1288 ... function FIL_Rename( $szSrc,$szDest )
1289 ... /*---------------------------------*/
1290 ... {
1291 ...     return ( @rename( $szSrc,$szDest ) );
1292 ... }   /* End of function FIL_Rename() */
1293 ... /* ====================================================================== */
1294 ... function FIL_Move( $szSrc,$szDest ) { return FIL_Rename( $szSrc,$szDest ); }
1295 ... 
1296 ... /* ====================================================================== */
1297 ... /** {{*FIL_Create( $szFile )=
1298 ... 
1299 ...     Creates a file
1300 ... 
1301 ...     {*params
1302 ...         $szFile     (string)    Specifies the file to create
1303 ...     *}
1304 ... 
1305 ...     {*version
1306 ...         5.0.0012
1307 ...     *}
1308 ... 
1309 ...     {*cdate
1310 ...         16/01/2013 - 11:28
1311 ...     *}
1312 ... 
1313 ...     {*return
1314 ...         (res)      resource handle to file if function is successful; [c]null[/c] otherwise
1315 ...     *}
1316 ... 
1317 ...     {*example
1318 ...         // Creates a file in read and write mode
1319 ...         if ( $rHandle = FIL_Create( $szFile ) )
1320 ...         {
1321 ...             // While NOT End Of File
1322 ...             while ( ! FIL_EOF( $rHandle ) )
1323 ...             {
1324 ...                 $szLine = FIL_Gets( $rHandle,512 );
1325 ...             }
1326 ... 
1327 ...             // Close file when no longer needed
1328 ...             FIL_Close( $rHandle );
1329 ...         }
1330 ...     *}
1331 ... 
1332 ...     {*seealso
1333 ...         FIL_Open(), FIL_Close()
1334 ...     *}
1335 ... 
1336 ...     *}}
1337 ...  */
1338 ... /* ====================================================================== */
1339 ... function FIL_Create( $szFile )
1340 ... /*--------------------------*/
1341 ... {
1342 ...     return ( fopen( $szFile,'w+' ) );               /* Return result to caller */
1343 ... }   /* End of function FIL_Create() */
1344 ... /* ====================================================================== */
1345 ... 
1346 ... /* ====================================================================== */
1347 ... /** {{*FIL_Open( $szFile[,$szMode] )=
1348 ... 
1349 ...     Opens file
1350 ... 
1351 ...     {*params
1352 ...         $szFile     (string)    Specifies the file to open
1353 ...         $szMode     (string)    Optional opening mode ([c]r[/c], [c]r+[/c], [c]w[/c],
1354 ...                                 [c]w+[/c], [c]a[/c], [c]a+[/c], [c]x[/c], [c]x+[/c]).
1355 ...                                 [c]'r'[/c] by default. See [c]open()[/c] function
1356 ...                                 of PHP for more doc.
1357 ...     *}
1358 ... 
1359 ...     {*version
1360 ...         5.0.0003
1361 ...     *}
1362 ... 
1363 ...     {*cdate
1364 ...         27/06/2012 - 18:40
1365 ...     *}
1366 ... 
1367 ...     {*return
1368 ...         (res)      resource handle to file if function is successful; null otherwise
1369 ...     *}
1370 ... 
1371 ...     {*example
1372 ...         // Open file in read mode
1373 ...         if ( $rHandle = FIL_Open( $szFile,'r+' ) )
1374 ...         {
1375 ...             // While NOT End Of File
1376 ...             while ( ! FIL_EOF( $rHandle ) )
1377 ...             {
1378 ...                 $szLine = FIL_Gets( $rHandle,512 );
1379 ...             }
1380 ... 
1381 ...             // Close file when no longer needed
1382 ...             FIL_Close( $rHandle );
1383 ...         }
1384 ...     *}
1385 ... 
1386 ...     {*seealso
1387 ...         FIL_Close(), FIL_Create()
1388 ...     *}
1389 ... 
1390 ...     *}}
1391 ...  */
1392 ... /* ====================================================================== */
1393 ... function FIL_Open( $szFile,$szMode = 'r' )
1394 ... /*--------------------------------------*/
1395 ... {
1396 ...     $rHandle = @fopen( $szFile,$szMode );
1397 ...     return ( is_bool( $rHandle ) ? null : $rHandle );
1398 ... }   /* End of function FIL_Open() */
1399 ... /* ====================================================================== */
1400 ... 
1401 ... /* ====================================================================== */
1402 ... /** {{*FIL_Close( $rHandle )=
1403 ... 
1404 ...     Closes file
1405 ... 
1406 ...     {*params
1407 ...         $rHandle    (res)       Resource handle of the file
1408 ...     *}
1409 ... 
1410 ...     {*version
1411 ...         5.0.0003
1412 ...     *}
1413 ... 
1414 ...     {*cdate
1415 ...         27/06/2012 - 18:46
1416 ...     *}
1417 ... 
1418 ...     {*return
1419 ...         (bool)      true if file is succesfully closed; false otherwise
1420 ...     *}
1421 ... 
1422 ...     {*example
1423 ...         // Open file in read mode
1424 ...         if ( $rHandle = FIL_Open( $szFile,'r+' ) )
1425 ...         {
1426 ...             // While NOT End Of File
1427 ...             while ( ! FIL_EOF( $rHandle ) )
1428 ...             {
1429 ...                 $szLine = FIL_Gets( $rHandle,512 );
1430 ...             }
1431 ... 
1432 ...             // Close file when no longer needed
1433 ...             FIL_Close( $rHandle );
1434 ...         }
1435 ...     *}
1436 ... 
1437 ...     {*seealso
1438 ...         FIL_Open(), FIL_Create()
1439 ...     *}
1440 ... 
1441 ...     *}}
1442 ...  */
1443 ... /* ====================================================================== */
1444 ... function FIL_Close( $rHandle )
1445 ... /*--------------------------*/
1446 ... {
1447 ...     return ( @fclose( $rHandle ) );
1448 ... }   /* End of function FIL_Close() */
1449 ... /* ====================================================================== */
1450 ... 
1451 ... /* ====================================================================== */
1452 ... /** {{*FIL_Gets( $rHandle[,$iLength] )=
1453 ... 
1454 ...     Get next line of file
1455 ... 
1456 ...     {*params
1457 ...         $rHandle    (res)       Resource handle of the file to get content from
1458 ...         $iLength    (int)       Maximum line length. Optional. 1024 by default
1459 ...     *}
1460 ... 
1461 ...     {*version
1462 ...         5.0.0003
1463 ...     *}
1464 ... 
1465 ...     {*cdate
1466 ...         27/06/2012 - 19:28
1467 ...     *}
1468 ... 
1469 ...     {*mdate
1470 ...         03/12/2012 - 11:19
1471 ...     *}
1472 ... 
1473 ...     {*return
1474 ...         (string)      Next line from file. [c]false[/c] if end of file encountered.
1475 ...     *}
1476 ... 
1477 ...     {*seealso   FIL_Open(), FIL_Close() *}
1478 ... 
1479 ...     {*example
1480 ...         // Open file in read mode
1481 ...         if ( $rHandle = FIL_Open( $szFile,'r+' ) )
1482 ...         {
1483 ...             // While NOT End Of File
1484 ...             while ( ! FIL_EOF( $rHandle ) )
1485 ...             {
1486 ...                 $szLine = FIL_Gets( $rHandle,512 );
1487 ...             }
1488 ... 
1489 ...             // Close file when no longer needed
1490 ...             FIL_Close( $rHandle );
1491 ...         }
1492 ...     *}
1493 ...     *}}
1494 ...  */
1495 ... /* ====================================================================== */
1496 ... function FIL_Gets( $rHandle,$iLength = 1024 )
1497 ... /*-----------------------------------------*/
1498 ... {
1499 ...     return ( @fgets( $rHandle,$iLength ) );
1500 ... }   /* End of function FIL_Gets() */
1501 ... /* ====================================================================== */
1502 ... 
1503 ... /* ====================================================================== */
1504 ... /** {{*FIL_BuildBackupName( $szFile )=
1505 ... 
1506 ...     Creates a pseudo backup name
1507 ... 
1508 ...     {*params
1509 ...         $szFile     (string)    Original file name
1510 ...     *}
1511 ... 
1512 ...     {*version
1513 ...         5.0.0003
1514 ...     *}
1515 ... 
1516 ...     {*cdate
1517 ...         27/06/2012 - 19:28
1518 ...     *}
1519 ... 
1520 ...     {*mdate
1521 ...         18/01/2013 - 09:24
1522 ...     *}
1523 ... 
1524 ...     {*return
1525 ...         (string)    Backup name (the name of the original file is
1526 ...                     appended with the time, microtime and a
1527 ...                     '.safe' extension)
1528 ...     *}
1529 ... 
1530 ...     {*exec
1531 ...         $szFile = 'C:\\mydir\\dir2\\waow.txt';
1532 ...         echo '<p>',FIL_BuildBackupName( $szFile ),'</p>';
1533 ...     *}
1534 ... 
1535 ...     {*seealso
1536 ...         FIL_Now()
1537 ...     *}
1538 ... 
1539 ...     *}}
1540 ...  */
1541 ... /* ====================================================================== */
1542 ... function FIL_BuildBackupName( $szFile )
1543 ... /*-----------------------------------*/
1544 ... {
1545 ...     return ( $szFile . '.' . time() . '.' . (int) microtime( true) . '.safe' );
1546 ... }   /* End of FIL_BuildBackupName() */
1547 ... /* ====================================================================== */
1548 ... 
1549 ... /* ====================================================================== */
1550 ... /** {{*FIL_Copy( $szSrc,$szDest )=
1551 ... 
1552 ...     Copies $szSrc to $szDest
1553 ... 
1554 ...     {*params
1555 ...         $szSrc  (string)    Source file
1556 ...         $szDest (string)    Target file
1557 ...     *}
1558 ... 
1559 ...     {*version
1560 ...         5.0.0003
1561 ...     *}
1562 ... 
1563 ...     {*cdate
1564 ...         27/06/2012 - 19:28
1565 ...     *}
1566 ... 
1567 ...     {*mdate
1568 ...         18/01/2013 - 09:24
1569 ...     *}
1570 ... 
1571 ...     {*return
1572 ...         (bool)  [c]true[/c] if $szSrc successfully copied to $szDest;
1573 ...                 [c]false[/c] if not.
1574 ...     *}
1575 ... 
1576 ...     {*example
1577 ...         if ( ! FIL_Copy( $szSrc,$szDest ) )
1578 ...         {
1579 ...             echo "<p>'{$szSrc}' cannot be copied to '{$szDest}'</p>";
1580 ...         }
1581 ...     *}
1582 ...     *}}
1583 ...  */
1584 ... /* ====================================================================== */
1585 ... function FIL_Copy( $szSrc,$szDest )
1586 ... /*-------------------------------*/
1587 ... {
1588 ...     return ( copy( $szSrc,$szDest ) );
1589 ... }   /* End of FIL_Copy() */
1590 ... /* ====================================================================== */
1591 ... 
1592 ... /* ====================================================================== */
1593 ... /** {{*FIL_Normalize( $szPath[,$bShorten] )=
1594 ... 
1595 ...     Normalizes $szPath and possibly shorten the name ([c]'..'[/c] treatment)
1596 ... 
1597 ...     {*params
1598 ...         $szPath     (string)    Path to normalize
1599 ...         $bShorten   (bool)      Optional. [c]false[/c] by default.
1600 ...     *}
1601 ... 
1602 ...     {*version
1603 ...         5.0.0003
1604 ...     *}
1605 ... 
1606 ...     {*cdate
1607 ...         27/06/2012 - 19:28
1608 ...     *}
1609 ... 
1610 ...     {*mdate
1611 ...         18/01/2013 - 09:24
1612 ...     *}
1613 ... 
1614 ...     {*return
1615 ...         (string)    $szPath normalized and potentially shortened
1616 ...     *}
1617 ... 
1618 ...     {*assert
1619 ...         FIL_Normalize( 'C:/MYDIR/MYSUBDIR/../MYFILE.TXT' ) === 'C:\MYDIR\MYSUBDIR\..\MYFILE.TXT'
1620 ...     *}
1621 ... 
1622 ...     {*assert
1623 ...         FIL_Normalize( 'C:/MYDIR/MYSUBDIR/../MYFILE.TXT',true ) === 'C:\MYDIR\MYFILE.TXT'
1624 ...     *}
1625 ... 
1626 ...     {*uses
1627 ...         FIL_RealPath()
1628 ...     *}
1629 ... 
1630 ...     {*seealso
1631 ...         FIL_RealPath()
1632 ...     *}
1633 ...     *}}
1634 ...  */
1635 ... /* ====================================================================== */
1636 ... function FIL_Normalize( $szPath,$bShorten = false )
1637 ... /*-----------------------------------------------*/
1638 ... {
1639 ...     $szPath = str_replace( '\\','/',$szPath );                      /* Let's first turn all backslashes to forward slashes */
1640 ...     $szPath = str_replace( '//','/',$szPath );                      /* Turn double slashes into single slash */
1641 ... 
1642 ...     if ( $bShorten )                                                /* If '..' must be treated as parent dirs */
1643 ...     {
1644 ...         return ( FIL_RealPath( $szPath ) );                         /* Recursion ... BUT no shorten */
1645 ...     }   /* if ( $bShorten ) */
1646 ... 
1647 ...     switch ( strtoupper( PHP_OS ) )                                 /* In function of the OS */
1648 ...     {
1649 ...         case 'WINNT'    :
1650 ...         case 'WINDOWS'  :
1651 ...         case 'WIN32'    :
1652 ...         case 'WIN'      :   $szPath = str_replace( '/','\\',$szPath );
1653 ...                             break;
1654 ...         case 'AIX'      :
1655 ...         case 'LINUX'    :
1656 ...         case 'OS400'    :
1657 ...         case 'MAC'      :
1658 ...         default         :   $szPath = str_replace( '\\','/',$szPath );
1659 ...                             break;
1660 ...     }   /* switch ( strtoupper( PHP_OS ) ) */
1661 ... 
1662 ...     return ( $szPath );                                             /* Return result to caller */
1663 ... 
1664 ... }   /* End of FIL_Normalize() */
1665 ... /* ====================================================================== */
1666 ... 
1667 ... /* ====================================================================== */
1668 ... /** {{*FIL_Now()=
1669 ... 
1670 ...     Returns a file name in the [c]YYYYMMDDHHmmSSXXXXXXXXXX[/c] format.
1671 ... 
1672 ...     {*params
1673 ...     *}
1674 ... 
1675 ...     {*remark
1676 ... 
1677 ...         [p][c]FIL_Now()[/c] makes it possible to determine a filename that corresponds
1678 ...         to the NOW moment. YYYY stands for the year, MM for the month, DD
1679 ...         for the day, HH for the hour, mm for the minutes, SS for the
1680 ...         seconds, and XXXXXXXXXX for the tick count (the tick count is left
1681 ...         padded with "0").[/p]
1682 ... 
1683 ...         [p][c]FIL_Now()[/c] makes it very easy to get a filename that is most likely
1684 ...         to be unique (although strictly speaking a file with the same name
1685 ...         might already be existing) and that can be used to store sequential
1686 ...         information.[/p]
1687 ... 
1688 ...         [p][c]FIL_Now()[/c] does not create the file.[/p]
1689 ...     *}
1690 ... 
1691 ...     {*return
1692 ...         (string)    Resulting filename.
1693 ...     *}
1694 ... 
1695 ...     {*example
1696 ...         echo FIL_Now();    // prints something similar to "201210291721330030346194"
1697 ...     *}
1698 ... 
1699 ...     {*seealso
1700 ...         FIL_BuildBackupName()
1701 ...     *}
1702 ...     *}}
1703 ...  */
1704 ... /* ====================================================================== */
1705 ... function FIL_Now()
1706 ... /*--------------*/
1707 ... {
1708 ...     return ( str_replace( '.','', date( 'YmdHis' ) . microtime( true ) ) );
1709 ... }   /* End of FIL_now() */
1710 ... /* ====================================================================== */
1711 ... 
1712 ... /* ====================================================================== */
1713 ... /** {{*FIL_RevertRoot( $szFileSpec,$szRoot )=
1714 ... 
1715 ...     Determines the site file compared to the root directory of the site.
1716 ...     Opposite function of [c]FIL_ResolveRoot()[/c].
1717 ... 
1718 ...     {*params
1719 ...         $szFileSpec (string)    Physical filename
1720 ...         $szRoot     (string)    Root of the site. Optional. By default we
1721 ...                                 use the value of $_SERVER['DOCUMENT_ROOT']
1722 ...     *}
1723 ... 
1724 ...     {*warning
1725 ...         Depending on the version of PHP and the proper handling of junctions
1726 ...         (symbolic links) the function can return weird results
1727 ...     *}
1728 ... 
1729 ...     {*return
1730 ...         (string)    Logical path compared to $szRoot
1731 ...     *}
1732 ... 
1733 ...     {*example
1734 ...         echo FIL_ResolveRoot( 'c:\websites\mysite\www\httpdocs\images\logo.png' )  // '/images/logo.png'
1735 ...     *}
1736 ... 
1737 ...     {*seealso
1738 ...         FIL_ResolveRoot()
1739 ...     *}
1740 ... 
1741 ...     *}}
1742 ...  */
1743 ... /* ====================================================================== */
1744 ... function FIL_RevertRoot( $szFileSpec,$szRoot = null )
1745 ... /*--------------------------------------------------*/
1746 ... {
1747 ...     $szFile = $szFileSpec;                                          /* Default return value */
1748 ... 
1749 ...     if ( is_null( $szRoot ) )                                       /* If root NOT passed */
1750 ...     {
1751 ...         $szRoot = $_SERVER['DOCUMENT_ROOT'];                        /* Use the site root by default */
1752 ...     }   /* if ( is_null( $szRoot ) ) */
1753 ... 
1754 ...     if ( strlen( $szRoot ) )                                        /* If the root of the web site is known */
1755 ...     {
1756 ...         $szRoot = FIL_Normalize( $szRoot );                         /* Normalize the root spec */
1757 ...         //echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . ": La root vaut : {$szRoot}</p>\n";
1758 ... 
1759 ...         if ( strlen( $szFileSpec ) )                                /* If file specifier */
1760 ...         {
1761 ...             $szFileSpec = FIL_Normalize( $szFileSpec );
1762 ...             //echo "<p style=\"font-size:2em;color:#000;\">Après normalisation:" . $szFileSpec . "</p>\n";
1763 ... 
1764 ...             if ( $szFileSpec[0] != '/' )                            /* If NOT starting with '/' */
1765 ...             {
1766 ...                 //if ( stristr( $szFileSpec,'5522f83f-f238-4e8b-a633-a678b23fc4f9' ) )
1767 ...                 //{
1768 ...                 //    echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . " at line " . __LINE__ . " : Le fichier vaut : {$szFileSpec}</p>\n";
1769 ...                 //    echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . " at line " . __LINE__ . " : La root vaut : {$szRoot}</p>\n";
1770 ...                 //}
1771 ... 
1772 ...                 // -- Commentaire: le 19/03/2011
1773 ...                 $szFileSpec = str_replace( array( $szRoot,dirname( __FILE__ ),'\\' ),
1774 ...                                            array( ''     ,''                 ,'/'  ),
1775 ...                                            $szFileSpec );
1776 ...                 //if ( stristr( $szFileSpec,'5522f83f-f238-4e8b-a633-a678b23fc4f9' ) )
1777 ...                 //{
1778 ...                 //    echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . " at line " . __LINE__ . " : Le fichier vaut : {$szFileSpec}</p>\n";
1779 ...                 //}
1780 ... 
1781 ...                 //$szFileSpec = realpath( $szFileSpec );
1782 ... 
1783 ...                 //if ( stristr( $szFileSpec,'5522f83f-f238-4e8b-a633-a678b23fc4f9' ) )
1784 ...                 //{
1785 ...                 //    echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . " at line " . __LINE__ . " : Le fichier vaut : {$szFileSpec}</p>\n";
1786 ...                 //}
1787 ... 
1788 ...                 //echo "<p style=\"font-size:2em;color:#000;\">Après str_replace() des backslashes en slashes : szFileSpec = {$szFileSpec}</p>\n";
1789 ...                 // -- Commentaire: le 19/03/2011
1790 ...                 // -- $szFile = STRTRAN( STRTRAN( $szFileSpec,'\\','/' ),STRTRAN( $szRoot,'\\','/' ),'' );
1791 ... 
1792 ...                 //echo "<p>Je dois remplacer '{$szRoot}' par rien dans {$szFileSpec}</p>\n";
1793 ... 
1794 ...                 //$szFile = str_replace( $szRoot,'',$szFileSpec );
1795 ...                 $szFile = $szFileSpec;
1796 ... 
1797 ...                 //if ( stristr( $szFileSpec,'5522f83f-f238-4e8b-a633-a678b23fc4f9' ) )
1798 ...                 //{
1799 ...                 //    echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . " at line " . __LINE__ . " : Le résultat FINAL vaut : {$szFile}</p>\n";
1800 ...                 //}
1801 ... 
1802 ...                 //echo "<p style=\"font-size:2em;color:#000;\">" . __FUNCTION__ . ": Fichier résultat: {$szFile}</p>\n";
1803 ...             }
1804 ...         }   /* if ( strlen( $szFileSpec ) ) */
1805 ...     }   /* if ( strlen( $szRoot ) ) */
1806 ...     else
1807 ...     {
1808 ...         //echo "<p>Pas de root</p>";
1809 ...     }
1810 ... 
1811 ...     //echo "<p style=\"font-size:2em;color:#000;\">Résultat final: szFileSpec = {$szFileSpec}</p>\n";
1812 ... 
1813 ...     return ( $szFile );
1814 ... }   /* End of FIL_RevertRoot() ========================================== */
1815 ... 
1816 ... /* ====================================================================== */
1817 ... /** {{*FIL_ResolveRoot( $szFileSpec,$szRoot )=
1818 ... 
1819 ...     Resolves the path of a file from the root directory of the site
1820 ... 
1821 ...     {*params
1822 ...         $szFileSpec (string)    Filename (relative path can be included)
1823 ...         $szRoot     (string)    Root of the site. Optional. By default we
1824 ...                                 use the value of [c]$_SERVER['DOCUMENT_ROOT'][/c]
1825 ...     *}
1826 ... 
1827 ...     {*warning
1828 ...         The function won't work properly with junctions (WinNT)
1829 ...     *}
1830 ... 
1831 ...     {*return
1832 ...         (string)    Complete physical path
1833 ...     *}
1834 ... 
1835 ...     {*example
1836 ...         echo FIL_ResolveRoot( '/images/logo.png' )  // 'c:\websites\mysite\www\httpdocs\images\logo.png'
1837 ...     *}
1838 ... 
1839 ...     {*seealso
1840 ...         FIL_RevertRoot()
1841 ...     *}
1842 ... 
1843 ...     *}}
1844 ...  */
1845 ... /* ====================================================================== */
1846 ... function FIL_ResolveRoot( $szFileSpec,$szRoot = null )
1847 ... /*--------------------------------------------------*/
1848 ... {
1849 ...     if ( is_null( $szRoot ) )                                       /* If root NOT passed */
1850 ...     {
1851 ...         $szRoot = $_SERVER['DOCUMENT_ROOT'];                        /* Use the site root by default */
1852 ...     }   /* if ( is_null( $szRoot ) ) */
1853 ... 
1854 ...     if ( strtoupper( PHP_OS ) == 'DARWIN' )                         /* If MAC */
1855 ...     {
1856 ...         if ( is_file( $szFileSpec ) )                               /* If file exists */
1857 ...         {
1858 ...             return ( $szFileSpec );                                 /* Return simply the name that was passed to us */
1859 ...         }   /* if ( is_file( $szFileSpec ) ) */
1860 ...     }   /* if ( strtoupper( PHP_OS ) == 'DARWIN' ) */
1861 ... 
1862 ...     /* If starting slash ... this must be the root of the site */
1863 ...     if ( ! is_null( $szFileSpec ) && ! empty( $szFileSpec ) && ( $szFileSpec[0] == '/' || $szFileSpec[0] == '\\' ) )
1864 ...     {                                                               /* then it must be evaluated towards the root of the site */
1865 ...         //echo "<p>On commence par un slash</p>";
1866 ...         $iFileSpecLength = strlen( $szFileSpec );                   /* Length of the Filename */
1867 ...         $iRootLength     = strlen( $szRoot );                       /* Length of the root path of the site */
1868 ... 
1869 ...         if ( $iFileSpecLength >= $iRootLength )                     /* If FileSpec longer than root */
1870 ...         {
1871 ...             $szFirstPart = strtolower(                              /* Extract the n first characters of the FileSpec */
1872 ...                                 strleft( $szFileSpec,$iRootLength )
1873 ...                                      );
1874 ... 
1875 ...             if ( $szFirstPart != strtolower( $szRoot ) )            /* If root not already in front of the FileSpec */
1876 ...             {
1877 ...                 $szFileSpec = $szRoot . $szFileSpec;                /* Add the root to it */
1878 ...             }   /* if ( $szFirstPart != strtolower( $szRoot ) ) */
1879 ...         }   /* if ( $iFileSpecLength >= $iRootLength ) */
1880 ...         else   /* Else of ... if ( $iFileSpecLength >= $iRootLength ) */
1881 ...         {
1882 ...             $szFileSpec = $szRoot . $szFileSpec;                    /* Add the root */
1883 ...         }   /* End of ... Else of ... if ( $iFileSpecLength >= $iRootLength ) */
1884 ... 
1885 ...     } /* if ( $szFileSpec[0] == '/' ) */
1886 ...     else
1887 ...     {
1888 ...         //echo "<p>-On commence par {$szFileSpec[0]}$szFileSpec[1]$szFileSpec[2]$szFileSpec[3] pour {$szFileSpec}</p>";
1889 ...     }
1890 ... 
1891 ...     return ( $szFileSpec );
1892 ... }   /* End of FIL_ResolveRoot() ============================================= */
1893 ... 
1894 ... /* ========================================================================== */
1895 ... /** {{*FIL_FileToStr( $szFile )=
1896 ... 
1897 ...     Returns the contents of a file as a character string.
1898 ... 
1899 ...     {*params
1900 ...         $szFile     (string)    Specifies the name of the file whose contents are returned as a character string
1901 ...     *}
1902 ... 
1903 ...     {*mdate
1904 ...         27/06/2012 - 11:34
1905 ...     *}
1906 ... 
1907 ...     {*return
1908 ...         (string)    Character string (file content)
1909 ...     *}
1910 ... 
1911 ...     {*alias
1912 ...         FIL_Read(), FIL_File2Str(), File2Str(), FileToStr()
1913 ...     *}
1914 ... 
1915 ...     {*example
1916 ...         $szStr = FIL_FileToStr( 'c:\website\mine\www\httpdocs\myfile.xml' ); / Read XML file
1917 ... 
1918 ...         if ( ! STR_Empty( $szStr ) )                                        // If got something
1919 ...         {
1920 ...             $oDom = new DOMDocument();                                      // Create a new DOM
1921 ...             if ( $oDom->loadXML( $szStr ) )                                 // Loads XML string
1922 ...             {
1923 ...                 echo $doc->saveXML();                                       // echo XML
1924 ...             }
1925 ...         }
1926 ...     *}
1927 ... 
1928 ...     {*exec
1929 ...         if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
1930 ...         {
1931 ...             $szContent = FIL_FileToStr( $szFile );
1932 ...             echo LSUnitTesting::assert( $szContent === $szStr                       ,
1933 ...                                         'ASSERTION SUCCESS: successful write & read',
1934 ...                                         'ASSERTION FAILURE: invalid resource'       ,
1935 ...                                         'GuideAssert' );
1936 ...             FIL_Delete( $szFile );
1937 ...         }
1938 ...     *}
1939 ... 
1940 ...     {*seealso
1941 ...         FIL_FileToStrEx()
1942 ...     *}
1943 ... 
1944 ...     *}}
1945 ...  */
1946 ... /* ====================================================================== */
1947 ... function FIL_FileToStr( $szFile )
1948 ... /*-----------------------------*/
1949 ... {
1950 ...     $szRetVal   = '';                                               /* Return value of the function (empty by default) */
1951 ... 
1952 ...     if ( ( $rh = @fopen( $szFile,'r' ) ) == true )                  /* If file could be opened */
1953 ...     {
1954 ...         $aFileStats = stat( $szFile );                              /* File stats */
1955 ...         $szRetVal   = @fread( $rh,$aFileStats['size'] );            /* Read the entire file */
1956 ...         @fclose( $rh );
1957 ...     }   /* if ( ( $rh = @fopen( $szFile,'r' ) ) == true ) */
1958 ... 
1959 ...     return ( $szRetVal );                                           /* Return result to caller */
1960 ... }   /* End of FIL_FileToStr() =============================================== */
1961 ... function FIL_Read( $szFile     ) { return ( FIL_FileToStr( $szFile ) ); }
1962 ... function FIL_File2Str( $szFile ) { return ( FIL_FileToStr( $szFile ) ); }
1963 ... function File2Str( $szFile     ) { return ( FIL_FileToStr( $szFile ) ); }
1964 ... function FileToStr( $szFile    ) { return ( FIL_FileToStr( $szFile ) ); }
1965 ... 
1966 ... /* ========================================================================== */
1967 ... /** {{*FIL_ReadEx( $szFile,$iLength )=
1968 ... 
1969 ...     Opens a file and read a given umber of bytes from it
1970 ... 
1971 ...     {*params
1972 ...         $szFile     (string)    Specifies the name of the file whose content
1973 ...                                 is returned as a string
1974 ...         $iLength    (int)       Number of bytes to read from $szFile
1975 ...     *}
1976 ... 
1977 ... 
1978 ... 
1979 ...     {*cdate 16/09/2013 - 06:12 *}
1980 ...     {*author  *}
1981 ... 
1982 ...     {*remark
1983 ...         $szFile gets opened and closed
1984 ...     *}
1985 ... 
1986 ...     {*return
1987 ...         (string)    Character string (file content)
1988 ...     *}
1989 ... 
1990 ...     {*seealso
1991 ...         FIL_Read()
1992 ...     *}
1993 ... 
1994 ...     *}}
1995 ...  */
1996 ... /* ========================================================================== */
1997 ... function FIL_ReadEx( $szFile,$iLength )
1998 ... /*-----------------------------------*/
1999 ... {
2000 ...     $szRetVal = null;                                               /* Return value of the function */
2001 ... 
2002 ...     if ( ( $rHandle = @fopen( $szFile,'r' ) ) == true )             /* If file could be opened */
2003 ...     {
2004 ...         $szRetVal   = @fread( $rHandle,$iLength );                   /* Read a number of bytes */
2005 ...         @fclose( $rHandle );
2006 ...     }   /* if ( ( $rHandle = @fopen( $szFile,'r' ) ) == true ) */
2007 ... 
2008 ...     return ( $szRetVal );                                           /* Return result to caller */
2009 ... }   /* End of FIL_ReadEx() ================================================== */
2010 ... 
2011 ... /* ========================================================================== */
2012 ... /** {{*FIL_FileToStrEx( $szFile,$iTries )=
2013 ... 
2014 ...     Returns the contents of a file as a character string. Extended function
2015 ...     of [c]FIL_FileToStr()[/c].
2016 ... 
2017 ...     {*params
2018 ...         $szFile     (string)    Specifies the name of the file whose contents are returned as a character string
2019 ...         $iTries     (int)       Trials opening the file (a delay of 1 sec between each trial). Optional. 3 by default.
2020 ...     *}
2021 ... 
2022 ...     {*mdate
2023 ...         27/06/2012 - 11:51
2024 ...     *}
2025 ... 
2026 ...     {*return
2027 ...         (string)    Character string (file content)
2028 ...     *}
2029 ... 
2030 ...     {*alias
2031 ...         FIL_Read(), FIL_File2Str(), File2Str(), FileToStr()
2032 ...     *}
2033 ... 
2034 ...     {*example
2035 ...         // Read XML file. Try 5 times
2036 ...         $szStr = FIL_FileToStrEx( 'c:\website\mine\www\httpdocs\myfile.xml',5 );
2037 ... 
2038 ...         if ( ! STR_Empty( $szStr ) )            // If got something
2039 ...         {
2040 ...             $oDom = new DOMDocument();          // Create a new DOM
2041 ...             if ( $oDom->loadXML( $szStr ) )     // Loads XML string
2042 ...             {
2043 ...                 echo $doc->saveXML();           // echo XML
2044 ...             }
2045 ...         }
2046 ...     *}
2047 ... 
2048 ...     {*exec
2049 ...         if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
2050 ...         {
2051 ...             $szContent = FIL_FileToStrEx( $szFile );
2052 ...             echo LSUnitTesting::assert( $szContent === $szStr                       ,
2053 ...                                         'ASSERTION SUCCESS: successful write & read',
2054 ...                                         'ASSERTION FAILURE: invalid resource'       ,
2055 ...                                         'GuideAssert' );
2056 ...             FIL_Delete( $szFile );
2057 ...         }
2058 ...     *}
2059 ... 
2060 ...     {*seealso
2061 ...         FIL_FileToStr()
2062 ...     *}
2063 ... 
2064 ...     *}}
2065 ...  */
2066 ... /* ====================================================================== */
2067 ... function FIL_FileToStrEx( $szFile,$iTries = 3 )
2068 ... /*-------------------------------------------*/
2069 ... {
2070 ...     $iCount     = 0;
2071 ...     $szRetVal   = '';
2072 ... 
2073 ...     do                                                              /* Code to execute ... DO this */
2074 ...     {
2075 ...         if ( $iCount > 0 )                                          /* If already seen */
2076 ...         {
2077 ...             sleep(1);                                               /* Wait for a sec before trying again */
2078 ...         }   /* if ( $iCount > 0 ) */
2079 ... 
2080 ...         $szRetVal = @file_get_contents( $szFile );                  /* Read the contents */
2081 ...         $iCount++;                                                  /* Increment counter */
2082 ... 
2083 ...     } while ( ( $iCount <= $iTries ) && ( $szRetVal === false ) );  /* While counter not reached limit AND could NOT read file */
2084 ... 
2085 ...     return ( $szRetVal );                                           /* Return result to caller */
2086 ... }   /* End of FIL_FileToStrEx() ========================================= */
2087 ... 
2088 ... /* ====================================================================== */
2089 ... /** {{*FIL_StrToFile( $szText,$szFile,$bAppend )=
2090 ... 
2091 ...     Writes the contents of a character string to a file.
2092 ... 
2093 ...     {*params
2094 ...         $szText     (string)    Specifies the character string that is written to the file
2095 ...         $szFile     (string)    Specifies the name of the file to which the character string is written
2096 ...         $bAppend    (bool)      Optional. [c]false[/c] by default. If [c]true[/c], file is appended
2097 ...     *}
2098 ... 
2099 ...     {*mdate
2100 ...         01/07/2012 - 14:24
2101 ...     *}
2102 ... 
2103 ...     {*return
2104 ...         (bool)      [c]true[/c] if $szFile is successfully written; [c]false[/c] if not
2105 ...     *}
2106 ... 
2107 ...     {*alias
2108 ...         FIL_Str2File(), strtofile()
2109 ...     *}
2110 ... 
2111 ...     {*exec
2112 ...         if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
2113 ...         {
2114 ...             $szContent = FIL_FileToStr( $szFile );
2115 ...             echo LSUnitTesting::assert( $szContent === $szStr                       ,
2116 ...                                         'ASSERTION SUCCESS: successful write & read',
2117 ...                                         'ASSERTION FAILURE: invalid resource'       ,
2118 ...                                         'GuideAssert' );
2119 ...             FIL_Delete( $szFile );
2120 ...         }
2121 ...     *}
2122 ... 
2123 ...     {*seealso
2124 ...         FIL_FileToStr()
2125 ...     *}
2126 ... 
2127 ...     *}}
2128 ...  */
2129 ... /* ========================================================================== */
2130 ... function FIL_StrToFile( $szText,$szFile,$bAppend = false )
2131 ... /*------------------------------------------------------*/
2132 ... {
2133 ...     $bRetVal = false;                                               /* Ready to return a logical false */
2134 ... 
2135 ...     /* Open file (create if does not exist). If Append mode ... open in 'a+' */
2136 ...     if ( ( $handle = @fopen( $szFile,( $bAppend ? 'a+' : 'w+' ) ) ) == true )
2137 ...     {
2138 ...         @fwrite( $handle,$szText );                                 /* Write contents to file */
2139 ...         @fclose( $handle );                                         /* Close file when done */
2140 ...         $bRetVal = true;
2141 ...     }   /* if ( ( $handle = @fopen( $szFile,( $bAppend ? 'a+' : 'w+' ) ) ) == true ) */
2142 ... 
2143 ...     return ( $bRetVal );                                            /* Return result to caller */
2144 ... }   /* End of function FIL_StrToFile() ====================================== */
2145 ... function strtofile( $szText,$szFile )     { return ( FIL_StrToFile( $szText,$szFile ) ); }
2146 ... function FIL_Str2File( $szText,$szFile )  { return ( FIL_StrToFile( $szText,$szFile ) ); }
2147 ... 
2148 ... /* ========================================================================== */
2149 ... /** {{*FIL_Write( $rHandle,$szText )=
2150 ... 
2151 ...     Writes $szText to a file specified by its $rHandle handle
2152 ... 
2153 ...     {*params
2154 ...         $rHandle    (res)       Resource handle of the file
2155 ...         $szText     (string)    Specifies the character string that is to be written to the file
2156 ...     *}
2157 ... 
2158 ...     {*cdate
2159 ...         01/07/2012 - 14:29
2160 ...     *}
2161 ... 
2162 ...     {*return
2163 ...         (int)   Returns the number of bytes written or -1 in case of failure
2164 ...     *}
2165 ... 
2166 ...     *}}
2167 ...  */
2168 ... /* ====================================================================== */
2169 ... function FIL_Write( $rHandle,$szText )
2170 ... /*----------------------------------*/
2171 ... {
2172 ...     $iBytes = @fwrite( $rHandle,$szText );                          /* Write contents to file */
2173 ... 
2174 ...     if ( is_bool( $iBytes ) )                                       /* If return is logical ... indicates a failure */
2175 ...     {
2176 ...         $iBytes = -1;                                               /* Indicates a failure */
2177 ...     }   /* if ( is_bool( $iBytes ) ) */
2178 ... 
2179 ...     return ( $iBytes );                                             /* Return result to caller */
2180 ... }   /* End of function FIL_Write() ====================================== */
2181 ... 
2182 ... /* ====================================================================== */
2183 ... /** {{*FIL_Append( $szFile,$szText )=
2184 ... 
2185 ...     Writes $szText to $szFile (append mode)
2186 ... 
2187 ...     {*params
2188 ...         $szFile     (string)    Name of the file to write to
2189 ...         $szText     (string)    Specifies the character string that is to be written to the file
2190 ...     *}
2191 ... 
2192 ...     {*return
2193 ...         (bool)  [c]true[/c] if $szText written successfully to $szFile;[c]false[/c]
2194 ...                 otherwise.
2195 ...     *}
2196 ... 
2197 ...     {*alias
2198 ...         FileAppend(), XAppend()
2199 ...     *}
2200 ...     *}}
2201 ...  */
2202 ... /* ========================================================================== */
2203 ... function FIL_Append( $szFile,$szText )
2204 ... /*----------------------------------*/
2205 ... {
2206 ...     $bRetVal = false;                                               /* Prepare to return a logical false */
2207 ... 
2208 ...     if ( $handle = @fopen( $szFile,'a+' ) )                         /* Open the file (create if not existing) ... if we could open/create the file */
2209 ...     {
2210 ...         fwrite( $handle,$szText . "\r\n" );                         /* Write the line of text to it - terminate with CRLF */
2211 ...         fclose( $handle );                                          /* Close the handle */
2212 ...         $bRetVal = true;                                            /* Return a logical true */
2213 ...     }   /* if ( $handle ) */
2214 ... 
2215 ...     return ( $bRetVal );                                            /* Return result to caller */
2216 ... }   /* End of FIL_Append() ================================================== */
2217 ... function FileAppend( $szFile,$szText ) { return ( FIL_Append( $szFile,$szText ) ); }
2218 ... function XAppend(    $szFile,$szText ) { return ( FIL_Append( $szFile,$szText ) ); }
2219 ... /* ========================================================================== */
2220 ... 
2221 ... /* ========================================================================== */
2222 ... /** {{*FIL_MkDir( $szDir )=
2223 ... 
2224 ...     Creates a directory including all inner directories if needed
2225 ... 
2226 ...     {*params
2227 ...         $szDir      (string)    Name of the directory that must be created
2228 ...     *}
2229 ... 
2230 ...     {*return
2231 ...         (bool)  [c]true[/c] if $szDir successfully created;[c]false[/c] if not
2232 ...     *}
2233 ... 
2234 ...     {*example
2235 ...         $szDir = 'c:\\mydir\\mysubdir\\dir3';
2236 ...         if ( ! FIL_IsDir( $szDir ) )
2237 ...         {
2238 ...             if ( FIL_MkDir( $szDir ) )
2239 ...             {
2240 ...                 echo "<p>'{$szDir}' successfully created</p>\n";
2241 ...             }
2242 ...             else
2243 ...             {
2244 ...                 echo "<p>CANNOT create '{$szDir}'</p>\n";
2245 ...             }
2246 ...         }
2247 ...     *}
2248 ... 
2249 ...     {*seealso
2250 ...         FIL_IsDir()
2251 ...     *}
2252 ...     *}}
2253 ...  */
2254 ... /* ====================================================================== */
2255 ... function FIL_MkDir( $szDir )
2256 ... /*------------------------*/
2257 ... {
2258 ...     $bRetVal    = false;                                            /* Prepare to return a logical false */
2259 ...     $szDir      = FIL_AddBS( str_replace( '\\','/',$szDir ),'/' );  /* Ending slash (all backslashes turned to slashes) */
2260 ...     //echo "<p>Dir de base à créer: {$szDir}</p>";
2261 ...     $szDisk     = FIL_Split( $szDir,1 );                            /* Get disk specifier */
2262 ...     $szDir      = FIL_split( $szDir,2 ) . FIL_split( $szDir,3 ) . FIL_split( $szDir,4 ); /* Treat only the path part */
2263 ...     $szDir      = str_replace( '\\','/',$szDir );                   /* Be sure about backslashes */
2264 ...     $szLast     = '';                                               /* Last directories we have created (concatenation) */
2265 ... 
2266 ...     //echo "<p>Dir juste avant les tokens: {$szDir}</p>";
2267 ...     $token      = strtok( $szDir,'/' );                             /* For each directory */
2268 ... 
2269 ...     while ( $token )                                                /* If the token was found */
2270 ...     {
2271 ...         //echo "<p>Token: {$token}</p>";
2272 ...         if ( ( ! STR_empty( $token ) &&                             /* If valid token */
2273 ...              (   $token != '.'     ) &&
2274 ...              (   $token != '..'    )
2275 ...            ) )
2276 ...         {
2277 ...             //echo "\n$token pas vide<br />\n";
2278 ...             $theDir = $szDisk . '/' . $szLast . $token;                   /* Make dir1/dir2/dir3/... */
2279 ... 
2280 ...             //echo "<p>Check de {$theDir}</p>";
2281 ...             if ( ! is_dir( $theDir ) )                              /* If not a directory */
2282 ...             {
2283 ...                 //echo "<p>{$theDir} n'est pas trouvée. Il faut la créer</p>";
2284 ...                 if ( ! @mkdir( $theDir ) )                          /* If the directory CANNOT be created */
2285 ...                 {
2286 ...                     //echo "<p>On arrête à {$theDir}</p>";
2287 ...                     break;                                          /* Stop here */
2288 ...                 }   /* if ( ! @mkdir( $theDir ) ) */
2289 ...                 else
2290 ...                 {
2291 ...                     //echo "<p>{$theDir} est créée</p>";
2292 ...                 }
2293 ...             }   /* if ( ! is_dir( $theDir ) ) */
2294 ...             else
2295 ...             {
2296 ...                 //echo "<p>{$theDir} existe!</p>";
2297 ...             }
2298 ... 
2299 ...             $szLast .= $token . '/';                                /* Concatenate directories */
2300 ...         }   /* if ( ( ! empty( $token ) && ... */
2301 ... 
2302 ...         $token = strtok( '/' );                                     /* Get next token */
2303 ...     }   /* while ( $token ) */
2304 ... 
2305 ...     $bRetVal = is_dir( $szDir );                                    /* true = the final directory exists */
2306 ... 
2307 ...     //if ( is_dir( $szDir ) )
2308 ...     //{
2309 ...     //    echo "<p>" . __FUNCTION__ . ' at line ' . __LINE__ . " -- CONFIRMATION: le répertoire {$szDir} a été créé</p>";
2310 ...     //}
2311 ... 
2312 ...     return ( $bRetVal );                                            /* Return value to caller */
2313 ... }   /* End of FIL_MkDir() */
2314 ... /* ====================================================================== */
2315 ... 
2316 ...     /* ====================================================================== */
2317 ...     /* .........................................................................
2318 ...        Function    :  DoesFileExist()
2319 ...        Purpose     :  Check whether a file exists or not in the current
2320 ...                       directory and in the include path
2321 ...        Parameters  :  szFile         ... the file whose existence must be
2322 ...                                          checked.
2323 ...                                          this parameter is updated upon return
2324 ...                                          if the file exists.
2325 ...        Return      :  true           ... if file exists
2326 ...                       false          ... if not
2327 ...     ......................................................................... */
2328 ...     function DoesFileExist( &$szFile,&$szNewFile = '' )
2329 ...     /*-----------------------------------------------*/
2330 ...     {
2331 ...         $bFound = false;                                                /* File not found by default */
2332 ... 
2333 ...         if ( strlen( $szFile ) > 0 )                                    /* If there is a file to look for */
2334 ...         {
2335 ...             if ( is_file( $szFile ) )                                   /* Check immediately the file itself */
2336 ...             {
2337 ...                 $szNewFile = $szFile;                                   /* Update final file */
2338 ...                 return ( true );                                        /* Return true to caller */
2339 ...             }   /* if ( is_file( $szFile ) ) */
2340 ... 
2341 ...             $token  = strtok( ini_get( "include_path" ),";" );          /* Get first path in list of paths */
2342 ... 
2343 ...             while ( $token )                                            /* While a path is found */
2344 ...             {
2345 ...                 /*********************************************/
2346 ...                 /* ATTENTION : THIS WILL NOT WORK WITH UNIX  */
2347 ...                 /*********************************************/
2348 ...                 if ( is_file( $token . "\\" . $szFile ) )               /* If file found with this path */
2349 ...                 {
2350 ...                     $szNewFile = $token . "\\" . $szFile;               /* Update parameter passed by reference */
2351 ...                     $bFound    = true;                                  /* Remember that we found the file */
2352 ...                     break;                                              /* Stop enumerating paths */
2353 ...                 }   /* if ( is_file( $token . "\\" . $szFile ) ) */
2354 ... 
2355 ...                 $token = strtok( ";" );
2356 ...             }   /* while ( $token ) */
2357 ...         }   /* if ( strlen( $szFile ) > 0 ) */
2358 ... 
2359 ...         return ( $bFound );                                             /* Return result to caller */
2360 ...     }   /* End of function DoesFileExist() */
2361 ...     /* ====================================================================== */
2362 ... 
2363 ... /* ====================================================================== */
2364 ... /** {{*SendFile( $szFile,$szType )=
2365 ... 
2366 ...     Sends a file
2367 ... 
2368 ...     {*params
2369 ...         $szFile (string)        the file to send back to the browser of
2370 ...                                 the visitor
2371 ...         $szType (string)        File type. Optional. By default the file
2372 ...                                 type is derived from its extension.
2373 ...     *}
2374 ... 
2375 ...     {*return
2376 ...         (void)                  The file identified by $szFile is returned
2377 ...                                 to the browser of the visitor
2378 ...     *}
2379 ... 
2380 ...     {*caution                   Make sure there is NO other output sent
2381 ...                                 back to the browser prior to this function
2382 ...                                 otherwise you may fool the browser by returning
2383 ...                                 an incorrect length and have files be truncated.
2384 ...     *}
2385 ... 
2386 ...     {*example
2387 ... 
2388 ...         // Example 1
2389 ...         // Sends a well-defined XML file if a backup is requested
2390 ...         if ( isset( $_GET['backup'] ) )     // if backup requested
2391 ...         {
2392 ...             ob_clean();                     // clean buffer before
2393 ...             SendFile( "myfile.xml",'xml' ); // Send myfile.xml!
2394 ...         }
2395 ... 
2396 ...         // Example 2
2397 ...         SendFile( FIL_Normalize( $szFile ),'docx' );
2398 ...     *}
2399 ... 
2400 ...     {*uses
2401 ...         FIL_GetFileType()
2402 ...     *}
2403 ... 
2404 ...     {*seealso
2405 ...         FIL_GetFileType()
2406 ...     *}
2407 ... 
2408 ...     *}}
2409 ...  */
2410 ... /* ====================================================================== */
2411 ... function SendFile( $szFile,$szType = null )
2412 ... /*---------------------------------------*/
2413 ... {
2414 ...     $szFullPath  = realpath( $szFile );
2415 ... 
2416 ...     if ( ! STR_Empty( $szFullPath ) )
2417 ...     {
2418 ...         $aPathSplit  = pathinfo( $szFullPath );
2419 ... 
2420 ...         if ( isset( $aPathSplit['extension'] ) )
2421 ...             $szExtension    = $aPathSplit['extension'];
2422 ...         else
2423 ...             $szExtension    = '';
2424 ... 
2425 ...         if ( isset( $aPathSplit['basename'] ) )
2426 ...             $szFile         = $aPathSplit['basename'];
2427 ...         else
2428 ...             $szFile         = '';
2429 ... 
2430 ...         if ( ! is_null(   $szType ) &&                                  /* If file type mentioned */
2431 ...                is_string( $szType ) &&
2432 ...                strlen(    $szType ) > 0
2433 ...            )
2434 ...         {
2435 ...             $szExtension = $szType;
2436 ...         }
2437 ... 
2438 ...         $szType = 'Unknown type';
2439 ... 
2440 ...         /**
2441 ...         * @todo Check file existance
2442 ...         */
2443 ... 
2444 ...         $szType = FIL_GetFileType( $szFile );                           /* Return proper type information in function of the extension */
2445 ... 
2446 ...         header( 'HTTP/1.1 200 OK'                                               );
2447 ...         header( 'Pragma: public'                                                );
2448 ...         header( 'Expires: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT'               );
2449 ...         header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0'     );
2450 ...         header( 'Cache-Control: private',false                                  );
2451 ...         header( 'Content-Type: ' . $szType                                      );
2452 ...         header( 'Content-Disposition: attachment; filename="' . $szFile . '"'   );
2453 ...         header( 'Content-Transfer-Encoding: binary'                             );
2454 ...         header( 'Content-Length: ' . filesize( $szFullPath )                    );
2455 ... 
2456 ...         readfile( $szFullPath );
2457 ...     }   /* if ( ! STR_Empty( $szFullPath ) ) */
2458 ... }   /* End of function SendFile() =========================================== */
2459 ... 
2460 ... /* ========================================================================== */
2461 ... /** {{*FIL_Compress( $szSource,$szTarget )=
2462 ... 
2463 ...     Compress a file
2464 ... 
2465 ...     {*params
2466 ...         $szSource   (string)   Name of the file to compress
2467 ...         $szTarget   (string)   Name of the target file
2468 ...     *}
2469 ... 
2470 ...     {*return
2471 ...         (bool)  True if the file was successfully compressed; false otherwise
2472 ...     *}
2473 ... 
2474 ...     {*seealso
2475 ...         FIL_Uncompress()
2476 ...     *}
2477 ... 
2478 ...     {*example
2479 ...         if ( FIL_Compress( 'C:\\myfile.txt','C:\\myfile.cmp' ) )
2480 ...         {
2481 ...             echo '<p>File successfully compressed</p>';
2482 ...         }
2483 ...     *}
2484 ...     *}}
2485 ...  */
2486 ... /* ====================================================================== */
2487 ... function FIL_Compress( $szSource,$szTarget )
2488 ... /*----------------------------------------*/
2489 ... {
2490 ...     $bRetVal    = false;                                            /* Return a logical false by default */
2491 ...     $HandleIn   = fopen( $szSource,'rb' );                          /* Open file for reading - binary mode */
2492 ...     $HandleOut  = gzopen( $szTarget,'wb9' );                        /* Open output file - maximum compression */
2493 ... 
2494 ...     if ( $HandleIn && $HandleOut )                                  /* If we successfully opened the input file and the output file */
2495 ...     {
2496 ...         while ( ! FIL_EOF( $HandleIn ) )                            /* While file not treated entirely */
2497 ...         {
2498 ...             $buffer = fread( $HandleIn,4096 );
2499 ...             gzwrite( $HandleOut,$buffer,4096 );
2500 ...         }
2501 ... 
2502 ...         $bRetVal = true;
2503 ...     }
2504 ... 
2505 ...     if ( $HandleIn )                                                /* If successful handle */
2506 ...     {
2507 ...         fclose( $HandleIn );                                        /* Close file when no longer needed */
2508 ...     }
2509 ... 
2510 ...     if ( $HandleOut )                                               /* If successful handle */
2511 ...     {
2512 ...         gzclose( $HandleOut );                                      /* Close file when no longer needed */
2513 ...     }
2514 ... 
2515 ...     return ( $bRetVal );                                            /* Return result to caller */
2516 ... }   /* End of function FIL_Compress() ======================================= */
2517 ... 
2518 ... /* ====================================================================== */
2519 ... /** {{*FIL_Uncompress( $szSource,$szTarget )=
2520 ... 
2521 ...     Uncompress a file
2522 ... 
2523 ...     {*params
2524 ...         $szSource   (string)   Name of the file to uncompress
2525 ...         $szTarget   (string)   Name of the target file
2526 ...     *}
2527 ... 
2528 ...     {*remark
2529 ...         FIL_Uncompress() is the natural companion of FIL_Compress()
2530 ...     *}
2531 ... 
2532 ...     {*return
2533 ...         (bool)  True if source file successfully uncompressed to $szTarget
2534 ...     *}
2535 ... 
2536 ...     {*seealso
2537 ...         FIL_Compress()
2538 ...     *}
2539 ... 
2540 ...     {*example
2541 ...         if ( FIL_Compress( 'C:\\myfile.txt','C:\\myfile.cmp' ) )
2542 ...         {
2543 ...             if ( FIL_Uncompress( 'C:\\myfile.cmp','C:\\myfile.2.txt' ) )
2544 ...             {
2545 ...                 echo '<p>Back to square 1: successful uncompression after successful compression</p>';
2546 ...             }
2547 ...         }
2548 ...     *}
2549 ...     *}}
2550 ...  */
2551 ... /* ====================================================================== */
2552 ... function FIL_Uncompress( $szSource,$szTarget )
2553 ... /*------------------------------------------*/
2554 ... {
2555 ...     $bRetVal    = false;                                            /* Return a logical false by default */
2556 ...     $HandleIn   = gzopen( $szSource,'rb' );                         /* Open file for reading - binary mode */
2557 ...     $HandleOut  = fopen( $szTarget,'wb' );                          /* Open output file for writing - binary mode */
2558 ... 
2559 ...     if ( $HandleIn && $HandleOut )                                  /* If we successfully opened the input file and the output file */
2560 ...     {
2561 ...         while ( ! gzeof( $HandleIn ) )                              /* While source file not entirely read */
2562 ...         {
2563 ...             $buffer = gzread( $HandleIn,4096 );                     /* Read by chunks of 4096 bytes */
2564 ...             fwrite( $HandleOut,$buffer,4096 );                      /* Write chunks of 4096 bytes */
2565 ...         }   /* while ( ! gzeof( $HandleIn ) ) */
2566 ... 
2567 ...         $bRetVal = true;
2568 ...     }
2569 ... 
2570 ...     if ( $HandleIn )
2571 ...     {
2572 ...         gzclose( $HandleIn );                                       /* Close file when no longer needed */
2573 ...     }
2574 ... 
2575 ...     if ( $HandleOut )
2576 ...     {
2577 ...         fclose( $HandleOut );                                       /* Close file when no longer needed */
2578 ...     }
2579 ... 
2580 ...     return ( $bRetVal );                                            /* Return result to caller */
2581 ... }   /* End of function FIL_Uncompress() ===================================== */
2582 ... 
2583 ... /* ========================================================================== */
2584 ... /** {{*FIL_mTime( $szFile[,$szFormat] )=
2585 ... 
2586 ...     Determines the last modification date and time of a file
2587 ... 
2588 ...     {*params
2589 ...         $szFile     (string)    Name of the file whose last modification date
2590 ...                                 and time must be returned
2591 ...         $szFormat   (string)    The format of the output date string. Optional.
2592 ...     *}
2593 ... 
2594 ...     {*cdate
2595 ...         15/07/2012 21:11
2596 ...     *}
2597 ... 
2598 ...     {*version
2599 ...         5.0.0004
2600 ...     *}
2601 ... 
2602 ...     {*return
2603 ...         (mixed) Last date and time returned as an int (same use as [c]time()[/c]
2604 ...                 if $szFormat === null; string if $szFormat mentioned)
2605 ...     *}
2606 ... 
2607 ...     {*seealso
2608 ...         FIL_aTime(), FIL_cTime(), FIL_Time()
2609 ...     *}
2610 ... 
2611 ...     {*example
2612 ...         $szVersion = '5.0.0004';
2613 ...         $szFile    = "/vaesoli/archive/vaesoli-{$szVersion}.zip";
2614 ...         $szDate    = FIL_mTime( FIL_ResolveRoot( $szFile ),"d-m-Y H:i" );
2615 ...         $szSize    = number_format( (float) FIL_Size(  FIL_ResolveRoot( $szFile ) ) ,
2616 ...                                     0                                               ,
2617 ...                                     ','                                             ,
2618 ...                                     '.' );
2619 ...     *}
2620 ...     *}}
2621 ...  */
2622 ... /* ========================================================================== */
2623 ... function FIL_mTime( $szFile,$szFormat = null )
2624 ... /*------------------------------------------*/
2625 ... {
2626 ...     return ( FIL_Time( $szFile,'m',$szFormat ) );
2627 ... }   /* End of function FIL_mtime() */
2628 ... function LastModificationTime( $szFile,$szFormat = null ) { return ( FIL_mTime( $szFile,$szFormat ) ); }
2629 ... /* ========================================================================== */
2630 ... 
2631 ... /* ========================================================================== */
2632 ... /** {{*FIL_cTime( $szFile[,$szFormat] )=
2633 ... 
2634 ...     Determines the creation date and time of a file
2635 ... 
2636 ...     {*params
2637 ...         $szFile     (string)    Name of the file whose creation date
2638 ...                                 and time must be returned
2639 ...         $szFormat   (string)    The format of the output date string. Optional.
2640 ...     *}
2641 ... 
2642 ...     {*cdate
2643 ...         17/07/2012 07:18
2644 ...     *}
2645 ... 
2646 ...     {*version
2647 ...         5.0.0005
2648 ...     *}
2649 ... 
2650 ...     {*return
2651 ...         (mixed) Last access date and time returned as an int (same use as [c]time()[/c])
2652 ...                 if $szFormat === null; string if $szFormat mentioned
2653 ...     *}
2654 ... 
2655 ...     {*seealso
2656 ...         FIL_aTime(), FIL_mTime(), FIL_Time()
2657 ...     *}
2658 ... 
2659 ...     {*exec
2660 ...         echo '<p>' . FIL_cTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php' )             . '</p>';
2661 ...         echo '<p>' . FIL_cTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php','Ymd H:i:s' ) . '</p>';
2662 ...     *}
2663 ...     *}}
2664 ...  */
2665 ... /* ========================================================================== */
2666 ... function FIL_cTime( $szFile,$szFormat = null )
2667 ... /*------------------------------------------*/
2668 ... {
2669 ...     return ( FIL_Time( $szFile,'c',$szFormat ) );
2670 ... }   /* End of function FIL_cTime() ========================================== */
2671 ... 
2672 ... /* ========================================================================== */
2673 ... /** {{*FIL_aTime( $szFile[,$szFormat] )=
2674 ... 
2675 ...     Determines the last access date and time of a file
2676 ... 
2677 ...     {*params
2678 ...         $szFile     (string)    Name of the file whose last access date
2679 ...                                 and time must be returned
2680 ...         $szFormat   (string)    Optional format of the output date string. See
2681 ...                                 [c]date()[/c] function of PHP to obtain in-depth
2682 ...                                 details of the format string.
2683 ...     *}
2684 ... 
2685 ...     {*cdate
2686 ...         17/07/2012 07:19
2687 ...     *}
2688 ... 
2689 ...     {*version
2690 ...         5.0.0005
2691 ...     *}
2692 ... 
2693 ...     {*return
2694 ...         (mixed) Last access date and time returned as an int (same use as [c]time()[/c])
2695 ...                 if $szFormat === null; string if $szFormat mentioned
2696 ...     *}
2697 ... 
2698 ...     {*seealso
2699 ...         FIL_cTime(), FIL_mTime(), FIL_Time()
2700 ...     *}
2701 ... 
2702 ...     {*exec
2703 ...         echo '<p>' . FIL_aTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php' )             . '</p>';
2704 ...         echo '<p>' . FIL_aTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php','Ymd H:i:s' ) . '</p>';
2705 ...     *}
2706 ...     *}}
2707 ...  */
2708 ... /* ========================================================================== */
2709 ... function FIL_aTime( $szFile,$szFormat = null )
2710 ... /*------------------------------------------*/
2711 ... {
2712 ...     return ( FIL_Time( $szFile,'a',$szFormat ) );
2713 ... }   /* End of function FIL_aTime() ========================================== */
2714 ... 
2715 ... /* ========================================================================== */
2716 ... /** {{*FIL_Time( $szFile[,$cType[,$szFormat]] )=
2717 ... 
2718 ...     Determines the date and time of a file (creation, modification or last access)
2719 ... 
2720 ...     {*params
2721 ...         $szFile     (string)    Name of the file whose last modification date
2722 ...                                 and time must be returned
2723 ...         $cType      (char)      Operation type:[br]
2724 ...                                 - [c]'a'[/c]: last access date and time[br]
2725 ...                                 - [c]'c'[/c]: creation date and time[br]
2726 ...                                 - [c]'m'[/c]: last modification date and time[br]
2727 ...         $szFormat   (string)    The format of the output date string
2728 ...     *}
2729 ... 
2730 ...     {*version
2731 ...         5.0.0005
2732 ...     *}
2733 ... 
2734 ...     {*return
2735 ...         (mixed) Last date and time returned as an int if $szFormat = null
2736 ...                 (same use as [c]time()[/c]); string if format mentioned
2737 ...     *}
2738 ... 
2739 ...     {*example
2740 ...         if ( FIL_Compress( 'C:\\myfile.txt','C:\\myfile.cmp' ) )
2741 ...         {
2742 ...             if ( FIL_Uncompress( 'C:\\myfile.cmp','C:\\myfile.2.txt' ) )
2743 ...             {
2744 ...                 echo '<p>Back to square 1: successful uncompression after successful compression</p>';
2745 ...             }
2746 ...         }
2747 ...     *}
2748 ... 
2749 ...     {*seealso
2750 ...         FIL_CDate(), FIL_MDate()
2751 ...     *}
2752 ... 
2753 ...     *}}
2754 ...  */
2755 ... /* ====================================================================== */
2756 ... function FIL_Time( $szFile,$cType = 'm',$szFormat = null )
2757 ... /*------------------------------------------------------*/
2758 ... {
2759 ...     if ( FIL_Exists( $szFile ) )                                    /* If file found */
2760 ...     {
2761 ...         switch ( $cType )                                           /* Depending on the type of operation */
2762 ...         {
2763 ...             case 'a'    :   $iTime = fileatime( $szFile );          /* Get last access time of file */
2764 ...                             break;
2765 ...             case 'c'    :   $iTime = filectime( $szFile );          /* Get creation time of file */
2766 ...                             break;
2767 ...             default     :   $iTime = filemtime( $szFile );          /* Get last modification time of file */
2768 ...                             break;
2769 ...         }   /* switch ( $szType ) */
2770 ... 
2771 ...         if ( is_null( $szFormat ) )                                 /* If not format mentioned */
2772 ...         {
2773 ...             return ( $iTime );                                      /* Return modification time of the file (int) */
2774 ...         }   /* if ( is_null( $szFormat ) ) */
2775 ...         else   /* Else of ... if ( is_null( $szFormat ) ) */
2776 ...         {
2777 ...             return ( date( $szFormat,$iTime ) );                    /* Return date as mentioned per format */
2778 ...         }   /* End of ... Else of ... if ( is_null( $szFormat ) ) */
2779 ...     }   /* if ( file_exists( $szFile ) ) */
2780 ...     else   /* Else of ... if ( file_exists( $szFile ) ) */
2781 ...     {
2782 ...         if ( is_null( $szFormat ) )                                 /* If not format mentioned */
2783 ...         {
2784 ...             return ( -1 );                                          /* Return -1 if file not found */
2785 ...         }   /* if ( is_null( $szFormat ) ) */
2786 ...         else   /* Else of ... if ( is_null( $szFormat ) ) */
2787 ...         {
2788 ...             return ( null );                                        /* Return a null */
2789 ...         }   /* End of ... Else of ... if ( is_null( $szFormat ) ) */
2790 ...     }   /* End of ... Else of ... if ( file_exists( $szFile ) ) */
2791 ... }   /* End of function FIL_Time() =========================================== */
2792 ... 
2793 ... /* ========================================================================== */
2794 ... /** {{*FIL_MDate( $szFile,$szFormat )=
2795 ... 
2796 ...     Determines the date and time of last modification of a file
2797 ... 
2798 ...     {*params
2799 ...         $szFile     (string)    Name of the file whose last modification date
2800 ...                                 and time must be returned
2801 ...         $szFormat   (string)    The format of the output date string
2802 ...     *}
2803 ... 
2804 ...     {*version
2805 ...         5.0.0012
2806 ...     *}
2807 ... 
2808 ...     {*mdate
2809 ...         14/01/2013 - 12:03
2810 ...     *}
2811 ... 
2812 ... 
2813 ...     {*return
2814 ...         (string)    Last modification date and time returned in
2815 ...                     [c]'d/m/Y - H:i:s'[/c] format if $szFormat NOT passed
2816 ...                     (see [c]date()[/c] function of PHP)
2817 ...     *}
2818 ... 
2819 ...     {*example
2820 ...         echo FIL_MDate( 'C:\\myfile.txt' );
2821 ...     *}
2822 ... 
2823 ...     {*exec
2824 ...         $szFile = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources\\ut\\bonjour.txt';
2825 ...         echo LSUnitTesting::assert( FIL_MDate( $szFile ) === '04/10/2013 - 15:39:18'    ,
2826 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2827 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2828 ...                                     'GuideAssert' );
2829 ...         echo LSUnitTesting::assert( FIL_MDate( $szFile,'Ymd' ) === '20131004'           ,
2830 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2831 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2832 ...                                     'GuideAssert' );
2833 ...         echo LSUnitTesting::assert( FIL_MDate( $szFile,'YmdHis' ) === '20131004153918'  ,
2834 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2835 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2836 ...                                     'GuideAssert' );
2837 ...         echo LSUnitTesting::assert( FIL_MDate( $szFile,'' ) === ''                      ,
2838 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2839 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2840 ...                                     'GuideAssert' );
2841 ...     *}
2842 ... 
2843 ...     {*seealso
2844 ...         FIL_Time(), FIL_CDate()
2845 ...     *}
2846 ... 
2847 ...     *}}
2848 ...  */
2849 ... /* ========================================================================== */
2850 ... function FIL_MDate( $szFile,$szFormat = 'd/m/Y - H:i:s' )
2851 ... {
2852 ...     return ( FIL_Time( $szFile,'m',$szFormat ) );
2853 ... }   /* End of function FIL_MDate() ========================================== */
2854 ... 
2855 ... /* ========================================================================== */
2856 ... /** {{*FIL_CDate( $szFile,$szFormat )=
2857 ... 
2858 ...     Determines the creation date and time of a file
2859 ... 
2860 ...     {*params
2861 ...         $szFile     (string)    Name of the file whose creation date
2862 ...                                 and time must be returned
2863 ...         $szFormat   (string)    The format of the output date string
2864 ...     *}
2865 ... 
2866 ...     {*version
2867 ...         5.0.0012
2868 ...     *}
2869 ... 
2870 ...     {*mdate
2871 ...         14/01/2013 - 12:05
2872 ...     *}
2873 ... 
2874 ...     {*return
2875 ...         (string)    Creation date and time returned in
2876 ...                     [c]'d/m/Y - H:i:s'[/c] format is $szFormat NOT passed
2877 ...                     (see [c]date()[/c] function of PHP)
2878 ...     *}
2879 ... 
2880 ...     {*example
2881 ...         echo FIL_CDate( 'C:\\myfile.txt' );
2882 ...     *}
2883 ... 
2884 ...     {*exec
2885 ...         $szFile = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources\\ut\\bonjour.txt';
2886 ...         echo FIL_CDate( $szFile );
2887 ...         echo LSUnitTesting::assert( FIL_CDate( $szFile ) === '04/10/2013 - 15:04:16'    ,
2888 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2889 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2890 ...                                     'GuideAssert' );
2891 ...         echo LSUnitTesting::assert( FIL_CDate( $szFile,'Ymd' ) === '20131004'           ,
2892 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2893 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2894 ...                                     'GuideAssert' );
2895 ...         echo LSUnitTesting::assert( FIL_CDate( $szFile,'YmdHis' ) === '20131004150416'  ,
2896 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2897 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2898 ...                                     'GuideAssert' );
2899 ...         echo LSUnitTesting::assert( FIL_CDate( $szFile,'' ) === ''                      ,
2900 ...                                     'ASSERTION SUCCESS: bonjour.txt OK'                 ,
2901 ...                                     'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
2902 ...                                     'GuideAssert' );
2903 ...     *}
2904 ... 
2905 ...     {*seealso
2906 ...         FIL_Time(), FIL_MDate()
2907 ...     *}
2908 ... 
2909 ...     *}}
2910 ...  */
2911 ... /* ========================================================================== */
2912 ... function FIL_CDate( $szFile,$szFormat = 'd/m/Y - H:i:s' )
2913 ... {
2914 ...     return ( FIL_Time( $szFile,'c',$szFormat ) );
2915 ... }   /* End of function FIL_CDate() ========================================== */
2916 ... 
2917 ... /* ========================================================================== */
2918 ... /** {{*FIL_aDirs( $szRoot )=
2919 ... 
2920 ...     Returns an array of directories found in $szRoot
2921 ... 
2922 ...     {*params
2923 ...         $szRoot     (string)   Root directory to scan for directories
2924 ...     *}
2925 ... 
2926 ...     {*return
2927 ...         (array)     An array of directories. The array is empty if no directory found.
2928 ...     *}
2929 ... 
2930 ...     {*exec
2931 ...         $szDir = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources';
2932 ...         $oArray = new LSArray();
2933 ...         $oArray->PushMany( $aArray = FIL_aDirs( $szDir ) );
2934 ...         var_dump( $aArray );
2935 ...         echo LSUnitTesting::assert( $oArray->Count() >= 8                   ,
2936 ...                                     'ASSERTION SUCCESS: directories OK'     ,
2937 ...                                     'ASSERTION FAILURE: directories NOT OK' ,
2938 ...                                     'GuideAssert' );
2939 ...         echo LSUnitTesting::assert( $oArray->Get(4) === 'images'                                ,
2940 ...                                     'ASSERTION SUCCESS: "images" dir found at proper place'     ,
2941 ...                                     'ASSERTION FAILURE: "images" dir NOT found at proper place' ,
2942 ...                                     'GuideAssert' );
2943 ...     *}
2944 ... 
2945 ...     {*seealso
2946 ...         FIL_aFiles()
2947 ...     *}
2948 ... 
2949 ...     *}}
2950 ...  */
2951 ... /* ====================================================================== */
2952 ... function FIL_aDirs( $szRoot )
2953 ... /*-------------------------*/
2954 ... {
2955 ...     $aDirs = array();                                               /* Ready to return an empty array */
2956 ... 
2957 ...     if ( $nHandle = opendir( $szRoot ) )                            /* Open the starting directory */
2958 ...     {
2959 ...         while ( ( $szFile = readdir( $nHandle ) ) != false )
2960 ...         {
2961 ...             if ( $szFile === "." || $szFile === '..' )              /* Skip current path and parent path */
2962 ...             {
2963 ...                 continue;
2964 ...             }   /* if ( $szFile === "." || $szFile === '..' ) */
2965 ... 
2966 ...             $szFullFile = realpath( ADDBS( $szRoot ) . $szFile );   /* Build full file name (including path) */
2967 ... 
2968 ...             if ( is_dir( $szFullFile ) )                            /* If this is a directory */
2969 ...             {
2970 ...                 array_push( $aDirs,$szFile );                       /* Push this directory onto the stack */
2971 ...             }
2972 ...         }   /* while ( ( $szFile = readdir( $nHandle ) ) != false ) */
2973 ... 
2974 ...       closedir( $nHandle );                                         /* Close root directory */
2975 ... 
2976 ...     }   /* if ( $nHandle = opendir( $szRoot ) ) */
2977 ... 
2978 ...     return ( $aDirs );                                              /* Return array of dirs */
2979 ... }   /* End of function FIL_aDirs() */
2980 ... /* ====================================================================== */
2981 ... 
2982 ... /* ====================================================================== */
2983 ... /** {{*FIL_aFiles( $szDir,$szPattern,$bWithRoot,$bWithDir )=
2984 ... 
2985 ...     Returns an array of files found in $szDir and that match the $szPattern regex pattern
2986 ... 
2987 ...     {*params
2988 ...         $szDir      (string)    Root directory to scan for directories
2989 ...         $szPattern  (string)    Regular expression pattern. Optional. [c]null[/c] by default.
2990 ...         $bWithRoot  (bool)      Optional. [c]true[/c] by default. Indicates whether
2991 ...                                 the file to be shoved in the array must contain the
2992 ...                                 full path.
2993 ...         $bWithDir   (bool)      Optional. [c]false[/c] by default. Indicates whether
2994 ...                                 directories should be included as well
2995 ...     *}
2996 ... 
2997 ...     {*abstract
2998 ...         Hello World
2999 ...     *}
3000 ... 
3001 ...     {*caution
3002 ... 
3003 ...         Make sure that the pattern is a valid pattern for regular expressions
3004 ...         ([c]preg_match()[/c]).
3005 ... 
3006 ...     *}
3007 ... 
3008 ...     {*return
3009 ...         (array)     An array of files corresponding to the $szPattern pattern
3010 ...     *}
3011 ... 
3012 ...     {*example
3013 ...         $aFiles = FIL_aFiles( FIL_ResolveRoot( '.' ),'/\.php/i',true );
3014 ...         foreach( $aFiles as $szFile )
3015 ...         {
3016 ...             echo "<p>File: {$szFile}</p>\n";
3017 ...         }
3018 ...     *}
3019 ... 
3020 ...     {*seealso
3021 ...         FIL_aDirs(), FIL_aFilesEx()
3022 ...     *}
3023 ... 
3024 ...     *}}
3025 ...  */
3026 ... /* ====================================================================== */
3027 ... function FIL_aFiles( $szDir,$szPattern = null,$bWithRoot = true,$bWithDir = false )
3028 ... /*-------------------------------------------------------------------------------*/
3029 ... {
3030 ...     $aFiles = array();                                              /* Ready to return an empty array */
3031 ... 
3032 ...     //echo "<p>" . __METHOD__ . "() at line " . __LINE__ . ": Directory to read from = {$szDir}</p>\n";
3033 ... 
3034 ...     if ( FIL_IsDir( $szDir ) && ( $nHandle = opendir( $szDir ) ) )  /* Open the starting directory */
3035 ...     {
3036 ...         $szDir = ADDBS( $szDir );                                   /* Add a backslash (or slash) if needed */
3037 ... 
3038 ...         //if ( $bWithDir )
3039 ...         //{
3040 ...         //    echo "Avec directories";
3041 ...         //}
3042 ...         //else
3043 ...         //{
3044 ...         //    echo "Sans directories";
3045 ...         //}
3046 ... 
3047 ...         while ( ( $szFile = readdir( $nHandle ) ) != false )
3048 ...         {
3049 ...             if ( $szFile === "." || $szFile === '..' )              /* Skip current path and parent path */
3050 ...             {
3051 ...                 continue;
3052 ...             }
3053 ... 
3054 ...             //echo "<p>" . __METHOD__ . "() at line " . __LINE__ . ": '{$szFile}'</p>\n";
3055 ... 
3056 ...             $szFullFile = realpath( $szDir . $szFile );             /* Build full file name (including path) */
3057 ... 
3058 ...             //echo "<p>" . __METHOD__ . "() at line " . __LINE__ . ": '{$szFullFile}'</p>\n";
3059 ... 
3060 ...             if ( $bWithDir || ! is_dir( $szFullFile ) )             /* If this is NOT a directory */
3061 ...             {
3062 ...                 //echo "<p>On traite {$szFullFile}</p>";
3063 ...                 if ( ! is_null( $szPattern ) )
3064 ...                 {
3065 ...                     //echo "<p>" . __METHOD__ . "() at line " . __LINE__ . ": Pattern = {$szPattern}'</p>\n";
3066 ...                     if ( $szPattern === '*.*' )
3067 ...                     {
3068 ...                         $szPattern = '/(.*)(\.)?(.*)/';
3069 ...                     }
3070 ...                     if ( preg_match( $szPattern,$szFile ) )         /* If file matches our pattern */
3071 ...                     {
3072 ...                         $aFiles[] = $bWithRoot ? $szFullFile : $szFile; /* Push this file onto the list */
3073 ...                         //echo "<p>" . __METHOD__ . "() at line " . __LINE__ . ": INSERTED: '{$szFullFile}'</p>\n";
3074 ...                     }
3075 ...                 }
3076 ...                 else
3077 ...                 {
3078 ...                     $aFiles[] = $bWithRoot ? $szFullFile : $szFile; /* Push this file onto the list */
3079 ...                     //echo "<p>" . __METHOD__ . "() at line " . __LINE__ . ": INSERTED: '{$szFullFile}'</p>\n";
3080 ...                 }
3081 ...             }   /* if ( $bWithDir || ! is_dir( $szFullFile ) ) */
3082 ...         }   /* while ( ( $szFile = readdir( $nHandle ) ) != false ) */
3083 ... 
3084 ...         closedir( $nHandle );                                       /* Close root directory */
3085 ... 
3086 ...     }   /* if ( $nHandle = opendir( $szDir ) ) */
3087 ... 
3088 ...     return ( $aFiles );                                             /* Return array of dirs */
3089 ... }   /* End of function FIL_aFiles() */
3090 ... /* ====================================================================== */
3091 ... 
3092 ... /* ====================================================================== */
3093 ... /** {{*FIL_EOF( $rHandle )=
3094 ... 
3095 ...     Determines if file is at END OF FILE position
3096 ... 
3097 ...     {*params
3098 ...         $rHandle    (res)       resource handle of file whose EOF position
3099 ...                                 must be checked
3100 ...     *}
3101 ... 
3102 ...     {*version
3103 ...         5.0.0010
3104 ...     *}
3105 ... 
3106 ...     {*cdate
3107 ...         03/12/2012 - 11:08
3108 ...     *}
3109 ... 
3110 ...     {*return
3111 ...         (boolean)   [c]true[/c] if $rHandle at EOF; [c]false[/c] otherwise.
3112 ...     *}
3113 ... 
3114 ...     {*example
3115 ...         // Open file in read mode
3116 ...         if ( $rHandle = FIL_Open( $szFile,'r+' ) )
3117 ...         {
3118 ...             // While NOT End Of File
3119 ...             while ( ! FIL_EOF( $rHandle ) )
3120 ...             {
3121 ...                 $szLine = FIL_Gets( $rHandle,512 );
3122 ...             }
3123 ... 
3124 ...             // Close file when no longer needed
3125 ...             FIL_Close( $rHandle );
3126 ...         }
3127 ...     *}
3128 ... 
3129 ...     {*seealso
3130 ...         FIL_Open(), FIL_Close()
3131 ...     *}
3132 ... 
3133 ... 
3134 ...     *}}
3135 ...  */
3136 ... /* ====================================================================== */
3137 ... function FIL_EOF( $rHandle )
3138 ... /*------------------------*/
3139 ... {
3140 ...     return ( feof( $rHandle ) ) ;
3141 ... }   /* End of function FIL_EOF */
3142 ... /* ====================================================================== */
3143 ... 
3144 ... /* ====================================================================== */
3145 ... /** {{*FIL_GetFileType( $szFile )=
3146 ... 
3147 ...     Returns the MIME type corresponding to the file extension of $szFile
3148 ... 
3149 ...     {*params
3150 ...         $szFile     (string)    File whose MIME type must be determined
3151 ...     *}
3152 ... 
3153 ...     {*doc
3154 ...         [url]http://fr.wikipedia.org/wiki/Type_MIME[/url][br]
3155 ...         [url]http://en.wikipedia.org/wiki/MIME_type[/url]
3156 ...     *}
3157 ... 
3158 ...     {*mdate
3159 ...         16/01/2013 - 21:11
3160 ...     *}
3161 ... 
3162 ...     {*remark
3163 ...         Only a small subset of MIME types is considered
3164 ...     *}
3165 ... 
3166 ...     {*return
3167 ...         (string)    The MIME type
3168 ...         [table]
3169 ...             [tr][td]    .aif     [/td][td]  audio/x-aiff                   [/td][/tr]
3170 ...             [tr][td]    .aiff    [/td][td]  audio/x-aiff                   [/td][/tr]
3171 ...             [tr][td]    .arc     [/td][td]  application/octet-stream       [/td][/tr]
3172 ...             [tr][td]    .arj     [/td][td]  application/octet-stream       [/td][/tr]
3173 ...             [tr][td]    .art     [/td][td]  image/x-jg                     [/td][/tr]
3174 ...             [tr][td]    .asf     [/td][td]  video/x-ms-asf                 [/td][/tr]
3175 ...             [tr][td]    .asx     [/td][td]  video/x-ms-asf                 [/td][/tr]
3176 ...             [tr][td]    .avi     [/td][td]  video/avi                      [/td][/tr]
3177 ...             [tr][td]    .bin     [/td][td]  application/octet-stream       [/td][/tr]
3178 ...             [tr][td]    .bm      [/td][td]  image/bmp                      [/td][/tr]
3179 ...             [tr][td]    .bmp     [/td][td]  image/bmp                      [/td][/tr]
3180 ...             [tr][td]    .bz2     [/td][td]  application/x-bzip2            [/td][/tr]
3181 ...             [tr][td]    .css     [/td][td]  text/css                       [/td][/tr]
3182 ...             [tr][td]    .csv     [/td][td]  text/csv                       [/td][/tr]
3183 ...             [tr][td]    .doc     [/td][td]  application/msword             [/td][/tr]
3184 ...             [tr][td]    .dot     [/td][td]  application/msword             [/td][/tr]
3185 ...             [tr][td]    .docx    [/td][td]  application/msword             [/td][/tr]
3186 ...             [tr][td]    .dv      [/td][td]  video/x-dv                     [/td][/tr]
3187 ...             [tr][td]    .exe     [/td][td]  application/octetstream        [/td][/tr]
3188 ...             [tr][td]    .gif     [/td][td]  image/gif                      [/td][/tr]
3189 ...             [tr][td]    .gz      [/td][td]  application/x-gzip             [/td][/tr]
3190 ...             [tr][td]    .gzip    [/td][td]  application/x-gzip             [/td][/tr]
3191 ...             [tr][td]    .htm     [/td][td]  text/html                      [/td][/tr]
3192 ...             [tr][td]    .html    [/td][td]  text/html                      [/td][/tr]
3193 ...             [tr][td]    .ico     [/td][td]  image/x-icon                   [/td][/tr]
3194 ...             [tr][td]    .jpe     [/td][td]  image/jpeg                     [/td][/tr]
3195 ...             [tr][td]    .jpeg    [/td][td]  image/jpeg                     [/td][/tr]
3196 ...             [tr][td]    .jpg     [/td][td]  image/jpeg                     [/td][/tr]
3197 ...             [tr][td]    .js      [/td][td]  application/x-javascript       [/td][/tr]
3198 ...             [tr][td]    .json    [/td][td]  application/json               [/td][/tr]
3199 ...             [tr][td]    .log     [/td][td]  text/plain                     [/td][/tr]
3200 ...             [tr][td]    .txt     [/td][td]  text/plain                     [/td][/tr]
3201 ...             [tr][td]    .mid     [/td][td]  audio/x-midi                   [/td][/tr]
3202 ...             [tr][td]    .mov     [/td][td]  video/quicktime                [/td][/tr]
3203 ...             [tr][td]    .mp2     [/td][td]  audio/mpeg                     [/td][/tr]
3204 ...             [tr][td]    .mpg     [/td][td]  audio/mpeg                     [/td][/tr]
3205 ...             [tr][td]    .mp3     [/td][td]  audio/mpeg3                    [/td][/tr]
3206 ...             [tr][td]    .mp4     [/td][td]  video/mp4                      [/td][/tr]
3207 ...             [tr][td]    .ogg     [/td][td]  application/ogg                [/td][/tr]
3208 ...             [tr][td]    .pdf     [/td][td]  application/pdf                [/td][/tr]
3209 ...             [tr][td]    .png     [/td][td]  image/png                      [/td][/tr]
3210 ...             [tr][td]    .ppt     [/td][td]  application/vnd.ms-powerpoint  [/td][/tr]
3211 ...             [tr][td]    .ra      [/td][td]  audio/vnd.rn-realaudioreal     [/td][/tr]
3212 ...             [tr][td]    .rtf     [/td][td]  application/rtf                [/td][/tr]
3213 ...             [tr][td]    .tif     [/td][td]  image/tiff                     [/td][/tr]
3214 ...             [tr][td]    .tiff    [/td][td]  image/tiff                     [/td][/tr]
3215 ...             [tr][td]    .vcard   [/td][td]  text/x-vCard                   [/td][/tr]
3216 ...             [tr][td]    .wav     [/td][td]  audio/x-wav                    [/td][/tr]
3217 ...             [tr][td]    .wma     [/td][td]  audio/x-ms-wma                 [/td][/tr]
3218 ...             [tr][td]    .xls     [/td][td]  application/vnd.ms-excel       [/td][/tr]
3219 ...             [tr][td]    .xml     [/td][td]  text/xml                       [/td][/tr]
3220 ...             [tr][td]    .zip     [/td][td]  application/zip );             [/td][/tr]
3221 ...             [tr][td]    default  [/td][td]  application/force-download     [/td][/tr]
3222 ...         [/table]
3223 ...     *}
3224 ... 
3225 ...     {*assert
3226 ...         FIL_GetFileType( 'c:\data\countries.xml' ) === 'text/xml'
3227 ...     *}
3228 ... 
3229 ...     {*assert
3230 ...         FIL_GetFileType( 'c:\images\woman.jpg'  ) === 'image/jpeg'
3231 ...     *}
3232 ... 
3233 ...     {*assert
3234 ...         FIL_GetFileType( 'c:\images\audio.ra'   ) === 'audio/vnd.rn-realaudioreal'
3235 ...     *}
3236 ... 
3237 ...     {*example
3238 ...         echo FIL_GetFileType( 'c:\data\countries.xml' ); // Prints "text/xml"
3239 ...         echo FIL_GetFileType( 'c:\images\woman.jpg'   ); // Prints "image/jpeg"
3240 ...     *}
3241 ... 
3242 ...     {*seealso
3243 ...         SendFile()
3244 ...     *}
3245 ... 
3246 ...     *}}
3247 ...  */
3248 ... /* ====================================================================== */
3249 ... function FIL_GetFileType( $szFile )
3250 ... /*-------------------------------*/
3251 ... {
3252 ...     $szType = '';                                               /* Return value of the function */
3253 ...     $szExt  = strtolower( FIL_Split( $szFile,4 ) );             /* File extension */
3254 ...     $aMIME  = array( '.aif'     => 'audio/x-aiff'                   ,
3255 ...                      '.aiff'    => 'audio/x-aiff'                   ,
3256 ...                      '.arc'     => 'application/octet-stream'       ,
3257 ...                      '.arj'     => 'application/octet-stream'       ,
3258 ...                      '.art'     => 'image/x-jg'                     ,
3259 ...                      '.asf'     => 'video/x-ms-asf'                 ,
3260 ...                      '.asx'     => 'video/x-ms-asf'                 ,
3261 ...                      '.avi'     => 'video/avi'                      ,
3262 ...                      '.bin'     => 'application/octet-stream'       ,
3263 ...                      '.bm'      => 'image/bmp'                      ,
3264 ...                      '.bmp'     => 'image/bmp'                      ,
3265 ...                      '.bz2'     => 'application/x-bzip2'            ,
3266 ...                      '.css'     => 'text/css'                       ,
3267 ...                      '.csv'     => 'text/csv'                       ,
3268 ...                      '.doc'     => 'application/msword'             ,
3269 ...                      '.dot'     => 'application/msword'             ,
3270 ...                      '.docx'    => 'application/msword'             ,
3271 ...                      '.dv'      => 'video/x-dv'                     ,
3272 ...                      '.exe'     => 'application/octetstream'        ,
3273 ...                      '.gif'     => 'image/gif'                      ,
3274 ...                      '.gz'      => 'application/x-gzip'             ,
3275 ...                      '.gzip'    => 'application/x-gzip'             ,
3276 ...                      '.htm'     => 'text/html'                      ,
3277 ...                      '.html'    => 'text/html'                      ,
3278 ...                      '.ico'     => 'image/x-icon'                   ,
3279 ...                      '.jpe'     => 'image/jpeg'                     ,
3280 ...                      '.jpeg'    => 'image/jpeg'                     ,
3281 ...                      '.jpg'     => 'image/jpeg'                     ,
3282 ...                      '.js'      => 'application/x-javascript'       ,
3283 ...                      '.json'    => 'application/json'               ,
3284 ...                      '.log'     => 'text/plain'                     ,
3285 ...                      '.txt'     => 'text/plain'                     ,
3286 ...                      '.mid'     => 'audio/x-midi'                   ,
3287 ...                      '.mov'     => 'video/quicktime'                ,
3288 ...                      '.mp2'     => 'audio/mpeg'                     ,
3289 ...                      '.mpg'     => 'audio/mpeg'                     ,
3290 ...                      '.mp3'     => 'audio/mpeg3'                    ,
3291 ...                      '.mp4'     => 'video/mp4'                      ,
3292 ...                      '.ogg'     => 'application/ogg'                ,
3293 ...                      '.pdf'     => 'application/pdf'                ,
3294 ...                      '.png'     => 'image/png'                      ,
3295 ...                      '.ppt'     => 'application/vnd.ms-powerpoint'  ,
3296 ...                      '.ra'      => 'audio/vnd.rn-realaudioreal'     ,
3297 ...                      '.rtf'     => 'application/rtf'                ,
3298 ...                      '.tif'     => 'image/tiff'                     ,
3299 ...                      '.tiff'    => 'image/tiff'                     ,
3300 ...                      '.vcard'   => 'text/x-vCard'                   ,
3301 ...                      '.wav'     => 'audio/x-wav'                    ,
3302 ...                      '.wma'     => 'audio/x-ms-wma'                 ,
3303 ...                      '.xls'     => 'application/vnd.ms-excel'       ,
3304 ...                      '.xml'     => 'text/xml'                       ,
3305 ...                      '.zip'     => 'application/zip' );
3306 ... 
3307 ...     if ( isset( $aMIME[$szExt] ) )
3308 ...     {
3309 ...         $szType = trim( $aMIME[$szExt] );
3310 ...     }
3311 ...     else
3312 ...     {
3313 ...         $szType = 'application/force-download';
3314 ...     }
3315 ... 
3316 ...     return ( $szType );                                             /* Return value to caller */
3317 ... }   /* End of function FIL_GetFileType() */
3318 ... /* ====================================================================== */
3319 ... 
3320 ... /* ====================================================================== */
3321 ... /** {{*FIL_aFilesEx( $szPattern,$iFlags )=
3322 ... 
3323 ...     Find pathnames matching a pattern
3324 ... 
3325 ...     {*params
3326 ...         $szPattern  (string)    Pattern
3327 ...         $iFlags     (int)       Optional. [c]0[/c] by default.[br][br]
3328 ... 
3329 ...                                 [c]GLOB_MARK[/c] : Adds a slash to each directory returned [br]
3330 ...                                 [c]GLOB_NOSORT[/c] : Return files as they appear in the directory (no sorting)[br]
3331 ...                                 [c]GLOB_NOCHECK[/c] : Return the search pattern if no files matching it were found[br]
3332 ...                                 [c]GLOB_NOESCAPE[/c] : Backslashes do not quote metacharacters[br]
3333 ...                                 [c]GLOB_BRACE[/c] : Expands a,b,c to match 'a', 'b', or 'c'[br]
3334 ...                                 [c]GLOB_ONLYDIR[/c] : Return only directory entries which match the pattern[br]
3335 ...                                 [c]GLOB_ERR[/c] : Stop on read errors (like unreadable directories), by default errors are ignored.[br]
3336 ... 
3337 ...     *}
3338 ... 
3339 ...     {*remark
3340 ...         This function is a wrapper of [c]glob()[/c]
3341 ...     *}
3342 ... 
3343 ...     {*return
3344 ...         (array)     Returns an array containing the matched files/directories,
3345 ...                     an empty array if no file matched or [c]false[/c] on error.
3346 ...     *}
3347 ... 
3348 ...     {*warning
3349 ...         We discourage the use of this function. Please prefer the [c]FIL_aFiles()[/c] function instead.
3350 ...     *}
3351 ... 
3352 ...     {*example
3353 ...         if ( count( $aFiles = FIL_aFilesEx( 'c:/mysite.com/images/*.png' ) ) > 0 && is_array( $aFiles ) )
3354 ...         {
3355 ...             foreach( $aFiles as $szFile )
3356 ...             {
3357 ...                 echo "<p>File: {$szFile}</p>\n";
3358 ...             }
3359 ...         }
3360 ...     *}
3361 ... 
3362 ...     {*seealso
3363 ...         FIL_aDirs(), FIL_aFiles()
3364 ...     *}
3365 ... 
3366 ...     *}}
3367 ...  */
3368 ... /* ====================================================================== */
3369 ... function FIL_aFilesEx( $szPattern,$iFlags = 0 )
3370 ... /*-------------------------------------------*/
3371 ... {
3372 ...     $x = glob( $szPattern,$iFlags );
3373 ...     return ( is_array( $x ) ? $x : array() );
3374 ... }
3375 ... 

Manifest Constants

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

VAESOLI_SHASH: Define the value of the slash character in the file system

LS_FILES_FUNCTIONS: Remember that THESE functions have been declared

Sources required

LSStrings.functions.php: String functions

LSUnitTesting.class.php: Vae Soli! Unit Testing

UltraEdit Syntax files

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

Function List (TOC)

  1. FIL_AddBS(): Adds a backslash at the end of a string if it does not have one already No assertion found for FIL_AddBS() (0 - 0)
  2. FIL_aDirs(): Returns an array of directories found in $szRoot
  3. FIL_aFiles(): Returns an array of files found in $szDir and that match the $szPattern regex pattern No assertion found for FIL_aFiles() (0 - 0)
  4. FIL_aFilesEx(): Find pathnames matching a pattern No assertion found for FIL_aFilesEx() (0 - 0)
  5. FIL_Append(): Writes $szText to $szFile (append mode) No assertion found for FIL_Append() (0 - 0)
  6. FIL_aTime(): Determines the last access date and time of a file No assertion found for FIL_aTime() (0 - 0)
  7. FIL_BuildBackupName(): Creates a pseudo backup name No assertion found for FIL_BuildBackupName() (0 - 0)
  8. FIL_CDate(): Determines the creation date and time of a file
  9. FIL_Chunk(): Splits a text file into multiple parts No assertion found for FIL_Chunk() (0 - 0)
  10. FIL_Close(): Closes file No assertion found for FIL_Close() (0 - 0)
  11. FIL_Combine(): Combines multiple files ($aFiles) into a single file No assertion found for FIL_Combine() (0 - 0)
  12. FIL_Compress(): Compress a file No assertion found for FIL_Compress() (0 - 0)
  13. FIL_Copy(): Copies $szSrc to $szDest No assertion found for FIL_Copy() (0 - 0)
  14. FIL_Create(): Creates a file No assertion found for FIL_Create() (0 - 0)
  15. FIL_CreateTemp(): Creates a temporary file No assertion found for FIL_CreateTemp() (0 - 0)
  16. FIL_cTime(): Determines the creation date and time of a file No assertion found for FIL_cTime() (0 - 0)
  17. FIL_DateTime(): Determines the last modification datetime of a file No assertion found for FIL_DateTime() (0 - 0)
  18. FIL_Delete(): Erases a file from disk No assertion found for FIL_Delete() (0 - 0)
  19. FIL_EOF(): Determines if file is at END OF FILE position No assertion found for FIL_EOF() (0 - 0)
  20. FIL_Exists(): Determines if a file exists. Uses paths mentioned in $szPath if passed.
  21. FIL_FileToStr(): Returns the contents of a file as a character string.
  22. FIL_FileToStrEx(): Returns the contents of a file as a character string. Extended function of FIL_FileToStr().
  23. FIL_GetFileType(): Returns the MIME type corresponding to the file extension of $szFile
  24. FIL_Gets(): Get next line of file No assertion found for FIL_Gets() (0 - 0)
  25. FIL_IncludeOnce(): Includes a file if it exists No assertion found for FIL_IncludeOnce() (0 - 0)
  26. FIL_IsDir(): Determines if $szDir is a directory No assertion found for FIL_IsDir() (0 - 0)
  27. FIL_IsLink(): Determines if a file/dir is a link or not No assertion found for FIL_IsLink() (0 - 0)
  28. FIL_IsReadOnly(): Is $szFile read only? No assertion found for FIL_IsReadOnly() (0 - 0)
  29. FIL_LinesCount(): Determines the number of lines in a text file
  30. FIL_MDate(): Determines the date and time of last modification of a file
  31. FIL_MkDir(): Creates a directory including all inner directories if needed No assertion found for FIL_MkDir() (0 - 0)
  32. FIL_mTime(): Determines the last modification date and time of a file No assertion found for FIL_mTime() (0 - 0)
  33. FIL_Normalize(): Normalizes $szPath and possibly shorten the name ('..' treatment)
  34. FIL_Now(): Returns a file name in the YYYYMMDDHHmmSSXXXXXXXXXX format. No assertion found for FIL_Now() (0 - 0)
  35. FIL_Open(): Opens file No assertion found for FIL_Open() (0 - 0)
  36. FIL_ReadEx(): Opens a file and read a given umber of bytes from it No assertion found for FIL_ReadEx() (0 - 0)
  37. FIL_RealPath(): Shorten a path by replacing all occurrences of \..\ or /../
  38. FIL_Rename(): Renames (moves) $szSrc to $szDest No assertion found for FIL_Rename() (0 - 0)
  39. FIL_ResolveRoot(): Resolves the path of a file from the root directory of the site No assertion found for FIL_ResolveRoot() (0 - 0)
  40. FIL_RevertRoot(): Determines the site file compared to the root directory of the site. Opposite function of FIL_ResolveRoot(). No assertion found for FIL_RevertRoot() (0 - 0)
  41. FIL_Seek(): Seeks on a file pointer
  42. FIL_Size(): Gets file size No assertion found for FIL_Size() (0 - 0)
  43. FIL_Split(): Splits a filename into basic components (drive, path, filename, extension)
  44. FIL_StrToFile(): Writes the contents of a character string to a file.
  45. FIL_Tell(): Returns the current position of the file read/write pointer
  46. FIL_Time(): Determines the date and time of a file (creation, modification or last access) No assertion found for FIL_Time() (0 - 0)
  47. FIL_Uncompress(): Uncompress a file No assertion found for FIL_Uncompress() (0 - 0)
  48. FIL_Write(): Writes $szText to a file specified by its $rHandle handle No assertion found for FIL_Write() (0 - 0)
  49. SendFile(): Sends a file No assertion found for SendFile() (0 - 0)

Functions of LSFiles.functions.php

FIL_AddBS(): Adds a backslash at the end of a string if it does not have one already

[ back to function list ]

Syntax

FIL_AddBS( $szStr,$cMark )

Alias

ADDBS()

Parameters
NameTypeDescription
$szStr string String to which a backslash must be added
$cMark character Backslash character. Optional. null by default
Return

(string) String with the added backslash

Example Executed
$szFile = FIL_AddBS( "C:\\MYDIR" );
echo "<p>'{$szFile}' ends with '" . STR_Last( $szFile ),"'</p>";

'C:\MYDIR\' ends with '\'

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(...); *}).

FIL_aDirs(): Returns an array of directories found in $szRoot

[ back to function list ]

Syntax

FIL_aDirs( $szRoot )

Parameters
NameTypeDescription
$szRoot string Root directory to scan for directories
Return

(array) An array of directories. The array is empty if no directory found.

Example Executed
$szDir = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources';
$oArray = new LSArray();
$oArray->PushMany( $aArray = FIL_aDirs( $szDir ) );
var_dump( $aArray );
echo LSUnitTesting::assert( $oArray->Count() >= 8                   ,
                            'ASSERTION SUCCESS: directories OK'     ,
                            'ASSERTION FAILURE: directories NOT OK' ,
                            'GuideAssert' );
echo LSUnitTesting::assert( $oArray->Get(4) === 'images'                                ,
                            'ASSERTION SUCCESS: "images" dir found at proper place'     ,
                            'ASSERTION FAILURE: "images" dir NOT found at proper place' ,
                            'GuideAssert' );

array (size=8)
  0 => string 'entities' (length=8)
  1 => string 'fonts' (length=5)
  2 => string 'geoip' (length=5)
  3 => string 'icons' (length=5)
  4 => string 'images' (length=6)
  5 => string 'media' (length=5)
  6 => string 'ut' (length=2)
  7 => string 'XML' (length=3)

GuideAssert() ... ASSERTION SUCCESS: directories OK

GuideAssert() ... ASSERTION SUCCESS: "images" dir found at proper place

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

FIL_aFiles()

FIL_aFiles(): Returns an array of files found in $szDir and that match the $szPattern regex pattern

[ back to function list ]

Caution

Make sure that the pattern is a valid pattern for regular expressions (preg_match()).

Abstract

Hello World

Syntax

FIL_aFiles( $szDir,$szPattern,$bWithRoot,$bWithDir )

Parameters
NameTypeDescription
$szDir string Root directory to scan for directories
$szPattern string Regular expression pattern. Optional. null by default.
$bWithRoot bool Optional. true by default. Indicates whether the file to be shoved in the array must contain the full path.
$bWithDir bool Optional. false by default. Indicates whether directories should be included as well
Parameters Warning

FIL_aFiles() uses 4 parameters whereas the suggested limit is 3.

Return

(array) An array of files corresponding to the $szPattern pattern

Example(s)
$aFiles = FIL_aFiles( FIL_ResolveRoot( '.' ),'/\.php/i',true );
foreach( $aFiles as $szFile )
{
    echo "<p>File: {$szFile}</p>\n";
}
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(...); *}).

See Also

FIL_aDirs(), FIL_aFilesEx()

FIL_aFilesEx(): Find pathnames matching a pattern

[ back to function list ]

Warning

We discourage the use of this function. Please prefer the FIL_aFiles() function instead.

Remark

This function is a wrapper of glob()

Syntax

FIL_aFilesEx( $szPattern,$iFlags )

Parameters
NameTypeDescription
$szPattern string Pattern
$iFlags int Optional. 0 by default.

GLOB_MARK : Adds a slash to each directory returned
GLOB_NOSORT : Return files as they appear in the directory (no sorting)
GLOB_NOCHECK : Return the search pattern if no files matching it were found
GLOB_NOESCAPE : Backslashes do not quote metacharacters
GLOB_BRACE : Expands a,b,c to match 'a', 'b', or 'c'
GLOB_ONLYDIR : Return only directory entries which match the pattern
GLOB_ERR : Stop on read errors (like unreadable directories), by default errors are ignored.
Return

(array) Returns an array containing the matched files/directories, an empty array if no file matched or false on error.

Example(s)
if ( count( $aFiles = FIL_aFilesEx( 'c:/mysite.com/images/*.png' ) ) > 0 && is_array( $aFiles ) )
{
    foreach( $aFiles as $szFile )
    {
        echo "<p>File: {$szFile}</p>\n";
    }
}
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(...); *}).

See Also

FIL_aDirs(), FIL_aFiles()

FIL_Append(): Writes $szText to $szFile (append mode)

[ back to function list ]

Syntax

FIL_Append( $szFile,$szText )

Alias

FileAppend(), XAppend()

Parameters
NameTypeDescription
$szFile string Name of the file to write to
$szText string Specifies the character string that is to be written to the file
Return

(bool) true if $szText written successfully to $szFile;false otherwise.

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(...); *}).

FIL_aTime(): Determines the last access date and time of a file

[ back to function list ]

Created: 17/07/2012 07:19

Since version 5.0.0005

Syntax

FIL_aTime( $szFile,$szFormat )

Parameters
NameTypeDescription
$szFile string Name of the file whose last access date and time must be returned
$szFormat string Optional format of the output date string. See date() function of PHP to obtain in-depth details of the format string.
Return

(mixed) Last access date and time returned as an int (same use as time()) if $szFormat === null; string if $szFormat mentioned

Example Executed
echo '<p>' . FIL_aTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php' )             . '</p>';
echo '<p>' . FIL_aTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php','Ymd H:i:s' ) . '</p>';

1425364370

20150303 06:32:50

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(...); *}).

See Also

FIL_cTime(), FIL_mTime(), FIL_Time()

FIL_BuildBackupName(): Creates a pseudo backup name

[ back to function list ]

Created: 27/06/2012 - 19:28

Since version 5.0.0003

Modified: 18/01/2013 - 09:24

Syntax

FIL_BuildBackupName( $szFile )

Parameters
NameTypeDescription
$szFile string Original file name
Return

(string) Backup name (the name of the original file is appended with the time, microtime and a '.safe' extension)

Example Executed
$szFile = 'C:\\mydir\\dir2\\waow.txt';
echo '<p>',FIL_BuildBackupName( $szFile ),'</p>';

C:\mydir\dir2\waow.txt.1427905189.1427905189.safe

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(...); *}).

See Also

FIL_Now()

FIL_CDate(): Determines the creation date and time of a file

[ back to function list ]

Since version 5.0.0012

Modified: 14/01/2013 - 12:05

Syntax

FIL_CDate( $szFile,$szFormat )

Parameters
NameTypeDescription
$szFile string Name of the file whose creation date and time must be returned
$szFormat string The format of the output date string
Return

(string) Creation date and time returned in 'd/m/Y - H:i:s' format is $szFormat NOT passed (see date() function of PHP)

Example(s)
echo FIL_CDate( 'C:\\myfile.txt' );
Example Executed
$szFile = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources\\ut\\bonjour.txt';
echo FIL_CDate( $szFile );
echo LSUnitTesting::assert( FIL_CDate( $szFile ) === '04/10/2013 - 15:04:16'    ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );
echo LSUnitTesting::assert( FIL_CDate( $szFile,'Ymd' ) === '20131004'           ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );
echo LSUnitTesting::assert( FIL_CDate( $szFile,'YmdHis' ) === '20131004150416'  ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );
echo LSUnitTesting::assert( FIL_CDate( $szFile,'' ) === ''                      ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );

04/10/2013 - 15:04:16

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

FIL_Time(), FIL_MDate()

FIL_Chunk(): Splits a text file into multiple parts

[ back to function list ]

Created: 29/06/2012 - 12:42

Since version 5.0.0003

Modified: 16/01/2013 - 21:15

Warning

Do not use FIL_Chunk() on other files than text files! Please be aware of the fact that the function stops writing to a part when $iMaxSize has been reached. Therefore the resulting file is often slightly bigger than $iMaxSize. This function is still experimental!

Caution

Large files can take some time to be split in smaller chunks. Please set the maximum execution limit accordingly (set_time_limit())

Syntax

FIL_Chunk( $szFile,$iLineLength,$iMaxSize )

Parameters
NameTypeDescription
$szFile string The file to split apart
$iLineLength int Optional line length for reading (in bytes). Default = 2048.
$iMaxSize int Optional maximum size of split (in bytes). Default = 100000.
Return

(int) Number of parts written. Each part ends with a ".split" extension. For example, if "traces-LATO.log" is split in 3 parts, 3 resulting files will be generated:

traces-LATO.log-0.split
traces-LATO.log-1.split
traces-LATO.log-2.split

Example(s)
$szFile = 'mybiglogfile.log';
if ( ( $iParts = FIL_Chunk( $szFile ) ) > 0 )
{
    echo '<p>' . $szFile . ' has been split in ' . $iParts . ' parts</p>';
}
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(...); *}).

See Also

FIL_Combine()

FIL_Close(): Closes file

[ back to function list ]

Created: 27/06/2012 - 18:46

Since version 5.0.0003

Syntax

FIL_Close( $rHandle )

Parameters
NameTypeDescription
$rHandle res Resource handle of the file
Return

(bool) true if file is succesfully closed; false otherwise

Example(s)
// Open file in read mode
if ( $rHandle = FIL_Open( $szFile,'r+' ) )
{
    // While NOT End Of File
    while ( ! FIL_EOF( $rHandle ) )
    {
        $szLine = FIL_Gets( $rHandle,512 );
    }

    // Close file when no longer needed
    FIL_Close( $rHandle );
}
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(...); *}).

See Also

FIL_Open(), FIL_Create()

FIL_Combine(): Combines multiple files ($aFiles) into a single file

[ back to function list ]

Created: 01/07/2012 - 13:58

Since version 5.0.0003

Modified: 16/01/2013 - 21:15

Uses

FIL_Open(), FIL_Write(), FIL_Close()

Caution

If $szFile exists it is overwritten

Syntax

FIL_Combine( $szFile,$aFiles )

Parameters
NameTypeDescription
$szFile string The resulting file
$aFiles array Array of physical files to combine into $szFile
Return

(int) Total number of bytes written or -1 if error

Example(s)
$szFile = 'mybiglogfile.log';
if ( ( $iParts = FIL_Chunk( $szFile ) ) > 0 )
{
    echo '<p>' . $szFile . ' has been split in ' . $iParts . ' parts'</p>';
}
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(...); *}).

See Also

FIL_Chunk()

FIL_Compress(): Compress a file

[ back to function list ]

Syntax

FIL_Compress( $szSource,$szTarget )

Parameters
NameTypeDescription
$szSource string Name of the file to compress
$szTarget string Name of the target file
Return

(bool) True if the file was successfully compressed; false otherwise

Example(s)
if ( FIL_Compress( 'C:\\myfile.txt','C:\\myfile.cmp' ) )
{
    echo '<p>File successfully compressed</p>';
}
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(...); *}).

See Also

FIL_Uncompress()

FIL_Copy(): Copies $szSrc to $szDest

[ back to function list ]

Created: 27/06/2012 - 19:28

Since version 5.0.0003

Modified: 18/01/2013 - 09:24

Syntax

FIL_Copy( $szSrc,$szDest )

Parameters
NameTypeDescription
$szSrc string Source file
$szDest string Target file
Return

(bool) true if $szSrc successfully copied to $szDest; false if not.

Example(s)
if ( ! FIL_Copy( $szSrc,$szDest ) )
{
    echo "<p>'{$szSrc}' cannot be copied to '{$szDest}'</p>";
}
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(...); *}).

FIL_Create(): Creates a file

[ back to function list ]

Created: 16/01/2013 - 11:28

Since version 5.0.0012

Syntax

FIL_Create( $szFile )

Parameters
NameTypeDescription
$szFile string Specifies the file to create
Return

(res) resource handle to file if function is successful; null otherwise

Example(s)
// Creates a file in read and write mode
if ( $rHandle = FIL_Create( $szFile ) )
{
    // While NOT End Of File
    while ( ! FIL_EOF( $rHandle ) )
    {
        $szLine = FIL_Gets( $rHandle,512 );
    }

    // Close file when no longer needed
    FIL_Close( $rHandle );
}
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(...); *}).

See Also

FIL_Open(), FIL_Close()

FIL_CreateTemp(): Creates a temporary file

[ back to function list ]

Since version 1.1.0001

Modified: 27/06/2012 - 15:06

Syntax

FIL_CreateTemp( $szFileSpec )

Parameters
NameTypeDescription
$szFileSpec string Temporary filename. This variable is not used to create the temporary file: it is updated upon return. Sent by reference.
Return

(bool) true if temporary file succesfully created; false if not

Example(s)
$szFile = '';
if ( FIL_CreateTmp( $szFile ) )
{
    echo '<p>' . $szFile . ' created</p>';
}
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(...); *}).

FIL_cTime(): Determines the creation date and time of a file

[ back to function list ]

Created: 17/07/2012 07:18

Since version 5.0.0005

Syntax

FIL_cTime( $szFile,$szFormat )

Parameters
NameTypeDescription
$szFile string Name of the file whose creation date and time must be returned
$szFormat string The format of the output date string. Optional.
Return

(mixed) Last access date and time returned as an int (same use as time()) if $szFormat === null; string if $szFormat mentioned

Example Executed
echo '<p>' . FIL_cTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php' )             . '</p>';
echo '<p>' . FIL_cTime( 'C:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php','Ymd H:i:s' ) . '</p>';

1375572472

20130803 23:27:52

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(...); *}).

See Also

FIL_aTime(), FIL_mTime(), FIL_Time()

FIL_DateTime(): Determines the last modification datetime of a file

[ back to function list ]

Warning

This function is provided for backward compatibility. It is recommended to use FIL_mTime() instead.

Syntax

FIL_DateTime( $szFile,$iRetType )

Parameters
NameTypeDescription
$szFile string File whose last update datetime must be determined
$iRetType int Optional return type. 1 by default = 'YYYYMMDDHHmmSS' string; any other integer value will return an array
Return

(mixed) if $iRetType == 1, a YYYYMMDDHHmmSS string is returned or null if date cannot be obtained. if $iRetType != 1, an associative array is returned if all goes well (otherwise it is also a null)

Example(s)
echo "<p>Last update: " . FIL_DateTime( "C:\\websites\\myfile.txt" ) . "</p>\n";
Example Executed
var_dump( FIL_DateTime( 'C:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFiles.functions.php',2 ) );

array (size=6)
  'YYYY' => string '2015' (length=4)
  'MM' => string '03' (length=2)
  'DD' => string '03' (length=2)
  'HH' => string '06' (length=2)
  'mm' => string '32' (length=2)
  'SS' => string '50' (length=2)
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(...); *}).

FIL_Delete(): Erases a file from disk

[ back to function list ]

Created: 27/06/2012 - 18:40

Since version 5.0.0003

Syntax

FIL_Delete( $szFile )

Alias

FIL_Del()

Parameters
NameTypeDescription
$szFile string Specifies the file to delete
Return

(bool) true if $szFile successfully deleted; false otherwise

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(...); *}).

See Also

FIL_Rename(), FIL_Copy()

FIL_EOF(): Determines if file is at END OF FILE position

[ back to function list ]

Created: 03/12/2012 - 11:08

Since version 5.0.0010

Syntax

FIL_EOF( $rHandle )

Parameters
NameTypeDescription
$rHandle res resource handle of file whose EOF position must be checked
Return

(boolean) true if $rHandle at EOF; false otherwise.

Example(s)
// Open file in read mode
if ( $rHandle = FIL_Open( $szFile,'r+' ) )
{
    // While NOT End Of File
    while ( ! FIL_EOF( $rHandle ) )
    {
        $szLine = FIL_Gets( $rHandle,512 );
    }

    // Close file when no longer needed
    FIL_Close( $rHandle );
}
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(...); *}).

See Also

FIL_Open(), FIL_Close()

FIL_Exists(): Determines if a file exists. Uses paths mentioned in $szPath if passed.

[ back to function list ]

Modified: 02/07/2012 - 08:42

Uses

FIL_Normalize()

Remark

This function will also search the $szPath path if mentioned

Syntax

FIL_Exists( $szFile,$szPath,$szFileSpec )

Parameters
NameTypeDescription
$szFile string File whose existence must be checked
$szPath string Tokenized paths (';'). Optional.
$szFileSpec string File that was found. Optional. Updated upon return if passed.
Return

(bool) returns true if the specified file is found on disk (either current dir or in $szPath )

Example(s)
// Example #1
if ( FIL_Exists( 'LSStrings.functions.php' ) )
{
    // Do something
}

// Example #2
// VAESOLI_INCLUDE is a manifest constant pointing to
// the installation of Vae Soli!
if ( FIL_Exists( 'LSStrings.functions.php',get_include_path() . PATH_SEPARATOR . VAESOLI_INCLUDE ) )
{
    // Do something
}

// Example #3
// VAESOLI_INCLUDE is a manifest constant pointing to
// the installation of Vae Soli!
// $szTheFile will be updated upon return with the
// exact filename that was found
$szTheFile = '';
if ( FIL_Exists( 'LSStrings.functions.php'                              ,
                 get_include_path() . PATH_SEPARATOR . VAESOLI_INCLUDE  ,
                 $szTheFile
               )
   )
{
    echo "<p>File found: {$szTheFile}</p>";
}
Example Executed
if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
{
    echo LSUnitTesting::assert( FIL_Exists( $szFile )                   ,
                                'ASSERTION SUCCESS: file exists'        ,
                                'ASSERTION FAILURE: file does NOT exist',
                                'GuideAssert' );
    FIL_Delete( $szFile );
    echo LSUnitTesting::assertFalse( FIL_Exists( $szFile )              ,
                                'ASSERTION SUCCESS: file does NOT exist',
                                'ASSERTION FAILURE: file exists'        ,
                                'GuideAssert' );
}

GuideAssert() ... ASSERTION SUCCESS: file exists

GuideAssert() ... ASSERTION SUCCESS: file does NOT exist

Assertions

FIL_Exists( null ) === false successful

FIL_Exists( '' ) === false successful

FIL_Exists( '%georama%' ) === false successful

Unit Testing

5 assertions: 5 successful; 0 failed

FIL_FileToStr(): Returns the contents of a file as a character string.

[ back to function list ]

Modified: 27/06/2012 - 11:34

Syntax

FIL_FileToStr( $szFile )

Alias

FIL_Read(), FIL_File2Str(), File2Str(), FileToStr()

Parameters
NameTypeDescription
$szFile string Specifies the name of the file whose contents are returned as a character string
Return

(string) Character string (file content)

Example(s)
$szStr = FIL_FileToStr( 'c:\website\mine\www\httpdocs\myfile.xml' ); / Read XML file

if ( ! STR_Empty( $szStr ) )                                        // If got something
{
    $oDom = new DOMDocument();                                      // Create a new DOM
    if ( $oDom->loadXML( $szStr ) )                                 // Loads XML string
    {
        echo $doc->saveXML();                                       // echo XML
    }
}
Example Executed
if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
{
    $szContent = FIL_FileToStr( $szFile );
    echo LSUnitTesting::assert( $szContent === $szStr                       ,
                                'ASSERTION SUCCESS: successful write & read',
                                'ASSERTION FAILURE: invalid resource'       ,
                                'GuideAssert' );
    FIL_Delete( $szFile );
}

GuideAssert() ... ASSERTION SUCCESS: successful write & read

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

FIL_FileToStrEx()

FIL_FileToStrEx(): Returns the contents of a file as a character string. Extended function of FIL_FileToStr().

[ back to function list ]

Modified: 27/06/2012 - 11:51

Syntax

FIL_FileToStrEx( $szFile,$iTries )

Alias

FIL_Read(), FIL_File2Str(), File2Str(), FileToStr()

Parameters
NameTypeDescription
$szFile string Specifies the name of the file whose contents are returned as a character string
$iTries int Trials opening the file (a delay of 1 sec between each trial). Optional. 3 by default.
Return

(string) Character string (file content)

Example(s)
// Read XML file. Try 5 times
$szStr = FIL_FileToStrEx( 'c:\website\mine\www\httpdocs\myfile.xml',5 );

if ( ! STR_Empty( $szStr ) )            // If got something
{
    $oDom = new DOMDocument();          // Create a new DOM
    if ( $oDom->loadXML( $szStr ) )     // Loads XML string
    {
        echo $doc->saveXML();           // echo XML
    }
}
Example Executed
if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
{
    $szContent = FIL_FileToStrEx( $szFile );
    echo LSUnitTesting::assert( $szContent === $szStr                       ,
                                'ASSERTION SUCCESS: successful write & read',
                                'ASSERTION FAILURE: invalid resource'       ,
                                'GuideAssert' );
    FIL_Delete( $szFile );
}

GuideAssert() ... ASSERTION SUCCESS: successful write & read

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

FIL_FileToStr()

FIL_GetFileType(): Returns the MIME type corresponding to the file extension of $szFile

[ back to function list ]

Modified: 16/01/2013 - 21:11

Remark

Only a small subset of MIME types is considered

Docs


Syntax

FIL_GetFileType( $szFile )

Parameters
NameTypeDescription
$szFile string File whose MIME type must be determined
Return

(string) The MIME type

.aif audio/x-aiff
.aiff audio/x-aiff
.arc application/octet-stream
.arj application/octet-stream
.art image/x-jg
.asf video/x-ms-asf
.asx video/x-ms-asf
.avi video/avi
.bin application/octet-stream
.bm image/bmp
.bmp image/bmp
.bz2 application/x-bzip2
.css text/css
.csv text/csv
.doc application/msword
.dot application/msword
.docx application/msword
.dv video/x-dv
.exe application/octetstream
.gif image/gif
.gz application/x-gzip
.gzip application/x-gzip
.htm text/html
.html text/html
.ico image/x-icon
.jpe image/jpeg
.jpeg image/jpeg
.jpg image/jpeg
.js application/x-javascript
.json application/json
.log text/plain
.txt text/plain
.mid audio/x-midi
.mov video/quicktime
.mp2 audio/mpeg
.mpg audio/mpeg
.mp3 audio/mpeg3
.mp4 video/mp4
.ogg application/ogg
.pdf application/pdf
.png image/png
.ppt application/vnd.ms-powerpoint
.ra audio/vnd.rn-realaudioreal
.rtf application/rtf
.tif image/tiff
.tiff image/tiff
.vcard text/x-vCard
.wav audio/x-wav
.wma audio/x-ms-wma
.xls application/vnd.ms-excel
.xml text/xml
.zip application/zip );
default application/force-download

Example(s)
echo FIL_GetFileType( 'c:\data\countries.xml' ); // Prints "text/xml"
echo FIL_GetFileType( 'c:\images\woman.jpg'   ); // Prints "image/jpeg"
Assertions

FIL_GetFileType( 'c:\data\countries.xml' ) === 'text/xml' successful

FIL_GetFileType( 'c:\images\woman.jpg' ) === 'image/jpeg' successful

FIL_GetFileType( 'c:\images\audio.ra' ) === 'audio/vnd.rn-realaudioreal' successful

Unit Testing

3 assertions: 3 successful; 0 failed

See Also

SendFile()

FIL_Gets(): Get next line of file

[ back to function list ]

Created: 27/06/2012 - 19:28

Since version 5.0.0003

Modified: 03/12/2012 - 11:19

Syntax

FIL_Gets( $rHandle,$iLength )

Parameters
NameTypeDescription
$rHandle res Resource handle of the file to get content from
$iLength int Maximum line length. Optional. 1024 by default
Return

(string) Next line from file. false if end of file encountered.

Example(s)
// Open file in read mode
if ( $rHandle = FIL_Open( $szFile,'r+' ) )
{
    // While NOT End Of File
    while ( ! FIL_EOF( $rHandle ) )
    {
        $szLine = FIL_Gets( $rHandle,512 );
    }

    // Close file when no longer needed
    FIL_Close( $rHandle );
}
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(...); *}).

See Also

FIL_Open(), FIL_Close()

FIL_IncludeOnce(): Includes a file if it exists

[ back to function list ]

Created: 02/03/2015 - 12:44

Author

Syntax

FIL_IncludeOnce( $szFile )

Parameters
NameTypeDescription
$szFile string File to include
Return

(bool) true if $szFile exists; false if not

Example(s)
THE EXAMPLE WILL NOT WORK
if ( $rHandle = FIL_Open( $szFile,'r' ) )
{
    echo '<p>POSITION AT OPENING: ',FIL_Tell( $rHandle ),'</p>';
    FIL_Seek( $rHandle,-10,SEEK_END );
    echo '<p>NEW POSITION: ',FIL_Tell( $rHandle ),'</p>';
    FIL_Close( $rHandle );
}
Example Executed
THE EXAMPLE WILL NOT WORK
if ( $rHandle = FIL_Open( $szFile = 'C:\websites\latosensu.be\www\httpdocs\vaesoli\include\LSFiles.functions.php','r' ) )
{
    $iPos = FIL_Tell( $rHandle );
    echo LSUnitTesting::assert( is_resource( $rHandle )                 ,
                                'ASSERTION SUCCESS: resource valid!'    ,
                                'ASSERTION FAILURE: invalid resource'   ,
                                'GuideAssert' );
    echo LSUnitTesting::assert( $iPos === 0                             ,
                                'ASSERTION SUCCESS: file pointer correct'   ,
                                'ASSERTION FAILURE: file pointer incorrect' ,
                                'GuideAssert' );
    $iSize = FIL_Size( $szFile );
    FIL_Seek( $rHandle,-10,SEEK_END );
    echo LSUnitTesting::assert( FIL_Tell( $rHandle ) === ( $iSize - 10 )    ,
                                'ASSERTION SUCCESS: file pointer correct'   ,
                                'ASSERTION FAILURE: file pointer incorrect' ,
                                'GuideAssert' );
    $bClosed = FIL_Close( $rHandle );
    echo LSUnitTesting::assert( $bClosed                                        ,
                                'ASSERTION SUCCESS: file successfully closed!'  ,
                                'ASSERTION FAILURE: file CANNOT be closed'      ,
                                'GuideAssert' );
}


( ! ) Parse error: syntax error, unexpected 'EXAMPLE' (T_STRING) in C:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSFunction.class.php(211) : eval()'d code on line 1
Call Stack
#TimeMemoryFunctionLocation
10.0041783056{main}( )..\guide.php:0
20.05146581032LSDocMaker->Doc( )..\guide.php:426
30.678510792104LSDocMaker->DocumentSourceFile( )..\guide.php:621
40.702411617864LSDocMaker->DocumentFunctionSourceFile( )..\guide.php:694
51.098413302848LSFunction->RenderExecs( )..\guide.php:869
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(...); *}).

FIL_IsDir(): Determines if $szDir is a directory

[ back to function list ]

Syntax

FIL_IsDir( $szDir )

Parameters
NameTypeDescription
$szDir string Directory to test
Return

(bool) true if $szDir is a directory; false otherwise

Example(s)
$szDir = "C:\\websites";
if ( FIL_IsDir( $szDir ) )
{
    echo "<p>{$szDir} is a directory</p>\n";
}
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(...); *}).

See Also

FIL_MkDir()

FIL_IsLink(): Determines if a file/dir is a link or not

[ back to function list ]

Modified: 16/01/2013 - 21:11

Uses

FIL_RealPath(), FIL_Normalize(), FIL_AddBS()

Warning

This function proved to be necessary after we have discovered that the is_link() function of PHP sometimes returned true and sometimes false on EXACTLY the same directory (byte per byte).

Syntax

FIL_IsLink( $szFile )

Parameters
NameTypeDescription
$szFile string File to check if link
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(...); *}).

FIL_IsReadOnly(): Is $szFile read only?

[ back to function list ]

Syntax

FIL_IsReadOnly( $szFile )

Parameters
NameTypeDescription
$szFile string File name
Return

(bool) [c]true[/c] if $szFile is in read only mode; [c]false[/c] otherwise.

Example(s)
if ( FIL_IsReadOnly( 'C:\\myfile.txt' ) )
{
    echo e<p>Read-only file</p>';
}
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(...); *}).

FIL_LinesCount(): Determines the number of lines in a text file

[ back to function list ]

Created: 04/10/2013 - 19:42

Remark

Use this function only with text files

Syntax

FIL_LinesCount( $szFile )

Parameters
NameTypeDescription
$szFile string File to examine
Return

(int) Number of lines

Example Executed
$szFile = 'C:\\websites\\latosensu.be\\www\\httpdocs\\vaesoli\\include\\LSFiles.functions.php';
$iLines = FIL_LinesCount( $szFile );
echo LSUnitTesting::assert( $iLines > 3000 && $iLines < 4000            ,
                            'ASSERTION SUCCESS: file seems OK'          ,
                            'ASSERTION FAILURE: file does NOT seem OK'  ,
                            'GuideAssert' );
$szFile = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources\\ut\\bonjour.txt';
$iLines = FIL_LinesCount( $szFile );
echo FIL_FileToStr( $szFile );
echo LSUnitTesting::assert( $iLines == 9                            ,
                            'ASSERTION SUCCESS: bonjour.txt OK'     ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK' ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESS: file seems OK

Bonjour les amis Bonjour les amis Bonjour les amis Bonjour les amis Bonjour les amis Bonjour les amis Bonjour les amis Bonjour les amis Bonjour les amis

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

Unit Testing

2 assertions: 2 successful; 0 failed

FIL_MDate(): Determines the date and time of last modification of a file

[ back to function list ]

Since version 5.0.0012

Modified: 14/01/2013 - 12:03

Syntax

FIL_MDate( $szFile,$szFormat )

Parameters
NameTypeDescription
$szFile string Name of the file whose last modification date and time must be returned
$szFormat string The format of the output date string
Return

(string) Last modification date and time returned in 'd/m/Y - H:i:s' format if $szFormat NOT passed (see date() function of PHP)

Example(s)
echo FIL_MDate( 'C:\\myfile.txt' );
Example Executed
$szFile = 'c:\\websites\\vaesoli.org\\www\\httpdocs\\vaesoli\\resources\\ut\\bonjour.txt';
echo LSUnitTesting::assert( FIL_MDate( $szFile ) === '04/10/2013 - 15:39:18'    ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );
echo LSUnitTesting::assert( FIL_MDate( $szFile,'Ymd' ) === '20131004'           ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );
echo LSUnitTesting::assert( FIL_MDate( $szFile,'YmdHis' ) === '20131004153918'  ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );
echo LSUnitTesting::assert( FIL_MDate( $szFile,'' ) === ''                      ,
                            'ASSERTION SUCCESS: bonjour.txt OK'                 ,
                            'ASSERTION FAILURE: bonjour.txt NOT OK'             ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

GuideAssert() ... ASSERTION SUCCESS: bonjour.txt OK

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

FIL_Time(), FIL_CDate()

FIL_MkDir(): Creates a directory including all inner directories if needed

[ back to function list ]

Syntax

FIL_MkDir( $szDir )

Parameters
NameTypeDescription
$szDir string Name of the directory that must be created
Return

(bool) true if $szDir successfully created;false if not

Example(s)
$szDir = 'c:\\mydir\\mysubdir\\dir3';
if ( ! FIL_IsDir( $szDir ) )
{
    if ( FIL_MkDir( $szDir ) )
    {
        echo "<p>'{$szDir}' successfully created</p>\n";
    }
    else
    {
        echo "<p>CANNOT create '{$szDir}'</p>\n";
    }
}
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(...); *}).

See Also

FIL_IsDir()

FIL_mTime(): Determines the last modification date and time of a file

[ back to function list ]

Created: 15/07/2012 21:11

Since version 5.0.0004

Syntax

FIL_mTime( $szFile,$szFormat )

Parameters
NameTypeDescription
$szFile string Name of the file whose last modification date and time must be returned
$szFormat string The format of the output date string. Optional.
Return

(mixed) Last date and time returned as an int (same use as time() if $szFormat === null; string if $szFormat mentioned)

Example(s)
$szVersion = '5.0.0004';
$szFile    = "/vaesoli/archive/vaesoli-{$szVersion}.zip";
$szDate    = FIL_mTime( FIL_ResolveRoot( $szFile ),"d-m-Y H:i" );
$szSize    = number_format( (float) FIL_Size(  FIL_ResolveRoot( $szFile ) ) ,
                            0                                               ,
                            ','                                             ,
                            '.' );
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(...); *}).

See Also

FIL_aTime(), FIL_cTime(), FIL_Time()

FIL_Normalize(): Normalizes $szPath and possibly shorten the name ('..' treatment)

[ back to function list ]

Created: 27/06/2012 - 19:28

Since version 5.0.0003

Modified: 18/01/2013 - 09:24

Uses

FIL_RealPath()

Syntax

FIL_Normalize( $szPath,$bShorten )

Parameters
NameTypeDescription
$szPath string Path to normalize
$bShorten bool Optional. false by default.
Return

(string) $szPath normalized and potentially shortened

Assertions

FIL_Normalize( 'C:/MYDIR/MYSUBDIR/../MYFILE.TXT' ) === 'C:\MYDIR\MYSUBDIR\..\MYFILE.TXT' successful

FIL_Normalize( 'C:/MYDIR/MYSUBDIR/../MYFILE.TXT',true ) === 'C:\MYDIR\MYFILE.TXT' successful

Unit Testing

2 assertions: 2 successful; 0 failed

See Also

FIL_RealPath()

FIL_Now(): Returns a file name in the YYYYMMDDHHmmSSXXXXXXXXXX format.

[ back to function list ]

Remark

FIL_Now() makes it possible to determine a filename that corresponds to the NOW moment. YYYY stands for the year, MM for the month, DD for the day, HH for the hour, mm for the minutes, SS for the seconds, and XXXXXXXXXX for the tick count (the tick count is left padded with "0").

FIL_Now() makes it very easy to get a filename that is most likely to be unique (although strictly speaking a file with the same name might already be existing) and that can be used to store sequential information.

FIL_Now() does not create the file.

Syntax

FIL_Now()

Parameters

None

Return

(string) Resulting filename.

Example(s)
echo FIL_Now();    // prints something similar to "201210291721330030346194"
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(...); *}).

See Also

FIL_BuildBackupName()

FIL_Open(): Opens file

[ back to function list ]

Created: 27/06/2012 - 18:40

Since version 5.0.0003

Syntax

FIL_Open( $szFile,$szMode )

Parameters
NameTypeDescription
$szFile string Specifies the file to open
$szMode string Optional opening mode (r, r+, w, w+, a, a+, x, x+). 'r' by default. See open() function of PHP for more doc.
Return

(res) resource handle to file if function is successful; null otherwise

Example(s)
// Open file in read mode
if ( $rHandle = FIL_Open( $szFile,'r+' ) )
{
    // While NOT End Of File
    while ( ! FIL_EOF( $rHandle ) )
    {
        $szLine = FIL_Gets( $rHandle,512 );
    }

    // Close file when no longer needed
    FIL_Close( $rHandle );
}
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(...); *}).

See Also

FIL_Close(), FIL_Create()

FIL_ReadEx(): Opens a file and read a given umber of bytes from it

[ back to function list ]

Created: 16/09/2013 - 06:12

Author

Remark

$szFile gets opened and closed

Syntax

FIL_ReadEx( $szFile,$iLength )

Parameters
NameTypeDescription
$szFile string Specifies the name of the file whose content is returned as a string
$iLength int Number of bytes to read from $szFile
Return

(string) Character string (file content)

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(...); *}).

See Also

FIL_Read()

FIL_RealPath(): Shorten a path by replacing all occurrences of \..\ or /../

[ back to function list ]

Uses

FIL_Normalize()

Syntax

FIL_RealPath( $szPath )

Parameters
NameTypeDescription
$szPath string Path to turn to a realpath
Return

(string) Real path

Assertions

FIL_RealPath( 'C:/webSEAL/resources/../images' ) === 'C:\webSEAL\images' successful

Unit Testing

1 assertions: 1 successful; 0 failed

FIL_Rename(): Renames (moves) $szSrc to $szDest

[ back to function list ]

Since version 2.1.0000

Caution

Physical file name (fully qualified) must be mentioned. Use FIL_ResolveRoot() to transform a logical filename into a physical filename.

Syntax

FIL_Rename( $szSrc,$szDest )

Alias

FIL_Move()

Parameters
NameTypeDescription
$szSrc string Old filename
$szDest string New filename
Return

(bool) true if $szSrc successfully renamed to $szDest; false otherwise

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(...); *}).

See Also

FIL_Delete(), FIL_Copy()

FIL_ResolveRoot(): Resolves the path of a file from the root directory of the site

[ back to function list ]

Warning

The function won't work properly with junctions (WinNT)

Syntax

FIL_ResolveRoot( $szFileSpec,$szRoot )

Parameters
NameTypeDescription
$szFileSpec string Filename (relative path can be included)
$szRoot string Root of the site. Optional. By default we use the value of $_SERVER['DOCUMENT_ROOT']
Return

(string) Complete physical path

Example(s)
echo FIL_ResolveRoot( '/images/logo.png' )  // 'c:\websites\mysite\www\httpdocs\images\logo.png'
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(...); *}).

See Also

FIL_RevertRoot()

FIL_RevertRoot(): Determines the site file compared to the root directory of the site. Opposite function of FIL_ResolveRoot().

[ back to function list ]

Warning

Depending on the version of PHP and the proper handling of junctions (symbolic links) the function can return weird results

Syntax

FIL_RevertRoot( $szFileSpec,$szRoot )

Parameters
NameTypeDescription
$szFileSpec string Physical filename
$szRoot string Root of the site. Optional. By default we use the value of $_SERVER['DOCUMENT_ROOT']
Return

(string) Logical path compared to $szRoot

Example(s)
echo FIL_ResolveRoot( 'c:\websites\mysite\www\httpdocs\images\logo.png' )  // '/images/logo.png'
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(...); *}).

See Also

FIL_ResolveRoot()

FIL_Seek(): Seeks on a file pointer

[ back to function list ]

Created: 16/09/2013 - 06:31

Author

Remark

This function acts as a wrapper around fseek()

Syntax

FIL_Seek( $rHandle,$iOffset,$iStrategy )

Parameters
NameTypeDescription
$rHandle resource Resource to file
$iOffset int Offset to consider for the move of the pointer
$iStrategy int Strategy to apply when moving the pointer:
  • SEEK_SET - Set position equal to offset bytes

  • SEEK_CUR - Set position to current location plus offset

  • SEEK_END - Set position to end-of-file plus offset

Default is SEEK_CUR.
Return

(int) true if pointer moved successfully. false otherwise

Example(s)
if ( $rHandle = FIL_Open( $szFile,'r' ) )
{
    echo '<p>POSITION AT OPENING: ',FIL_Tell( $rHandle ),'</p>';
    FIL_Seek( $rHandle,-10,SEEK_END ); // Move 10 bytes before end
    echo '<p>NEW POSITION: ',FIL_Tell( $rHandle ),'</p>';
    FIL_Close( $rHandle );
}
Example Executed
if ( $rHandle = FIL_Open( $szFile = 'C:\websites\latosensu.be\www\httpdocs\vaesoli\include\LSFiles.functions.php','r' ) )
{
    $iPos = FIL_Tell( $rHandle );
    echo LSUnitTesting::assert( is_resource( $rHandle )                 ,
                                'ASSERTION SUCCESS: resource valid!'    ,
                                'ASSERTION FAILURE: invalid resource'   ,
                                'GuideAssert' );
    echo LSUnitTesting::assert( $iPos === 0                             ,
                                'ASSERTION SUCCESS: file pointer correct'   ,
                                'ASSERTION FAILURE: file pointer incorrect' ,
                                'GuideAssert' );
    $iSize = FIL_Size( $szFile );
    FIL_Seek( $rHandle,-10,SEEK_END );
    echo LSUnitTesting::assert( FIL_Tell( $rHandle ) === ( $iSize - 10 )    ,
                                'ASSERTION SUCCESS: file pointer correct'   ,
                                'ASSERTION FAILURE: file pointer incorrect' ,
                                'GuideAssert' );
    $bClosed = FIL_Close( $rHandle );
    echo LSUnitTesting::assert( $bClosed                                        ,
                                'ASSERTION SUCCESS: file successfully closed!'  ,
                                'ASSERTION FAILURE: file CANNOT be closed'      ,
                                'GuideAssert' );
}

GuideAssert() ... ASSERTION SUCCESS: resource valid!

GuideAssert() ... ASSERTION SUCCESS: file pointer correct

GuideAssert() ... ASSERTION SUCCESS: file pointer correct

GuideAssert() ... ASSERTION SUCCESS: file successfully closed!

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

FIL_Tell()

FIL_Size(): Gets file size

[ back to function list ]

Created: 27/06/2012 - 07:37

Since version 5.0.0003

Caution

May return unexpected results for files which are larger than 2GB.

Syntax

FIL_Size( $szFile )

Parameters
NameTypeDescription
$szFile string File whose size must be determined
Return

(int) Size in bytes or -1 in case of problem

Example(s)
if ( ( $iSize = FIL_Size( "C:\\websites\\myfile.txt" ) ) != -1 )
{
    // can treat the file
}
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(...); *}).

FIL_Split(): Splits a filename into basic components (drive, path, filename, extension)

[ back to function list ]

Since version 2.0.0009

Modified: 27/06/2012 - 11:09

Uses

FIL_Normalize(), STRTRAN()

Syntax

FIL_Split( $szFile,$i )

Parameters
NameTypeDescription
$szFile string File that must be split
$i int Component part (1 = drive; 2 = path; 3 = filename; 4 = extension; 5 = all parts (returned as array))
Return

(mixed) Part that is expected if $i is between 1 and 4 (string); if $i == 5, return value is an array of file parts

Example Executed
echo '<p>' . MISC_CastString( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',4 ) == '.klm' ) . '</p>';
echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',1 )                              . '</p>';
echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',2 )                              . '</p>';
echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',3 )                              . '</p>';
echo '<p>' . FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',4 )                              . '</p>';
var_dump( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',5 ) );

false

c:

\website\mine\www\httpdocs\

myfile

.xml

array (size=4)
  'dirname' => string 'c:\website\mine\www\httpdocs' (length=28)
  'basename' => string 'myfile.xml' (length=10)
  'extension' => string '.xml' (length=4)
  'filename' => string 'myfile' (length=6)
Assertions

MISC_CastString( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',4 ) == '.xml' ) == 'true' successful

FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',3 ) == 'myfile' successful

is_array( FIL_Split( 'c:\website\mine\www\httpdocs\myfile.xml',5 ) ) == true successful

Unit Testing

3 assertions: 3 successful; 0 failed

FIL_StrToFile(): Writes the contents of a character string to a file.

[ back to function list ]

Modified: 01/07/2012 - 14:24

Syntax

FIL_StrToFile( $szText,$szFile,$bAppend )

Alias

FIL_Str2File(), strtofile()

Parameters
NameTypeDescription
$szText string Specifies the character string that is written to the file
$szFile string Specifies the name of the file to which the character string is written
$bAppend bool Optional. false by default. If true, file is appended
Return

(bool) true if $szFile is successfully written; false if not

Example Executed
if ( FIL_StrToFile( $szStr = 'This is my string',$szFile = 'C:\\tmp\\pure-example.txt' ) )
{
    $szContent = FIL_FileToStr( $szFile );
    echo LSUnitTesting::assert( $szContent === $szStr                       ,
                                'ASSERTION SUCCESS: successful write & read',
                                'ASSERTION FAILURE: invalid resource'       ,
                                'GuideAssert' );
    FIL_Delete( $szFile );
}

GuideAssert() ... ASSERTION SUCCESS: successful write & read

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

FIL_FileToStr()

FIL_Tell(): Returns the current position of the file read/write pointer

[ back to function list ]

Created: 16/09/2013 - 06:52

Author

Remark

This function acts as a wrapper around ftell()

Syntax

FIL_Tell( $rHandle )

Parameters
NameTypeDescription
$rHandle resource Resource to file
Return

(int) Position of the file pointer referenced by $rHandle

Example(s)
if ( $rHandle = FIL_Open( $szFile,'r' ) )
{
    echo '<p>POSITION AT OPENING: ',FIL_Tell( $rHandle ),'</p>';
    FIL_Seek( $rHandle,-10,SEEK_END );
    echo '<p>NEW POSITION: ',FIL_Tell( $rHandle ),'</p>';
    FIL_Close( $rHandle );
}
Example Executed
if ( $rHandle = FIL_Open( $szFile = 'C:\websites\latosensu.be\www\httpdocs\vaesoli\include\LSFiles.functions.php','r' ) )
{
    $iPos = FIL_Tell( $rHandle );
    echo LSUnitTesting::assert( is_resource( $rHandle )                 ,
                                'ASSERTION SUCCESS: resource valid!'    ,
                                'ASSERTION FAILURE: invalid resource'   ,
                                'GuideAssert' );
    echo LSUnitTesting::assert( $iPos === 0                             ,
                                'ASSERTION SUCCESS: file pointer correct'   ,
                                'ASSERTION FAILURE: file pointer incorrect' ,
                                'GuideAssert' );
    $iSize = FIL_Size( $szFile );
    FIL_Seek( $rHandle,-10,SEEK_END );
    echo LSUnitTesting::assert( FIL_Tell( $rHandle ) === ( $iSize - 10 )    ,
                                'ASSERTION SUCCESS: file pointer correct'   ,
                                'ASSERTION FAILURE: file pointer incorrect' ,
                                'GuideAssert' );
    $bClosed = FIL_Close( $rHandle );
    echo LSUnitTesting::assert( $bClosed                                        ,
                                'ASSERTION SUCCESS: file successfully closed!'  ,
                                'ASSERTION FAILURE: file CANNOT be closed'      ,
                                'GuideAssert' );
}

GuideAssert() ... ASSERTION SUCCESS: resource valid!

GuideAssert() ... ASSERTION SUCCESS: file pointer correct

GuideAssert() ... ASSERTION SUCCESS: file pointer correct

GuideAssert() ... ASSERTION SUCCESS: file successfully closed!

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

FIL_Seek()

FIL_Time(): Determines the date and time of a file (creation, modification or last access)

[ back to function list ]

Since version 5.0.0005

Syntax

FIL_Time( $szFile,$cType,$szFormat )

Parameters
NameTypeDescription
$szFile string Name of the file whose last modification date and time must be returned
$cType char Operation type:
- 'a': last access date and time
- 'c': creation date and time
- 'm': last modification date and time
$szFormat string The format of the output date string
Return

(mixed) Last date and time returned as an int if $szFormat = null (same use as time()); string if format mentioned

Example(s)
if ( FIL_Compress( 'C:\\myfile.txt','C:\\myfile.cmp' ) )
{
    if ( FIL_Uncompress( 'C:\\myfile.cmp','C:\\myfile.2.txt' ) )
    {
        echo '<p>Back to square 1: successful uncompression after successful compression</p>';
    }
}
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(...); *}).

See Also

FIL_CDate(), FIL_MDate()

FIL_Uncompress(): Uncompress a file

[ back to function list ]

Remark

FIL_Uncompress() is the natural companion of FIL_Compress()

Syntax

FIL_Uncompress( $szSource,$szTarget )

Parameters
NameTypeDescription
$szSource string Name of the file to uncompress
$szTarget string Name of the target file
Return

(bool) True if source file successfully uncompressed to $szTarget

Example(s)
if ( FIL_Compress( 'C:\\myfile.txt','C:\\myfile.cmp' ) )
{
    if ( FIL_Uncompress( 'C:\\myfile.cmp','C:\\myfile.2.txt' ) )
    {
        echo '<p>Back to square 1: successful uncompression after successful compression</p>';
    }
}
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(...); *}).

See Also

FIL_Compress()

FIL_Write(): Writes $szText to a file specified by its $rHandle handle

[ back to function list ]

Created: 01/07/2012 - 14:29

Syntax

FIL_Write( $rHandle,$szText )

Parameters
NameTypeDescription
$rHandle res Resource handle of the file
$szText string Specifies the character string that is to be written to the file
Return

(int) Returns the number of bytes written or -1 in case of failure

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(...); *}).

SendFile(): Sends a file

[ back to function list ]

Uses

FIL_GetFileType()

Caution

Make sure there is NO other output sent back to the browser prior to this function otherwise you may fool the browser by returning an incorrect length and have files be truncated.

Syntax

SendFile( $szFile,$szType )

Parameters
NameTypeDescription
$szFile string the file to send back to the browser of the visitor
$szType string File type. Optional. By default the file type is derived from its extension.
Return

(void) The file identified by $szFile is returned to the browser of the visitor

Example(s)
// Example 1
// Sends a well-defined XML file if a backup is requested
if ( isset( $_GET['backup'] ) )     // if backup requested
{
    ob_clean();                     // clean buffer before
    SendFile( "myfile.xml",'xml' ); // Send myfile.xml!
}

// Example 2
SendFile( FIL_Normalize( $szFile ),'docx' );
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(...); *}).

See Also

FIL_GetFileType()

Précédent Suivant

D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php:3658:
object(LogicException)[82]
  protected 'message' => string 'Class LSContentsShare could not be loaded' (length=41)
  private 'string' (Exception) => string '' (length=0)
  protected 'code' => int 0
  protected 'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
  protected 'line' => int 3587
  private 'trace' (Exception) => 
    array (size=15)
      0 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 3587
          'function' => string 'spl_autoload' (length=12)
          'args' => 
            array (size=1)
              ...
      1 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 3262
          'function' => string 'EmergeIsland' (length=12)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=6)
              ...
      2 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 2756
          'function' => string 'EmergeIslands' (length=13)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=5)
              ...
      3 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php' (length=72)
          'line' => int 2994
          'function' => string 'EmergeArchipelagosFromParent' (length=28)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=3)
              ...
      4 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5928
          'function' => string 'EmergeArchipelagos' (length=18)
          'class' => string 'LSGeorama' (length=9)
          'type' => string '->' (length=2)
          'args' => 
            array (size=2)
              ...
      5 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\template\vaesoli.html' (length=58)
          'line' => int 111
          'function' => string 'Land' (length=4)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      6 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 6110
          'args' => 
            array (size=1)
              ...
          'function' => string 'include' (length=7)
      7 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 6053
          'function' => string 'XInclude' (length=8)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      8 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5828
          'function' => string 'IncludeTemplate' (length=15)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      9 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 5580
          'function' => string 'UseTemplate' (length=11)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      10 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 3282
          'function' => string 'RenderXML' (length=9)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      11 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSPage.class.php' (length=69)
          'line' => int 2082
          'function' => string 'StartPage' (length=9)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=1)
              ...
      12 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSApplication.class.php' (length=76)
          'line' => int 814
          'function' => string 'Render' (length=6)
          'class' => string 'LSPage' (length=6)
          'type' => string '->' (length=2)
          'args' => 
            array (size=0)
              ...
      13 => 
        array (size=6)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\master.php' (length=47)
          'line' => int 8
          'function' => string 'Run' (length=3)
          'class' => string 'LSApplication' (length=13)
          'type' => string '->' (length=2)
          'args' => 
            array (size=0)
              ...
      14 => 
        array (size=4)
          'file' => string 'D:\websites\vaesoli.org\www\httpdocs\documentation\documentation-vaesoli-code-source.php' (length=88)
          'line' => int 1
          'args' => 
            array (size=1)
              ...
          'function' => string 'include' (length=7)
  private 'previous' (Exception) => null
  public 'xdebug_message' => string '<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> LogicException: Class LSContentsShare could not be loaded in D:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSGeorama.class.php on line <i>3587</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</t'... (length=6277)