Zend_Captcha-Adapters.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.captcha.adapters">
  4. <title>CAPTCHA Adapters</title>
  5. <para>
  6. The following adapters are shipped with Zend Framework by default.
  7. </para>
  8. <sect2 id="zend.captcha.adapters.word">
  9. <title>Zend_Captcha_Word</title>
  10. <para>
  11. <classname>Zend_Captcha_Word</classname> is an abstract adapter that serves as the base
  12. class for most other <acronym>CAPTCHA</acronym> adapters. It provides mutators for
  13. specifying word length, session <acronym>TTL</acronym>, the session namespace object
  14. to use, and the session namespace class to use for persistence if
  15. you do not wish to use <classname>Zend_Session_Namespace</classname>.
  16. <classname>Zend_Captcha_Word</classname> encapsulates validation logic.
  17. </para>
  18. <para>
  19. By default, the word length is 8 characters, the session timeout is
  20. 5 minutes, and <classname>Zend_Session_Namespace</classname> is used for persistence
  21. (using the namespace "<classname>Zend_Form_Captcha_&lt;captcha ID&gt;</classname>").
  22. </para>
  23. <para>
  24. In addition to the methods required by the
  25. <classname>Zend_Captcha_Adapter</classname> interface,
  26. <classname>Zend_Captcha_Word</classname> exposes the following methods:
  27. </para>
  28. <itemizedlist>
  29. <listitem><para>
  30. <methodname>setWordLen($length)</methodname> and
  31. <methodname>getWordLen()</methodname> allow you to specify the length of the
  32. generated "word" in characters, and to retrieve the current value.
  33. </para></listitem>
  34. <listitem><para>
  35. <methodname>setTimeout($ttl)</methodname> and <methodname>getTimeout()</methodname>
  36. allow you to specify the time-to-live of the session token, and
  37. to retrieve the current value. <varname>$ttl</varname> should be
  38. specified in seconds.
  39. </para></listitem>
  40. <listitem><para>
  41. <methodname>setSessionClass($class)</methodname> and
  42. <methodname>getSessionClass()</methodname> allow you to specify an
  43. alternate <classname>Zend_Session_Namespace</classname> implementation to
  44. use to persist the <acronym>CAPTCHA</acronym> token and to retrieve the
  45. current value.
  46. </para></listitem>
  47. <listitem><para>
  48. <methodname>getId()</methodname> allows you to retrieve the current token
  49. identifier.
  50. </para></listitem>
  51. <listitem><para>
  52. <methodname>getWord()</methodname> allows you to retrieve the generated
  53. word to use with the <acronym>CAPTCHA</acronym>. It will generate the word for you
  54. if none has been generated yet.
  55. </para></listitem>
  56. <listitem><para>
  57. <methodname>setSession(Zend_Session_Namespace $session)</methodname> allows
  58. you to specify a session object to use for persisting the
  59. <acronym>CAPTCHA</acronym> token. <methodname>getSession()</methodname> allows you
  60. to retrieve the current session object.
  61. </para></listitem>
  62. </itemizedlist>
  63. <para>
  64. All word <acronym>CAPTCHA</acronym>s allow you to pass an array of options to the
  65. constructor, or, alternately, pass them to
  66. <methodname>setOptions()</methodname>. You can also pass a
  67. <classname>Zend_Config</classname> object to <methodname>setConfig()</methodname>. By
  68. default, the <emphasis>wordLen</emphasis>, <emphasis>timeout</emphasis>, and
  69. <emphasis>sessionClass</emphasis> keys may all be used. Each concrete
  70. implementation may define additional keys or utilize the options in
  71. other ways.
  72. </para>
  73. <note>
  74. <para>
  75. <classname>Zend_Captcha_Word</classname> is an abstract class and may not be
  76. instantiated directly.
  77. </para>
  78. </note>
  79. </sect2>
  80. <sect2 id="zend.captcha.adapters.dumb">
  81. <title>Zend_Captcha_Dumb</title>
  82. <para>
  83. The <classname>Zend_Captch_Dumb</classname> adapter is mostly self-descriptive. It
  84. provides a random string that must be typed in reverse to validate. As such, it's
  85. not a good <acronym>CAPTCHA</acronym> solution and should only be used for
  86. testing. It extends <classname>Zend_Captcha_Word</classname>.
  87. </para>
  88. </sect2>
  89. <sect2 id="zend.captcha.adapters.figlet">
  90. <title>Zend_Captcha_Figlet</title>
  91. <para>
  92. The <classname>Zend_Captcha_Figlet</classname> adapter utilizes <link
  93. linkend="zend.text.figlet"><classname>Zend_Text_Figlet</classname></link> to present
  94. a figlet to the user.
  95. </para>
  96. <para>
  97. Options passed to the constructor will also be passed to the <link
  98. linkend="zend.text.figlet">Zend_Text_Figlet</link> object. See
  99. the <link linkend="zend.text.figlet">Zend_Text_Figlet</link>documentation for
  100. details on what configuration options are available.
  101. </para>
  102. </sect2>
  103. <sect2 id="zend.captcha.adapters.image">
  104. <title>Zend_Captcha_Image</title>
  105. <para>
  106. The <classname>Zend_Captcha_Image</classname> adapter takes the generated word and
  107. renders it as an image, performing various skewing permutations to make it
  108. difficult to automatically decipher. It
  109. requires the <ulink url="http://php.net/gd">GD extension</ulink>
  110. compiled with TrueType or Freetype support. Currently, the
  111. <classname>Zend_Captcha_Image</classname> adapter can only generate
  112. <acronym>PNG</acronym> images.
  113. </para>
  114. <para>
  115. <classname>Zend_Captcha_Image</classname> extends
  116. <classname>Zend_Captcha_Word</classname>, and additionally exposes the
  117. following methods:
  118. </para>
  119. <itemizedlist>
  120. <listitem><para>
  121. <methodname>setExpiration($expiration)</methodname> and
  122. <methodname>getExpiration()</methodname> allow you to specify a maximum
  123. lifetime the <acronym>CAPTCHA</acronym> image may reside on the filesystem. This is
  124. typically a longer than the session lifetime. Garbage
  125. collection is run periodically each time the <acronym>CAPTCHA</acronym> object is
  126. invoked, deleting all images that have expired.
  127. Expiration values should be specified in seconds.
  128. </para></listitem>
  129. <listitem><para>
  130. <methodname>setGcFreq($gcFreq)</methodname> and <methodname>getGcFreg()</methodname>
  131. allow you to specify how frequently garbage collection should
  132. run. Garbage collection will run every <emphasis>1/$gcFreq</emphasis>
  133. calls. The default is 100.
  134. </para></listitem>
  135. <listitem><para>
  136. <methodname>setFont($font)</methodname> and <methodname>getFont()</methodname> allow
  137. you to specify the font you will use. <varname>$font</varname>
  138. should be a fully qualified path to the font file.
  139. This value is required; the <acronym>CAPTCHA</acronym> will throw an
  140. exception during generation if the font file has not been specified.
  141. </para></listitem>
  142. <listitem><para>
  143. <methodname>setFontSize($fsize)</methodname> and
  144. <methodname>getFontSize()</methodname> allow you to specify the font size in pixels
  145. for generating the <acronym>CAPTCHA</acronym>. The default is 24px.
  146. </para></listitem>
  147. <listitem><para>
  148. <methodname>setHeight($height)</methodname> and <methodname>getHeight()</methodname>
  149. allow you to specify the height in pixels of the generated
  150. <acronym>CAPTCHA</acronym> image. The default is 50px.
  151. </para></listitem>
  152. <listitem><para>
  153. <methodname>setWidth($width)</methodname> and <methodname>getWidth()</methodname>
  154. allow you to specify the width in pixels of the generated
  155. <acronym>CAPTCHA</acronym> image. The default is 200px.
  156. </para></listitem>
  157. <listitem><para>
  158. <methodname>setImgDir($imgDir)</methodname> and <methodname>getImgDir()</methodname>
  159. allow you to specify the directory for storing <acronym>CAPTCHA</acronym> images.
  160. The default is "<filename>./images/captcha/</filename>", relative to the bootstrap
  161. script.
  162. </para></listitem>
  163. <listitem><para>
  164. <methodname>setImgUrl($imgUrl)</methodname> and <methodname>getImgUrl()</methodname>
  165. allow you to specify the relative path to a <acronym>CAPTCHA</acronym> image to
  166. use for <acronym>HTML</acronym> markup. The default is
  167. "<filename>/images/captcha/</filename>".
  168. </para></listitem>
  169. <listitem><para>
  170. <methodname>setSuffix($suffix)</methodname> and <methodname>getSuffix()</methodname>
  171. allow you to specify the filename suffix for the <acronym>CAPTCHA</acronym> image.
  172. The default is "<filename>.png</filename>". Note: changing this value will not
  173. change the type of the generated image.
  174. </para></listitem>
  175. </itemizedlist>
  176. <para>
  177. All of the above options may be passed to the
  178. constructor by simply removing the 'set' method prefix and casting
  179. the initial letter to lowercase: "suffix", "height", "imgUrl", etc.
  180. </para>
  181. </sect2>
  182. <sect2 id="zend.captcha.adapters.recaptcha">
  183. <title>Zend_Captcha_ReCaptcha</title>
  184. <para>
  185. The <classname>Zend_Captcha_ReCaptcha</classname> adapter uses <link
  186. linkend="zend.service.recaptcha">Zend_Service_ReCaptcha</link>
  187. to generate and validate <acronym>CAPTCHA</acronym>s. It exposes the following
  188. methods:
  189. </para>
  190. <itemizedlist>
  191. <listitem><para>
  192. <methodname>setPrivKey($key)</methodname> and <methodname>getPrivKey()</methodname>
  193. allow you to specify the private key to use for the ReCaptcha
  194. service. This must be specified during construction, although it
  195. may be overridden at any point.
  196. </para></listitem>
  197. <listitem><para>
  198. <methodname>setPubKey($key)</methodname> and <methodname>getPubKey()</methodname>
  199. allow you to specify the public key to use with the ReCaptcha
  200. service. This must be specified during construction, although it
  201. may be overridden at any point.
  202. </para></listitem>
  203. <listitem><para>
  204. <methodname>setService(Zend_Service_ReCaptcha $service)</methodname> and
  205. <methodname>getService()</methodname> allow you to set and get
  206. the ReCaptcha service object.
  207. </para></listitem>
  208. </itemizedlist>
  209. </sect2>
  210. </sect1>
  211. <!--
  212. vim:se ts=4 sw=4 et:
  213. -->