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-20 à 07:28:37

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) (20/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)

LSMisc.functions.php

Generated by The Vae Soli! Documentor: Guide v. 1.3.0018 on 01-04-2015 16:19:53 (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/LSMisc.functions.phpC:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSMisc.functions.phpapplication/force-downloadC:\websites\vaesoli.org\www\httpdocs\vaesoli\include83420 bytes03/08/2013 23:27:5227/05/2014 13:39:2727/05/2014 13:39:27

Compliance

Assertions count: 50

Assertions successful: 50

Assertion failures: 0

Early Warning

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

LSMisc.functions.php contains 2051 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                  LSMisc.functions.php *}
0005 ...     {*purpose               Miscellaneous functions (all purpose) *}
0006 ...     {*author                 *}
0007 ...     {*company               Lato Sensu Management[br]
0008 ...                             Rue Bois des Mazuis, 47[br]
0009 ...                             5070 Vitrival[br]
0010 ...                             Belgium (BE)[br]
0011 ...                             [url]http://www.latosensu.be[/url][br]
0012 ...                             Vae Soli! : [url]http://www.vaesoli.org[/url] *}
0013 ...     {*cdate                 03/03/2008 - 14:38 *}
0014 ...     {*mdate                 auto *}
0015 ...     {*uses                  LSStrings.functions.php,
0016 ...                             LSTracingLevels.inc
0017 ...     *}
0018 ...     {*license               [url]http://creativecommons.org/licenses/by-sa/2.0/be/[/url][br]
0019 ... 
0020 ...                             To obtain detailed information about the license
0021 ...                             terms, please head to the full license text
0022 ...                             available in the [file]LSCopyright.php[/file] file *}
0023 ... 
0024 ...     ------------------------------------------------------------------------
0025 ...     Changes History:
0026 ... 
0027 ...     [include]C:\websites\vaesoli.org\www\httpdocs\vaesoli\include\LSMisc.functions.journal[/include]
0028 ... 
0029 ...     *}}} */
0030 ... /**************************************************************************/
0031 ... if ( ! defined( 'LS_MISC_FUNCTIONS' ) )
0032 ... {
0033 ...     /* {*define (LS_MISC_FUNCTIONS)   Define the miscellaneous functions) *} */
0034 ...     define( 'LS_MISC_FUNCTIONS','PWH' );
0035 ... }   /* if ( ! defined( 'LS_MISC_FUNCTIONS' ) ) */
0036 ... 
0037 ... if ( ! defined( 'VAESOLI_PATH' ) )
0038 ... {
0039 ...     /* {*define (VAESOLI_PATH)  Define the path where Vae Soli! is installed *} */
0040 ...     define( 'VAESOLI_PATH',__DIR__ );
0041 ... }   /* if ( ! defined( 'VAESOLI_PATH' ) ) */
0042 ... 
0043 ... if ( ! defined( 'VAESOLI_PLUGINS' ) )
0044 ... {
0045 ...     /* {*define (VAESOLI_PLUGINS)  Define the path where plugins are located *} */
0046 ...     define( 'VAESOLI_PLUGINS',VAESOLI_PATH . '/../plugins' );
0047 ... }   /* if ( ! defined( 'VAESOLI_PLUGINS' ) ) */
0048 ... 
0049 ... if ( ! defined( 'LS_STRINGS_FUNCTIONS' ) )
0050 ... {
0051 ...     /* {*require (LSStrings.functions.php) String functions *} */
0052 ...     require_once( VAESOLI_PATH . '/LSStrings.functions.php' );
0053 ... }   /* if ( ! defined( 'LS_STRINGS_FUNCTIONS' ) ) */
0054 ... 
0055 ... if ( ! defined( 'LS_FILES_FUNCTIONS' ) )
0056 ... {
0057 ...     /* {*require (LSFiles.functions.php) File functions *} */
0058 ...     require_once( VAESOLI_PATH . '/LSFiles.functions.php' );
0059 ... }   /* if ( ! defined( 'LS_FILES_FUNCTIONS' ) ) */
0060 ... 
0061 ... if ( ! defined( 'LS_UNIT_TESTING_CLASS' ) )
0062 ... {
0063 ...     /* {*require (LSUnitTesting.class.php)  Vae Soli! Unit Testing *} */
0064 ...     require_once( VAESOLI_PATH . '/LSUnitTesting.class.php'   );
0065 ... }
0066 ... 
0067 ... 
0068 ... /* Cette fonction est NON documentée */
0069 ... /* ========================================================================== */
0070 ... /** {{*MISC_SetError( $i )=
0071 ... 
0072 ...     Set error reporting
0073 ... 
0074 ...     {*params
0075 ...         $i  (integer)   Error setting. Optional: [c]E_ALL | E_NOTICE[/c]
0076 ...                         by default
0077 ...     *}
0078 ... 
0079 ...     {*return
0080 ...         (void)
0081 ...     *}
0082 ... 
0083 ...     {*example
0084 ...         MISC_SetError();
0085 ...     *}
0086 ... 
0087 ...     *}}
0088 ...  */
0089 ... /* ========================================================================== */
0090 ... function MISC_SetError( $i = null )
0091 ... /*-------------------------------*/
0092 ... {
0093 ...     ini_set( 'error_reporting', E_ALL | E_NOTICE );
0094 ...     error_reporting( E_ALL | E_NOTICE );
0095 ...     ini_set( 'display_errors','On' );
0096 ... }   /* End of function MISC_SetError() ====================================== */
0097 ... 
0098 ... function MISC_Dump( $x )
0099 ... /*--------------------*/
0100 ... {
0101 ...     if ( is_object( $x ) )
0102 ...     {
0103 ...         echo "Should DUMP {$x}";
0104 ...     }
0105 ...     else
0106 ...     {
0107 ...         var_dump( $x );
0108 ...     }
0109 ... }
0110 ... 
0111 ... /* ========================================================================== */
0112 ... /** {{*MISC_Giro( $xNumber )=
0113 ... 
0114 ...     Calculates the check digit of a giro (VCS)
0115 ... 
0116 ...     {*params
0117 ...         $xNumber    (mixed)     Ideally an integer of no more than 10 digits
0118 ...     *}
0119 ... 
0120 ...     {*return
0121 ...         (int)   The check digit corresponding to $xNumber
0122 ...     *}
0123 ... 
0124 ...     {*cdate 03/04/2014 19:13 *}
0125 ...     {*version 6.0.0005 *}
0126 ...     {*author  *}
0127 ... 
0128 ...     {*assert
0129 ...         MISC_Giro( 2014000001 ) === 59
0130 ...     *}
0131 ... 
0132 ...     {*exec
0133 ...         echo LSUnitTesting::assert( MISC_Giro( 2014000001 ) === 59              ,
0134 ...                                     'ASSERTION SUCCESSFUL: giro (VCS) correct'  ,
0135 ...                                     'ASSERTION FAILURE: giro (VCS) incorrect'   ,
0136 ...                                     'GuideAssert' );
0137 ...         echo LSUnitTesting::assert( MISC_Giro( '2014/000001' ) === 59           ,
0138 ...                                     'ASSERTION SUCCESSFUL: giro (VCS) correct'  ,
0139 ...                                     'ASSERTION FAILURE: giro (VCS) incorrect'   ,
0140 ...                                     'GuideAssert' );
0141 ...         echo LSUnitTesting::assert( MISC_Giro( '14/444/215' ) === 29            ,
0142 ...                                     'ASSERTION SUCCESSFUL: giro (VCS) correct'  ,
0143 ...                                     'ASSERTION FAILURE: giro (VCS) incorrect'   ,
0144 ...                                     'GuideAssert' );
0145 ...     *}
0146 ... 
0147 ...     {*seealso
0148 ...         MISC_MakeGiro()
0149 ...     *}
0150 ... 
0151 ...     *}}
0152 ...  */
0153 ... /* ========================================================================== */
0154 ... function MISC_Giro( $xNumber,$iLength = 12 )
0155 ... /*----------------------------------------*/
0156 ... {
0157 ...     if      ( is_string( $xNumber ) )
0158 ...     {
0159 ...         $szNumber = STR_dionly( $xNumber );
0160 ...     }
0161 ...     else
0162 ...     {
0163 ...         $szNumber = MISC_Cast( 'string',$xNumber );
0164 ...     }
0165 ... 
0166 ...     $szNumber = STR_padr( $szNumber,$iLength - 2,'0' );
0167 ...     $iNumber  = (int) $szNumber;
0168 ... 
0169 ...     if ( ( $iRetVal = $iNumber % 97 ) == 0 )
0170 ...     {
0171 ...         $iRetVal = 97;
0172 ...     }
0173 ... 
0174 ...     return ( $iRetVal );
0175 ... 
0176 ... }   /* End of function MISC_Giro() ========================================== */
0177 ... 
0178 ... /* ========================================================================== */
0179 ... /** {{*MISC_MakeGiro( $xNumber,$iLength )=
0180 ... 
0181 ...     Creates a giro (VCS)
0182 ... 
0183 ...     {*params
0184 ...         $xNumber    (mixed)     Ideally an integer of no more than 10 digits
0185 ...         $iLength    (int)       The length of the giro
0186 ...     *}
0187 ... 
0188 ...     {*return
0189 ...         (int)   The check digit corresponding to $xNumber
0190 ...     *}
0191 ... 
0192 ...     {*assert
0193 ...         MISC_MakeGiro( 2100830270 ) === '210/0830/27002'
0194 ...     *}
0195 ... 
0196 ...     {*exec
0197 ...         echo LSUnitTesting::assert( MISC_MakeGiro( 2014000001 ) === '201/4000/00159'    ,
0198 ...                                     'ASSERTION SUCCESSFUL: giro (VCS) correct'          ,
0199 ...                                     'ASSERTION FAILURE: giro (VCS) incorrect'           ,
0200 ...                                     'GuideAssert' );
0201 ...         echo LSUnitTesting::assert( MISC_MakeGiro( '2014/000001' ) === '201/4000/00159' ,
0202 ...                                     'ASSERTION SUCCESSFUL: giro (VCS) correct'          ,
0203 ...                                     'ASSERTION FAILURE: giro (VCS) incorrect'           ,
0204 ...                                     'GuideAssert' );
0205 ...         echo LSUnitTesting::assert( MISC_MakeGiro( '14/444/215' ) === '144/4421/50029'  ,
0206 ...                                     'ASSERTION SUCCESSFUL: giro (VCS) correct'          ,
0207 ...                                     'ASSERTION FAILURE: giro (VCS) incorrect'           ,
0208 ...                                     'GuideAssert' );
0209 ...     *}
0210 ... 
0211 ...     {*seealso
0212 ...         MISC_Giro()
0213 ...     *}
0214 ... 
0215 ...     *}}
0216 ...  */
0217 ... /* ========================================================================== */
0218 ... function MISC_MakeGiro( $xNumber,$iLength = 12 )
0219 ... /*--------------------------------------------*/
0220 ... {
0221 ...     $iCheck = MISC_Giro( $xNumber );
0222 ... 
0223 ...     $szNumber = STR_padr( STR_dionly( (string) $xNumber ),$iLength - 2,'0' );
0224 ... 
0225 ...     $szRetVal = substr( $szNumber,0,3 ) . '/' .
0226 ...                 substr( $szNumber,3,4 ) . '/' .
0227 ...                 substr( $szNumber,7,3 )       .
0228 ...                 STR_padl( (string) $iCheck,2,'0' );
0229 ... 
0230 ...     return ( $szRetVal );
0231 ... 
0232 ... }   /* End of function MISC_MakeGiro() ====================================== */
0233 ... 
0234 ... /* ========================================================================== */
0235 ... /** {{*MISC_BackLink( $iYear,$iMonth,$iDay,$szURL,$szAnchor,$szTooltip,$szCSSClass )=
0236 ... 
0237 ...     Creates a back link to a URL that handles year, month, day
0238 ... 
0239 ...     {*params
0240 ...         $iYear      (int)       Year of the back link
0241 ...         $iMonth     (int)       Month of the back link
0242 ...         $iDay       (int)       Day of the back link
0243 ...         $szURL      (string)    URL of back link. Optional. [c]null[/c] by default
0244 ...         $szAnchor   (string)    Text of the anchor. Optional. [c]null[/c] by default
0245 ...         $szTooltip  (string)    Tooltip of the anchor. Optional. [c]null[/c] by default
0246 ...         $szCSSClass (string)    CSS class of the anchor. Optional. [c]null[/c] by default
0247 ...     *}
0248 ... 
0249 ...     {*return
0250 ...         (string)    The HTML code of a [c]<a>...</a>[/c] back link
0251 ...     *}
0252 ... 
0253 ...     {*exec
0254 ...         echo '<p>',MISC_BackLink( 2008,2,7 ),'</p>';
0255 ...         echo '<p>',MISC_BackLink( 2008,2,7,'/news.php' ),'</p>';
0256 ...         echo '<p>',MISC_BackLink( 2008,2,7,'/news.php','Great news!' ),'</p>';
0257 ...         echo '<p>',MISC_BackLink( 2008,2,7,'/news.php','Great news!','Announcement of a new version' ),'</p>';
0258 ...         echo '<p>',MISC_BackLink( 2008,2,7,'/news.php','Great news!','Announcement of a new version','headline' ),'</p>';
0259 ...         echo '<p>',
0260 ...                    wordwrap(
0261 ...                        htmlentities(
0262 ...                            MISC_BackLink( 2008,2,7                          ,
0263 ...                                           '/news.php'                       ,
0264 ...                                           'Great news!'                     ,
0265 ...                                           'Announcement of a new version'   ,
0266 ...                                           'headline' ) ) ),
0267 ...              '</p>';
0268 ...     *}
0269 ... 
0270 ...     *}}
0271 ...  */
0272 ... /* ========================================================================== */
0273 ... function MISC_BackLink( $iYear,$iMonth,$iDay,$szURL = null,$szAnchor = null,$szTooltip = null,$szCSSClass = null )
0274 ... /*--------------------------------------------------------------------------------------------------------------*/
0275 ... {
0276 ...     $szRetVal = '';
0277 ... 
0278 ...     if ( is_null( $szURL ) )
0279 ...     {
0280 ...         $szURL = MISC_Self();
0281 ...     }
0282 ... 
0283 ...     if ( is_null( $szAnchor ) )
0284 ...     {
0285 ...         $szAnchor = sprintf( "%02d-%02d-%04d",$iDay,$iMonth,$iYear );
0286 ...     }
0287 ... 
0288 ...     if ( ! is_null( $szTooltip ) )
0289 ...     {
0290 ...         $szTooltip = " title=\"{$szTooltip}\"";
0291 ...     }
0292 ... 
0293 ...     if ( ! is_null( $szCSSClass ) )
0294 ...     {
0295 ...         $szCSSClass = " class=\"{$szCSSClass} LS_VAESOLI_BackLink\"";
0296 ...     }
0297 ...     else
0298 ...     {
0299 ...         $szCSSClass = " class=\"LS_VAESOLI_BackLink\"";
0300 ...     }
0301 ... 
0302 ...     $szRetVal = "<a href=\"{$szURL}?year={$iYear}&amp;month={$iMonth}&amp;day={$iDay}\"{$szTooltip}{$szCSSClass}>{$szAnchor}</a>";
0303 ... 
0304 ...     return ( $szRetVal );
0305 ... }
0306 ... 
0307 ... /* ========================================================================== */
0308 ... /** {{*MISC_iif( $bExpr,$xTrue,$xFalse )=
0309 ... 
0310 ...     Immediate if
0311 ... 
0312 ...     {*params
0313 ...         $xExpr  (boolean) An expression that yields a boolean result
0314 ...         $xTrue  (mixed)   What is to be returned if $xExpr is [c]true[/c]
0315 ...         $xFalse (mixed)   What is to be returned if $xExpr is [c]false[/c]
0316 ...     *}
0317 ... 
0318 ...     {*return
0319 ...         (mixed) $xTrue or $xFalse
0320 ...     *}
0321 ... 
0322 ...     {*exec
0323 ...         echo iif( isset( $NotExist ),'Exist','Does not exist' );
0324 ...     *}
0325 ... 
0326 ...     {*alias
0327 ...         iif()
0328 ...     *}
0329 ... 
0330 ...     {*assert
0331 ...         MISC_iif( true,'hello','goodbye' ) === 'hello'
0332 ...     *}
0333 ... 
0334 ...     {*assert
0335 ...         MISC_iif( false,'hello','goodbye' ) === 'goodbye'
0336 ...     *}
0337 ... 
0338 ...     *}}
0339 ...  */
0340 ... /* ========================================================================== */
0341 ... function MISC_iif( $bExpr,$xTrue,$xFalse )
0342 ... /*--------------------------------------*/
0343 ... {
0344 ...     return ( $bExpr ? $xTrue : $xFalse );
0345 ... }   /* End of function MISC_iif() =========================================== */
0346 ... function iif( $bExpr,$xTrue,$xFalse ) { return ( MISC_iif( $bExpr,$xTrue,$xFalse ) ); }
0347 ... 
0348 ... /* ========================================================================== */
0349 ... /** {{*MISC_Self()=
0350 ... 
0351 ...     Returns the name of the running script (Self)
0352 ... 
0353 ...     {*params
0354 ...     *}
0355 ... 
0356 ...     {*return
0357 ...         (string)    Name of the running script or [c]null[/c] if it cannot
0358 ...                     be determined.
0359 ...     *}
0360 ... 
0361 ...     {*exec
0362 ...         echo $szSelf = MISC_Self();
0363 ... 
0364 ...         echo LSUnitTesting::assert( $szSelf === '/guide.php'            ,
0365 ...                                     'ASSERTION SUCCESSFUL: self OK'     ,
0366 ...                                     'ASSERTION FAILURE: self NOT OK'    ,
0367 ...                                     'GuideAssert' );
0368 ...     *}
0369 ... 
0370 ...     *}}
0371 ... */
0372 ... /* ========================================================================== */
0373 ... function MISC_Self()
0374 ... /*----------------*/
0375 ... {
0376 ...     return ( isset( $_SERVER['PHP_SELF'] ) ?
0377 ...              $_SERVER['PHP_SELF']          :
0378 ...              null );                                                /* The name of the running script (e.g. "/index.php") */
0379 ... }   /* End of function MISC_Self() ========================================== */
0380 ... 
0381 ... /* ========================================================================== */
0382 ... /** {{*MISC_Swap( $x,$y )=
0383 ... 
0384 ...     Swaps $x and $y
0385 ... 
0386 ...     {*params
0387 ...         $x  (mixed)     1st element whose value must be swapped.
0388 ...                         Passed by reference. Updated upon return.
0389 ...         $y  (mixed)     2nd element whose value must be swapped.
0390 ...                         Passed by reference. Updated upon return.
0391 ...     *}
0392 ... 
0393 ...     {*return
0394 ...         (void)  $x and $y are swapped
0395 ...     *}
0396 ... 
0397 ...     {*example
0398 ...         // $xValue can be something like "DD-MM-YYYY" or "DD/MM/YYYY"
0399 ...         if ( preg_match( '/(?P<day>\d{2})[\/-](?P<month>\d{2})[\/-](?P<year>\d{4})/',$xValue,$aMatch ) )
0400 ...         {
0401 ...             $szMonth = $aMatch['month'];          // Get month
0402 ...             $szDay   = $aMatch['day'];            // Get day
0403 ... 
0404 ...             if ( (int) $szDay <= 12 )             // If day can be a month
0405 ...             {
0406 ...                 if ( (int) $szMonth > 12 )        // If month seems to be a day
0407 ...                 {
0408 ...                     MISC_Swap( $szDay,$szMonth ); // Swap month and day
0409 ...                 }
0410 ...             }
0411 ... 
0412 ...             $iTime = TIM_MakeInt( $aMatch['year'] . $szMonth . $szDay );
0413 ...         }
0414 ...     *}
0415 ... 
0416 ...     {*noassert *}
0417 ... 
0418 ...     {*exec
0419 ...         $x = 14;
0420 ...         $y = 21;
0421 ... 
0422 ...         MISC_Swap( $x,$y );
0423 ... 
0424 ...         echo LSUnitTesting::assert(  $x === 21 && $y === 14                         ,
0425 ...                                     'ASSERTION SUCCESSFUL: values swapped correctly',
0426 ...                                     'ASSERTION FAILURE: values swapped correctly'   ,
0427 ...                                     'GuideAssert' );
0428 ...     *}
0429 ... 
0430 ...     *}}
0431 ...  */
0432 ... /* ========================================================================== */
0433 ... function MISC_Swap( &$x,&$y )
0434 ... /*-------------------------*/
0435 ... {
0436 ...     $z = $x;
0437 ...     $x = $y;
0438 ...     $y = $z;
0439 ... }   /* End of function MISC_Swap() ========================================== */
0440 ... 
0441 ... /* ========================================================================== */
0442 ... /** {{*MISC_Empty( $x )=
0443 ... 
0444 ...     Determines if $x is empty or not
0445 ... 
0446 ...     {*params
0447 ...         $x  (mixed)     element to test
0448 ...     *}
0449 ... 
0450 ...     {*alias
0451 ...         MIS_Empty()
0452 ...     *}
0453 ... 
0454 ...     {*return
0455 ...         (bool)          true if $x is empty; false otherwise
0456 ...     *}
0457 ... 
0458 ...     {*example
0459 ...         echo MISC_CastString( MISC_Empty( 'My god' ) );    // Prints 'false'
0460 ...     *}
0461 ... 
0462 ...     {*assert
0463 ...         MISC_CastString( MISC_Empty( 'My god' ) ) === 'false'
0464 ...     *}
0465 ... 
0466 ...     {*assert
0467 ...         MISC_CastString( MISC_Empty( ' ' ) ) === 'false'
0468 ...     *}
0469 ... 
0470 ...     {*assert
0471 ...         MISC_CastString( MISC_Empty( '' ) ) === 'true'
0472 ...     *}
0473 ... 
0474 ...     {*assert
0475 ...         MISC_CastString( MISC_Empty( null ) ) === 'true'
0476 ...     *}
0477 ... 
0478 ...     {*seealso
0479 ...         STR_Empty()
0480 ...     *}
0481 ... 
0482 ...     *}}
0483 ...  */
0484 ... /* ========================================================================== */
0485 ... function MISC_Empty( $x )
0486 ... /*---------------------*/
0487 ... {
0488 ...     return ( is_null( $x ) || empty( $x ) );
0489 ... }   /* End of function MIS_Empty() ========================================== */
0490 ... function MIS_Empty( $x ) { return ( MISC_Empty( $x ) ); }
0491 ... 
0492 ... /* ========================================================================== */
0493 ... /** {{*MISC_Cast( $szType,$x )=
0494 ... 
0495 ...     Cast a variable value
0496 ... 
0497 ...     {*params
0498 ...         $szType (string)    The type to cast the variable to. Same type set as
0499 ...                             for [c]settype[/c].[br]
0500 ... 
0501 ...                             [c]"boolean"[/c] or [c]"bool"[/c][br]
0502 ...                             [c]"integer"[/c] or [c]"int"[/c][br]
0503 ...                             [c]"float"[/c][br]
0504 ...                             [c]"string"[/c][br]
0505 ...                             [c]"array"[/c][br]
0506 ...                             [c]"object"[/c][br]
0507 ...                             [c]"null"[/c]
0508 ... 
0509 ...         $x      (mixed)     Variable whose value must be cast
0510 ...     *}
0511 ... 
0512 ...     {*return
0513 ...         (mixed)     $x value turned to $szType
0514 ...     *}
0515 ... 
0516 ...     {*example
0517 ...         $xPropValue = $oPropertyNode->nodeValue;
0518 ...         $szPropType = $oPropertyNode->getAttribute( 'vartype' );
0519 ... 
0520 ...         if ( ! STR_Empty( $szPropType ) )
0521 ...         {
0522 ...             $xPropValue = MISC_Cast( $szPropType,$xPropValue );
0523 ...         }
0524 ...     *}
0525 ... 
0526 ...     {*assert
0527 ...         MISC_Cast( 'string',18 ) === '18'
0528 ...     *}
0529 ... 
0530 ...     {*assert
0531 ...         MISC_Cast( 'int',18 ) === 18
0532 ...     *}
0533 ... 
0534 ...     {*assert
0535 ...         MISC_Cast( 'bool','hello' ) === true
0536 ...     *}
0537 ... 
0538 ...     {*assert
0539 ...         MISC_Cast( 'bool',null ) === false
0540 ...     *}
0541 ... 
0542 ...     {*seealso
0543 ...         MISC_CastBool(), MISC_CastString()
0544 ...     *}
0545 ... 
0546 ...     *}}
0547 ...  */
0548 ... /* ========================================================================== */
0549 ... function MISC_Cast( $szType,$x )
0550 ... /*----------------------------*/
0551 ... {
0552 ...     $z = $x;
0553 ...     settype ( $z,$szType );
0554 ...     return ( $z );
0555 ... }   /* End of function MIS_Cast() =========================================== */
0556 ... 
0557 ... /* ========================================================================== */
0558 ... /** {{*MISC_BuildCSRFToken( [$szToken] )=
0559 ... 
0560 ...     Generates a token to defeat Cross-Site Request Forgeries
0561 ... 
0562 ...     {*params
0563 ...         $szToken    (string)    Not used! (reserved for later). Optional.
0564 ...     *}
0565 ... 
0566 ...     {*return
0567 ...         (string)    Returns the value of the anti Cross-Site Request Forgery token
0568 ...     *}
0569 ... 
0570 ...     {*example
0571 ...         $txtFToken = new LSInput( 'hidden','token','token',MISC_BuildCSRFToken() );
0572 ...     *}
0573 ... 
0574 ...     *}}
0575 ...  */
0576 ... /* ========================================================================== */
0577 ... function MISC_BuildCSRFToken( $szToken = null )
0578 ... /*-------------------------------------------*/
0579 ... {
0580 ...     $szValue = hash( 'sha256',uniqid( rand(),true ) );              /* Generate unique ID - hash with sha256 (64 bytes) */
0581 ... 
0582 ...     if ( STR_Empty( $szToken ) )                                    /* If no token provided */
0583 ...     {
0584 ...         $szSeptum = '-';                                            /* Partition value */
0585 ...     }
0586 ...     else
0587 ...     {
0588 ...         $szSeptum = '-' . trim( $szToken ) . '-';                   /* Partition value */
0589 ...     }
0590 ... 
0591 ...     $bSessionStarted = false;                                       /* No session started by default */
0592 ...     $oApp            = null;                                        /* Application object */
0593 ...     $oSession        = null;                                        /* Session object is null */
0594 ... 
0595 ...     /* If global application object found and IS a valid LSApplication */
0596 ...     if ( isset( $GLOBALS['oApp'] ) && ( $oApp = $GLOBALS['oApp'] ) instanceof LSApplication )
0597 ...     {
0598 ...         /* If session object found and IS a valid LSSession */
0599 ...         if ( isset( $oApp->oSession ) && ( $oSession = $oApp->oSession ) instanceof LSSession )
0600 ...         {
0601 ...             $bSessionStarted = ! STR_Empty( $oSession->GetID() );   /* Session has started ? */
0602 ...         }
0603 ...         else
0604 ...         {
0605 ...             $bSessionStarted = ! STR_Empty( session_id() );         /* Session has started ? */
0606 ...         }
0607 ...     }
0608 ...     else
0609 ...     {
0610 ...         $bSessionStarted = ! STR_Empty( session_id() );             /* Session has started ? */
0611 ...     }
0612 ... 
0613 ...     if ( ! $bSessionStarted )                                       /* If no session started already */
0614 ...     {
0615 ...         if ( ! STR_Empty( $oApp ) && isset( $oApp->oTracer ) && $oApp->oTracer instanceof LSTracer )
0616 ...         {
0617 ...             require_once( VAESOLI_PATH . '/LSTracingLevels.inc'             );  /* Load the tracing levels */
0618 ...             $oApp->oTracer->Trace( __METHOD__ . ' (' . basename( __FILE__ ) . ' at line ' . __LINE__ . ") : start or resume session",TRACING_INFO_MEDIUM_LEVEL );
0619 ...         }   /*if ( ! STR_Empty( $oApp ) && isset( $oApp->oTracer ) ... */
0620 ... 
0621 ...         if ( ! STR_Empty( $oSession ) )                             /* If session found */
0622 ...         {
0623 ...             $oSession->Start();                                     /* Start a session here (or resume a session) */
0624 ...         }   /* if ( ! STR_Empty( $oSession ) ) */
0625 ...         else   /* Else of ... if ( ! STR_Empty( $oSession ) ) */
0626 ...         {
0627 ...             session_start();                                        /* Creates a session or resumes the current one  */
0628 ...         }   /* End of ... Else of ... if ( ! STR_Empty( $oSession ) ) */
0629 ...     }   /* if ( ! $bSessionStarted ) */
0630 ...                                                                     /* Imagine $szToken = 'contacts' */
0631 ...     $_SESSION["CSRF{$szSeptum}value"] = $szValue;                   /* Creates a 'CSRF-contacts-value' cell */
0632 ...     $_SESSION["CSRF{$szSeptum}time" ] = time();                     /* Creates a 'CSRF-contacts-time' cell */
0633 ... 
0634 ...     //var_dump( $_SESSION );
0635 ... 
0636 ...     return ( $szValue );                                            /* Return result to caller */
0637 ... }   /* End of function MISC_BuildCSRFToken() ================================ */
0638 ... 
0639 ... /* ========================================================================== */
0640 ... /** {{*MISC_IsLocalPC()=
0641 ... 
0642 ...     Determines if application runs on local PC
0643 ... 
0644 ...     {*params
0645 ...     *}
0646 ... 
0647 ...     {*return
0648 ...         (bool)          true if IP address == 127.0.0.1; false otherwise
0649 ...     *}
0650 ... 
0651 ...     {*noassert *}
0652 ... 
0653 ...     {*example
0654 ...         if ( MISC_IsLocalPC() )
0655 ...         {
0656 ...             phpinfo();
0657 ...         }
0658 ...     *}
0659 ... 
0660 ...     *}}
0661 ...  */
0662 ... /* ====================================================================== */
0663 ... function MISC_IsLocalPC()
0664 ... /*---------------------*/
0665 ... {
0666 ...     return ( $_SERVER['REMOTE_ADDR'] === '127.0.0.1' );
0667 ... }   /* End of function MISC_IsLocalPC() ================================= */
0668 ... 
0669 ... /* ====================================================================== */
0670 ... /** {{*MISC_MessageBox( $szMsg,$iFlags )=
0671 ... 
0672 ...     Displays a Javascript alert box
0673 ... 
0674 ...     {*params
0675 ...         $szMsg  (string)        Message to display
0676 ...         $iFlags (integer)       Optional flags. [c]64[/c] by default. NOT USED AT THE MOMENT
0677 ...     *}
0678 ... 
0679 ...     {*warning
0680 ...         The $iFlags parameter is NOT used yet
0681 ...     *}
0682 ... 
0683 ...     {*alias
0684 ...         MISC_MsgBox()
0685 ...     *}
0686 ... 
0687 ...     {*return
0688 ...         (string)    The HTML code that must be echoed
0689 ...     *}
0690 ... 
0691 ...     {*assert
0692 ...         preg_match( '/alert(.*OK BUTTON.*)/si',MISC_MessageBox( 'Click the OK button' ) )
0693 ...     *}
0694 ... 
0695 ...     {*exec
0696 ...         $szHTML = MISC_MessageBox( 'Click the OK button' );
0697 ...         echo htmlentities( $szHTML );
0698 ... 
0699 ...         echo LSUnitTesting::assert( preg_match( '/alert(.*OK BUTTON.*)/si',$szHTML ),
0700 ...                                     'ASSERTION SUCCESSFUL: message box OK'          ,
0701 ...                                     'ASSERTION FAILURE: message box NOT OK'         ,
0702 ...                                     'GuideAssert' );
0703 ...     *}
0704 ... 
0705 ...     *}}
0706 ...  */
0707 ... /* ========================================================================== */
0708 ... function MISC_MessageBox( $szMsg,$iFlags = 64 )
0709 ... /*-------------------------------------------*/
0710 ... {
0711 ...     return MISC_Script( "alert( '" . addslashes( $szMsg ) . "' );" );
0712 ... }   /* End of function MISC_MessageBox() ==================================== */
0713 ... function MISC_MsgBox( $szMsg,$iFlags = 64 ) { return MISC_MessageBox( $szMsg,$iFlags ); }
0714 ... 
0715 ... /* ========================================================================== */
0716 ... /** {{*MISC_WaitJSFnc( $szFnc,$iDelay,$szECMA,$WithScript )=
0717 ... 
0718 ...     Waits until a specific JavaScript function gets defined
0719 ... 
0720 ...     {*params
0721 ...         $szFnc      (string)    The function that must exist before we can
0722 ...                                 execute the ECMA script
0723 ...         $iDelay     (int)       The delay in milliseconds between 2 checks
0724 ...         $szECMA     (string)    The code that can be executed as soon as $szFnc
0725 ...                                 is defined
0726 ...         $WithScript (bool)      Optional. [c]true[/c] to embrace the result with
0727 ...                                 [c]MISC_Script()[/c]; [c]false[/c] if not.
0728 ...                                 [c]true[/c] by default.
0729 ...     *}
0730 ... 
0731 ...     {*cdate 23/04/2014 19:14 *}
0732 ...     {*version 6.0.0006 *}
0733 ... 
0734 ...     {*return
0735 ...         (string)    The HTML code that must be echoed.
0736 ...     *}
0737 ... 
0738 ...     {*exec
0739 ...         echo wordwrap( htmlentities( $szHTML = MISC_WaitJSFnc( 'Hello',5000,'alert(\'Hello() IS defined\')' ) ) );
0740 ...         echo LSUnitTesting::assert( preg_match( '/<script.+window\.INT_VAL_Hello *= '                           .
0741 ...                                                 '*setInterval.+clearInterval.+5000.+<\/script>.+/si',$szHTML )  ,
0742 ...                                     'ASSERTION SUCCESSFUL: script seems correct'                                ,
0743 ...                                     'ASSERTION FAILURE: incorrect script'                                       ,
0744 ...                                     'GuideAssert' );
0745 ...     *}
0746 ... 
0747 ...     {*seealso
0748 ...         MISC_AddJS(), MISC_AddJSEx(), MISC_Script(), MISC_RequireJS()
0749 ...     *}
0750 ... 
0751 ...     *}}
0752 ...  */
0753 ... /* ========================================================================== */
0754 ... function MISC_WaitJSFnc( $szFnc,$iDelay = 1000,$szECMA = null,$WithScript = true )
0755 ... /*------------------------------------------------------------------------------*/
0756 ... {
0757 ...     $szRetVal = '';
0758 ...     $szFnc    = str_replace( ' ','',$szFnc );
0759 ...     $szRetVal .=    "(" .
0760 ...                         "function() \n"                                                         .
0761 ...                         "{\n"                                                                   .
0762 ...                             "if ( typeof {$szFnc} == 'function' )\n"                            .
0763 ...                             "{\n"                                                               .
0764 ...                                 "{$szECMA};\n"                                                  .
0765 ...                             "}\n"                                                               .
0766 ...                             "else\n"                                                            .
0767 ...                             "{\n"                                                               .
0768 ...                                 "window.INT_VAL_{$szFnc} = setInterval( function() \n"          .
0769 ...                                               "{\n"                                             .
0770 ...                                                 "if ( typeof {$szFnc} == 'function' )\n"        .
0771 ...                                                 "{\n"                                           .
0772 ...                                                   "clearInterval( window.INT_VAL_{$szFnc} );\n" .
0773 ...                                                   "{$szECMA};\n"                                .
0774 ...                                                 "}\n"                                           .
0775 ...                                               "},{$iDelay});\n"                                 .
0776 ...                             "}\n"                                                               .
0777 ...                         "}());";
0778 ... 
0779 ...     return ( $WithScript ? MISC_Script( $szRetVal ) : $szRetVal );
0780 ... }   /* End of function MISC_WaitJSFnc() ===================================== */
0781 ... 
0782 ... /* ========================================================================== */
0783 ... /** {{*MISC_AddJS( $szScripts,$bScoped,$bDefer,$bCDATA )=
0784 ... 
0785 ...     Add a list of .js to the current markup
0786 ... 
0787 ...     {*params
0788 ...         $szScripts  (string)    A tokenized list (;) of JavaScript sources to be added
0789 ...         $bScoped    (bool)      Include a [c]"scoped"[/c] attribute if set.
0790 ...                                 Optional: [c]false[/c] by default.
0791 ...         $bDefer     (bool)      Indicates whether the script is to
0792 ...                                 be deferred or not.
0793 ...                                 Optional: [c]false[/c] by default.
0794 ...         $bCDATA     (bool)      Indicates whether the script must be
0795 ...                                 included in a CDATA section.
0796 ...                                 Optional: [c]true[/c] by default.
0797 ...     *}
0798 ... 
0799 ...     {*cdate 12/05/2013 11:11 *}
0800 ...     {*mdate 04/06/2013 06:13 *}
0801 ...     {*version 5.3.0002 *}
0802 ... 
0803 ...     {*return
0804 ...         (string)    The HTML code that must be echoed.
0805 ...     *}
0806 ... 
0807 ...     {*exec
0808 ...         echo wordwrap( htmlentities( $szHTML = MISC_AddJS( 'LSVAjax.js' ) ) );
0809 ... 
0810 ...         echo LSUnitTesting::assert( preg_match( '%var script *?= *document.+?LSVAjax.js%si',$szHTML )   ,
0811 ...                                     'ASSERTION SUCCESSFUL: ECMA seems to be correct'                    ,
0812 ...                                     'ASSERTION FAILURE: incorrect ECMA'                                 ,
0813 ...                                     'GuideAssert' );
0814 ...     *}
0815 ... 
0816 ...     {*seealso
0817 ...         MISC_AddJSEx(), MISC_Script(), MISC_RequireJS()
0818 ...     *}
0819 ... 
0820 ...     *}}
0821 ...  */
0822 ... /* ========================================================================== */
0823 ... function MISC_AddJS( $szScripts,$bScoped = false,$bDefer = false,$bCDATA = true,$szOnload = null )
0824 ... /*----------------------------------------------------------------------------------------------*/
0825 ... {
0826 ...     $szPath = FIL_RevertRoot( VAESOLI_PATH );
0827 ... 
0828 ...     if ( STR_Empty( $szPath ) )                                     /* This damn bug in PHP about junctions !!! */
0829 ...     {
0830 ...         $szPath = '/vaesoli/include';                               /* This is usually where Vae Soli! is */
0831 ...     }
0832 ... 
0833 ...     $aScripts = explode( ';',str_replace( ',',';',$szScripts ) );
0834 ...     $szECMA   = '';
0835 ... 
0836 ...     foreach( $aScripts as $szScript )                               /* For each script to be included */
0837 ...     {
0838 ...         if ( ! STR_Empty( $szScript ) )                             /* If script not empty */
0839 ...         {
0840 ...             $szVar      = "DEFINE_" . str_replace( array('.','\\','/' ),'_',$szScript );
0841 ...             $szNow      = date( 'YmdHis' );
0842 ... 
0843 ...             $szECMA    .= "/* Generated {$szNow} */\n";
0844 ...             //$szECMA    .= "if ( undefined === {$szVar} )\n";
0845 ...             $szECMA    .= "if ( typeof {$szVar} === 'undefined' )\n";
0846 ...             $szECMA    .= "{\n";
0847 ...             $szECMA    .= "/* {$szPath} */\n";
0848 ...             $szECMA    .= "    var script = document.createElement(\"script\");\n";
0849 ...             $szECMA    .= "    var head   = document.getElementsByTagName(\"head\")[0];\n";
0850 ...             $szECMA    .= "    script.src = \"{$szPath}/../scripts/{$szScript}\";\n";
0851 ... 
0852 ...             if ( ! STR_Empty( $szOnload ) )
0853 ...             {
0854 ...                 $szECMA .= "/* ONLOAD: {$szOnload} */\n";
0855 ...                 $szECMA .= "   script.onload = function() { {$szOnload}; };\n";
0856 ...             }
0857 ...             $szECMA    .= "    (head || document.body).appendChild( script );\n";
0858 ...             $szECMA    .= "}\n";
0859 ...         }   /* if ( ! STR_Empty( $szScript ) ) */
0860 ...     }   /* foreach( $aScripts as $szScript ) */
0861 ... 
0862 ...     return ( MISC_Script( $szECMA,$bScoped,$bDefer,$bCDATA ) );
0863 ... }   /* End of function MISC_AddJS() ========================================= */
0864 ... 
0865 ... /* ========================================================================== */
0866 ... /** {{*MISC_AddJSEx( $aScripts,$aOnloads,$aScoped,$aDefer,$aCDATA )=
0867 ... 
0868 ...     Add a list of .js to the current markup
0869 ... 
0870 ...     {*params
0871 ...         $aScripts   (array)     An array of JavaScript sources to be added.
0872 ...         $aOnloads   (array)     An array of JavaScript code; each slot of the array
0873 ...                                 is the code that will be triggered when the
0874 ...                                 onload event of the JavaScript source is fired.
0875 ...         $aScoped    (bool)      An array of [c]"scoped"[/c] attributes.
0876 ...                                 Optional: [c]null[/c] by default ... which maps
0877 ...                                 to ALL sources having NO scoped attribute
0878 ...         $aDefer     (bool)      An array of [c]"defer"[/c] attributes.
0879 ...                                 Optional: [c]null[/c] by default ... which maps
0880 ...                                 to ALL sources NOT being deferred.
0881 ...         $aCDATA     (bool)      An array of boolean attributes that indicate
0882 ...                                 whether the JavaScript code should be included
0883 ...                                 in a CDATA section.
0884 ...     *}
0885 ... 
0886 ...     {*cdate 09/06/2013 09:58 *}
0887 ...     {*mdate 09/06/2013 11:38 *}
0888 ...     {*version 5.3.0002 *}
0889 ... 
0890 ...     {*return
0891 ...         (string)    The HTML code that must be echoed.
0892 ...     *}
0893 ... 
0894 ...     {*seealso
0895 ...         MISC_AddJS(), MISC_Script(), MISC_RequireJS()
0896 ...     *}
0897 ... 
0898 ...     {*exec
0899 ...         echo MISC_AddJSEx( array( 'LSVAjax.js' ),
0900 ...                            array( 'console.log("LSVAjax.js loaded!")' ) );
0901 ...     *}
0902 ... 
0903 ...     *}}
0904 ...  */
0905 ... /* ========================================================================== */
0906 ... function MISC_AddJSEx( $aScripts,$aOnloads = null,$aScoped = null,$aDefer = null,$aCDATA = null )
0907 ... /*---------------------------------------------------------------------------------------------*/
0908 ... {
0909 ...     $szRetVal = '';                                                 /* Return value of the function */
0910 ... 
0911 ...     if ( ( $iCount = count( $aScripts ) ) > 0 )                     /* If scripts found */
0912 ...     {
0913 ...         for( $i = 0; $i < $iCount;$i++ )                            /* For each script to be included */
0914 ...         {
0915 ...             $szScript   = ( ( ! is_null( $aScripts ) ) && isset( $aScripts[$i] ) ) ? $aScripts[$i] : null;
0916 ...             $szOnload   = ( ( ! is_null( $aOnloads ) ) && isset( $aOnloads[$i] ) ) ? $aOnloads[$i] : null;
0917 ...             $bScoped    = ( ( ! is_null( $aScoped  ) ) && isset( $aScoped[$i]  ) ) ? $aScoped[$i]  : false;
0918 ...             $bDefer     = ( ( ! is_null( $aDefer   ) ) && isset( $aDefer[$i]   ) ) ? $aDefer[$i]   : false;
0919 ...             $bCDATA     = ( ( ! is_null( $aCDATA   ) ) && isset( $aCDATA[$i]   ) ) ? $aCDATA[$i]   : true;
0920 ... 
0921 ...             if ( ! STR_Empty( $szScript ) )                         /* If script passed */
0922 ...             {
0923 ...                 $szRetVal .= MISC_AddJS( $szScript,$bScoped,$bDefer,$bCDATA,$szOnload );
0924 ...             }   /* if ( ! STR_Empty( $szScript ) ) */
0925 ...         }   /* if ( ! STR_Empty( $szScript ) ) */
0926 ...     }   /* if ( ( $iCount = count( $aScripts ) ) > 0 ) */
0927 ... 
0928 ...     return ( $szRetVal );                                           /* Return result to caller */
0929 ... }   /* End of function MISC_AddJSEx() ======================================= */
0930 ... 
0931 ... /* ========================================================================== */
0932 ... /** {{*MISC_RequireJS( $szJS,$szID,$szScript,$WithScript )=
0933 ... 
0934 ...     Adds non-blocking JavaScript script
0935 ... 
0936 ...     {*params
0937 ...         $szJS       (string)    The JavaScript source (.js) to load
0938 ...         $szID       (string)    ID of script element. If script#id does exist
0939 ...                                 the JavaScript returns immediately. Optional
0940 ...                                 (but NOT recommended). [c]null[/c] by default.
0941 ...         $szScript   (string)    The JavaScript code to be inserted
0942 ...         $WithScript (bool)      Optional. [c]true[/c] to embrace the result with
0943 ...                                 [c]MISC_Script()[/c]; [c]false[/c] if not.
0944 ...                                 [c]true[/c] by default.
0945 ...     *}
0946 ... 
0947 ...     {*return
0948 ...         (string)    The HTML code that must be echoed
0949 ...     *}
0950 ... 
0951 ...     {*exec
0952 ...         echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js','MY-SCRIPT' ) ) );
0953 ...         echo LSUnitTesting::assert( preg_match( "/<script type=['\"]text\/javascript['\"]>.*?"      .
0954 ...                                                 "\/js\/myscript\.js.*?\(document,['\"]script['\"]," .
0955 ...                                                 "['\"]MY-SCRIPT['\"]\).*?"                          .
0956 ...                                                 "<\/script>/s",$szHTML )                            ,
0957 ...                                     'ASSERTION SUCCESSFUL: script seems to be correct'              ,
0958 ...                                     'ASSERTION FAILURE: incorrect script'                           ,
0959 ...                                     'GuideAssert' );
0960 ...         echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js' ) ) );
0961 ...         echo LSUnitTesting::assert( preg_match( "/<script type=['\"]text\/javascript['\"]>.*?"      .
0962 ...                                                 "\/js\/myscript\.js.*?\(document,['\"]script['\"]," .
0963 ...                                                 "['\"]VAE-[[:digit:][:upper:]]{32}['\"]\).*?"       .
0964 ...                                                 "<\/script>/s",$szHTML )                            ,
0965 ...                                     'ASSERTION SUCCESSFUL: ID as guid found'                        ,
0966 ...                                     'ASSERTION FAILURE: NO ID as guid found'                        ,
0967 ...                                     'GuideAssert' );
0968 ...         echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js',null,$szJS = 'alert("bonjour")' ) ) );
0969 ...         echo LSUnitTesting::assert( preg_match( "/<script type=['\"]text\/javascript['\"]>.*?"                      .
0970 ...                                                 "\/js\/myscript\.js.*?alert\(.+\).*?\(document,['\"]script['\"],"   .
0971 ...                                                 "['\"]VAE-[[:digit:][:upper:]]{32}['\"]\).*?"                       .
0972 ...                                                 "<\/script>/s",$szHTML )                                            ,
0973 ...                                     'ASSERTION SUCCESSFUL: script injected in script'                               ,
0974 ...                                     'ASSERTION FAILURE: no script injection'                                        ,
0975 ...                                     'GuideAssert' );
0976 ...         echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js',null,$szJS = 'alert("bonjour")',false ) ) );
0977 ...         echo LSUnitTesting::assert( STR_iPos( 'text/javascript',$szHTML ) === -1  &&
0978 ...                                     STR_iPos( '<script',$szHTML )         === -1                            ,
0979 ...                                     'ASSERTION SUCCESSFUL: no &lt;script&gt;...&lt;/script&gt; as expected' ,
0980 ...                                     'ASSERTION FAILURE: &lt;script&gt;...&lt;/script&gt; found = problem'   ,
0981 ...                                     'GuideAssert' );
0982 ...     *}
0983 ... 
0984 ...     *}}
0985 ...  */
0986 ... /* ========================================================================== */
0987 ... function MISC_RequireJS( $szJS,$szID = null,$szScript = null,$WithScript = true )
0988 ... /*-----------------------------------------------------------------------------*/
0989 ... {
0990 ...     $szECMA = '';
0991 ... 
0992 ...     if ( is_null( $szID ) )
0993 ...     {
0994 ...         $szID = 'VAE-' . str_replace( array( '{','}','-' ),'',guid() );
0995 ...     }
0996 ... 
0997 ...     $szECMA .= "(function(d,s,id) {";
0998 ...     $szECMA .= "if (d.getElementById(id)) return;";
0999 ...     $szECMA .= "var js, vjs = d.getElementsByTagName(s)[0];";
1000 ...     $szECMA .= "js = d.createElement(s); js.id = id;";
1001 ...     $szECMA .= "js.src = \"{$szJS}\";";
1002 ...     $szECMA .= "vjs.parentNode.insertBefore(js,vjs);";
1003 ...     if ( ! STR_Empty( $szScript ) )
1004 ...     {
1005 ...         $szECMA .= "{$szScript};";
1006 ...     }
1007 ...     $szECMA .= "}(document,'script','{$szID}'));";
1008 ... 
1009 ...     return ( $WithScript ? MISC_Script( $szECMA,false,false,false ) : $szECMA );
1010 ... }   /* End of function MISC_RequireJS() ===================================== */
1011 ... 
1012 ... /* ========================================================================== */
1013 ... /** {{*MISC_RequireCSS( $szCSS,$szMedia,$szID,$szTitle,$szBefore,$szAfter,$WithScript )=
1014 ... 
1015 ...     Adds non-blocking CSS
1016 ... 
1017 ...     {*params
1018 ...         $szCSS      (string)    The stylesheet (.css) to load
1019 ...         $szMedia    (string)    The targeted media (screen, projection, print,
1020 ...                                 ...)
1021 ...         $szID       (string)    ID of script element. If script#id does exist
1022 ...                                 the JavaScript returns immediately. Optional
1023 ...                                 (but NOT recommended). [c]null[/c] by default.
1024 ...         $szTitle    (string)    Title set to stylesheet. Optional.
1025 ...                                 [c]null[/c] by default.
1026 ...         $szBefore   (string)    CSS that must be precede by the one that must now be
1027 ...                                 inserted. Optional. [c]null[/c] by default.
1028 ...         $szAfter    (string)    CSS that must precede the one that must now be
1029 ...                                 inserted. Optional. [c]null[/c] by default.
1030 ...         $WithScript (bool)      [c]true[/c] to embrace the result with
1031 ...                                 [c]MISC_Script()[/c]; [c]false[/c] if not.
1032 ...                                 [c]true[/c] by default.
1033 ...     *}
1034 ... 
1035 ...     {*return
1036 ...         (string)    The HTML code that must be echoed
1037 ...     *}
1038 ... 
1039 ...     {*exec
1040 ...         echo wordwrap( htmlentities( MISC_RequireCSS( '/css/base.css','MY-CSS' ) ) );
1041 ...     *}
1042 ... 
1043 ...     *}}
1044 ...  */
1045 ... /* ========================================================================== */
1046 ... function MISC_RequireCSS( $szCSS                ,$szMedia = 'all',
1047 ...                           $szID         = null  ,$szTitle = null,
1048 ...                           $szBefore     = null  ,$szAfter = null,
1049 ...                           $WithScript   = true )
1050 ... /*--------------------------------------------------------------*/
1051 ... {
1052 ...     $szECMA = '';
1053 ... 
1054 ...     if ( is_null( $szMedia ) )
1055 ...         $szMedia = 'all';
1056 ... 
1057 ...     if ( is_null( $szID ) )
1058 ...         $szID = 'VAE-' . str_replace( array( '{','}','-' ),'',guid() );
1059 ... 
1060 ...     if ( is_null( $WithScript ) )
1061 ...         $WithScript = true;
1062 ... 
1063 ...     if ( ! STR_Empty( $szBefore ) )
1064 ...     {
1065 ...         //var found=false;
1066 ...         //olnk = d.getElementsByTagName(t)
1067 ...         //if olnk.length > 0
1068 ...         //for (var i=0;i<olnk.length;i=i+1)
1069 ...         //{
1070 ...         //    if ( olnk[i].src==szBefore ) { vlnk = olnk[i]; found=true; }
1071 ...         //}
1072 ...         // if (!found) vlnk=olnk[0];
1073 ...     }
1074 ... 
1075 ...     if ( ! STR_Empty( $szAfter ) )
1076 ...     {
1077 ...         //var found=false;
1078 ...         //olnk = d.getElementsByTagName(t)
1079 ...         //if olnk.length > 0
1080 ...         //for (var i=0;i<olnk.length;i=i+1)
1081 ...         //{
1082 ...         //    if ( olnk[i].src==szBefore ) { vlnk = olnk[i+1]; found=true; }
1083 ...         //}
1084 ...         // if (!found) vlnk=olnk[0];
1085 ...         // Cas où i est déjà le dernier pas prévu
1086 ...     }
1087 ... 
1088 ...     $szECMA .= "(function(d,t,id) {";
1089 ...     $szECMA .= "if (d.getElementById(id)) return;";
1090 ...     $szECMA .= "var lnk,vlnk = d.getElementsByTagName(t)[0];";
1091 ...     $szECMA .= "lnk = d.createElement(t); ";
1092 ...     $szECMA .= "lnk.id = id;";
1093 ...     $szECMA .= "lnk.rel = \"stylesheet\";";
1094 ...     $szECMA .= "lnk.href = \"{$szCSS}\";";
1095 ...     $szECMA .= "lnk.type = \"text/css\";";
1096 ...     $szECMA .= "lnk.media = \"{$szMedia}\";";
1097 ... 
1098 ...     if ( ! STR_Empty( $szTitle ) )
1099 ...         $szECMA .= "lnk.title = \"{$szTitle}\";";
1100 ... 
1101 ...     $szECMA .= "vlnk.parentNode.insertBefore(lnk,vlnk);";
1102 ...     $szECMA .= "}(document,'link','{$szID}'));";
1103 ... 
1104 ...     return ( $WithScript ? MISC_Script( $szECMA,false,false,false ) : $szECMA );
1105 ... }   /* End of function MISC_RequireCSS() ==================================== */
1106 ... 
1107 ... /* ========================================================================== */
1108 ... /** {{*MISC_Sleep( $iMicroSeconds )=
1109 ... 
1110 ...     Delay execution in microseconds
1111 ... 
1112 ...     {*params
1113 ...         $iMicroSeconds  (int)   Dealy time in micro seconds (a micro second is
1114 ...                                 one millionth of a second).
1115 ...     *}
1116 ... 
1117 ...     {*return
1118 ...         (void)
1119 ...     *}
1120 ... 
1121 ...     {*example
1122 ...         MISC_Sleep( 1000000 ); // Suspend execution for 1 sec
1123 ...     *}
1124 ... 
1125 ...     *}}
1126 ...  */
1127 ... /* ========================================================================== */
1128 ... function MISC_Sleep( $iMicroSeconds )
1129 ... /*---------------------------------*/
1130 ... {
1131 ...     usleep( $iMicroSeconds );
1132 ... }   /* End of function MISC_Sleep() ========================================= */
1133 ... 
1134 ... /* ========================================================================== */
1135 ... /** {{*MISC_OnLoad( $szScript,$WithScript )=
1136 ... 
1137 ...     Adds JavaScript code to the load event of the page (window)
1138 ... 
1139 ...     {*params
1140 ...         $szScript   (string)    The Javascript code to be inserted
1141 ...         $WithScript (bool)      [c]true[/c] to embrace the result with
1142 ...                                 [c]MISC_Script()[/c]; [c]false[/c] if not.
1143 ...                                 [c]true[/c] by default.
1144 ...     *}
1145 ... 
1146 ...     {*return
1147 ...         (string)    The HTML code that must be echoed
1148 ...                     ([c]&lt;script&gt;window.addEventlistener( "load",function() { ... } )&lt;/script&gt;[/c])
1149 ...     *}
1150 ... 
1151 ...     {*exec
1152 ...         $szRetVal   = '';
1153 ...         $szRetVal  .= MISC_AddJSEx( array( 'LSVExplorer.js' ) );
1154 ...         $szObject   = 'oCacheExplorer';
1155 ...         $szRetVal  .= MISC_OnLoad( "{$szObject} =
1156 ...                                         new LSVExplorer(  'oCacheExplorer',"                    .
1157 ...                                                          "'LS_CACHE',\n"                        .
1158 ...                                                          "'C:/mazuis.org/www/httpdocs/',"       .
1159 ...                                                          "'C:/mazuis.org/www/httpdocs/css/',\n" .
1160 ...                                                          "'/ajax/ajax.php?',"                   .
1161 ...                                                          "'fr',"                                .
1162 ...                                                          "2048000,"                             .
1163 ...                                                          "'image/gif;image/png;image/jpeg',"    .
1164 ...                                                          "true );\n" );
1165 ...         echo htmlentities( $szRetVal );
1166 ... 
1167 ...         echo LSUnitTesting::assert( preg_match( "/window.addEventListener.*\"load\","   .
1168 ...                                     "function.*{$szObject}.*LS_CACHE/s",$szRetVal )     ,
1169 ...                                     'ASSERTION SUCCESSFUL: JavaScript has a good face'  ,
1170 ...                                     'ASSERTION FAILURE: incorrect JavaScript'           ,
1171 ...                                     'GuideAssert' );
1172 ...     *}
1173 ... 
1174 ...     {*seealso
1175 ...         MISC_RequireJS(), MISC_WaitJSFnc()
1176 ...     *}
1177 ... 
1178 ...     *}}
1179 ...  */
1180 ... /* ========================================================================== */
1181 ... function MISC_OnLoad( $szScript,$WithScript = true )
1182 ... /*------------------------------------------------*/
1183 ... {
1184 ...     $szRetVal = ( $WithScript ? "<script>\n" : '' ) . 
1185 ...                 "window.addEventListener( \"load\",function () { {$szScript} } );" .
1186 ...                 ( $WithScript ? "\n</script>\n" : '' );
1187 ...     return ( $szRetVal );
1188 ... }   /* End of function MISC_OnLoad() ======================================== */
1189 ... 
1190 ... /* ========================================================================== */
1191 ... /** {{*MISC_Script( $szScript,$bScoped,$bDefer,$bCDATA )=
1192 ... 
1193 ...     Generates the proper code to include a JavaScript
1194 ... 
1195 ...     {*params
1196 ...         $szScript   (string)    The Javascript code to be inserted
1197 ...         $bScoped    (bool)      Include a [c]"scoped"[/c] attribute if set.
1198 ...                                 Optional: [c]false[/c] by default.
1199 ...         $bDefer     (bool)      Indicates whether the script is to
1200 ...                                 be deferred or not.
1201 ...                                 Optional: [c]false[/c] by default.
1202 ...         $bCDATA     (bool)      Indicates whether the script must be
1203 ...                                 included in a CDATA section.
1204 ...                                 Optional: [c]true[/c] by default.
1205 ...     *}
1206 ... 
1207 ...     {*return
1208 ...         (string)    The HTML code that must be echoed.
1209 ...     *}
1210 ... 
1211 ...     {*remark
1212 ...         An empty script does not produce any output.
1213 ...     *}
1214 ... 
1215 ...     {*exec
1216 ...         echo htmlentities( MISC_Script( 'alert("Hey");' ) );
1217 ...         echo htmlentities( MISC_Script( '' ) );
1218 ...     *}
1219 ... 
1220 ...     {*seealso
1221 ...         MISC_RequireJS(), MISC_AddJS(), MISC_AddJSEx()
1222 ...     *}
1223 ... 
1224 ...     *}}
1225 ...  */
1226 ... /* ========================================================================== */
1227 ... function MISC_Script( $szScript,$bScoped = false,$bDefer = false,$bCDATA = true )
1228 ... /*-----------------------------------------------------------------------------*/
1229 ... {
1230 ...     $szRetVal = '';                                                 /* Default return value of the function */
1231 ... 
1232 ...     if ( ! STR_Empty( trim( $szScript ) ) )                         /* If script NOT empty */
1233 ...     {
1234 ...         $szRetVal .= "<script type=\"text/javascript\""     .       /* Start script tag */
1235 ...                      ( $bDefer ? ' defer="defer"' : '' )    .
1236 ...                      ( $bScoped ? ' scoped="scoped"' : '' ) . ">\n";
1237 ... 
1238 ...         if ( $bCDATA )                                              /* If included in a CDATA section */
1239 ...             $szRetVal .= "// <![CDATA[\n";                          /* Start of CDATA */
1240 ... 
1241 ...         $szRetVal .= $szScript . "\n";                              /* Insert real script */
1242 ... 
1243 ...         if ( $bCDATA )                                              /* If included in a CDATA section */
1244 ...             $szRetVal .= "//]]>\n";                                 /* End of script comment (CDATA) */
1245 ... 
1246 ...         $szRetVal .= "</script>\n";                                 /* Close script tag */
1247 ...     }   /* if ( ! STR_Empty( $szScript ) ) */
1248 ... 
1249 ...     return ( $szRetVal );                                           /* Return value to caller */
1250 ... }   /* End of function MISC_Script() ======================================== */
1251 ... 
1252 ... /* ========================================================================== */
1253 ... /** {{*MISC_Taxonomize( $szResource[,$szLang][,$szType] )=
1254 ... 
1255 ...     Taxonomize a resource
1256 ... 
1257 ...     {*params
1258 ...         $szResource (string)    The resource to taxonomize (a URL, a file, ...)
1259 ...         $szLang     (string)    Language of the taxonomy
1260 ...         $szType     (string)    Resource type
1261 ...     *}
1262 ... 
1263 ...     {*return
1264 ...         (array)     An array of words found in the $szResource resource
1265 ...     *}
1266 ... 
1267 ...     {*warning
1268 ...         Experimental function. Do not use ina production environment!
1269 ...     *}
1270 ... 
1271 ...     {*example
1272 ...         var_dump( MISC_Taxonomize( 'http://www.vaesoli.org' ) );
1273 ...     *}
1274 ... 
1275 ...     *}}
1276 ...  */
1277 ... /* ========================================================================== */
1278 ... function MISC_Taxonomize( $szResource = null,&$szLang = 'fr',$szType = 'url' )
1279 ... /*--------------------------------------------------------------------------*/
1280 ... {
1281 ...     require_once( VAESOLI_PATH . '/LSHtml.functions.php'    );
1282 ...     require_once( VAESOLI_PATH . '/LSHttp.functions.php'    );
1283 ...     require_once( VAESOLI_PATH . '/LSStrings.functions.php' );
1284 ...     require_once( VAESOLI_PATH . '/LSMisc.functions.php'    );
1285 ...     require_once( VAESOLI_PATH . '/LSFiles.functions.php'   );
1286 ... 
1287 ...     if ( STR_Empty( $szResource ) && $szType === 'url' )
1288 ...     {
1289 ...         $szResource = 'http://'                                     .
1290 ...                        $_SERVER['SERVER_NAME']                      . /* www.ls.poc */
1291 ...                        $_SERVER['SCRIPT_NAME']                      . /* /info.php */
1292 ...                        isset( $_SERVER['QUERY_STRING'] )            ?
1293 ...                               ( '?' . $_SERVER['QUERY_STRING'] )    : /* ?hpp=klm */
1294 ...                               '';
1295 ...     }   /* if ( STR_Empty( $szResource ) ) */
1296 ... 
1297 ...     $aWords         = array();                                      /* Return value of the function */
1298 ...     $szURLPattern   = '/\b(?P<protocol>https?|ftp):\/\/(?P<domain>[-A-Z0-9.]+)(?P<file>\/[-A-Z0-9+&@#\/%=~_|!:,.;]*)?(?P<params>\?[A-Z0-9+&@#\/%=~_|!:,.;]*)?/si';
1299 ...     $bFile          = false;
1300 ...     $szCharset      = 'ISO-8859-15';
1301 ...     $szHeader       = '';                                           /* Response header */
1302 ... 
1303 ...     if ( preg_match( $szURLPattern,$szResource,$aParts ) ||
1304 ...          ( $bFile = ( STR_iPos( $szResource,'file://' ) != -1 ) )
1305 ...        )
1306 ...     {
1307 ...         if ( ! $bFile )                                             /* If URL must be considered (NOT a file) */
1308 ...         {
1309 ...             if ( $szType === 'string' )
1310 ...             {
1311 ...                 $szText = $szResource;
1312 ...             }
1313 ...             else
1314 ...             {
1315 ...                 if ( isset( $aParts['domain'] ) )
1316 ...                 {
1317 ...                     $aURLWords = STR_aUniqueWords( MISC_TopDomain( $aParts['domain'] ) );
1318 ...                     $aWords = array_merge( $aWords,$aURLWords );
1319 ...                 }   /* if ( isset( $aParts['domain'] ) ) */
1320 ... 
1321 ...                 if ( isset( $aParts['file'] ) )
1322 ...                 {
1323 ...                     $szFullFile = $aParts['file'];
1324 ...                     $aFileParts = pathinfo( $szFullFile );
1325 ...                     $szFile = '';
1326 ... 
1327 ...                     if ( isset( $aFileParts['dirname' ] ) )
1328 ...                     {
1329 ...                         $szFile .= $aFileParts['dirname' ];
1330 ...                     }   /* if ( isset( $aFileParts['dirname' ] ) ) */
1331 ... 
1332 ...                     if ( isset( $aFileParts['filename' ] ) )
1333 ...                     {
1334 ...                         $szFile .= ' ' . $aFileParts['filename' ];
1335 ...                     }   /* if ( isset( $aFileParts['filename' ] ) ) */
1336 ... 
1337 ...                     $szFile = trim( str_replace( '/',' ',$szFile ) );
1338 ... 
1339 ...                     $aURLWords = STR_aUniqueWords( $szFile );
1340 ...                     $aWords = array_merge( $aWords,$aURLWords );
1341 ...                 }   /* if ( isset( $aParts['file'] ) ) */
1342 ... 
1343 ...                 $iErrCode = 0;
1344 ... 
1345 ...                 if ( HTML_IsUTF8( $szText = HTTP_GetURL( $szResource,null /* user */,null /* pwd */,$iErrCode,null /* options */,$szHeader ) ) )
1346 ...                 {
1347 ...                     $szCharset = 'UTF-8';
1348 ...                     //$szText = utf8_decode( $szText );
1349 ...                     //echo "C'est de l'UTF 8";
1350 ...                 }   /* if ( HTML_IsUTF8( $szText = HTTP_GetURL( ... ) ) ) */
1351 ...             }
1352 ...         }   /* if ( ! $bFile ) */
1353 ...         else   /* Else of ... if ( ! $bFile ) */
1354 ...         {
1355 ...             if ( preg_match( '/file:\/\/(?P<file>.*)/si',$szResource,$aParts ) )
1356 ...             {
1357 ...                 if ( FIL_Exists( $szFile = FIL_Normalize( $aParts['file'] ) ) )
1358 ...                 {
1359 ...                     $szText = FIL_FileToStr( $szFile );
1360 ...                 }   /* if ( FIL_Exists( $szFile = FIL_Normalize( $aParts['file'] ) ) ) */
1361 ...             }   /* if ( preg_match( '/file:\/\/(?P<file>.*)/si',$szResource,$aParts ) ) */
1362 ...         }   /* End of ... Else of ... if ( ! $bFile ) */
1363 ... 
1364 ...         if ( $szCharset === 'UTF-8' && isset( $szText ) )
1365 ...         {
1366 ...             //$szText = @iconv( $szCharset,"ISO-8859-1//TRANSLIT",str_replace( array('«','»'),array('"','"'),$szText ) );
1367 ...             $szText = @iconv( $szCharset,"ISO-8859-1//TRANSLIT",$szText );
1368 ...         }   /* if ( $szCharset === 'UTF-8' ) */
1369 ... 
1370 ...         /********************************************************************/
1371 ...         /* Language detection (http://www.w3.org/TR/i18n-html-tech-lang/    */
1372 ...         /********************************************************************/
1373 ...         $szLanguage = null;
1374 ... 
1375 ...         /********************************************************************/
1376 ...         /* Strategy #1: language extraction from the <html>...</html> tag   */
1377 ...         /*                                                                  */
1378 ...         /* Extract <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> */
1379 ...         /********************************************************************/
1380 ...         {
1381 ...             if ( isset( $szText ) && preg_match( '/<html.*?>/si',$szText,$aMatch ) )
1382 ...                 $szHTMLTag = $aMatch[0];
1383 ...             else
1384 ...                 $szHTMLTag = '';
1385 ... 
1386 ...             /* If <html ...> tag found */
1387 ...             if ( ! STR_Empty( $szHTMLTag ) )
1388 ...             {
1389 ...                 /* Looking for something like ... <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> */
1390 ...                 if ( preg_match( '/<html.*lang=(["\']{1})(.*?)\1.*?>/si',$szHTMLTag,$aMatch ) )
1391 ...                 {
1392 ...                     $szLanguage = $aMatch[2];
1393 ...                 }   /* if ( preg_match( '/<html.*lang=(["\']{1})(.*?)\... ) */
1394 ...             }   /* if ( ! STR_Empty( $szHTMLTag ) ) */
1395 ...         }
1396 ... 
1397 ...         /********************************************************************/
1398 ...         /* Strategy #2: language extraction from the Content-Language meta  */
1399 ...         /*                                                                  */
1400 ...         /* Extract <meta http-equiv="Content-Language" content="en" />      */
1401 ...         /********************************************************************/
1402 ...         if ( is_null( $szLanguage ) )                               /* If language NOT found yet */
1403 ...         {
1404 ...             /* This is the second best strategy to determine the language */
1405 ...             if ( preg_match('/<meta *?http-equiv="Content-Language" *?content=(["\']{1})(.*?)\1.*?>/si',$szText,$aMatch ) )
1406 ...             {
1407 ...                 $szLanguage = $aMatch[2];
1408 ...             }   /* if ( preg_match('/<meta *?http-equiv="Content...) ) */
1409 ...         }   /* if ( is_null( $szLanguage ) ) */
1410 ... 
1411 ...         /********************************************************************/
1412 ...         /* Strategy #3: Dublin core meta                                    */
1413 ...         /*                                                                  */
1414 ...         /* Extract <meta name="dc.language" content="en" />                 */
1415 ...         /********************************************************************/
1416 ...         if ( is_null( $szLanguage ) )                               /* If language NOT found yet */
1417 ...         {
1418 ...             /* This is the second best strategy to determine the language */
1419 ...             if ( preg_match('/<meta *?name="dc.language" *?content=(["\']{1})(.*?)\1.*?>/si',$szText,$aMatch ) )
1420 ...             {
1421 ...                 $szLanguage = $aMatch[2];
1422 ...             }   /* if ( preg_match('/<meta *?http-equiv="Content...) ) */
1423 ...         }   /* if ( is_null( $szLanguage ) ) */
1424 ... 
1425 ...         /********************************************************************/
1426 ...         /* Strategy #4: HTTP Header                                         */
1427 ...         /*                                                                  */
1428 ...         /* HTTP/1.1 200 OK                                                  */
1429 ...         /* Date: Wed, 05 Nov 2003 10:46:04 GMT                              */
1430 ...         /* Server: Apache/1.3.28 (Unix) PHP/4.2.3                           */
1431 ...         /* Content-Location: CSS2-REC.en.html                               */
1432 ...         /* Vary: negotiate,accept-language,accept-charset                   */
1433 ...         /* Accept-Ranges: bytes                                             */
1434 ...         /* Content-Length: 10734                                            */
1435 ...         /* Connection: close                                                */
1436 ...         /* Content-Type: text/html; charset=iso-8859-1                      */
1437 ...         /* Content-Language: en                                             */
1438 ...         /********************************************************************/
1439 ...         if ( is_null( $szLanguage ) )                               /* If language NOT found yet */
1440 ...         {
1441 ...             if ( ! STR_Empty( $szHeader ) )                         /* If we go the header back */
1442 ...             {
1443 ...                 if ( preg_match( '/Content-Language: *?(?P<lang>.*?)$/sim',$szHeader,$aMatch ) )
1444 ...                 {
1445 ...                     if ( isset( $aMatch['lang'] ) )                 /* If match found */
1446 ...                     {
1447 ...                         $szLanguage = trim( $aMatch['lang'] );
1448 ...                     }   /* if ( isset( $aMatch['lang'] ) ) */
1449 ...                 }   /* if ( preg_match( '/Content-Language: *?(?P<lang>.*?)$/sim',$szHeader,$aMatch ) ) */
1450 ...             }   /* if ( ! STR_Empty( $szHeader ) ) */
1451 ...         }   /* if ( is_null( $szLanguage ) ) */
1452 ... 
1453 ...         /********************************************************************/
1454 ...         /* Default handling:                                                */
1455 ...         /********************************************************************/
1456 ...         if ( is_null( $szLanguage ) )                               /* If language NOT found yet */
1457 ...         {
1458 ...             $szLanguage = 'fr';                                     /* Default language */
1459 ...         }   /* if ( is_null( $szLanguage ) ) */
1460 ... 
1461 ...         /********************************************************************/
1462 ...         /* Language assignment                                              */
1463 ...         /********************************************************************/
1464 ...         if ( ! is_null( $szLanguage ) )                             /* If language found ... mention it */
1465 ...         {
1466 ...             $szLang = $szLanguage;
1467 ...         }   /* if ( ! is_null( $szLanguage ) ) */
1468 ...         /********************************************************************/
1469 ...         /* End of language detection                                        */
1470 ...         /********************************************************************/
1471 ... 
1472 ...         //echo $szText;
1473 ...         //die('ICI');
1474 ... 
1475 ...         //echo "<p>",__METHOD__,"() at line ",__LINE__,": appel de STR_UnEntities()</p>\n";
1476 ...         $szText         = STR_UnEntities( $szText,$szCharset );     /* Entities turned back to their accented fluctions */
1477 ...         //echo $szText;
1478 ...         //die('ICI');
1479 ... 
1480 ...         $aUniqueWords   = STR_aUniqueWords( $szText );              /* Get an array of unique words */
1481 ...         //var_dump( $aUniqueWords );
1482 ...         $aWords         = array_merge( $aWords,$aUniqueWords );     /* Merge the unique words with the words we already collected */
1483 ...         //die('ICI');
1484 ... 
1485 ... 
1486 ... 
1487 ...         MISC_RemoveUnwantedWords( $aWords,$szLanguage );            /* Remove the unwanted words (ONLY French for the time being) */
1488 ... 
1489 ...         arsort( $aWords,SORT_NUMERIC );                             /* Sort the array */
1490 ...     }   /* if ( preg_match( ... ) || ( $bFile = ( STR_iPos( ... ) != -1 ) ) ) */
1491 ...     elseif ( $szType === 'string' )
1492 ...     {
1493 ... 
1494 ...         die( "Il faut examiner une string" );
1495 ...     }
1496 ... 
1497 ... 
1498 ...     return ( $aWords );                                             /* Return result to caller */
1499 ... }   /* End of function MISC_Taxonomize() ================================ */
1500 ... 
1501 ... function MISC_RemoveUnwantedWords( &$aWords,$szLang = 'fr' )
1502 ... /*--------------------------------------------------------*/
1503 ... {
1504 ...     /* Faudrait que je prenne tous les adverbes de la langue française
1505 ...        car ils ne me servent pas à qualifier les textes :
1506 ...        http://www.linternaute.com/dictionnaire/fr/type/adverbe/1/ */
1507 ...     $aUnwantedWords = array( /* Pronoms personnels */
1508 ...                              'je','me','moi','tu','te','toi','nous','vous','il','elle','ils','elles','se','en'  ,
1509 ...                              'le','la','les','lui','soi','leur','eux','lui',
1510 ... 
1511 ...                              /* Pronoms démonstratifs */
1512 ...                              'celui','celle','ceux','celles','ce','ceci','cela','ça'                                ,
1513 ... 
1514 ...                              /* Pronoms possessifs */
1515 ...                              'mien','tien','sien','mienne','tienne','sienne','miens','tiens','siens'                ,
1516 ...                              'miennes','tiennes','siennes','nôtre','vôtre','leur','nôtres','vôtres','leurs'         ,
1517 ... 
1518 ...                              /* Adjectifs possessifs */
1519 ...                              'mon','ton','son','ma','ta','sa','mes','tes','ses','notre','votre','leur','nos','vos'  ,
1520 ... 
1521 ...                              /* Pronoms relatifs */
1522 ...                              'qui','que','quoi','dont','où','lequel','auquel','duquel','laquelle','lesquels'        ,
1523 ...                              'auxquels','desquels','lesquelles','auxquelles','desquelles'                           ,
1524 ... 
1525 ...                              /* chiffre - nombres */
1526 ...                              'un','deux','trois','quatre','cinq','six','sept','huit','neuf','dix','cent','mille'    ,
1527 ... 
1528 ...                              /* adjectifs démonstratifs */
1529 ...                              'ce','cet','cette','ces',
1530 ... 
1531 ...                              /* adverbes - temps */
1532 ...                              'quelquefois','parfois','autrefois','sitôt','bientôt','aussitôt','tantôt','alors'  ,
1533 ...                              'après','ensuite','enfin','abord','premièrement','soudain','aujourd','demain'      ,
1534 ...                              'hier','auparavant','avant','cependant','déjà','demain','depuis','désormais'       ,
1535 ...                              'enfin','ensuite','jadis','jamais','maintenant','puis','quand','souvent'           ,
1536 ...                              'entrefaites','toujours','tard','tôt'                                              ,
1537 ... 
1538 ...                              /* adverbes - manière */
1539 ...                              'bien','comme','mal','volontiers','aveuglette','nouveau','larigot','admirablement' ,
1540 ...                              'ainsi','aussi','bel','bien','comment','guingois','debout','également','ensemble'  ,
1541 ...                              'exprès','mieux','importe','comment','pire','pis','plutôt','bon','bonne','presque' ,
1542 ...                              'vite',
1543 ... 
1544 ...                              /* adverbes - affirmation */
1545 ...                              'assurément','certainement','certes','oui','précisément','probablement'            ,
1546 ...                              'volontiers','vraiment',
1547 ... 
1548 ...                              /* adverbes - lieu */
1549 ...                              'ici','ailleurs','alentour','arrière','autour','dedans','dehors','derrière'        ,
1550 ...                              'dessous','devant','là','loin','où','partout','près',
1551 ... 
1552 ...                              /* adverbes - laison */
1553 ...                              'ainsi','aussi','pourtant','néanmoins','toutefois','cependant','effet','puis'      ,
1554 ...                              'ensuite','pourquoi','conséquent',
1555 ... 
1556 ...                              /* adverbes - quantité */
1557 ...                              'quasi','davantage','plus','moins','ainsi','assez','aussi','autant','beaucoup'     ,
1558 ...                              'combien','encore','environ','fort','guère','presque','peu','si','tant','tellement',
1559 ...                              'tout','très','trop','peu',
1560 ... 
1561 ...                              /* adverbes - négation */
1562 ...                              'non','vrai','faux',
1563 ... 
1564 ...                              /* articles définis et indéfinis */
1565 ...                              'un','une','des','le','la','les','au','aux','du','de',
1566 ... 
1567 ...                              /* Couleurs */
1568 ...                              'blanc','noir','rouge','vert','bleu','gris','brun',
1569 ... 
1570 ...                              /* Fourre-tout ... à nettoyer */
1571 ...                              'grand','grande','petit','petite','énorme','minuscule',
1572 ...                              'ce','cet','cette','là','ou','et','donc'   ,
1573 ...                              'es','est','sont','vont','comme'           ,
1574 ...                              'ai','as','a','avons','avez','ont','pas','être','comment',
1575 ... 
1576 ...                              'du','de','des'            ,
1577 ...                              'une','ma','ta','sa','mon' ,
1578 ...                              'nos','vos',
1579 ... 
1580 ...                              'qui','que','quoi','quel','quels','quelles','lequel','laquelle','lesquels','lesquelles',
1581 ...                              'dans','dehors','autre','autres'               ,
1582 ...                              'par','avec','aussi','pour','sur','car','peut' ,
1583 ...                              'beaucoup','aucun','aucune','insuffisamment','assez','insuffisamment',
1584 ...                              'tout','toutes','tous',
1585 ...                              'bienvenu','bienvenue',
1586 ...                              'même','ainsi','selon','puisque','sans'                 ,
1587 ...                              'lui','ces','ce','notamment','mal','bien','chez','bon','bonne' ,
1588 ...                              'vers','jusqu','parfois','souvent','pendant','cependant','quoique','celui','seul','seule',
1589 ...                              'fois','à','aux','tel','tels','ici','là'           ,
1590 ...                              'quant','quand','dès','voire','lorsque','plus','moins'     ,
1591 ...                              'afin','étant','mais',
1592 ...                            );
1593 ... 
1594 ...     foreach( $aUnwantedWords as $szWord )
1595 ...     {
1596 ...         if ( isset( $aWords[$szWord] ) )
1597 ...         {
1598 ...             unset( $aWords[$szWord] );
1599 ...         }
1600 ...     }
1601 ... 
1602 ... }
1603 ... 
1604 ... 
1605 ... /* ========================================================================== */
1606 ... /** {{*MISC_TopDomain( $szDomain )=
1607 ... 
1608 ...     Returns the principal name of the domain we're dealing with
1609 ... 
1610 ...     {*params
1611 ...         $szDomain   (string)    Optional domain name. If not passed
1612 ...                                 the [c]$_SERVER['SERVER_NAME'][/c] name is
1613 ...                                 used instead
1614 ...     *}
1615 ... 
1616 ...     {*warning       Only URLs using http or https can safely be processed
1617 ...     *}
1618 ... 
1619 ...     {*return
1620 ...         (string)    The top domain name of $szDomain
1621 ...     *}
1622 ... 
1623 ...     {*assert
1624 ...         MISC_TopDomain( 'http://www.latosensu.be' ) === 'latosensu'
1625 ...     *}
1626 ... 
1627 ...     {*assert
1628 ...         MISC_TopDomain( 'www.latosensu.be' ) === 'latosensu'
1629 ...     *}
1630 ... 
1631 ...     {*assert
1632 ...         MISC_TopDomain( 'latosensu.be' ) === 'latosensu'
1633 ...     *}
1634 ... 
1635 ...     {*exec
1636 ...         echo MISC_TopDomain( 'http://www.latosensu.be' );
1637 ...     *}
1638 ... 
1639 ...     *}}
1640 ...  */
1641 ... /* ========================================================================== */
1642 ... function MISC_TopDomain( $szDomain = null )
1643 ... /*---------------------------------------*/
1644 ... {
1645 ...     if ( STR_Empty( $szDomain ) )                                   /* If no domain mentioned */
1646 ...     {
1647 ...         $szDomain = $_SERVER['SERVER_NAME'];                        /* Server name will be our basis */
1648 ...     }   /* if ( STR_Empty( $szDomain ) ) */
1649 ... 
1650 ...     //echo strtolower( preg_replace( '/\.(.*)/si' ,
1651 ...     //                                   ''           ,
1652 ...     //                                   str_ireplace( array( 'www.','http://','https://' ),'',$szDomain )
1653 ...     //                                 ) );
1654 ...     /* Top domain we're on (e.g. 'www.latosensu.be' returns 'latosensu') */
1655 ...     return ( strtolower( preg_replace( '/\.(.*)/si' ,
1656 ...                                        ''           ,
1657 ...                                        str_ireplace( array( 'www.','http://','https://' ),'',$szDomain )
1658 ...                                      ) ) );
1659 ... }   /* End of function MISC_TopDomain() ===================================== */
1660 ... 
1661 ... /* ========================================================================== */
1662 ... /** {{*MISC_CastString( $x,$iLength )=
1663 ... 
1664 ...     Casts a value to a string
1665 ... 
1666 ...     {*params
1667 ...         $x          (mixed)     The value to cast to a string
1668 ...         $iLength    (int)       Optional return length. Full string
1669 ...                                 is returned if $iLength < [c]0[/c]. [c]-1[/c] by default
1670 ...     *}
1671 ... 
1672 ...     {*alias
1673 ...         MISC_MakeString()
1674 ...     *}
1675 ... 
1676 ...     {*return
1677 ...         (string)    $x turned to a string
1678 ...     *}
1679 ... 
1680 ...     {*assert
1681 ...         MISC_CastString( true ) === 'true'
1682 ...     *}
1683 ... 
1684 ...     {*assert
1685 ...         MISC_CastString( false ) === 'false'
1686 ...     *}
1687 ... 
1688 ...     {*assert
1689 ...         MISC_CastString( 18 ) === '18'
1690 ...     *}
1691 ... 
1692 ...     {*assert
1693 ...         MISC_CastString( array(),3 ) === 'arr'
1694 ...     *}
1695 ... 
1696 ...     {*example
1697 ...         Example #1
1698 ...         echo MISC_CastString( 'hello',4 ); Prints 'hell'
1699 ... 
1700 ...         Example #2
1701 ...         echo MISC_CastString( true ); Prints 'true'
1702 ...     *}
1703 ... 
1704 ...     *}}
1705 ...  */
1706 ... /* ========================================================================== */
1707 ... function MISC_CastString( $x,$iLength = -1 )
1708 ... /*----------------------------------------*/
1709 ... {
1710 ...     $szRetVal = null;                                               /* Return value of the function */
1711 ... 
1712 ...     if ( is_string( $x ) )                                          /* If already string */
1713 ...     {
1714 ...         $szRetVal = $x;
1715 ...     }
1716 ...     elseif ( is_bool( $x ) )                                        /* If boolean/logical value */
1717 ...     {
1718 ...         $szRetVal = $x ? 'true' : 'false';
1719 ...     }
1720 ...     elseif ( is_object( $x ) )                                      /* If object */
1721 ...     {
1722 ...         $szRetVal = 'object';
1723 ...     }
1724 ...     elseif ( is_array( $x ) )                                       /* If array */
1725 ...     {
1726 ...         $szRetVal = 'array';
1727 ...     }
1728 ...     else                                                            /* In any other case */
1729 ...     {
1730 ...         $szRetVal = (string) $x;
1731 ...     }
1732 ... 
1733 ...     if ( $iLength > 0 )                                             /* If result should be limited */
1734 ...     {
1735 ...         $szRetVal = substr( $szRetVal,0,$iLength );                  /* Get only a part of the return value */
1736 ...     }   /* if ( $iLength > 0 ) */
1737 ... 
1738 ...     return ( $szRetVal );                                           /* Return result to caller */
1739 ... }   /* End of function MISC_CastString() ==================================== */
1740 ... function MISC_MakeString( $x,$iLength = -1 ) { return ( MISC_CastString( $x,$iLength ) ); }
1741 ... function STR_Make( $x                      ) { return ( MISC_CastString( $x          ) ); }
1742 ... 
1743 ... /* ========================================================================== */
1744 ... /** {{*MISC_CastBool( $x,$bDefault )=
1745 ... 
1746 ...     Casts a value to a boolean
1747 ... 
1748 ...     {*params
1749 ...         $x          (mixed)     The value to cast to a boolean
1750 ...         $bDefault   (bool)      Optional default return value
1751 ...     *}
1752 ... 
1753 ...     {*return
1754 ...         (bool)  $x turned to a boolean
1755 ...     *}
1756 ... 
1757 ...     {*assert
1758 ...         MISC_CastBool( true ) === true
1759 ...     *}
1760 ... 
1761 ...     {*assert
1762 ...         MISC_CastBool( 'yes' ) === true
1763 ...     *}
1764 ... 
1765 ...     {*assert
1766 ...         MISC_CastBool( 0 ) === false
1767 ...     *}
1768 ... 
1769 ...     {*assert
1770 ...         MISC_CastBool( 18 ) === true
1771 ...     *}
1772 ... 
1773 ...     {*assert
1774 ...         MISC_CastBool( 'hello' ) === false
1775 ...     *}
1776 ... 
1777 ...     {*assert
1778 ...         MISC_CastBool( 'ja' ) === true
1779 ...     *}
1780 ... 
1781 ...     {*assert
1782 ...         MISC_CastBool( 'on' ) === true
1783 ...     *}
1784 ... 
1785 ...     {*assert
1786 ...         MISC_CastBool( 'vrai' ) === true
1787 ...     *}
1788 ... 
1789 ...     {*assert
1790 ...         MISC_CastBool( 'true' ) === true
1791 ...     *}
1792 ... 
1793 ...     {*assert
1794 ...         MISC_CastBool( array() ) === true
1795 ...     *}
1796 ... 
1797 ...     {*example
1798 ...         if ( MISC_CastBool( $_GET['xml'] ) )
1799 ...         {
1800 ...             echo "XML required";
1801 ...         }
1802 ...     *}
1803 ... 
1804 ...     *}}
1805 ...  */
1806 ... /* ========================================================================== */
1807 ... function MISC_CastBool( $x = null,$bDefault = false )
1808 ... /*-------------------------------------------------*/
1809 ... {
1810 ...     $x2 = $bDefault;                                                /* Ready to return a logical false */
1811 ... 
1812 ...     if ( ! is_null( $x ) )                                          /* If $x is NOT null */
1813 ...     {
1814 ...         $szType = gettype( $x );                                    /* Get variable type */
1815 ... 
1816 ...         switch ( $szType )                                          /* In function of the type of the parameter */
1817 ...         {
1818 ...             case 'boolean'  :   $x2 = $x;                           /* Return what was passed to us */
1819 ...                                 break;
1820 ...             case 'float'    :
1821 ...             case 'integer'  :
1822 ...             case 'double'   :   $x2 = ( $x != 0 );                  /* 0 => false */
1823 ...                                 break;
1824 ...             case 'string'   :   $x  = strtolower( $x );             /* Make lowercase */
1825 ...                                 $x2 = false;
1826 ...                                 if ( ( $x === 'true' ) ||
1827 ...                                      ( $x === 'vrai' ) ||
1828 ...                                      ( $x === 'waar' ) ||
1829 ...                                      ( $x === 'ja'   ) ||
1830 ...                                      ( $x === 'yes'  ) ||
1831 ...                                      ( $x === 'oui'  ) ||
1832 ...                                      ( $x === 'on'   ) ||
1833 ...                                      ( $x === '1'    )
1834 ...                                    )
1835 ...                                 {
1836 ...                                     $x2 = true;
1837 ...                                 }
1838 ...                                 break;
1839 ...             case 'array'    :
1840 ...             case 'object'   :   $x2 = true;                         /* An object is true; so is an array (convention) */
1841 ...                                 break;
1842 ...         }   /* switch ( $szType ) */
1843 ...     }   /* if ( ! is_null( $x ) ) */
1844 ... 
1845 ...     return ( $x2 );                                                 /* Return result to caller */
1846 ... }   /* End of function MISC_CastBool() ====================================== */
1847 ... 
1848 ... /* ========================================================================== */
1849 ... /** {{*MISC_True( $x,$y,$z )
1850 ... 
1851 ...     Returns a true (ALWAYS) whatever $x,$y,$z were sent
1852 ... 
1853 ...     {*params
1854 ...         $x          (mixed)     Optional. Not used by the function.
1855 ...         $y          (mixed)     Optional. Not used by the function.
1856 ...         $z          (mixed)     Optional. Not used by the function.
1857 ...     *}
1858 ... 
1859 ...     {*return
1860 ...         (bool)  true (ALWAYS)
1861 ...     *}
1862 ... 
1863 ...     {*assert
1864 ...         MISC_True( false ) === true
1865 ...     *}
1866 ...     *}}
1867 ...  */
1868 ... /* ========================================================================== */
1869 ... function MISC_True( $x = null,$y = null, $z = null )
1870 ... /*------------------------------------------------*/
1871 ... {
1872 ...     return ( true );                                                /* Return a true (ALWAYS) */
1873 ... }   /* End of function MISC_True() ========================================== */
1874 ... 
1875 ... /* ========================================================================== */
1876 ... /** {{*MISC_False( $x,$y,$z )
1877 ... 
1878 ...     Returns a false (ALWAYS) whatever $x,$y,$z were sent
1879 ... 
1880 ...     {*params
1881 ...         $x          (mixed)     Optional. Not used by the function.
1882 ...         $y          (mixed)     Optional. Not used by the function.
1883 ...         $z          (mixed)     Optional. Not used by the function.
1884 ...     *}
1885 ... 
1886 ...     {*return
1887 ...         (bool)  false (ALWAYS)
1888 ...     *}
1889 ... 
1890 ...     {*assert
1891 ...         MISC_False( true ) === false
1892 ...     *}
1893 ...     *}}
1894 ...  */
1895 ... /* ========================================================================== */
1896 ... function MISC_False( $x = null,$y = null, $z = null )
1897 ... /*------------------------------------------------*/
1898 ... {
1899 ...     return ( false );                                               /* Return a false (ALWAYS) */
1900 ... }   /* End of function MISC_False() ========================================= */
1901 ... 
1902 ... /* ========================================================================== */
1903 ... /** {{*MISC_Null( $x,$y,$z )
1904 ... 
1905 ...     Returns a null (ALWAYS) whatever $x,$y,$z were sent
1906 ... 
1907 ...     {*params
1908 ...         $x          (mixed)     Optional. Not used by the function.
1909 ...         $y          (mixed)     Optional. Not used by the function.
1910 ...         $z          (mixed)     Optional. Not used by the function.
1911 ...     *}
1912 ... 
1913 ...     {*return
1914 ...         (null)  null (ALWAYS)
1915 ...     *}
1916 ... 
1917 ...     {*assert
1918 ...         MISC_Null( true ) === null
1919 ...     *}
1920 ... 
1921 ...     {*assert
1922 ...         MISC_Null( false ) === null
1923 ...     *}
1924 ... 
1925 ...     {*assert
1926 ...         MISC_Null( 'Hello' ) === null
1927 ...     *}
1928 ... 
1929 ...     {*assert
1930 ...         MISC_Null( 18 ) === null
1931 ...     *}
1932 ... 
1933 ...     *}}
1934 ...  */
1935 ... /* ========================================================================== */
1936 ... function MISC_Null( $x = null,$y = null, $z = null )
1937 ... /*------------------------------------------------*/
1938 ... {
1939 ...     return ( null );                                                /* Return a null (ALWAYS) */
1940 ... }   /* End of function MISC_Null() ========================================== */
1941 ... 
1942 ... /* ========================================================================== */
1943 ... /** {{*MISC_Tao( $x = null )
1944 ... 
1945 ...     Simply returns what was given as input
1946 ... 
1947 ...     {*params
1948 ...         $x          (mixed)     Optional. Not used by the function.
1949 ...     *}
1950 ... 
1951 ...     {*remark
1952 ...         TAO functions do return what they were given
1953 ...     *}
1954 ... 
1955 ...     {*return
1956 ...         (mixed)     strictly equal to $x
1957 ...     *}
1958 ... 
1959 ...     {*example
1960 ...         echo MISC_Tao( 'Hello World' );     // Prints 'Hello World'
1961 ...         echo MISC_Tao( 18 );                // Prints 18
1962 ...     *}
1963 ...     *}}
1964 ...  */
1965 ... /* ========================================================================== */
1966 ... function MISC_Tao( $x = null )
1967 ... /*--------------------------*/
1968 ... {
1969 ...     return ( $x );
1970 ... }   /* == End of function MISC_Tao() =======================================  */
1971 ... 
1972 ... /* ========================================================================== */
1973 ... /** {{*MISC_Ticket()=
1974 ... 
1975 ...     Creates a string value that can be used as a ticket number.
1976 ... 
1977 ...     {*params
1978 ...     *}
1979 ... 
1980 ...     {*abstract 
1981 ...         Handy to create ticket numbers for Tech Support for example.
1982 ...     *}
1983 ... 
1984 ...     {*return
1985 ...         (string)    A ticket number (e.g. 127001-1906-98)
1986 ...     *}
1987 ... 
1988 ...     {*exec
1989 ...         echo $szTicket = MISC_Ticket();
1990 ...         echo LSUnitTesting::assert( preg_match( "/\d{6}-\d{4}-\d{2}/s",$szTicket )              ,
1991 ...                                     'ASSERTION SUCCESSFUL: ticket number seems to be correct'   ,
1992 ...                                     'ASSERTION FAILURE: incorrect ticket number'                ,
1993 ...                                     'GuideAssert' );
1994 ...     *}
1995 ... 
1996 ...     *}}
1997 ...  */
1998 ... /* ========================================================================== */
1999 ... function MISC_Ticket()
2000 ... /*------------------*/
2001 ... {
2002 ...     $szIP = isset( $_SERVER['REMOTE_ADDR'] ) ?
2003 ...             $_SERVER['REMOTE_ADDR']          :
2004 ...             STR_GeneratePassword( 10 );
2005 ...     return ( substr( str_replace( '.','',$szIP ),-6 ) . '-' .
2006 ...              date( 'is' )                             . '-' .
2007 ...              sprintf( '%02d',rand( 1,99 ) )
2008 ...            );
2009 ... }   /* End of function MISC_Ticket() ======================================== */
2010 ... 
2011 ... /* ========================================================================== */
2012 ... /** {{*MISC_Include( $szStr )=
2013 ... 
2014 ...     Includes a string as if it were a file
2015 ... 
2016 ...     {*params
2017 ...         $szStr  (string)    String to include (call to <code>include()</code>).
2018 ...                             &lt;?php ... ?&gt; fragments can be interpreted.
2019 ...     *}
2020 ... 
2021 ...     {*return
2022 ...         (void)
2023 ...     *}
2024 ... 
2025 ...     {*noassert *}
2026 ... 
2027 ...     {*example
2028 ...         echo MISC_Include( 'A whole string (can be very long)');
2029 ...     *}
2030 ... 
2031 ...     *}}
2032 ...  */
2033 ... /* ========================================================================== */
2034 ... function MISC_include( $szStr )
2035 ... /*---------------------------*/
2036 ... {
2037 ...     $szTmpFileName = tempnam( VAESOLI_PATH . '/../tmp/','FOO' );    /* Create a temporary file */
2038 ... 
2039 ...     if ( $szTmpFileName )                                           /* If we got something worth it */
2040 ...     {
2041 ...         if ( ( $handle = @fopen( $szTmpFileName,'w+' ) ) == true )
2042 ...         {
2043 ...             @fwrite( $handle,$szStr );                              /* Put the whole contents in the temporary file */
2044 ...             @fclose( $handle );                                     /* Close the temporary file */
2045 ...             include( $szTmpFileName );                              /* Include the file now (PHP commands got executed) */
2046 ...             @unlink( $szTmpFileName );                              /* Delete temporary file now that we don't longer need it */
2047 ...         }   /* if ( ( $handle = @fopen( $szTmpFileName,'w+' ) ) == true ) */
2048 ...     }   /* if ( $szTmpFileName ) */
2049 ... }   /* End of function MISC_include() ======================================= */
2050 ... ?>
2051 ... 

Manifest Constants

LS_MISC_FUNCTIONS: Define the miscellaneous functions)

VAESOLI_PATH: Define the path where Vae Soli! is installed

VAESOLI_PLUGINS: Define the path where plugins are located

Sources required

LSStrings.functions.php: String functions

LSFiles.functions.php: File functions

LSUnitTesting.class.php: Vae Soli! Unit Testing

UltraEdit Syntax files

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

Function List (TOC)

  1. MISC_AddJS(): Add a list of .js to the current markup
  2. MISC_AddJSEx(): Add a list of .js to the current markup No assertion found for MISC_AddJSEx() (0 - 0)
  3. MISC_BackLink(): Creates a back link to a URL that handles year, month, day No assertion found for MISC_BackLink() (0 - 0)
  4. MISC_BuildCSRFToken(): Generates a token to defeat Cross-Site Request Forgeries No assertion found for MISC_BuildCSRFToken() (0 - 0)
  5. MISC_Cast(): Cast a variable value
  6. MISC_CastBool(): Casts a value to a boolean
  7. MISC_CastString(): Casts a value to a string
  8. MISC_Empty(): Determines if $x is empty or not
  9. MISC_Giro(): Calculates the check digit of a giro (VCS)
  10. MISC_iif(): Immediate if
  11. MISC_Include(): Includes a string as if it were a file
  12. MISC_IsLocalPC(): Determines if application runs on local PC
  13. MISC_MakeGiro(): Creates a giro (VCS)
  14. MISC_MessageBox(): Displays a Javascript alert box
  15. MISC_OnLoad(): Adds JavaScript code to the load event of the page (window)
  16. MISC_RequireCSS(): Adds non-blocking CSS No assertion found for MISC_RequireCSS() (0 - 0)
  17. MISC_RequireJS(): Adds non-blocking JavaScript script
  18. MISC_Script(): Generates the proper code to include a JavaScript No assertion found for MISC_Script() (0 - 0)
  19. MISC_Self(): Returns the name of the running script (Self)
  20. MISC_SetError(): Set error reporting No assertion found for MISC_SetError() (0 - 0)
  21. MISC_Sleep(): Delay execution in microseconds No assertion found for MISC_Sleep() (0 - 0)
  22. MISC_Swap(): Swaps $x and $y
  23. MISC_Taxonomize(): Taxonomize a resource No assertion found for MISC_Taxonomize() (0 - 0)
  24. MISC_Ticket(): Creates a string value that can be used as a ticket number.
  25. MISC_TopDomain(): Returns the principal name of the domain we're dealing with
  26. MISC_WaitJSFnc(): Waits until a specific JavaScript function gets defined

Functions of LSMisc.functions.php

MISC_AddJS(): Add a list of .js to the current markup

[ back to function list ]

Created: 12/05/2013 11:11

Since version 5.3.0002

Modified: 04/06/2013 06:13

Syntax

MISC_AddJS( $szScripts,$bScoped,$bDefer,$bCDATA )

Parameters
NameTypeDescription
$szScripts string A tokenized list (;) of JavaScript sources to be added
$bScoped bool Include a "scoped" attribute if set. Optional: false by default.
$bDefer bool Indicates whether the script is to be deferred or not. Optional: false by default.
$bCDATA bool Indicates whether the script must be included in a CDATA section. Optional: true by default.
Parameters Warning

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

Return

(string) The HTML code that must be echoed.

Example Executed
echo wordwrap( htmlentities( $szHTML = MISC_AddJS( 'LSVAjax.js' ) ) );

echo LSUnitTesting::assert( preg_match( '%var script *?= *document.+?LSVAjax.js%si',$szHTML )   ,
                            'ASSERTION SUCCESSFUL: ECMA seems to be correct'                    ,
                            'ASSERTION FAILURE: incorrect ECMA'                                 ,
                            'GuideAssert' );

<script type="text/javascript">
// <![CDATA[
/* Generated 20150401161954 */
if ( typeof DEFINE_LSVAjax_js === 'undefined' )
{
/* /vaesoli/include */
    var script = document.createElement("script");
    var head   = document.getElementsByTagName("head")[0];
    script.src = "/vaesoli/include/../scripts/LSVAjax.js";
    (head || document.body).appendChild( script );
}

//]]>
</script>

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

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

MISC_AddJSEx(), MISC_Script(), MISC_RequireJS()

MISC_AddJSEx(): Add a list of .js to the current markup

[ back to function list ]

Created: 09/06/2013 09:58

Since version 5.3.0002

Modified: 09/06/2013 11:38

Syntax

MISC_AddJSEx( $aScripts,$aOnloads,$aScoped,$aDefer,$aCDATA )

Parameters
NameTypeDescription
$aScripts array An array of JavaScript sources to be added.
$aOnloads array An array of JavaScript code; each slot of the array is the code that will be triggered when the onload event of the JavaScript source is fired.
$aScoped bool An array of "scoped" attributes. Optional: null by default ... which maps to ALL sources having NO scoped attribute
$aDefer bool An array of "defer" attributes. Optional: null by default ... which maps to ALL sources NOT being deferred.
$aCDATA bool An array of boolean attributes that indicate whether the JavaScript code should be included in a CDATA section.
Parameters Warning

MISC_AddJSEx() uses 5 parameters whereas the suggested limit is 3.

Return

(string) The HTML code that must be echoed.

Example Executed
echo MISC_AddJSEx( array( 'LSVAjax.js' ),
                   array( 'console.log("LSVAjax.js loaded!")' ) );


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

MISC_AddJS(), MISC_Script(), MISC_RequireJS()

MISC_BackLink(): Creates a back link to a URL that handles year, month, day

[ back to function list ]

Syntax

MISC_BackLink( $iYear,$iMonth,$iDay,$szURL,$szAnchor,$szTooltip,$szCSSClass )

Parameters
NameTypeDescription
$iYear int Year of the back link
$iMonth int Month of the back link
$iDay int Day of the back link
$szURL string URL of back link. Optional. null by default
$szAnchor string Text of the anchor. Optional. null by default
$szTooltip string Tooltip of the anchor. Optional. null by default
$szCSSClass string CSS class of the anchor. Optional. null by default
Parameters Warning

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

Return

(string) The HTML code of a ... back link

Example Executed
echo '<p>',MISC_BackLink( 2008,2,7 ),'</p>';
echo '<p>',MISC_BackLink( 2008,2,7,'/news.php' ),'</p>';
echo '<p>',MISC_BackLink( 2008,2,7,'/news.php','Great news!' ),'</p>';
echo '<p>',MISC_BackLink( 2008,2,7,'/news.php','Great news!','Announcement of a new version' ),'</p>';
echo '<p>',MISC_BackLink( 2008,2,7,'/news.php','Great news!','Announcement of a new version','headline' ),'</p>';
echo '<p>',
           wordwrap(
               htmlentities(
                   MISC_BackLink( 2008,2,7                          ,
                                  '/news.php'                       ,
                                  'Great news!'                     ,
                                  'Announcement of a new version'   ,
                                  'headline' ) ) ),
     '</p>';

07-02-2008

07-02-2008

Great news!

Great news!

Great news!

<a href="/news.php?year=2008&amp;month=2&amp;day=7" title="Announcement of a new version" class="headline LS_VAESOLI_BackLink">Great news!</a>

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

MISC_BuildCSRFToken(): Generates a token to defeat Cross-Site Request Forgeries

[ back to function list ]

Syntax

MISC_BuildCSRFToken( $szToken )

Parameters
NameTypeDescription
$szToken string Not used! (reserved for later). Optional.
Return

(string) Returns the value of the anti Cross-Site Request Forgery token

Example(s)
$txtFToken = new LSInput( 'hidden','token','token',MISC_BuildCSRFToken() );
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(...); *}).

MISC_Cast(): Cast a variable value

[ back to function list ]

Syntax

MISC_Cast( $szType,$x )

Parameters
NameTypeDescription
$szType string The type to cast the variable to. Same type set as for settype.
"boolean" or "bool"
"integer" or "int"
"float"
"string"
"array"
"object"
"null"
$x mixed Variable whose value must be cast
Return

(mixed) $x value turned to $szType

Example(s)
$xPropValue = $oPropertyNode->nodeValue;
$szPropType = $oPropertyNode->getAttribute( 'vartype' );

if ( ! STR_Empty( $szPropType ) )
{
    $xPropValue = MISC_Cast( $szPropType,$xPropValue );
}
Assertions

MISC_Cast( 'string',18 ) === '18' successful

MISC_Cast( 'int',18 ) === 18 successful

MISC_Cast( 'bool','hello' ) === true successful

MISC_Cast( 'bool',null ) === false successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

MISC_CastBool(), MISC_CastString()

MISC_CastBool(): Casts a value to a boolean

[ back to function list ]

Syntax

MISC_CastBool( $x,$bDefault )

Parameters
NameTypeDescription
$x mixed The value to cast to a boolean
$bDefault bool Optional default return value
Return

(bool) $x turned to a boolean

Example(s)
if ( MISC_CastBool( $_GET['xml'] ) )
{
    echo "XML required";
}
Assertions

MISC_CastBool( true ) === true successful

MISC_CastBool( 'yes' ) === true successful

MISC_CastBool( 0 ) === false successful

MISC_CastBool( 18 ) === true successful

MISC_CastBool( 'hello' ) === false successful

MISC_CastBool( 'ja' ) === true successful

MISC_CastBool( 'on' ) === true successful

MISC_CastBool( 'vrai' ) === true successful

MISC_CastBool( 'true' ) === true successful

MISC_CastBool( array() ) === true successful

Unit Testing

10 assertions: 10 successful; 0 failed

MISC_CastString(): Casts a value to a string

[ back to function list ]

Syntax

MISC_CastString( $x,$iLength )

Alias

MISC_MakeString()

Parameters
NameTypeDescription
$x mixed The value to cast to a string
$iLength int Optional return length. Full string is returned if $iLength < 0. -1 by default
Return

(string) $x turned to a string

Example(s)
Example #1
echo MISC_CastString( 'hello',4 ); Prints 'hell'

Example #2
echo MISC_CastString( true ); Prints 'true'
Assertions

MISC_CastString( true ) === 'true' successful

MISC_CastString( false ) === 'false' successful

MISC_CastString( 18 ) === '18' successful

MISC_CastString( array(),3 ) === 'arr' successful

Unit Testing

4 assertions: 4 successful; 0 failed

MISC_Empty(): Determines if $x is empty or not

[ back to function list ]

Syntax

MISC_Empty( $x )

Alias

MIS_Empty()

Parameters
NameTypeDescription
$x mixed element to test
Return

(bool) true if $x is empty; false otherwise

Example(s)
echo MISC_CastString( MISC_Empty( 'My god' ) );    // Prints 'false'
Assertions

MISC_CastString( MISC_Empty( 'My god' ) ) === 'false' successful

MISC_CastString( MISC_Empty( ' ' ) ) === 'false' successful

MISC_CastString( MISC_Empty( '' ) ) === 'true' successful

MISC_CastString( MISC_Empty( null ) ) === 'true' successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

STR_Empty()

MISC_Giro(): Calculates the check digit of a giro (VCS)

[ back to function list ]

Created: 03/04/2014 19:13

Since version 6.0.0005

Author

Syntax

MISC_Giro( $xNumber )

Parameters
NameTypeDescription
$xNumber mixed Ideally an integer of no more than 10 digits
Return

(int) The check digit corresponding to $xNumber

Example Executed
echo LSUnitTesting::assert( MISC_Giro( 2014000001 ) === 59              ,
                            'ASSERTION SUCCESSFUL: giro (VCS) correct'  ,
                            'ASSERTION FAILURE: giro (VCS) incorrect'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( MISC_Giro( '2014/000001' ) === 59           ,
                            'ASSERTION SUCCESSFUL: giro (VCS) correct'  ,
                            'ASSERTION FAILURE: giro (VCS) incorrect'   ,
                            'GuideAssert' );
echo LSUnitTesting::assert( MISC_Giro( '14/444/215' ) === 29            ,
                            'ASSERTION SUCCESSFUL: giro (VCS) correct'  ,
                            'ASSERTION FAILURE: giro (VCS) incorrect'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: giro (VCS) correct

GuideAssert() ... ASSERTION SUCCESSFUL: giro (VCS) correct

GuideAssert() ... ASSERTION SUCCESSFUL: giro (VCS) correct

Assertions

MISC_Giro( 2014000001 ) === 59 successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

MISC_MakeGiro()

MISC_iif(): Immediate if

[ back to function list ]

Syntax

MISC_iif( $bExpr,$xTrue,$xFalse )

Alias

iif()

Parameters
NameTypeDescription
$bExpr boolean An expression that yields a boolean result
$xTrue mixed What is to be returned if $xExpr is true
$xFalse mixed What is to be returned if $xExpr is false
Return

(mixed) $xTrue or $xFalse

Example Executed
echo iif( isset( $NotExist ),'Exist','Does not exist' );

Does not exist
Assertions

MISC_iif( true,'hello','goodbye' ) === 'hello' successful

MISC_iif( false,'hello','goodbye' ) === 'goodbye' successful

Unit Testing

2 assertions: 2 successful; 0 failed

MISC_Include(): Includes a string as if it were a file

[ back to function list ]

Syntax

MISC_Include( $szStr )

Parameters
NameTypeDescription
$szStr string String to include (call to include()). <?php ... ?> fragments can be interpreted.
Return

(void)

Example(s)
echo MISC_Include( 'A whole string (can be very long)');
Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

MISC_IsLocalPC(): Determines if application runs on local PC

[ back to function list ]

Syntax

MISC_IsLocalPC()

Parameters

None

Return

(bool) true if IP address == 127.0.0.1; false otherwise

Example(s)
if ( MISC_IsLocalPC() )
{
    phpinfo();
}
Assertions

true === true successful

Unit Testing

1 assertions: 1 successful; 0 failed

MISC_MakeGiro(): Creates a giro (VCS)

[ back to function list ]

Syntax

MISC_MakeGiro( $xNumber,$iLength )

Parameters
NameTypeDescription
$xNumber mixed Ideally an integer of no more than 10 digits
$iLength int The length of the giro
Return

(int) The check digit corresponding to $xNumber

Example Executed
echo LSUnitTesting::assert( MISC_MakeGiro( 2014000001 ) === '201/4000/00159'    ,
                            'ASSERTION SUCCESSFUL: giro (VCS) correct'          ,
                            'ASSERTION FAILURE: giro (VCS) incorrect'           ,
                            'GuideAssert' );
echo LSUnitTesting::assert( MISC_MakeGiro( '2014/000001' ) === '201/4000/00159' ,
                            'ASSERTION SUCCESSFUL: giro (VCS) correct'          ,
                            'ASSERTION FAILURE: giro (VCS) incorrect'           ,
                            'GuideAssert' );
echo LSUnitTesting::assert( MISC_MakeGiro( '14/444/215' ) === '144/4421/50029'  ,
                            'ASSERTION SUCCESSFUL: giro (VCS) correct'          ,
                            'ASSERTION FAILURE: giro (VCS) incorrect'           ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: giro (VCS) correct

GuideAssert() ... ASSERTION SUCCESSFUL: giro (VCS) correct

GuideAssert() ... ASSERTION SUCCESSFUL: giro (VCS) correct

Assertions

MISC_MakeGiro( 2100830270 ) === '210/0830/27002' successful

Unit Testing

4 assertions: 4 successful; 0 failed

See Also

MISC_Giro()

MISC_MessageBox(): Displays a Javascript alert box

[ back to function list ]

Warning

The $iFlags parameter is NOT used yet

Syntax

MISC_MessageBox( $szMsg,$iFlags )

Alias

MISC_MsgBox()

Parameters
NameTypeDescription
$szMsg string Message to display
$iFlags integer Optional flags. 64 by default. NOT USED AT THE MOMENT
Return

(string) The HTML code that must be echoed

Example Executed
$szHTML = MISC_MessageBox( 'Click the OK button' );
echo htmlentities( $szHTML );

echo LSUnitTesting::assert( preg_match( '/alert(.*OK BUTTON.*)/si',$szHTML ),
                            'ASSERTION SUCCESSFUL: message box OK'          ,
                            'ASSERTION FAILURE: message box NOT OK'         ,
                            'GuideAssert' );

<script type="text/javascript">
// <![CDATA[
alert( 'Click the OK button' );
//]]>
</script>

GuideAssert() ... ASSERTION SUCCESSFUL: message box OK

Assertions

preg_match( '/alert(.*OK BUTTON.*)/si',MISC_MessageBox( 'Click the OK button' ) ) successful

Unit Testing

2 assertions: 2 successful; 0 failed

MISC_OnLoad(): Adds JavaScript code to the load event of the page (window)

[ back to function list ]

Syntax

MISC_OnLoad( $szScript,$WithScript )

Parameters
NameTypeDescription
$szScript string The Javascript code to be inserted
$WithScript bool true to embrace the result with MISC_Script(); false if not. true by default.
Return

(string) The HTML code that must be echoed (<script>window.addEventlistener( "load",function() { ... } )</script>)

Example Executed
$szRetVal   = '';
$szRetVal  .= MISC_AddJSEx( array( 'LSVExplorer.js' ) );
$szObject   = 'oCacheExplorer';
$szRetVal  .= MISC_OnLoad( "{$szObject} =
                                new LSVExplorer(  'oCacheExplorer',"                    .
                                                 "'LS_CACHE',\n"                        .
                                                 "'C:/mazuis.org/www/httpdocs/',"       .
                                                 "'C:/mazuis.org/www/httpdocs/css/',\n" .
                                                 "'/ajax/ajax.php?',"                   .
                                                 "'fr',"                                .
                                                 "2048000,"                             .
                                                 "'image/gif;image/png;image/jpeg',"    .
                                                 "true );\n" );
echo htmlentities( $szRetVal );

echo LSUnitTesting::assert( preg_match( "/window.addEventListener.*\"load\","   .
                            "function.*{$szObject}.*LS_CACHE/s",$szRetVal )     ,
                            'ASSERTION SUCCESSFUL: JavaScript has a good face'  ,
                            'ASSERTION FAILURE: incorrect JavaScript'           ,
                            'GuideAssert' );

<script type="text/javascript">
// <![CDATA[
/* Generated 20150401161954 */
if ( typeof DEFINE_LSVExplorer_js === 'undefined' )
{
/* /vaesoli/include */
    var script = document.createElement("script");
    var head   = document.getElementsByTagName("head")[0];
    script.src = "/vaesoli/include/../scripts/LSVExplorer.js";
    (head || document.body).appendChild( script );
}

//]]>
</script>
<script>
window.addEventListener( "load",function () { oCacheExplorer =
                                new LSVExplorer(  'oCacheExplorer','LS_CACHE',
'C:/mazuis.org/www/httpdocs/','C:/mazuis.org/www/httpdocs/css/',
'/ajax/ajax.php?','fr',2048000,'image/gif;image/png;image/jpeg',true );
 } );
</script>

GuideAssert() ... ASSERTION SUCCESSFUL: JavaScript has a good face

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

MISC_RequireJS(), MISC_WaitJSFnc()

MISC_RequireCSS(): Adds non-blocking CSS

[ back to function list ]

Syntax

MISC_RequireCSS( $szCSS,$szMedia,$szID,$szTitle,$szBefore,$szAfter,$WithScript )

Parameters
NameTypeDescription
$szCSS string The stylesheet (.css) to load
$szMedia string The targeted media (screen, projection, print, ...)
$szID string ID of script element. If script#id does exist the JavaScript returns immediately. Optional (but NOT recommended). null by default.
$szTitle string Title set to stylesheet. Optional. null by default.
$szBefore string CSS that must be precede by the one that must now be inserted. Optional. null by default.
$szAfter string CSS that must precede the one that must now be inserted. Optional. null by default.
$WithScript bool true to embrace the result with MISC_Script(); false if not. true by default.
Parameters Warning

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

Return

(string) The HTML code that must be echoed

Example Executed
echo wordwrap( htmlentities( MISC_RequireCSS( '/css/base.css','MY-CSS' ) ) );

<script type="text/javascript">
(function(d,t,id) {if (d.getElementById(id)) return;var lnk,vlnk =
d.getElementsByTagName(t)[0];lnk = d.createElement(t); lnk.id = id;lnk.rel
= "stylesheet";lnk.href = "/css/base.css";lnk.type =
"text/css";lnk.media =
"MY-CSS";vlnk.parentNode.insertBefore(lnk,vlnk);}(document,'link','VAE-D8D2B6F7E4CC499B92E2BE3B0BF85981'));
</script>
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(...); *}).

MISC_RequireJS(): Adds non-blocking JavaScript script

[ back to function list ]

Syntax

MISC_RequireJS( $szJS,$szID,$szScript,$WithScript )

Parameters
NameTypeDescription
$szJS string The JavaScript source (.js) to load
$szID string ID of script element. If script#id does exist the JavaScript returns immediately. Optional (but NOT recommended). null by default.
$szScript string The JavaScript code to be inserted
$WithScript bool Optional. true to embrace the result with MISC_Script(); false if not. true by default.
Parameters Warning

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

Return

(string) The HTML code that must be echoed

Example Executed
echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js','MY-SCRIPT' ) ) );
echo LSUnitTesting::assert( preg_match( "/<script type=['\"]text\/javascript['\"]>.*?"      .
                                        "\/js\/myscript\.js.*?\(document,['\"]script['\"]," .
                                        "['\"]MY-SCRIPT['\"]\).*?"                          .
                                        "<\/script>/s",$szHTML )                            ,
                            'ASSERTION SUCCESSFUL: script seems to be correct'              ,
                            'ASSERTION FAILURE: incorrect script'                           ,
                            'GuideAssert' );
echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js' ) ) );
echo LSUnitTesting::assert( preg_match( "/<script type=['\"]text\/javascript['\"]>.*?"      .
                                        "\/js\/myscript\.js.*?\(document,['\"]script['\"]," .
                                        "['\"]VAE-[[:digit:][:upper:]]{32}['\"]\).*?"       .
                                        "<\/script>/s",$szHTML )                            ,
                            'ASSERTION SUCCESSFUL: ID as guid found'                        ,
                            'ASSERTION FAILURE: NO ID as guid found'                        ,
                            'GuideAssert' );
echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js',null,$szJS = 'alert("bonjour")' ) ) );
echo LSUnitTesting::assert( preg_match( "/<script type=['\"]text\/javascript['\"]>.*?"                      .
                                        "\/js\/myscript\.js.*?alert\(.+\).*?\(document,['\"]script['\"],"   .
                                        "['\"]VAE-[[:digit:][:upper:]]{32}['\"]\).*?"                       .
                                        "<\/script>/s",$szHTML )                                            ,
                            'ASSERTION SUCCESSFUL: script injected in script'                               ,
                            'ASSERTION FAILURE: no script injection'                                        ,
                            'GuideAssert' );
echo wordwrap( htmlentities( $szHTML = MISC_RequireJS( '/js/myscript.js',null,$szJS = 'alert("bonjour")',false ) ) );
echo LSUnitTesting::assert( STR_iPos( 'text/javascript',$szHTML ) === -1  &&
                            STR_iPos( '<script',$szHTML )         === -1                            ,
                            'ASSERTION SUCCESSFUL: no &lt;script&gt;...&lt;/script&gt; as expected' ,
                            'ASSERTION FAILURE: &lt;script&gt;...&lt;/script&gt; found = problem'   ,
                            'GuideAssert' );

<script type="text/javascript">
(function(d,s,id) {if (d.getElementById(id)) return;var js, vjs =
d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.src =
"/js/myscript.js";vjs.parentNode.insertBefore(js,vjs);}(document,'script','MY-SCRIPT'));
</script>

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

<script type="text/javascript"> (function(d,s,id) {if (d.getElementById(id)) return;var js, vjs = d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.src = "/js/myscript.js";vjs.parentNode.insertBefore(js,vjs);}(document,'script','VAE-4B39992116D74F34858991404150FDB3')); </script>

GuideAssert() ... ASSERTION SUCCESSFUL: ID as guid found

<script type="text/javascript"> (function(d,s,id) {if (d.getElementById(id)) return;var js, vjs = d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.src = "/js/myscript.js";vjs.parentNode.insertBefore(js,vjs);alert("bonjour");}(document,'script','VAE-B07F66269083435B973FC0F708FDEB3E')); </script>

GuideAssert() ... ASSERTION SUCCESSFUL: script injected in script

(function(d,s,id) {if (d.getElementById(id)) return;var js, vjs = d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.src = "/js/myscript.js";vjs.parentNode.insertBefore(js,vjs);alert("bonjour");}(document,'script','VAE-B0B1656A6D7E4CFEADFD0617D183F587'));

GuideAssert() ... ASSERTION SUCCESSFUL: no <script>...</script> as expected

Unit Testing

4 assertions: 4 successful; 0 failed

MISC_Script(): Generates the proper code to include a JavaScript

[ back to function list ]

Remark

An empty script does not produce any output.

Syntax

MISC_Script( $szScript,$bScoped,$bDefer,$bCDATA )

Parameters
NameTypeDescription
$szScript string The Javascript code to be inserted
$bScoped bool Include a "scoped" attribute if set. Optional: false by default.
$bDefer bool Indicates whether the script is to be deferred or not. Optional: false by default.
$bCDATA bool Indicates whether the script must be included in a CDATA section. Optional: true by default.
Parameters Warning

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

Return

(string) The HTML code that must be echoed.

Example Executed
echo htmlentities( MISC_Script( 'alert("Hey");' ) );
echo htmlentities( MISC_Script( '' ) );

<script type="text/javascript">
// <![CDATA[
alert("Hey");
//]]>
</script>
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

MISC_RequireJS(), MISC_AddJS(), MISC_AddJSEx()

MISC_Self(): Returns the name of the running script (Self)

[ back to function list ]

Syntax

MISC_Self()

Parameters

None

Return

(string) Name of the running script or null if it cannot be determined.

Example Executed
echo $szSelf = MISC_Self();

echo LSUnitTesting::assert( $szSelf === '/guide.php'            ,
                            'ASSERTION SUCCESSFUL: self OK'     ,
                            'ASSERTION FAILURE: self NOT OK'    ,
                            'GuideAssert' );

/guide.php

GuideAssert() ... ASSERTION SUCCESSFUL: self OK

Unit Testing

1 assertions: 1 successful; 0 failed

MISC_SetError(): Set error reporting

[ back to function list ]

Syntax

MISC_SetError( $i )

Parameters
NameTypeDescription
$i integer Error setting. Optional: E_ALL | E_NOTICE by default
Return

(void)

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

MISC_Sleep(): Delay execution in microseconds

[ back to function list ]

Syntax

MISC_Sleep( $iMicroSeconds )

Parameters
NameTypeDescription
$iMicroSeconds int Dealy time in micro seconds (a micro second is one millionth of a second).
Return

(void)

Example(s)
MISC_Sleep( 1000000 ); // Suspend execution for 1 sec
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(...); *}).

MISC_Swap(): Swaps $x and $y

[ back to function list ]

Syntax

MISC_Swap( $x,$y )

Parameters
NameTypeDescription
$x mixed 1st element whose value must be swapped. Passed by reference. Updated upon return.
$y mixed 2nd element whose value must be swapped. Passed by reference. Updated upon return.
Return

(void) $x and $y are swapped

Example(s)
// $xValue can be something like "DD-MM-YYYY" or "DD/MM/YYYY"
if ( preg_match( '/(?P<day>\d{2})[\/-](?P<month>\d{2})[\/-](?P<year>\d{4})/',$xValue,$aMatch ) )
{
    $szMonth = $aMatch['month'];          // Get month
    $szDay   = $aMatch['day'];            // Get day

    if ( (int) $szDay <= 12 )             // If day can be a month
    {
        if ( (int) $szMonth > 12 )        // If month seems to be a day
        {
            MISC_Swap( $szDay,$szMonth ); // Swap month and day
        }
    }

    $iTime = TIM_MakeInt( $aMatch['year'] . $szMonth . $szDay );
}
Example Executed
$x = 14;
$y = 21;

MISC_Swap( $x,$y );

echo LSUnitTesting::assert(  $x === 21 && $y === 14                         ,
                            'ASSERTION SUCCESSFUL: values swapped correctly',
                            'ASSERTION FAILURE: values swapped correctly'   ,
                            'GuideAssert' );

GuideAssert() ... ASSERTION SUCCESSFUL: values swapped correctly

Assertions

true === true successful

Unit Testing

2 assertions: 2 successful; 0 failed

MISC_Taxonomize(): Taxonomize a resource

[ back to function list ]

Warning

Experimental function. Do not use ina production environment!

Syntax

MISC_Taxonomize( $szResource,$szLang,$szType )

Parameters
NameTypeDescription
$szResource string The resource to taxonomize (a URL, a file, ...)
$szLang string Language of the taxonomy
$szType string Resource type
Return

(array) An array of words found in the $szResource resource

Example(s)
var_dump( MISC_Taxonomize( 'http://www.vaesoli.org' ) );
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(...); *}).

MISC_Ticket(): Creates a string value that can be used as a ticket number.

[ back to function list ]

Abstract

Handy to create ticket numbers for Tech Support for example.

Syntax

MISC_Ticket()

Parameters

None

Return

(string) A ticket number (e.g. 127001-1906-98)

Example Executed
echo $szTicket = MISC_Ticket();
echo LSUnitTesting::assert( preg_match( "/\d{6}-\d{4}-\d{2}/s",$szTicket )              ,
                            'ASSERTION SUCCESSFUL: ticket number seems to be correct'   ,
                            'ASSERTION FAILURE: incorrect ticket number'                ,
                            'GuideAssert' );

127001-1954-54

GuideAssert() ... ASSERTION SUCCESSFUL: ticket number seems to be correct

Unit Testing

1 assertions: 1 successful; 0 failed

MISC_TopDomain(): Returns the principal name of the domain we're dealing with

[ back to function list ]

Warning

Only URLs using http or https can safely be processed

Syntax

MISC_TopDomain( $szDomain )

Parameters
NameTypeDescription
$szDomain string Optional domain name. If not passed the $_SERVER['SERVER_NAME'] name is used instead
Return

(string) The top domain name of $szDomain

Example Executed
echo MISC_TopDomain( 'http://www.latosensu.be' );

latosensu
Assertions

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

MISC_TopDomain( 'www.latosensu.be' ) === 'latosensu' successful

MISC_TopDomain( 'latosensu.be' ) === 'latosensu' successful

Unit Testing

3 assertions: 3 successful; 0 failed

MISC_WaitJSFnc(): Waits until a specific JavaScript function gets defined

[ back to function list ]

Created: 23/04/2014 19:14

Since version 6.0.0006

Syntax

MISC_WaitJSFnc( $szFnc,$iDelay,$szECMA,$WithScript )

Parameters
NameTypeDescription
$szFnc string The function that must exist before we can execute the ECMA script
$iDelay int The delay in milliseconds between 2 checks
$szECMA string The code that can be executed as soon as $szFnc is defined
$WithScript bool Optional. true to embrace the result with MISC_Script(); false if not. true by default.
Parameters Warning

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

Return

(string) The HTML code that must be echoed.

Example Executed
echo wordwrap( htmlentities( $szHTML = MISC_WaitJSFnc( 'Hello',5000,'alert(\'Hello() IS defined\')' ) ) );
echo LSUnitTesting::assert( preg_match( '/<script.+window\.INT_VAL_Hello *= '                           .
                                        '*setInterval.+clearInterval.+5000.+<\/script>.+/si',$szHTML )  ,
                            'ASSERTION SUCCESSFUL: script seems correct'                                ,
                            'ASSERTION FAILURE: incorrect script'                                       ,
                            'GuideAssert' );

<script type="text/javascript">
// <![CDATA[
(function() 
{
if ( typeof Hello == 'function' )
{
alert('Hello() IS defined');
}
else
{
window.INT_VAL_Hello = setInterval( function() 
{
if ( typeof Hello == 'function' )
{
clearInterval( window.INT_VAL_Hello );
alert('Hello() IS defined');
}
},5000);
}
}());
//]]>
</script>

GuideAssert() ... ASSERTION SUCCESSFUL: script seems correct

Unit Testing

1 assertions: 1 successful; 0 failed

See Also

MISC_AddJS(), MISC_AddJSEx(), MISC_Script(), MISC_RequireJS()

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)