Author Topic: Webpage Dice Roller  (Read 1694 times)

Offline Ros

  • Level 4
  • *
  • Posts: 13
  • Reputation: +0/-0
    • View Profile
Webpage Dice Roller
« on: December 02, 2008, 08:23:40 AM »
Out of curiosity, does anyone know of a webpage or a code that lets you roll dice, perhaps with a simple registration system, and it just lists the rolls on the page, maybe with the ability to make notes?

I want to use a dice roller on a free forum host, but most of the mods for free forums are easily hacked.

Offline raestlyn

  • Level 29
  • **
  • Posts: 464
  • Reputation: +9/-5
    • View Profile
Re: Webpage Dice Roller
« Reply #1 on: December 02, 2008, 09:15:56 AM »
You'll find one in here: http://www.hotscripts.com/search?q=dice&cat=PHP&imageField.x=36&imageField.y=14

Hotscripts is THE site for things like this..


I can send you pics of my cocks if you want reference.


Offline Ros

  • Level 4
  • *
  • Posts: 13
  • Reputation: +0/-0
    • View Profile
Re: Webpage Dice Roller
« Reply #2 on: December 03, 2008, 06:15:22 PM »
Ah, no, that's not quite what I was looking for.  I want something that records the rolls permanently, like a blog.  There are lots of plain dice rollers out there, but I only found one that kinda did this, and it didn't work too well.

Offline raestlyn

  • Level 29
  • **
  • Posts: 464
  • Reputation: +9/-5
    • View Profile
Re: Webpage Dice Roller
« Reply #3 on: December 04, 2008, 04:46:23 AM »
Fine, I'll do one for you when I get back home from work.


I can send you pics of my cocks if you want reference.


Offline Qwerty

  • Level 12
  • *
  • Posts: 90
  • Reputation: +0/-0
    • View Profile
Re: Webpage Dice Roller
« Reply #4 on: December 04, 2008, 11:27:17 AM »
Well a dice shows a number from 1 to 6 so you could just use this function: rand(1, 6);

And if you want to store the dice roll, assign that to a variable, then run a insert query on a database or store it in a file.
- "I sentance you to life"
- "You moron I'm already alive"

Offline raestlyn

  • Level 29
  • **
  • Posts: 464
  • Reputation: +9/-5
    • View Profile
Re: Webpage Dice Roller
« Reply #5 on: December 04, 2008, 12:23:30 PM »
Code: (dice.php) [Select]
<?php
$db 
mysql_connect("hosts_name""user_name""password") or die("Could not connect.");
if(!
$db
die("no db");
if(!
mysql_select_db("database_name",$db))
 
die(mysql_error());

if(isset(
$_POST['roll']))
{
$dice=rand(1,6); //change the range if you want bigger dice, like d20
echo "You rolled $dice with your Dice.<br />";
mysql_query("insert into dice (dice) values ('$dice')") or die(mysql_error());
?>

<br />Click Roll to roll a dice
<br />
<form method="post" action="dice.php">
<input type="submit" value="Roll">
</form><?php
$results
=mysql_query("select * from dice order by id asc") or die(mysql_error());
echo 
"Your previous rolls:<br />";
while(
$result=mysql_fetch_array($results)){
echo 
"$result[id]: Your rolled $result['dice'].<br />";
?>


There you go, simple as possible dice roller with saving option.

You only need to do one simple table in the database:
Code: [Select]
CREATE TABLE dice (
  id int(11) NOT NULL auto_increment,
  dice int(11) NOT NULL,
   PRIMARY KEY  (id)
)
Have fun with it.


I can send you pics of my cocks if you want reference.


Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Re: Webpage Dice Roller
« Reply #6 on: December 04, 2008, 12:53:54 PM »
I made a captcha using dice:

http://www.duo-designs.net/?content=contact

Refresh the page for new rolls.


Offline Scion

  • Level 27
  • **
  • Posts: 402
  • Reputation: +11/-0
    • View Profile
Re: Webpage Dice Roller
« Reply #7 on: December 05, 2008, 02:24:16 AM »
nice....but um...at the risk of saying something you already know....

<img src = 'images/die1.jpg' alt = 'Dice'/>
<img src = 'images/die4.jpg' alt = 'Dice'/>
<img src = 'images/die4.jpg' alt = 'Dice'/>
<img src = 'images/die3.jpg' alt = 'Dice'/>

The problem with using a captcha made from composite images is that the image file name often provides a very simple way to decode the value in the image....

On a 'Contact Us' form this is fine, especially if its a one off....in fact rolling a custom hand made captcha even one using named images like this is probably more successfull at blocking spambots that using a readymade widely distributed one.

But for a game, it wont take long for the script kiddies to bypass it...

but the dice rolling script gives me a nice idea for a javascript client side effect.... you know when you roll a dice it starts off with the numbers spinning over fast slwoly slowing down till the one face up is displayed....how about a javascript snippet that displays a bunch of random values before finally settling on the random number generated by the server...

maybe if i get some spare time this afternoon.....or during lunch....



Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Re: Webpage Dice Roller
« Reply #8 on: December 05, 2008, 02:48:20 AM »
On a 'Contact Us' form this is fine, especially if its a one off....in fact rolling a custom hand made captcha even one using named images like this is probably more successfull at blocking spambots that using a readymade widely distributed one.

That was my thinking, I was more interested in seeing if I could come up with a more original idea for a captcha than anything that would be very effective.  I know it has a major flaw.

Offline Tribal

  • Level 22
  • *
  • Posts: 256
  • Reputation: +1/-1
    • View Profile
Re: Webpage Dice Roller
« Reply #9 on: December 10, 2008, 06:06:08 PM »
I quite like the idea to be honest.

A really quick simple way around the image problem.

images/dice.php
Code: [Select]
<?php

// Random number between 1 and 6
$dice rand(1,6);

// Display the image.
$image imagecreatefromjpeg("images/dice".$dice.".jpg");

header('Content-Type: image/jpeg');

imagejpeg($image);

?>


To be honest, you could probably get away with using one dice image, and then having: if got wrong more than 4 times block ip. That way a machine couldnt do a "number dictionary" attack on it.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal