From: "Jack" on
Hello All,


I have some code which converts to some html to ascii characters. This
basically obfuscates the html code, but shows it correctly on an page.


I am trying to show the results of the obfuscation ( works correctly because
it displays the html value ), but I want to then show the obfuscated html
code so they can copy it.

An example is I want to show them this below:

<a
href="&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x79;&#x6f;&#117;&#114;&#x4
0;&#101;&#x6d;&#00097;&#x69;&#x6c;&#x2e;&#97;&#x64;&#x64;&#x72;&#000101;&#00
0115;&#115;?subject=&cc=&bcc=&body=" style="" class=""
id="">&#x79;&#000111;&#x75;&#000114;&#x40;&#x65;&#x6d;&#97;&#105;&#x6c;&#000
46;&#x61;&#x64;&#x64;&#000114;&#x65;&#000115;&#x73;</a>



Which was created by the code, but I apparently can't seem to echo it and
get it to display like above.. It converts it to html no matter what I do.





Thanks!

Jack




From: Marc Guay on
> Which was created by the code, but I apparently can't seem to echo it and
> get it to display like above.. It converts it to html no matter what I do.

Have you tried the <pre> HTML tag? (http://www.w3schools.com/TAGS/tag_pre.asp)

Putting inside a <textarea> might also work for you...


--
Marc Guay
MobilizeMe
mobilizeme.com
From: Andrew Ballard on
On Thu, Sep 9, 2010 at 9:52 AM, Jack <JackListMail(a)gmail.com> wrote:
>
> Hello All,
>
>
> I have some code which converts to some html to ascii characters.  This
> basically obfuscates the html code, but shows it correctly on an page.
>
>
> I am trying to show the results of the obfuscation ( works correctly because
> it displays the html value ), but I want to then show the obfuscated html
> code so they can copy it.
>
> An example is I want to show them this below:
>
> <a
> href="&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x79;&#x6f;&#117;&#114;&#x4
> 0;&#101;&#x6d;&#00097;&#x69;&#x6c;&#x2e;&#97;&#x64;&#x64;&#x72;&#000101;&#00
> 0115;&#115;?subject=&cc=&bcc=&body=" style="" class=""
> id="">&#x79;&#000111;&#x75;&#000114;&#x40;&#x65;&#x6d;&#97;&#105;&#x6c;&#000
> 46;&#x61;&#x64;&#x64;&#000114;&#x65;&#000115;&#x73;</a>
>
>
>
> Which was created by the code, but I apparently can't seem to echo it and
> get it to display like above.. It converts it to html no matter what I do..


This should do it:

<?php

$var = '<a href="&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x79;&#x6f;&#117;&#114;&#x40;&#101;&#x6d;&#00097;&#x69;&#x6c;&#x2e;&#97;&#x64;&#x64;&#x72;&#000101;&#000115;&#115;?subject=&cc=&bcc=&body="
style="" class=""
id="">&#x79;&#000111;&#x75;&#000114;&#x40;&#x65;&#x6d;&#97;&#105;&#x6c;&#00046;&#x61;&#x64;&#x64;&#000114;&#x65;&#000115;&#x73;</a>';


echo htmlspecialchars($var);

?>

The obfuscation doesn't buy you much, though.

<?php

var_dump(html_entity_decode($var, ENT_QUOTES, 'utf-8'));

?>
string(106) "<a
href="mailto:your(a)email.address?subject=&cc=&bcc=&body=" style=""
class="" id="">your(a)email.address</a>"

The only people for whom the value will be obscure will be the humans
who actually try to read the HTML source code itself. Neither web
browsers nor harvesting scripts won't have any trouble reading it.

Andrew
From: Richard Quadling on
On 9 September 2010 14:52, Jack <JackListMail(a)gmail.com> wrote:
> Hello All,
> I have some code which converts to some html to ascii characters.  This
> basically obfuscates the html code, but shows it correctly on an page.
> I am trying to show the results of the obfuscation ( works correctly because
> it displays the html value ), but I want to then show the obfuscated html
> code so they can copy it.
> An example is I want to show them this below:
> <a
> href="&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x79;&#x6f;&#117;&#114;&#x4
> 0;&#101;&#x6d;&#00097;&#x69;&#x6c;&#x2e;&#97;&#x64;&#x64;&#x72;&#000101;&#00
> 0115;&#115;?subject=&cc=&bcc=&body=" style="" class=""
> id="">&#x79;&#000111;&#x75;&#000114;&#x40;&#x65;&#x6d;&#97;&#105;&#x6c;&#000
> 46;&#x61;&#x64;&#x64;&#000114;&#x65;&#000115;&#x73;</a>
> Which was created by the code, but I apparently can't seem to echo it and
> get it to display like above.. It converts it to html no matter what I do..
> Thanks!
> Jack

htmlentities() is your friend here.

<?php
$text = '<a href="&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x79;&#x6f;&#117;&#114;&#x40;&#101;&#x6d;&#00097;&#x69;&#x6c;&#x2e;&#97;&#x64;&#x64;&#x72;&#000101;&#000115;&#115;?subject=&cc=&bcc=&body="
style="" class=""
id="">&#x79;&#000111;&#x75;&#000114;&#x40;&#x65;&#x6d;&#97;&#105;&#x6c;&#00046;&#x61;&#x64;&#x64;&#000114;&#x65;&#000115;&#x73;</a>';
echo $text, htmlentities($text);
?>

outputs ...

your(a)email.address<a
href="&#x6d;&#x61;&#x69;&#108;&#x74;&#111;&#x3a;&#x79;&#x6f;&#117;&#114;&#x40;&#101;&#x6d;&#00097;&#x69;&#x6c;&#x2e;&#97;&#x64;&#x64;&#x72;&#000101;&#000115;&#115;?subject=&cc=&bcc=&body="
style="" class=""
id="">&#x79;&#000111;&#x75;&#000114;&#x40;&#x65;&#x6d;&#97;&#105;&#x6c;&#00046;&#x61;&#x64;&#x64;&#000114;&#x65;&#000115;&#x73;</a>
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
From: "Jack" on
-----Original Message-----
From: Andrew Ballard [mailto:aballard(a)gmail.com]


The only people for whom the value will be obscure will be the humans who actually try to read the HTML source code itself. Neither web browsers nor harvesting scripts won't have any trouble reading it.

Andrew


Andrew,

One other note, if the link doesn't say mailto: a harvester will have to decode the entire page in order to find the mailto, do you think that’s happening. This could be one of those things where you help against a percentage of harvesters, and not others.

J

 |  Next  |  Last
Pages: 1 2
Prev: Reformat array result.
Next: Zend framework