31
robstockley
Re: Converting email addresses as images

I've had a closer look and notice that you also require the FreeType library to use true type fonts and imagettftext().

Try commenting out this line
imagettftext($image$fontSize0015$fontColor$font$emailAddress);


And uncommenting this line
// ImageString($image,3,2,2,$emailAddress,$fontColor);


And see if that helps. The font won't be as pretty but it might help narrow down your problem.



32
robstockley
Re: Converting email addresses as images

Ah, I see you are using KuBaZ's solution and not mine. I have not installed that version so am not sure what is wrong. My solution works with 2.0.15 using plain GD.

I've modified my approach a bit now. At first I liked KuBaZ's solution but I couldn't see an easy way to implement it for the email xoopscodes. Once I've done some more testing of my final solution I'll upload the results.



33
robstockley
Re: Converting email addresses as images

Most likely the font file doesn't exist on your server or there is no GD support.



34
robstockley
Re: Converting email addresses as images

Doh!!!!

Just found this excellent post.

Not sure how I can sort the email tags yet but this approach appears superior to the one I've taken.

Rob



35
robstockley
Converting email addresses as images

I manage a site based on XOOPS and one of my users was concerned about the potential for email addresses to be harvested. I've since introduced a hack to convert email addresses into images on the fly. This works both for tagged emails in articles and for the emails displayed in the user's profile. For an example check this link.

Basically there are four elements to this hack.
1. a php script to generate the image
2. an update to module.textsanitiser.php
3. an update to userinfo.php
4. an update to the userinfo template

The image generation script is pretty rough. I'm not a professional and I make no promises as to how well this might work for you. I called it swirl.php and put it in the include folder.
<?php
/* 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
*/
if (($_GET['l1'] != "")&&($_GET['l2'] != "")) {
    
$msg $_GET['l1'].'@'.$_GET['l2'];
    
// you need to make sure this font file exists
    
$font '/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf';

    if (
$_GET['l3'] != "") {
        
$size $_GET['l3'];
        if (
$size 16$size 16;
        if (
$size 8$size 8;
    } else {
        
$size 8;
    }
    
// top, right, bottom, left
    
$padding = array($size/22$size/22);

    
$textbox imageTTFBbox($size0$font$msg);
    
$textwidth abs($textbox[4] - $textbox[0]);
    
$totalwidth $textwidth $padding[1] + $padding[3];
    
$textheight abs($textbox[5] - $textbox[1]);
    
$totalheight $textheight $padding[0] + $padding[2];
    if (
$textbox[1] > $textbox[3]) {
        
$textorigin = array($padding[3], ($totalheight $padding[2] - $textbox[1]));
    } else {
        
$textorigin = array($padding[3], ($totalheight $padding[2] - $textbox[3]));
    }
    
$im imagecreatetruecolor($totalwidth,$totalheight);
    
imagealphablending($imFALSE);
    
imagesavealpha($imTRUE);
    
// Create some colors
    
$white imagecolorallocatealpha($im255255255100);
    
$grey imagecolorallocatealpha($im128128128100);
    
$black imagecolorallocatealpha($im0000);

    
// Add the text with a shadow
    
imagefilledrectangle ($im00$totalwidth$totalheight$white); # Make transparent
    
imagettftext($im$size0$textorigin[0]+1$textorigin[1]+1$grey$font$msg);
    
imagettftext($im$size0$textorigin[0], $textorigin[1], $black$font$msg);

    
// create a blank image to copy into
    
$dest imagecreatetruecolor($totalwidth,$totalheight);
    
imagealphablending($destFALSE);
    
imagesavealpha($destTRUE);
    
imagefilledrectangle ($dest00$totalwidth$totalheight$white); # Make transparent

    // make it wavy
    
$yperiod $size*3;
    
$yamp min($padding[0], $padding[2])-1;
    for (
$i 1$i $totalwidth$i++) {
        
imagecopy($dest$im$i$off$i01$totalheight);
        
$off sin($i/$yperiod)*$yamp;
    }
} else {
    
$im imagecreatetruecolor(1,1);
    
imagealphablending($imFALSE);
    
imagesavealpha($imTRUE);
    
$bg imagecolorallocatealpha($im25500125);
    
imagefilledrectangle ($im0011$bg); # Make transparent
}
header('Content-type: image/jpg');
imagepng($dest);
imagedestroy($im);
imagedestroy($dest);
?>


Next I modified module.textsanitiser.php to tie in the email tags. I haven't modified the textbox to include font size though. Users can add that manually if required. The default size 8 works well on my site.
// The following changed by Rob Stockley to include image emails
//$patterns[] = "/[email]([^;<>*()"']*)[/email]/sU";
//$replacements[] = '<a href="mailto:\1">\1</a>';
$patterns[] = "/[email]([^;<>*()"'@]*)@([^;<>*()"'@]*)[/email]/sU";
$replacements[] = '<img src="'.XOOPS_URL.'/include/swirl.php?l1=\1&l2=\2">';
$patterns[] = "/[email=(['"]?)([0-9]*)\1]([^;<>*()"'@]*)@([^;<>*()"'@]*)[/email]/sU";
$replacements[] = '<img src="'.XOOPS_URL.'/include/swirl.php?l1=\3&l2=\4&l3=\2">';


Next I had to modify userinfo.php. I chose to add a new smarty tag user_email_img to the template rather than delete teh existing code for emails. This way I can roll back the change (if required) simply by updating the template.

// added by Rob 25 May 07 to incorporate image emails
list($e_name$e_domain) = explode("@"$thisUser->getVar('email'));
$e_img '<img src="'.XOOPS_URL.'/include/swirl.php?l1='.$e_name.'&l2='.$e_domain.'">';

if (
$thisUser->getVar('user_viewemail') == 1) {
    
$xoopsTpl->assign('user_email'$thisUser->getVar('email''E'));
    
$xoopsTpl->assign('user_email_img'$e_img); //added by Rob
} 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''E'));
            
$xoopsTpl->assign('user_email_img'$e_img); // added by Rob
        
} else {
            
$xoopsTpl->assign('user_email''&nbsp;');
            
$xoopsTpl->assign('user_email_img''&nbsp;'); //added by Rob
        
}
    }
}


The last change was done through the XOOPS site admin pages. Under the system templates I editted system_userinfo.html and switched to the new user_email_img tag about half way down.

I know this approach is not bullet proof but it has satisfied my users for the moment. I hope someone else finds it of use.

Rob



36
robstockley
Re: Multiple sessions - Fixed

<td id="menubar">
        <
a href="<{$xoops_url}>/">Home</a>
        <
a href="<{$xoops_url}>/modules/extcal">Calendar</a>
        <
a href="<{$xoops_url}>/modules/wfsection">Information</a>
        <
a href="<{$xoops_url}>/modules/myalbum/">Gallery</a>
        <
a href="<{$xoops_url}>/modules/xfguestbook/">Guestbook</a>
        <
a href="<{$xoops_url}>/modules/wflinks/">Links</a>
        <
a href="<{$xoops_url}>/modules/wfdownloads/">Downloads</a>
        <
a href="<{$xoops_url}>/modules/newbb/">&nbsp;Forum&nbsp;</a>
        <
a href="<{$xoops_url}>/modules/formulaire/index.php?id=2">Contact Us</a>
      </
td>


The snippet above is part of theme.html and is used twice to draw a menubar at the top and bottom of every page. When I went to hard code the index.html in I found that the two affected modules (extcal, wfsection) lacked a terminating / in their urls. Simply inserting the / fixed the problem completely.

I still can't get my head around quite why this was a problem but for now all is good.

Rob



37
robstockley
Re: Multiple sessions

One of the affected modules is extcal. If I browse tohttp://site-url/modules/extcal a new session is started, however, when to browse back to a system page or an unaffected module then the original session gets picked up.

Okay here's something very odd. If I browse tohttp://site-url/modules/extcal/index.php then everything works as normal with the original session id. In both cases I get redirected to calendar.php which suggests that index.php is in fact being executed in both cases but the context is somehow different.

Now I can hardcode the index.php part in, and I will, but why are these modules behaving this way and why only these modules? I'm guessing that the DirectoryIndex statement on the production server is what's different (can't check right now) and not a php variable afterall.

Rob



38
robstockley
Re: Multiple sessions

Hmmm here's something else strange. When I enter one of the modules directly by url/modules/module-name it tells me "Sorry, you don't have the permission ... yada yada" and then lets me in anyway. The group and module permissions say that I should be allowed in. I'm picking that this is somehow related to the session issue above. I think it must be something to do with a global variable that is either not available or available when it shouldn't be.

Using a .htaccess causes a server error. I'll try to toggle register_globals off at run time and see if that helps.

Rob



39
robstockley
Re: Multiple sessions

Quote:

snow77 wrote:
I've heard that emptying xoops_sessions table can fix things sometimes.


I heard the same and tried that already. The dual sessions are duely recreated. Hmmmm



40
robstockley
Multiple sessions

I've searched the forum and google and was surprised to find nothing of help. This is the same problem as I reported earlier in this post

Basically I transferred my site from the development server to the production one and now sessions seem to be messed up. Seven modules all create and access the regular session record in the xoops_session table. The other three modules create and use a second session record against the same IP address. In these three modules when logged in the user login block gets displayed as if the user was not logged in, however, if you click login you get taken to you profile page.

I have moved this site to three different servers without issue. It seems that the fourth one's a dud. I don't know enough about XOOPS sessions to trouble shoot this further and so I'm baffled. Could this be something to do with register_globals or some other php.ini setting?

Please share your ideas as these may help me to form a different search phrase for google.

Rob




TopTop
« 1 2 3 (4) 5 »



Login

Who's Online

257 user(s) are online (154 user(s) are browsing Support Forums)


Members: 0


Guests: 257


more...

Donat-O-Meter

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

Latest GitHub Commits