Maian Script World on Facebook Maian Script World on Twitter Maian Script World - Latest News Maian Script World on YouTube Maian Script World on LinkedIn


Please Read

You are required to register before you can post. This is via a custom verification system. 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. There are no guarantees when a reply will appear but I do my best to answer all within 3/4 days max. Bumping topics won`t make the slightest difference.

IMPORTANT: Posts in English ONLY please, thank you! Any other languages will be ignored and your message deleted.
SEARCH: Use the search option to see if your question has been answered on the forum before. Or check the relevant script docs.
CUSTOMER: If you have purchased a commercial version of any of my software, using the contact option at the licence centre ensures a faster response.
AUTO DELETION: Accounts older than 5 days, with no posts or topics, are automatically deleted. Only register if you are thinking of posting.
PRIVATE MESSAGES: Private messages are currently disabled.
LINKS: Any links posted are 'NOFOLLOW' and will not be picked up by search engines.

You are not logged in.

#1 25-07-2009 18:25:47

paranormalsos.com
Members
From: VA
Registered: 24-07-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')->setSize(80)->setRatingAsPG()->setDefaultImageAsMonsterId();

?>
<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=%sdefault=%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-07-2009 08:50:47

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,073

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 Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#3 26-07-2009 16:30:52

paranormalsos.com
Members
From: VA
Registered: 24-07-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-07-2009 16:35:50

paranormalsos.com
Members
From: VA
Registered: 24-07-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  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-07-2009 17:15:14

paranormalsos.com
Members
From: VA
Registered: 24-07-2009
Posts: 13

Re: Gravatars for Avatars (question)

YEAH!! It works :-) (I'm doing a Happy Dance)  http://paranormalsos.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-07-2009 18:26:31

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,073

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 Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#7 27-07-2009 21:45:01

paranormalsos.com
Members
From: VA
Registered: 24-07-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-07-2009 06:27:12

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,073

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 Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

Board footer

2Checkout.com is an authorized reseller of goods and services provided by Maian Script World.© 2003-2013 David Ian Bennett. All Rights Reserved | Forum: FluxBB

Privacy Policy | Refund Policy