Name: Member Profile Email Image

Version: 1.1

Last modified: 31/03/2009 @ 05:30 (GMT)

Description:
This modification will replace the e-mail address in member profiles with an image.
All email (mailto:) links will now link to the member profile to prevent bots from finding them.
The email image uses the same colors as the theme being used to make it blend in with the page.
The email image will also use the same font as the theme (Provided the font '.ttf' file is uploaded to the 'fonts' directory.
There are a few common fonts included with the download (Verdana, Arial, Tahoma).

Compatibility: XMB v1.9.8 SP3

Tested On: XMB 1.9.SP3

Code Developed By: Adam Clarke (http://www.xmbservices.com)

MOD History: V1.0 (29/11/2005 @ 23:00) - Initial Release.
                         V1.1 (30/11/2005 @ 20:00) - Updated image function to check $uid is a number to prevent SQL injection.
                         V1.1 (30/04/2006 @ 05:40) - Removed a forward slash at the beginning of the img tag for member_profile_email template that was preventing the image from displaying.
                         V1.1 (31/03/2009 @ 05:30) - Updated for XMB 1.9.8 SP3

License Note: This modification is released under the GPL License.

Note: Backup all affected files, templates & database's.

Affected Files (4): member.php, misc.php, viewthread.php, English.lang.php

Affected Templates (3): member_profile_email, misc_mlist_row_email, viewthread_post_email




====================================================================================================
STEP 1: Edit File 'member.php'

Find Code:
----------------------------------------------------------------------------------------------------

    case 'coppa':
        if (X_MEMBER) {

----------------------------------------------------------------------------------------------------

Add Code Above:
----------------------------------------------------------------------------------------------------

// Member Profile Email Image Mod Begin
if ($action == 'emaildisplay') {
    $imagestring = '';
    $uid = (isset($uid) && is_numeric($uid)) ? (int) $uid : 0;
    if ($uid > 0) {
        $query = $db->query("SELECT email, showemail FROM $table_members WHERE uid = '$uid'");
        $result = $db->fetch_array($query);
        $db->free_result($query);
        if($result['showemail'] == 'yes') {
            $imagestring = $result['email'];
        }
    }

    if (@function_exists("imagecreate")) {

        // Lets load the theme font's for the image.
        $imgfonts = explode(',', strtolower($THEME['font']));
        while (list($key, $value) = each ($imgfonts)) {
            $tempfont = trim(strtolower($value)) . '.ttf';
            if(file_exists('fonts/' . $tempfont)) {
                $imgfont = 'fonts/' . $tempfont;
                break;
            }
        }

        if (!isset($imgfont)) {
            $imgfont = 'fonts/verdana.ttf';
        }

        $fontwidth = @imageFontWidth(5);
        $fontheight = @imageFontHeight(5);
        $textwidth = $fontwidth*strlen($imagestring);
        $textheight = $fontheight;

        $imgheight = $textheight+2;
        $imgwidth = $textwidth+2;
        $textposh = ($imgwidth-$textwidth);
        $textposv = $imgheight - 5;

        $im = @imagecreate($imgwidth, $imgheight);

        $bg_red = "0x" . substr($THEME['altbg2'], 1, 2);
        $bg_green = "0x" . substr($THEME['altbg2'], 3, 2);
        $bg_blue = "0x" . substr($THEME['altbg2'], 5, 2);

        $text_red = "0x" . substr($THEME['tabletext'], 1, 2);
        $text_green = "0x" . substr($THEME['tabletext'], 3, 2);
        $text_blue = "0x" . substr($THEME['tabletext'], 5, 2);
 
        eval("\$background_color = imagecolorallocate(\$im, $bg_red, $bg_green, $bg_blue);");
        eval("\$text_color = imagecolorallocate(\$im, $text_red, $text_green, $text_blue);");

        @imagecolortransparent($im, $background_color); 

        @imagettftext($im, 8, 0, $textposh, $textposv, $text_color, $imgfont, $imagestring);


        @header("Content-type: image/png");
        @imagepng($im);
        imagedestroy($im);
        exit;
    } else {
        @header("Location: ./images/pixel.gif");
    }
}
// Member Profile Email Image Mod End

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 2: Edit File 'misc.php'

Find Code:
----------------------------------------------------------------------------------------------------

            while($member = $db->fetch_array($querymem)) {
                $member['regdate'] = gmdate($dateformat, $member['regdate'] + $adjTime);

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

            while($member = $db->fetch_array($querymem)) {
                // Member Profile Email Image Mod Begin
                $encodename = rawurlencode($member['username']);
                // Member Profile Email Image Mod End
                $member['regdate'] = gmdate($dateformat, $member['regdate'] + $adjTime);

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 3: Edit File 'viewthread.php'

Find Code & Delete:
----------------------------------------------------------------------------------------------------

            $encodename = recodeOut($post['author']);

----------------------------------------------------------------------------------------------------


Find Code:
----------------------------------------------------------------------------------------------------

        if ($post['author'] != 'Anonymous' && $post['username']) {

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

        if ($post['author'] != 'Anonymous' && $post['username']) {
            // Member Profile Email Image Mod Begin
            $encodename = recodeOut($post['author']);
            // Member Profile Email Image Mod End

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 4: Edit File 'lang/English.lang.php'

Add To End Of File:
----------------------------------------------------------------------------------------------------

// Member Profile Email Image Mod Begin
$lang['email_image'] = "Spam Prevention by XMB Services";
// Member Profile Email Image Mod End

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 5: Edit Template 'member_profile_email'


Find Code:
----------------------------------------------------------------------------------------------------

<a href="mailto:$email">$email</a>

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

<img src="member.php?action=emaildisplay&uid=$memberinfo[uid]" alt="$lang[email_image]" title="$lang[email_image]" />

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 6: Edit Template 'misc_mlist_row_email'


Find Code:
----------------------------------------------------------------------------------------------------

<a href="mailto:$member[email]">

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

<a href="member.php?action=viewpro&amp;member=$encodename">

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 7: Edit Template 'viewthread_post_email'


Find Code:
----------------------------------------------------------------------------------------------------

<a href="mailto:$post[email]">

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

<a href="member.php?action=viewpro&amp;member=$encodename">

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 8:

Upload included 'fonts' directory to your forum directory.
====================================================================================================




====================================================================================================
STEP 9:

Upload font files to the 'fonts' directory if you want the font to be the same as your theme(s).
The file must have a '.ttf' extension.
====================================================================================================
