11
robstockley
Re: Converting email addresses as images

Thanks skenow. I also found gd_info() works. In the end I've decided not to do this right now.

The extension to the XoopsObject::getVar() in /kernel/object.php is as follows
function getVar($key$format 's')
{
...
    case 
XOBJ_DTYPE_TXTBOX:
        switch (
strtolower($format)) {
        
//the next six lines added by Rob Stockley for image conversion
        
case 'i':
        case 
'image':
            
$ts =& MyTextSanitizer::getInstance();
            
$e_enc strencode($ts->htmlSpecialChars($ret).'|8');
            return 
'.XOOPS_URL.'/include/swirl.php?data='.$e_enc.'">';
            break 
1;
        case 
's':
        case 
'show':
...


Essentially all I've done is add a new output format for XOBJ_DTYPE_TXTBOX type fields. If you use the format on other types it will be ignored and the default option output instead. Email, ICQ, and MSNM are all TXTBOXes so this seems like enough.

Now all I have to do in /userinfo.php is specify the output format as 'I' like so.
...
$xoopsTpl->assign('lang_icq'_US_ICQ);
$xoopsTpl->assign('user_icq'$thisUser->getVar('user_icq''I'));
...
if (
$thisUser->getVar('user_viewemail') == 1) {
    
$xoopsTpl->assign('user_email'$thisUser->getVar('email''I'));
} else {
    if (
is_object($xoopsUser)) {
        
// All admins will be allowed to see emails, even those that are not allowed to edit users (I think it's ok like this)
        
if ($xoopsUserIsAdmin || ($xoopsUser->getVar("uid") == $thisUser->getVar("uid"))) {
            
$xoopsTpl->assign('user_email'$thisUser->getVar('email''I'));
...


I commented out all my previous email tags in module.textsanitiser and added the following near the end of xoopsCodeDecode()
$text preg_replace($patterns$replacements$text);

// lastly decode the email tags added by Rob Stockley 25 May 07
$e_pattern "/[email]([^;<>*()"']*)[/email]/sU";
$e_matches = array();
while (preg_match($e_pattern, $text, $e_matches) != 0) {
    $e_enc = strencode($e_matches[1].'
|8');
    $e_repl = '
<img src="'.XOOPS_URL.'/include/swirl.php?data='.$e_enc.'">';
    $text = preg_replace($e_pattern, $e_repl, $text, 1);
}
$e_pattern = "/[email=(['"]?)([0-9]*)\1]([^;<>*()"']*)[/email]/sU";
while (preg_match($e_pattern, $text, $e_matches) != 0) {
    $e_enc = strencode($e_matches[3].'
|'.$e_matches[2]);
    $e_repl = '
<img src="'.XOOPS_URL.'/include/swirl.php?data='.$e_enc.'">';
    $text = preg_replace($e_pattern, $e_repl, $text, 1);
}
return $text;


The beginning of swirl.php has changed a little to cope with the encoding of email adresses.
/* script adapted by Rob Stockley from example published at
* http://nz2.php.net/manual/en/function.imagestring.php
* by brooks dot boyd at gmail dot com
*/

include './functions.php';

if (
$_GET['data'] != "") {
    
$data explode("|"strdecode($_GET['data']));
    
$msg $data[0];
    
$size intval($data[1]);
    if (
$size 16$size 16;
    if (
$size 8$size 8;

    
// you need to make sure this font file exists
    
$font '/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf';
...


Lastly you'll notice that I've referred to a pair of functions named strencode() and strdecode(). These do some pretty basic character based obfuscation so that the html source bears no resemblance to an email address. I tacked them on to the end of /include/functions.php so that they'd be in scope for all.

So anyway this approach has worked for me. I can now display text fields and emails enclosed with xoopsCode tags all as images. The default size for fields is hardcoded while the xoopsCode take a size variable between 8 and 16.

Enjoy,
Rob

12
robstockley
Re: Converting email addresses as images

With all the recent comment about phpmailer vulnerabilities I took another look at my hack. I use Protector 3.x so in order to take advantage of Protector's spam filtering I need to include ../mainfile.php in swirl.php rather that the direct reference to functions.php.

13
giba
Re: Converting email addresses as images
  • 2007/6/24 0:01

  • giba

  • Just can't stay away

  • Posts: 638

  • Since: 2003/4/26


Your sugestion is very welcome robstockley

For your idea, look customization for new version team x2016.xoopers.

[quote]
[
img]http://www.fabioegas.com.br/resultado.png[/img]
[/quote]


This alteration was based on the idea that you passed and developed by FabioEgas and TheRpLima.

Thanks.

14
robstockley
Re: Converting email addresses as images

Cool Glad to hear someone found it useful. When you've got it up and running PM me a link. I'd be keen to see it in action.
Rob

15
giba
Re: Converting email addresses as images
  • 2007/6/24 23:11

  • giba

  • Just can't stay away

  • Posts: 638

  • Since: 2003/4/26


Sorry, text in portuguese, but in soon translated for english

[img]http://img409.imageshack.us/img409/5140/doc001yp0.gif[/img]


This is admin area definitions by FabioEgas team http://www.xoops.net.br and integration by TheRpLima.

Bellow, translated by google temporary.

To protect E-mails against Spam?

Selecting “Yes” all emails that they are part of the content of the site will be transformed automatically into images to prevent Spam

Archive of source for the image of the email


I will choose one of the sources in the list to be used for the generator of email images. Obs.: This resource alone has effect if the option To protect E-mails against Spam? it will be activated.

Size of the source

It types a number to show the text in this size of source.

Color of the source in the image of the email


I will choose a color to show the image of the email. Obs.: This resource alone has effect if the option To protect E-mails against Spam? it will be activated.


Color of the shade of the image of the email


I will choose a color to show the shade of the image of the email. Blank case leaves does not want to use shade. Obs.: This resource alone has effect if the option To protect E-mails against Spam? it will be activated.


Displacement X of the shade

It types a value that will represent the horizontal displacement of the shade of the text of the email in pixels. Obs.: This resource alone has effect if the option Color of the shade of the image of the email will not be empty.

Displacement Y of the shade

It types a value that will represent the vertical displacement of the shade of the text of the email in pixels. Obs.: This resource alone has effect if the option Color of the shade of the image of the email will not be empty.

16
mortuk
Re: Converting email addresses as images
  • 2007/6/25 12:30

  • mortuk

  • Not too shy to talk

  • Posts: 122

  • Since: 2005/12/13


is this in 2.016? i canot find it?

Login

Who's Online

277 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 277


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits