fck.afpa.code 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  2. * Copyright (C) 2003-2009 Frederico Caldeira Knabben
  3. *
  4. * == BEGIN LICENSE ==
  5. *
  6. * Licensed under the terms of any of the following licenses at your
  7. * choice:
  8. *
  9. * - GNU General Public License Version 2 or later (the "GPL")
  10. * http://www.gnu.org/licenses/gpl.html
  11. *
  12. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  13. * http://www.gnu.org/licenses/lgpl.html
  14. *
  15. * - Mozilla Public License Version 1.1 or later (the "MPL")
  16. * http://www.mozilla.org/MPL/MPL-1.1.html
  17. *
  18. * == END LICENSE ==
  19. *
  20. * This is the class definition file for the sample pages.
  21. *
  22. DEFINE CLASS fckeditor AS custom
  23. cInstanceName =""
  24. BasePath =""
  25. cWIDTH =""
  26. cHEIGHT =""
  27. ToolbarSet =""
  28. cValue=""
  29. DIMENSION aConfig(10,2)
  30. && -----------------------------------------------------------------------
  31. FUNCTION fckeditor( tcInstanceName )
  32. LOCAL lnLoop,lnLoop2
  33. THIS.cInstanceName = tcInstanceName
  34. THIS.BasePath = '../../../FCKeditor/'
  35. THIS.cWIDTH = '100%'
  36. THIS.cHEIGHT = '200'
  37. THIS.ToolbarSet = 'Default'
  38. THIS.cValue = ''
  39. FOR lnLoop=1 TO 10
  40. FOR lnLoop2=1 TO 2
  41. THIS.aConfig(lnLoop,lnLoop2) = ""
  42. NEXT
  43. NEXT
  44. RETURN
  45. ENDFUNC
  46. && -----------------------------------------------------------------------
  47. FUNCTION CREATE()
  48. RETURN(THIS.CreateHtml())
  49. ENDFUNC
  50. && -----------------------------------------------------------------------
  51. FUNCTION CreateHtml()
  52. LOCAL html
  53. LOCAL lcLink
  54. HtmlValue = THIS.cValue && HTMLSPECIALCHARS()
  55. html = [<div>]
  56. IF THIS.IsCompatible()
  57. lcLink = THIS.BasePath+[editor/fckeditor.html?InstanceName=]+THIS.cInstanceName
  58. IF ( !THIS.ToolbarSet == '' )
  59. lcLink = lcLink + [&Toolbar=]+THIS.ToolbarSet
  60. ENDIF
  61. && Render the LINKED HIDDEN FIELD.
  62. html = html + [<input type="hidden" id="]+THIS.cInstanceName +[" name="]+THIS.cInstanceName +[" value="]+HtmlValue+[">]
  63. && Render the configurations HIDDEN FIELD.
  64. html = html + [<input type="hidden" id="]+THIS.cInstanceName +[___Config" value="]+THIS.GetConfigFieldString() + [">] +CHR(13)+CHR(10)
  65. && Render the EDITOR IFRAME.
  66. html = html + [<iframe id="]+THIS.cInstanceName +[___Frame" src="]+lcLink+[" width="]+THIS.cWIDTH+[" height="]+THIS.cHEIGHT+[" frameborder="no" scrolling="no"></iframe>]
  67. ELSE
  68. IF ( AT("%", THIS.cWIDTH)=0 )
  69. WidthCSS = THIS.cWIDTH + 'px'
  70. ELSE
  71. WidthCSS = THIS.cWIDTH
  72. ENDIF
  73. IF ( AT("%",THIS.cHEIGHT)=0 )
  74. HeightCSS = THIS.cHEIGHT + 'px'
  75. ELSE
  76. HeightCSS = THIS.cHEIGHT
  77. ENDIF
  78. html = html + [<textarea name="]+THIS.cInstanceName +[" rows="4" cols="40" style="width: ]+WidthCSS+[ height: ]+HeightCSS+[" wrap="virtual">]+HtmlValue+[</textarea>]
  79. ENDIF
  80. html = html + [</div>]
  81. RETURN (html)
  82. ENDFUNC
  83. && -----------------------------------------------------------------------
  84. FUNCTION IsCompatible()
  85. LOCAL llRetval
  86. LOCAL sAgent
  87. llRetval=.F.
  88. sAgent= LOWER(Request.ServerVariables("HTTP_USER_AGENT"))
  89. IF AT("msie",sAgent) >0 .AND. AT("mac",sAgent)=0 .AND. AT("opera",sAgent)=0
  90. iVersion=VAL(SUBSTR(sAgent,AT("msie",sAgent)+5,3))
  91. llRetval= iVersion > 5.5
  92. ELSE
  93. IF AT("gecko",sAgent)>0
  94. iVersion=VAL(SUBSTR(sAgent,AT("gecko/",sAgent)+6,8))
  95. llRetval =iVersion > 20030210
  96. ENDIF
  97. ENDIF
  98. RETURN (llRetval)
  99. ENDFUNC
  100. && -----------------------------------------------------------------------
  101. FUNCTION GetConfigFieldString()
  102. LOCAL sParams
  103. LOCAL bFirst
  104. LOCAL sKey
  105. sParams = ""
  106. bFirst = .T.
  107. FOR lnLoop=1 TO 10 && ALEN(this.aconfig)
  108. IF !EMPTY(THIS.aConfig(lnLoop,1))
  109. IF bFirst = .F.
  110. sParams = sParams + "&"
  111. ELSE
  112. bFirst = .F.
  113. ENDIF
  114. sParams = sParams +THIS.aConfig(lnLoop,1)+[=]+THIS.aConfig(lnLoop,2)
  115. ELSE
  116. EXIT
  117. ENDIF
  118. NEXT
  119. RETURN(sParams)
  120. ENDFUNC
  121. && -----------------------------------------------------------------------
  122. && This function removes unwanted characters in URL parameters mostly entered by hackers
  123. FUNCTION StripAttacks
  124. LPARAMETERS tcString
  125. IF !EMPTY(tcString)
  126. tcString=STRTRAN(tcString,"&","")
  127. tcString=STRTRAN(tcString,"?","")
  128. tcString=STRTRAN(tcString,";","")
  129. tcString=STRTRAN(tcString,"!","")
  130. tcString=STRTRAN(tcString,"<%","")
  131. tcString=STRTRAN(tcString,"%>","")
  132. tcString=STRTRAN(tcString,"<","")
  133. tcString=STRTRAN(tcString,">","")
  134. tcString=STRTRAN(tcString,"..","")
  135. tcString=STRTRAN(tcString,"/","")
  136. tcString=STRTRAN(tcString,"\","")
  137. tcString=STRTRAN(tcString,":","")
  138. ELSE
  139. tcString=""
  140. ENDIF
  141. RETURN (tcString)
  142. ENDDEFINE