mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-04 04:07:59 +02:00
Update Gelato to 1.0.3
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
/**
|
||||
* The version of Gelato
|
||||
*/
|
||||
define('GELATO_VERSION', '1.0.2');
|
||||
define('GELATO_VERSION', '1.0.3');
|
||||
|
||||
/**
|
||||
* Define __DIR__ constant for PHP 5.2.x
|
||||
|
@@ -28,6 +28,13 @@ class Html
|
||||
'accept', 'tabindex', 'accesskey', 'alt', 'title', 'class',
|
||||
'style', 'selected', 'checked', 'readonly', 'disabled',
|
||||
);
|
||||
|
||||
/**
|
||||
* The registered custom macros.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $macros = array();
|
||||
|
||||
/**
|
||||
* Protected constructor since this is a static class.
|
||||
@@ -279,7 +286,56 @@ class Html
|
||||
$attributes['alt'] = (isset($attributes['alt'])) ? $attributes['alt'] : pathinfo($file, PATHINFO_FILENAME);
|
||||
|
||||
return '<img'.Html::attributes($attributes).' />';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obfuscate an e-mail address to prevent spam-bots from sniffing it.
|
||||
*
|
||||
* <code>
|
||||
* echo Html::email('gelato@monstra.org');
|
||||
* </code>
|
||||
*
|
||||
* @param string $email
|
||||
* @return string
|
||||
*/
|
||||
public static function email($email)
|
||||
{
|
||||
return str_replace('@', '@', Html::obfuscate($email));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obfuscate a string to prevent spam-bots from sniffing it.
|
||||
*
|
||||
* This method obfuscate the value, randomly convert each
|
||||
* letter to its entity or hexadecimal representation, keeping a
|
||||
* bot from sniffing the randomly obfuscated letters.
|
||||
*
|
||||
* <code>
|
||||
* echo Html::obfuscate('gelato@monstra.org');
|
||||
* </code>
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public static function obfuscate($value)
|
||||
{
|
||||
$safe = '';
|
||||
|
||||
foreach (str_split($value) as $letter) {
|
||||
switch (rand(1, 3)) {
|
||||
case 1:
|
||||
$safe .= '&#'.ord($letter).';';
|
||||
break;
|
||||
case 2:
|
||||
$safe .= '&#x'.dechex(ord($letter)).';';
|
||||
break;
|
||||
case 3:
|
||||
$safe .= $letter;
|
||||
}
|
||||
}
|
||||
|
||||
return $safe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert html to plain text
|
||||
|
@@ -4,6 +4,6 @@ Gelato is a PHP5 library for kickass Web Applications.
|
||||
|
||||
## Links
|
||||
- [Site](http://gelato.monstra.org)
|
||||
- [Github Repository](https://github.com/Monstra/gelato)
|
||||
- [Github Repository](https://github.com/MonstrLab/gelato)
|
||||
|
||||
Copyright (C) 2013 Romanenko Sergey / Awilum [awilum@msn.com]
|
@@ -1,3 +1,13 @@
|
||||
Gelato 1.0.3, 2013-04-03
|
||||
------------------------
|
||||
- Html Class: obfuscate() method added.
|
||||
- Html Class: email() method added.
|
||||
- Html Class: missing $macros var added.
|
||||
|
||||
Gelato 1.0.2, 2013-03-17
|
||||
------------------------
|
||||
- Added support for PHP 5.2.3
|
||||
|
||||
Gelato 1.0.1, 2013-03-05
|
||||
------------------------
|
||||
- New constant GELATO_CLASS_LOADER instead of GELATO_AUTOLOADER
|
||||
|
Reference in New Issue
Block a user