Previous Thread
Next Thread
Print Thread
Rate Thread
#57746 06/08/2004 11:20 AM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
I have my own custom avatar solution that prevents two people from having the same avatar, but there is too much manual intervention on my part. I have an idea to cut this down quite a bit, but I need some help.

I have already modified the avatar selection popup supplied by Infopop to only be an avatar gallery of sorts, but I plan to modify it further to once again make it select and assign your avatar. The trouble is, I won’t allow two people to have the same avatar. I need to create some sort of flat file that holds the names of the avatars that are taken and have it check this file before allowing an avatar to be assigned. This is the hard part.

What would be the best format or organization for the file? Are there more efficient ways to search a file like this? Do I have to use some file locking method to prevent people from reading/writing to the file at the same time?

Or is there a better and entirely different way to solve the problem of unique avatars?


"For who would lie idle when the king has returned?"
www.MinasTirith.com
Sponsored Links
#57747 06/08/2004 1:54 PM
Joined: Nov 2001
Posts: 745
Admin Emeritus
Admin Emeritus
Offline
Joined: Nov 2001
Posts: 745
What about forcing all users accounts to have a custom avatar URL such as http://www.domain.com/avatars/00000000.cgi where 00000000 is the member number of the user. Then don't allow users to change the avatars. Then you just drop in the avatar in the directory.

#57748 06/08/2004 2:42 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
I'm not sure what 00000000.cgi would do, but it seems like there would still be a lot of manual intervention on my part. I don't want to have to do anything except put approved images in the avatar directory.

Here is my modified avatar selection page . It only displays every image in the avatar directory and displays that person's profile when you click it.

What I would like to do is keep this functionality, but add to it to allow you to change your own avatar. I see a set of buttons/links that allow you to filter the display to show either taken avatars, not taken, or both. There might be a colored border around each image that signified whether the image was taken or not. If you clicked on a taken image, it would still display that person's profile. If you clicked on one that was not taken, it might pop up and ask you if you are sure and then change your avatar to that image.

An image is either taken or it is not, so there would be no duplicate avatars.

BTW, I use Custom Field #1 for my avatar field. I had my own custom solution in place before avatars were available and I stuck with it once I saw that I couldn't use Infopop's feature in the way I wanted.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
#57749 06/08/2004 3:03 PM
Joined: Nov 2001
Posts: 745
Admin Emeritus
Admin Emeritus
Offline
Joined: Nov 2001
Posts: 745
I was using 00000000 as an example. Replace with your member number.

Hmmm...that would be a serious hack to do what you are looking for.

#57750 06/08/2004 3:36 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
I know 00000000.cgi was an example! OMG! But what does it do? Your first post wasn't exactly clear on exactly what you propose.

I was hoping that someone with some experience with hacks that read and write to external files would give me some advice. For instance, LK has to read and write to a file with his Calendar. I have yet to examine his code, but I imagine he somehow locks the file so only one person can write to it at once.

That's probably the only serious part. Setting your avatar by clicking it is not a big deal and the rest is a cakewalk.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
Sponsored Links
#57751 06/08/2004 4:52 PM
Joined: Nov 2001
Posts: 745
Admin Emeritus
Admin Emeritus
Offline
Joined: Nov 2001
Posts: 745
I mistakenly put .cgi instead of .jpg/.gif, etc.

Old habit.

#57752 06/08/2004 5:08 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
Ahh, actually, that is similar to what I do now, although the filename I use is avatar00000.gif. The big problem is that I have to rename and move each file whenever they want to add / change their avatar. If this is their first avatar, I also have to edit their profile manually through the CP.

Needless to say, the job has gotten increasingly more labor intensive and frankly I'm so behind that I don't want to do it anymore.

If I get some schooling on files, I could whip this mod into shape and get this monkey off my back.

Oh, another addition to the mod would be to not allow avatars to people who haven't passed the "new user" posting threshold (100 posts on my site). Don't want to see people who don't plan on sticking around hogging all the good avatars.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
#57753 06/08/2004 6:56 PM
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
You woudn't consider them linking to their own from somewhere else?


- Allen wavey
- What Drives You?
#57754 06/08/2004 9:54 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
I care enough about the look and feel of my site to not allow the chaos of linked avatars.

I also have two members who have dedicated themselves over the years to creating hundreds of avatars choices within the required theme and size restrictions. If anyone has a custom request, they work with them to create one to their liking. This hoard of avatars should be more than enough choice for any serious member of the site.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
#57755 06/10/2004 11:59 AM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
I no one has any advice for reading and writing to a flat file, perhaps those more familiar with the mods here can suggest a few besides LK's Calendar that use these files.

I'll just have to learn what I can from those.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
Sponsored Links
#57756 06/18/2004 12:10 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
I really need some advice on how to read and write to a file. I don't know where to begin.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
#57757 06/18/2004 12:32 PM
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
$ted = &OpenFileAsString("file_path/file_name");

&WriteFileAsString("file_path/file_name", $ted);

#57758 06/18/2004 5:38 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
Is that the best way to accomplish what I want to do?
Code
$ted = &OpenFileAsString("file_path/file_name");
That would put the entire contents of the file into $ted, right? This seems like it would be unwieldly to try to search.

And when writing, I have to modify $ted and then overwrite the entire file each time?

I guess I expected to read and write only the line of the file I needed. As far as making sure that no one takes the same avatar, I'll have to search the file again right before I write to it to make sure no one else has written to it in the mean time.

I thought it would be more complicated, with having to lock the file, having to search the file for a particular line and then writing to a specific line of that file. I guess I could just keep it simple and see how it goes.


"For who would lie idle when the king has returned?"
www.MinasTirith.com
#57759 06/18/2004 8:46 PM
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
@ted = &OpenFileAsArray("file_path/file_name");

#57760 06/22/2004 11:01 PM
Joined: Nov 2001
Posts: 96
Member
Member
Offline
Joined: Nov 2001
Posts: 96
Since the file is very simple (consisting of only the filename and the user #), I was thinking of using a hash with the filename as the key and the user # as the value.

I could find, add and remove items fairly easily, from what I'm learning about PERL.

Am I barking up the wrong tree?


"For who would lie idle when the king has returned?"
www.MinasTirith.com

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)