|
Avatars: A Proposed Solution
StoreTags: greasemonkey, avatar, avatard, hack
Viewed 4065 times. 11 people liked this blog. You can rate it below if you haven't already.
People who enjoyed reading this: owl, energygiant, mlbot, monty, cbit, frnortnr, utofbu, quicks, Roshi, airliner, adcBicycle
-->
I know a lot of us miss avatars, myself included. They added a lot of enjoyment to the site. So I thought of a workaround.
When I was going to sleep last night, this came to me. Let me preface this by saying that I have never used greasemonkey, whether for running other people's scripts or for writing my own, so perhaps this was written prematurely, but I would like to get the gears turning on this issue again.
Ingredients:
-greasemonkey script.
AND(
(
-a ftp server on which to host the avatars
-some system where users can have a password for uploading or something
)
OR
-a centralized list that points to filenames on other servers (probably slower)
)
Again, I haven't used greasemonkey so I don't know the particulars, but wouldn't it be a matter of (similar to the P___L - banning script):
METHOD 1:
-getting the username from a post
-instead of blocking the post, insert an img src tag based on username
METHOD 2:
-getting the username from a post
-loading the list of references to images, and choosing an image based on username
-insert an img src tag for that image
It seems like this could be done in greasemonkey...right?
I guess I'll look into this on my own.
Some of the advantages of this option are:
-we don't whine to Bogdan for anything
-people who don't care about avatards can just skip on downloading the script
-we don't have to be restricted by the original file size, format limitations (though they are pretty good and we should probably stick to them or something similar)
Disadvantages:
-slower than if avatards were integrated into the site again
-managing the uploading of files would be more tricky
-is going to take up some bandwidth on someone's server
What do you guys think? I think I'd be willing to learn greasemonkey if no one else is interested, and as I'm more confident in my PHP/MySQL skills, I'd probably be willing to offer up some webspace and make a simple interface for uploading.
| |
Comments
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
Well, if you have blacklist enabled, you wouldn't even see so called porn avatars.
You also might want to look into autosizing graphics server side or rejecting avatars above a certain size.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
Actually, duh. If you had a lookup table implemented that added just added a url tag to the html code, everybody could host their own avatars.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
I guess it depends on how much control you are willing to give up.
Sorry for the nonsensical multiple posts.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
mlbot
between jdg and myself, I think we have enuff avatars to supply all of em411.
You just hafta choose, who do I wanna be, jdg or mlbot? Well, i think the answer to that is fairly obvious.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
jdg
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
license
I think I like the lookup table idea better, because that would decentralize the traffic. the caveat being that 1) it is almost definitely going to load more slowly with requests going to several servers and 2) some people don't have webspace.
I was also wondering about resizing images. Does anyone remember whether Bogdan's resize method was to make separate thumbnails, or to simply specify a new width/height for the original image?
Another thing - to be honest, I'm an OK coder but I'm really insecure about my computer science vocabulary. Some terms I'm a little foggy on:
-caching
-requests (I assume this means a request to retrieve a resource from a server? and the "multiple requests" issue discussed is in reference to the list?)
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
license
ooh, that's great jdg. random selection of one of those images should be part of the script.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
license
(for default userimages)
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
I seem to remember if it didn't fit the dimension reqs, it wouldn't get uploaded.
A request is basically a message (sometimes from a server, sometimes from the browser client) to request information from the server...all webservers respond to requests...it's how the internet works.
Caching is just the saving of information to allow easy loading. Here we're talking browser side cache, so the servers are not hit over and over again.
Here's how I would see how a lookup table would work in Pseudocode:
parse user names into array a from page
for each user u in array a
request url for user u from server
write image tag
end
Should be fairly simple. You will probably have to write up a little lookup php script on your end so that sending a request such as
http:/yourserver.net/lookup.php?value=mlbot
will return the proper url to the javascript such as
http:/mlbotsucks.com/images/mlbotispoo.png
Or something like that.
Cbit, please tell me if I'm full of crap. I don't do web programming as much as you do.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
license
If you mean "caching" by what I think you mean, then that would mean storing the necessary users in an array before making a request.
Again, excuse any liberties taken with terminology and please correct me.
So I will take some notes publically:
-maximum of 16 avatards per page (including blog poster/thread starter)
-would a simple GET request work? for example ?u1=poop&u2=potatoes&u3=horsey&u4=disastrato ... this could then return XML or just a simple list of images. how long is GET allowed to get?
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
Caching is just saving information already requested client side. Things such as graphics, etc. So you don't have to request them.
Yes, that should work. I haven't used php in a long time, but I believe you can pass an array of values by naming all of the variables the same name.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
license
2 specific questions:
-what is the maximum allowed length of a username?
-what is the maximum allowed length of a GET string?
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
link
The POST and GET variables are superglobals. There is no theoretical limit to them, though you can't really have a 5GB variable if you only have 2GB of RAM (incl. swap).
However, PHP DOES limit the size of each request based on settings in the php.ini file. PHP also allows you to set the maximum amount of memory consumed by each child. So if you have limited each request to 50MB, then you've got nearly 50MB of data that could be in your $_POST superglobal, but some of it is taken up by the HTTP headers sent by the users browser.
An HTTP GET request passes through the URL (if you didn't already notice) and each browser DOES have a limit to how long a URL can be. IE is 2083 characters, Opera is about 4,050 characters, Netscape 6 about 2,000 characters. There is no limit imposed in the RFC, though you are recommended to avoid depending on URLs over 255 characters.
HTTP POST requests are sent differently, though, and don't have nearly as many restrictions. One that is taken advantage of quite frequently is the fact that binary data can be sent...so you can easily upload non-ascii files.
BTW, most browsers just ignore the maxlength field, and it's really really really really easy to circumvent, so I wouldn't recommend trusting it. You can't trust file extensions, mimetypes, or anything else coming from the browser either. It's a pretty daunting task to do a secure file upload. I can upload a BASH script to a website with any extension using sockets to specify the mimetype as an image/jpeg and then execute it if they don't have the proper checks in place and permissions set.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
Roshi
I think you should be ok both in terms of GET request and maximum username length.
06/27/07
+
PM |
QUOTE |
PERMALINK |
REPORT
license
cool, cos I think I'll only need (4 + maxlen) * 16. and I doubt every username is going to be 12+ chars, especially with how often you, jdg and mlbot post (5 chars, 3 chars and 5 chars) 
Register / login
|
^
EM411 is Copyright 2001-2008 EM411.com
All rights reserved. | Contact | RSS
|