icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.
Old July 1st, 2007, 2:04 AM   #1 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,544 posts
Gave thanks: 91
Thanked 49 times
PHP Random Text

Well, I've been checking via Google and such, but there is no help... either has information on random numbers or inefficient ways to make random things...

Anyone have a simple, easy customize, php code for randomly displaying text (changes on reload)? I might just go java...
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 1st, 2007, 2:07 AM   #2 (permalink)
Skittles
Super #1
 
DewKnight's Avatar
 
Joined in Aug 2004
Lives in a space ship
Hosted on dedi
6,723 posts
Gave thanks: 98
Thanked 190 times
what kind of text are you looking to display? If you have like a few phrases, I would say just use a switch and a random number to pick one to display or use.
__________________
Mountain Dew Knight
People should not be afraid of their governments. Governments should be afraid of their people.
DewKnight is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 1st, 2007, 3:07 AM   #3 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,219 posts
Gave thanks: 18
Thanked 86 times
Here's what I use to spit out a 5 character image from randomly generated text. You could probably put the chr(rand(48,126)) part inside a loop to generate however many characters you needed and dump all the image stuff and just echo out $code if all you wanted was the text.

PHP Code:
<?php
    session_start
();
    
// generate random characters and output it as an image

    
$code chr(rand(48,126)).chr(rand(48,126)).chr(rand(48,126)).chr(rand(48,126)).chr(rand(48,126));
    
$im = @imagecreate(6020) or die("Cannot Initialize new GD image stream");
    
$background_color imagecolorallocate($im255255255);
    
$text_color imagecolorallocate($im2331491);
    
imagestring($im433,  $code$text_color);
    
//imagepng($im);
    
$_SESSION['code'] = $code;
    
header("Content-type: image/gif");
    
imagegif($im);
    
imagedestroy($im);
?>
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 1st, 2007, 7:30 AM   #4 (permalink)
Yabadabadoo
Super #1
 
Geoff's Avatar
 
Joined in Nov 2004
Lives in B.C., Canada
Hosted on Dedicated
1,013 posts
Gave thanks: 7
Thanked 28 times
wait, are these set phrases that you want to display randomly? or you just want a random word showing up much like a bot-deterant thing
__________________
Geoff Ellis - Surpass Dedicated Server Customer
www.adepttechs.net
Geoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 2nd, 2007, 6:16 PM   #5 (permalink)
wgm
Registered User
Super #1
 
Joined in Mar 2005
Lives in Washougal, WA
1,306 posts
Gave thanks: 23
Thanked 39 times
Hey MarkRH, could anyone use that, if so, I may if I can get my contact form up, implement that for verification, way better then what I had.

Thanks.
wgm is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 2nd, 2007, 7:02 PM   #6 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,219 posts
Gave thanks: 18
Thanked 86 times
Sure.. just include it (a separate php file) as the src of an img tag. Add a field in the form to accept input from the user.. and then check the value in the form field against the session variable. Most bots don't even request the php file and the session variable doesn't even exist.

It's in action on my guestbook. I reset my guestbook log at 10:23 this morning and 55 failed attempts so far.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 2nd, 2007, 7:24 PM   #7 (permalink)
wgm
Registered User
Super #1
 
Joined in Mar 2005
Lives in Washougal, WA
1,306 posts
Gave thanks: 23
Thanked 39 times
thank you MarkRH, plus explaining its use, this will make the form even better.
wgm is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 26th, 2007, 2:50 AM   #8 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,544 posts
Gave thanks: 91
Thanked 49 times
Thanks for the help, sorry I never replied!

I foudn a solution from using a .txt that had a word on each line. Basically, it would display a random image, but this image was made of three different ones... so a random word would define the name of the image for all three.

Thanks for the help though!
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 27th, 2007, 5:13 AM   #9 (permalink)
Surpass Fan
On a golden path...
 
Neil's Avatar
 
Joined in Oct 2004
Lives in UK
356 posts
Gave thanks: 6
Thanked 13 times
try the one here http://www.dagondesign.com/articles/...mailer-script/ it includes a full custom form as well
__________________
D17/D21/P59/P62/VPSX - "Faith can move mountains" (Faiths a big girl....) - I'm not paranoid, I know they are out to get me!
Neil is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On