HTML_Crypt
[ class tree: HTML_Crypt ] [ index: HTML_Crypt ] [ all elements ]

Class: HTML_Crypt

Source Location: /HTML_Crypt-1.3.4/HTML/Crypt.php

Class Overview


HTML_Crypt


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 43]
HTML_Crypt

HTML_Crypt provides methods to encrypt text, which can be later be decrypted using JavaScript on the client side

This is very useful to prevent spam robots collecting email addresses from your site, included is a method to add mailto links to the text being generated.

The "encryption" function is basically works like ROT13, with the difference that the $offset setting replaces the 13. It is also limited to ASCII characters between 32 and 127 (included). Other characters will not be encrypted.

a basic example to encrypt an email address $c = new HTML_Crypt('yourname@emailaddress.com', 8); $c->addMailTo(); $c->output();



[ Top ]


Class Variables

$apreg =

[line 98]

a preg expression for an <a href=mailto: ... tag
  • Access: public

Type:   string


[ Top ]

$cryptString =  ''

[line 73]

The text encrypted - without any js
  • See: cyrptText
  • Access: public

Type:   string


[ Top ]

$emailpreg =

[line 106]

a preg expression for an email
  • Access: public

Type:   string


[ Top ]

$offset =

[line 82]

The number to offset the text by
  • Access: public

Type:   int


[ Top ]

$script =  ''

[line 63]

The full javascript to be sent to the browser

Type:   string


[ Top ]

$text =  ''

[line 54]

The unencrypted text

Type:   string


[ Top ]

$useJS =

[line 90]

Whether or not to use JS for encryption or simple html
  • Access: public

Type:   int


[ Top ]



Method Detail

HTML_Crypt (Constructor)   [line 120]

HTML_Crypt HTML_Crypt( [string $text = ''], [int $offset = 3], [boolean $JS = true])

Constructor
  • Access: public

Parameters:

string   $text     The text to encrypt
int   $offset     The offset used to encrypt/decrypt
boolean   $JS     If javascript shall be used on the client side

[ Top ]

addMailTo   [line 165]

void addMailTo( [string $template = '<a href="mailto:%email%">%email%</a>'])

Turns the text into a mailto link (make sure the text only contains an email).

This method has an optional parameter that allows you to customize the email tag and tag text. To get the email address included, use "%email%' as template variable.

  • Access: public

Parameters:

string   $template     Mailto template string

[ Top ]

getOutput   [line 276]

string getOutput( )

Returns the encrypted text.
  • Return: Encrypted text

[ Top ]

getScript   [line 216]

string getScript( )

Returns the script html source including the function to decrypt it.
  • Return: The javascript generated
  • Access: public

[ Top ]

obEnd   [line 309]

void obEnd( )

Ends output buffering and echoes the captured text.

[ Top ]

obStart   [line 299]

void obStart( )

Starts output buffering.

[ Top ]

output   [line 263]

void output( )

Outputs the full JS to the browser
  • Access: public

[ Top ]

setText   [line 143]

void setText( string $text)

Set name of the current realm
  • Access: public

Parameters:

string   $text     The text to be encrypted

[ Top ]


Documentation generated on Mon, 25 Oct 2010 14:01:53 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.