Fixing a bug in the call of a static method. Cleaning up code.
This commit is contained in:
1 parent
d62c15f8d3
commit
0457d838af
1 file changed
+32
-34
+32
-34
@@ -225,40 +225,7 @@ class HtmlBuilder {
|
|||||||
*/
|
*/
|
||||||
public function email($email)
|
public function email($email)
|
||||||
{
|
{
|
||||||
return str_replace('@', '@', static::obfuscate($email));
|
return str_replace('@', '@', $this->obfuscate($email));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obfuscate a string to prevent spam-bots from sniffing it.
|
|
||||||
*
|
|
||||||
* @param string $value
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function obfuscate($value)
|
|
||||||
{
|
|
||||||
$safe = '';
|
|
||||||
|
|
||||||
foreach (str_split($value) as $letter)
|
|
||||||
{
|
|
||||||
// To properly obfuscate the value, we will randomly convert each
|
|
||||||
// letter to its entity or hexadecimal representation, keeping a
|
|
||||||
// bot from sniffing the randomly obfuscated letters.
|
|
||||||
switch (rand(1, 3))
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
$safe .= '&#'.ord($letter).';';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
$safe .= '&#x'.dechex(ord($letter)).';';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
$safe .= $letter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $safe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -389,6 +356,37 @@ class HtmlBuilder {
|
|||||||
if ( ! is_null($value)) return $key.'="'.e($value).'"';
|
if ( ! is_null($value)) return $key.'="'.e($value).'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obfuscate a string to prevent spam-bots from sniffing it.
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function obfuscate($value)
|
||||||
|
{
|
||||||
|
$safe = '';
|
||||||
|
|
||||||
|
foreach (str_split($value) as $letter)
|
||||||
|
{
|
||||||
|
// To properly obfuscate the value, we will randomly convert each letter to
|
||||||
|
// its entity or hexadecimal representation, keeping a bot from sniffing
|
||||||
|
// the randomly obfuscated letters out of the string on the responses.
|
||||||
|
switch (rand(1, 3))
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
$safe .= '&#'.ord($letter).';'; break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
$safe .= '&#x'.dechex(ord($letter)).';'; break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
$safe .= $letter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $safe;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically handle calls to the html class.
|
* Dynamically handle calls to the html class.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in new issue
Block a user