Please read before posting on the forums:
Welcome to the Maian Script World support forums. This is the only method for FREE support. If you require assistance or your problem is urgent, think about sending a donation first. Use your descretion with donations. Don`t expect too much of my time for a dollar. :p

You are required to register before you can post. Please post any problems you are encountering here and I`ll do my best to respond as soon as I can. Please note that a reply WILL be posted to all queries, so do not double post. Finally, there are no guarantees when a reply will appear. DO NOT post here and also use the contact option. Unless you have sent a donation, this will NOT speed up the response.

IMPORTANT! Posts in English ONLY please, thank you! Any other languages will be ignored.
SEARCH! Use the search option to see if your question has been answered on the forum before.
PRIVATE MESSAGES! Do NOT contact me via the private message option for support. Your message will be ignored.
DOCUMENTATION: Did you check to see if your question has been answered already in the script documentation?
AUTO ACCOUNT DELETION: If you have an account older than 2 months, but have made no posts or started no topics, it will automatically be deleted. Only register if you are thinking of posting. Thanks.

You are not logged in.

#1 25 July 2009 19:25:47

paranormalsos.com
Member
From: VA
Registered: 24 July 2009
Posts: 13

Gravatars for Avatars (question)

Sorry to be a pest :-) LOL

I'm working on setting up gravatars in my guestbook rather then the avatars or permitting people to up load their own.

I hope it is OK to post the links & codes here if not I apologize. OK here is the link I have with my working gravatar so I know the code works I just need to find away for the code to pull the users email address from the post if they have a gravatar account then their picture will show if they don't I have it set to use the MonsterID avatars.

this is the page fetching my gravatar  http://paranormalsos.com/guestbook/inc/gravatar1.php

here is the code

***  <?php

    include_once('TalkPHP_Gravatar.php');
   
    $pAvatar = new TalkPHP_Gravatar();
    $pAvatar->setEmail('angela@paranormalsos.com')->setSiz e(80)->setRatingAsPG()->setDefaultImageAsMonsterId();< br />
?>
<img src="<?php echo $pAvatar->getAvatar(); ?>" />  ***



Here is the code for the TalkPHP_Gravatar.php

***  <?php

    class TalkPHP_Gravatar
    {
        private $m_szImage;
        private $m_szEmail;
        private $m_iSize;
        private $m_szRating;
        private $m_szDefaultImage;
       
        const GRAVATAR_SITE_URL = 'http://www.gravatar.com/avatar.php?gravatar_id=%ssize=%sdef ault=%srating=%s&default=%s';
       
        public function __construct()
        {
            $this->m_iSize = 80;
            $this->m_szRating = 'R';
            $this->m_szImage = '';
            $this->m_szDefaultImage = '';
        }
       
        public function getAvatar()
        {
            return (string) sprintf
            (
                self::GRAVATAR_SITE_URL,
                $this->m_szEmail,
                $this->m_iSize,
                $this->m_szImage,
                $this->m_szRating,
                $this->m_szDefaultImage
            );
        }
       
        public function setImage($szImage)
        {
            $this->m_szImage = (string) urlencode($szImage);
            return $this;
        }
       
        public function setDefaultImageAsIdentIcon()
        {
            $this->m_szDefaultImage = 'identicon';
            return $this;
        }
       
        public function setDefaultImageAsMonsterId()
        {
            $this->m_szDefaultImage = 'monsterid';
            return $this;
        }
       
        public function setDefaultImageAsWavatar()
        {
            $this->m_szDefaultImage = 'wavatar';
            return $this;
        }
       
        public function setEmail($szEmail)
        {
            $this->m_szEmail = (string) md5($szEmail);
            return $this;
        }
       
        public function setSize($iSize)
        {
            $this->m_iSize = (int) $iSize;
            return $this;
        }
       
        public function setRatingAsG()
        {
            $this->m_szRating = 'G';
            return $this;
        }
       
        public function setRatingAsPG()
        {
            $this->m_szRating = 'PG';
            return $this;
        }
       
        public function setRatingAsR()
        {
            $this->m_szRating = 'R';
            return $this;
        }
       
        public function setRatingAsX()
        {
            $this->m_szRating = 'X';
            return $this;
        }
    }

?>  ***

Offline

 

#2 26 July 2009 09:50:47

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 9 May 2006
Posts: 4482

Re: Gravatars for Avatars (question)

Looks like you need to pass the relevant e-mail address into the class. I can`t see which part of the code checks if an image is available. However, try this:

1. Firstly, include a link somewhere at the top of the index.php page to your gravatar class.

2. Next, open the index.php file and find line 142:

$GBentries .=  '<tr>

BEFORE that add:

$pAvatar = new TalkPHP_Gravatar();
$pAvatar->setEmail($entries['post_email'])->setSize( 80)->setRatingAsPG()->setDefaultImageAsMonsterId();
$gravatarImage = $pAvatar->getAvatar();

On line 143 find:

images/avatars/'.$entries['post_avatar'].'

Change to:

'.($gravatarImage ? $gravatarImage : 'images/avatars/'.$entries['post_avatar']).'

Try that.


David.

Maian Script World
http://www.maianscriptworld.co.uk

Offline

 

#3 26 July 2009 17:30:52

paranormalsos.com
Member
From: VA
Registered: 24 July 2009
Posts: 13

Re: Gravatars for Avatars (question)

Thank you so much!!  I'll give that a try. I love your guestbook it is the best I have seen yet & I have tried many! lol Do you have a banner that I could add at my site to link to your scripts?

Oh & it doesn't store photos it calls them from your gravatar account you can make it so it stores them in a cache or where it pulls them right from the gravatar site, lots of blog services use it like the wordpress blogs & others for comments & members That's how I found out about the gravatars and then I started added that service into my site.

Thanks again & take care,
Angela

Offline

 

#4 26 July 2009 17:35:50

paranormalsos.com
Member
From: VA
Registered: 24 July 2009
Posts: 13

Re: Gravatars for Avatars (question)

And with this...

"Looks like you need to pass the relevant e-mail address into the class. I can`t see which part of the code checks if an image is available. However, try this:" 

If the person has no gravatar account you can pick a default image or use another servers as listed in the 2nd code I posted if the person has no gravatar it will post an avatar for them like here http://paranormalsos.com/guestbook/inc/gravatar2.php&nbs p; I have it set to grab a MonsterID there are a few others to choose from but that one is best for the theme of my site :-)

Offline

 

#5 26 July 2009 18:15:14

paranormalsos.com
Member
From: VA
Registered: 24 July 2009
Posts: 13

Re: Gravatars for Avatars (question)

YEAH!! It works :-) (I'm doing a Happy Dance)  http://p aranormalsos.com/guestbook/index.php  OK Now I need to get it to show in the Preview area when signing & in the admin preview for approving messages 

also another great feature with gravatars is you can set the rating for images to be view or not viewed

Offline

 

#6 26 July 2009 19:26:31

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 9 May 2006
Posts: 4482

Re: Gravatars for Avatars (question)

Hi Angela,

Glad you like my script. smile Glad the code works. The preview option will be more difficult. If you get stuck I could help you out with a custom mod. Let me know via the contact option.


David.

Maian Script World
http://www.maianscriptworld.co.uk

Offline

 

#7 27 July 2009 22:45:01

paranormalsos.com
Member
From: VA
Registered: 24 July 2009
Posts: 13

Re: Gravatars for Avatars (question)

I got the preview OK for when people's signing the book I just have it listed as this
"  - SIGN GUESTBOOK -

We use Gravatars for our Avatars

(with a Gravatar Pic here)

if you don't have one a MonsterID will be used "

I don't have it working yet in the admin preview I was thinking I may have to call it from the temp rather than the post? or from the java scripts :-)

Offline

 

#8 28 July 2009 07:27:12

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 9 May 2006
Posts: 4482

Re: Gravatars for Avatars (question)

Its been that long since I looked at the guestbook code I can`t remember it too well. The same code will probably work in the admin area?


David.

Maian Script World
http://www.maianscriptworld.co.uk

Offline

 

Board footer

MSWorld Forum
© R. Andersson