Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 16376 программистов и 1651 робот. Сейчас ищут 1635 программистов ...

HTML_Crypt

Вернуться к: HTML

The 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.

A basic example to encrypt an email address

<?php
// encrypt 'yourname@emailaddress.com'
// with offset 8
$c = new HTML_Crypt('yourname@emailaddress.com'8);

// add <a href="mailto:"></a> around this email
$c->addMailTo();

// output the javascript which writes the decrypted email.
$c->output();
?>

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.

If you don't want to output the generated javascript directly to the browser but use it otherwise or replace a template variable, use getOutput() instead of output() - the first returns the generated javascript, the latter echoes it out.



Вернуться к: HTML

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware