I generated an obfuscated email using the Hive Logic Enkoder. I want to echo the result in PHP.
The problem is that it contains ', ", \\ and \\\\, all of which mess up how PHP reads the string. How can I make PHP take this literally – escape the characters that need escaping, and un-escape the characters that don’t?
So I want to:
echo '<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=102){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return " +
"o.substr(0,ol);}f(\")12,\\\",&.=1,p?3k`,gcheB8'Xfo!l720\\\\430\\\\120\\\\>X" +
"%E220\\\\230\\\\100\\\\530\\\\700\\\\RS,OT130\\\\630\\\\400\\\\230\\\\130\\" +
"\\530\\\\4[120\\\\700\\\\600\\\\010\\\\300\\\\520\\\\,a038t=68&>&2?120\\\\(" +
"*\\\"\\\\,v$>%!&+g030\\\\~$$2Wt\\\\I330\\\\400\\\\r\\\\JOGUImi3hu771\\\\tmt" +
"yq\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoCrahCmorf.gnirtS=+o;721=%y;i=" +
"+y)12==i(fi{)++i;l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x(f noitcnuf\")" ;
while(x=eval(x));
//-->
//]]>
</script>
';
Edit: here’s the function I’m using now:
function supportEmail() {
$str = <<<'EOT'
<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=102){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return " +
"o.substr(0,ol);}f(\")12,\\\",&.=1,p?3k`,gcheB8'Xfo!l720\\\\430\\\\120\\\\>X" +
"%E220\\\\230\\\\100\\\\530\\\\700\\\\RS,OT130\\\\630\\\\400\\\\230\\\\130\\" +
"\\530\\\\4[120\\\\700\\\\600\\\\010\\\\300\\\\520\\\\,a038t=68&>&2?120\\\\(" +
"*\\\"\\\\,v$>%!&+g030\\\\~$$2Wt\\\\I330\\\\400\\\\r\\\\JOGUImi3hu771\\\\tmt" +
"yq\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoCrahCmorf.gnirtS=+o;721=%y;i=" +
"+y)12==i(fi{)++i;l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x(f noitcnuf\")" ;
while(x=eval(x));
//-->
//]]>
</script>
EOT;
echo $str;
}
But I get this error returned:
Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_END_HEREDOC or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN
Wrap your string in <<<‘EOT’ EOT;