topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday October 12, 2024, 1:12 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Forum Random Quotes Generator - salting your forum signature with wits  (Read 26369 times)

Wordzilla

  • Forum Search Daemon
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 470
  • Two there should be; no more, no less.
    • View Profile
    • FreeThesaurus.net - The Free Online Synonym Finder
    • Read more about this member.
    • Donate to Member
This is a php script that randomly picks out a quote from your quotes collection and display it in image format on forums (i.e. DonationCoder.com ;)). Every time a visitor views your forum profile or signature below your post, he sees a random fun quote. It's fairly customizable and super easy to use.


See it in action:

Screenshot - 14_05_2007 , 1_56_21 PM.pngForum Random Quotes Generator - salting your forum signature with wits
Screenshot - 14_05_2007 , 1_58_43 PM.pngForum Random Quotes Generator - salting your forum signature with wits


How it works

Two components powers this script:
1. Text-to-image converter, which converts a text string into image that displays in your forum signature.  (can be found in qb.zip)
2. Random quote picker, which picks out a quote from your quotes collection and feed it to text-to-image converter   (can be found in myquotes.zip)



Requirements
You need to have ftp write access to a web server that supports PHP, otherwise I'll be very happy to receive "please include this FUN quote" requests from you. ;)



Installation and Usage

1. The no-brainer way, no php knowledge required

Download myquotes.zip, uncompress and upload files to your web server (e.g. http://yoursite.com/myquotes/), add quotes to quotes.txt (sample provided), one quote per line.

Modify your forum signature to display the random quote image, by adding these lines:

[b]Random Quote:[/b]
[img]http://www.mrcody.com/qb/q.php?u=yoursite.com/myquotes/[/img]

5 mins that's all it takes to get it working. 8)


2. If you decide to hack the script...

The Text-to-image converter and Random quote picker scripts are now "sold separately" ;), for I'm reluctant to complicate things for people with no php knowledge - this way they only have to deal with one php file (which works right out of the box) and one plain text file that contains quotes.

You may want to seriously customize the script, plz feel absolutely free to do so.

Note: your web server PHP engine must be compiled with GD2 library in order for the Text-to-image converter (q.php) to work.



Customization Options

There are many url parameter that you can make use of when calling the text-to-image converter script.

f - fontname  (e.g. default)
c - color code in hex  (e.g. 000000)
b - background color code in hex  (e.g. FFFFFF)
s - line spacing   (e.g. 3) (range = 1-5)
w - image width   (e.g. 500) (range = 200-600)
pt - top padding   (e.g. 3) (range = 0 - 10)
pl - left padding   (e.g. 1) (range = 0 - 10)
a - author line spacing   (e.g. 3) (range = 0 - 10)
i - image format   (e.g. 1) (default 0 = png, 1 = gif, 2 = jpeg)

u - url, without "http://"   (e.g. yoursite.com/myquotes/)


Note: we have a few fonts available for your choice:
default
courier
iso915   (not set to as default, but also recommended)
proggyclean
proggysquare
trisk
reize


Usage:

[img]http://mrcody.com/qb/q.php?u=yoursite.com/myquotes/[/img]

[img]http://mrcody.com/qb/q.php?u=yoursite.com/myquotes/&s=3&c=999999&pt=4&f=iso915[/img]

[img]http://www.mrcody.com/qb/q.php?u=www.mrcody.com/myquotes&c=222222&b=e9f2fe&pl=3&pt=4[/img] <-- that's what i have in my forum signature.



How to add quotes to quotes.txt

One quote per line. Text is to be auto-wrapped by the script so dont worry about line wrapping. Two consecutive vertical bars || represents a hard line break.

Example:
"There is Windows ME, Windows NT and Windows CE... So we have Windows CEMENT"||-- Joto

Screenshot - 14_05_2007 , 3_17_05 PM.pngForum Random Quotes Generator - salting your forum signature with wits




Author's note:

You are allowed to download, use and modify the script in anyway you like. And as long as you don't post ASCII porn and is a member of DonationCoder.com, you are allowed to call the text-to-image converter script on www.mrcody.com for free.  :D :D

I'd really LOVE to see more dynamic fun quotes (not at all necessarily from DC members) in forum signatures here everyday!! :Thmbsup:


Grorgy

  • Supporting Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 821
    • View Profile
    • Donate to Member
 >:D >:D >:D > What a great idea, mow now for some quotes  :o

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,119
    • View Profile
    • Donate to Member
fantastic.

i've really enjoyed reading the quotes on wordzilla's posts too.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
great!  :up:

hamradio

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 881
  • Amateur Radio Guy
    • View Profile
    • HamRadioUSA.net
    • Read more about this member.
    • Donate to Member
Cool I just created a quotes file and it has been added to my signature as you can now see!  :)  :up:

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
do i understand that your running the script off mrcody, and each time a quote needs to be shown, your mycody.com hosted script re-downloads the quote file from users pc, and picks one and displays it.. each time? if so, you have reached new levels of figuring out how to slow down and kill a server, which i know personally you have been studying for the best ways to do it  :D :D :P :P

in all seriousness, if this is what you are doing you have to figure out a better way to do it, through caching, having people run php script locally, etc.  a good compromise might simply be to hash the parameter string and cache images and quote files, so that:
1) it regenerates a new image if the old one is over X minutes old.
2) it redownloads the quotes files if the old one is over Y days old.
« Last Edit: May 14, 2007, 11:33 PM by mouser »

Wordzilla

  • Forum Search Daemon
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 470
  • Two there should be; no more, no less.
    • View Profile
    • FreeThesaurus.net - The Free Online Synonym Finder
    • Read more about this member.
    • Donate to Member
Mouser, u scared me!

do i understand that your running the script off mrcody, and each time a quote needs to be shown, your mycody.com hosted script re-downloads the quote file from users pc, and picks one and displays it.. each time?

that's soooo untrue (otherwise plz rename my forum name to wordsucker  :D :D)! It fetches only a string with maximum length of 450 characters from the user server (consumes very little bandwidth). And the script on mrcody.com will stop running after 3 seconds of execution, so there's even less chance it could overload servers.

set_time_limit(3);
$len_limit = 450;

Remember the Random quote picker on the user server is responsible for picking out a single quote every time it runs.  :)

It is so designed that the user will not need PHP GD2 library on his server in order to get the thing to work (just call the text-to-image converter on mrcody.com to do the job), while offering the flexibility for him to script his own random quote generator (he may prefer getting quotes from mysql, adding more ASCII flavors to the end output quote, etc.)

Wordzilla

  • Forum Search Daemon
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 470
  • Two there should be; no more, no less.
    • View Profile
    • FreeThesaurus.net - The Free Online Synonym Finder
    • Read more about this member.
    • Donate to Member
Cool I just created a quotes file and it has been added to my signature as you can now see!  :)  :up:

Awesome! And thanks for using the script! :Thmbsup:

It's fun to read words of wisdom!  :beerchug:

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
To avoid creating a new image everytime someone sees a page which contains the signature (which i think is what is happening now), you probably should cache the image and only reload it every few minutes... This is what allen does with his imagiine, which powers my signature :)

Wordzilla

  • Forum Search Daemon
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 470
  • Two there should be; no more, no less.
    • View Profile
    • FreeThesaurus.net - The Free Online Synonym Finder
    • Read more about this member.
    • Donate to Member
Thanks for the tip jgpaiva  :)

I'm afraid caching/re-validating could be more costly in terms of sys resource usage, with this script. Because the Text-to-image converter that is hosted on dc server simple grabs a <450 chars string from user server and output a 0.5-2kb image straightaway. If the script is now required to compare text, cache/revalidate images, there'd be much work for it to do, and it still has to output the 0.5-2kb image anyway.  :)

allen

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,206
    • View Profile
    • Donate to Member
In the case of imagiine, it's considerably more pressing it be cached, I admit--imagiine has a pretty big rendering engine, does more than just spit out quotes--and it uses externally hosted quote files exclusively, so all uses of it are on the same machine -- ultimately making it a much more demanding task--some things it renders are mechanically fairly complex...



That being said, I still advocate caching--particularly for dynamic images intended for forum/signature use.  I originally shared your view, but I believe it was JG (or maybe mouser, or both) who changed my line of thinking... The big question is, are you considering scale?  If there are 10 readers viewing the post, that image has just been drawn from scratch 10 times, maybe all in the same second.  If you've posted more than one post in that thread, 10 becomes 20, 30, 40, etc.  So now, in a single moment, you have one server reading the quotes file into memory, then the rendering server retrieving the quote after downloading it from a remote server, rendering it into the image, then the image being downloaded by the client.  On the other hand, a simple mechanism to quickly check the age of the image is considerably less work for the server.  If the cached images were hosted in the location of the main script, you'd eliminate having to contact the server that hosts the quote file altogether in cases when the cached image was fresh. The entire opration would consist exclusively of checking the age of the recent cache and serving the image.  If the file was old, it would have to be re-rendered--but instead of going through the whole process of reading the quotes file, fetching it, rendering the image from scratch once for every single viewer for every instance of the image on a page... It would be done once. Just once. :)

While on the per-view scale the difference between caching and not caching is fairly negligible, the value increases with the view rate -- a DC forum post getting slash-dotted or significantly dug would make the difference between a cached random quote image and an on-demand rendered quote image nothing short of exponential.

A novel advantage to caching is everybody sees the same random quote--if someone likes a quote and exclaims as much, a shared view would make sense of that exclamation :)

Cached or not, though--great little script.  I find the way you handled remote quote files particularly fascinating.  While it's a bit more complicated for the end user to set up, it certainly decreases the amount of data that has to be exchanged between the renderer and the remotely hosted quote file.

One warning/bit of advice from my own experience--is some forum software tries to detect and filter out php scripts being used as images.  The easiest way to get around that is with mod-rewrite.  Sneaking the remote quote page into the URL, but making it ultimately look like a png, jpeg, whatever.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
A novel advantage to caching is everybody sees the same random quote--if someone likes a quote and exclaims as much, a shared view would make sense of that exclamation

I agree with this very much..  Although it may at first seem counterintuitive, i think the cacheing effect is actually quite nice, in that the same quote will be used for all viewers for some period of time (say 1 hour).  i find this more pleasing mentally than everyone seeing a new quote every time.  it makes it more enjoyable to space them out, and as allen says, it makes it nicer that everyone is seeing the same quote at the same time.

I find the way you handled remote quote files particularly fascinating.  While it's a bit more complicated for the end user to set up, it certainly decreases the amount of data that has to be exchanged between the renderer and the remotely hosted quote file.

agreed -- wordzilla is a clever little dinosaur!


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
ps it would be nice to find a handwriting font for the quotes.

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,119
    • View Profile
    • Donate to Member
ps it would be nice to find a handwriting font for the quotes.

i think the font used at the moment looks about right as the quotes are coming from irc chat sessions.

i agree that handwriting would be good for none irc text quotes.