Re: Show text without converting to html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 9, 2010 at 9:52 AM, Jack <JackListMail@xxxxxxxxx> 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@xxxxxxxxxxxxx?subject=&cc=&bcc=&body="; style=""
class="" id="">your@xxxxxxxxxxxxx</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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux