Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Mod Name / Version: Raffle Winner

Description: Just is my rendition of a random Raffle Winner Modification based on ideas and posts here at ThreadsDev.

This modication picks a random winner based on the amount of posts you enter and a date to start the contest on.

The Picked winner chosen will have to be active on your board because the date you choose means they will have to be on your board and posted since that date and have greater than the posts you enter. Also the user can not be an admin or mod.

I tried to do this up based on everyones suggestions. More checkboxes can be added and things adjusted so let me know.

Working Under: UBB.Threads 6.2-6.3-6.4

Mod Status: Finished

Any pre-requisites: None

Author(s): Omegatron

Date: 11/24/03

Credits: DeeJay, Gardener and Photopost

Files Altered: N/A

New Files: N/A

Database Altered: No

Info/Instructions: N/A

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.
Attachments
100359-raffle.txt (0 Bytes, 65 downloads)

Sponsored Links
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Screenshot posted
Attachments
100378-raffle.jpg (0 Bytes, 36 downloads)

sf49rminer #263437 11/24/2003 8:58 PM
Joined: Jan 2003
Posts: 338
Enthusiast
Enthusiast
Offline
Joined: Jan 2003
Posts: 338
[b]I wrote "100" i second row and in first "2001-02-02" and this script found user

My forum was found in 2002-11-12, so what this script do???????????? Explain me, please.

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
The date means that it picks one user among those who have posted at least once since the given date so if you set a date older than when your board started it will choose among all users.

c0bra #263439 11/24/2003 9:42 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Exactly the winner will not be admin mod but any other user in any other group and they will have to have posted since the date you enter and have at least how many posts you specify. This helps cut out the people who register and are not true members but lurkers. It just picks a purely random user for any raffles or prizes you are giving away.

Sponsored Links
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
It will not pick users who have anything written in the second extra field, why is that?

Also, I think it gives users one ticket for each post they've made, is this really how it is supposed to be? And if so, a checkbox to select only to let each user count once.

I also added a count to show how many users were in the draw, to set my mind at ease about setting the right parameters.

I changed the query code to this:
Code
<br />    $query = "SELECT COUNT(DISTINCT u.U_Username) FROM w3t_Users AS u<br />        LEFT JOIN w3t_Posts AS b ON b.B_PosterId=u.U_Number<br />        WHERE u.U_LastOn > UNIX_TIMESTAMP('$date') AND u.U_TotalPosts > '$posts' AND b.B_Posted > UNIX_TIMESTAMP('$date') AND u.U_Status != 'Banned' AND u.U_Status != 'Administrator' AND u.U_Status != 'Moderator' ORDER BY RAND() LIMIT 1";<br />    $sth = $dbh -> do_query($query);<br /><br />   list ($count) = $dbh -> fetch_array($sth);<br /><br />    $query = "SELECT DISTINCT u.U_Username FROM w3t_Users AS u<br />        LEFT JOIN w3t_Posts AS b ON b.B_PosterId=u.U_Number<br />        WHERE u.U_LastOn > UNIX_TIMESTAMP('$date') AND u.U_TotalPosts > '$posts' AND b.B_Posted > UNIX_TIMESTAMP('$date') AND u.U_Status != 'Banned' AND u.U_Status != 'Administrator' AND u.U_Status != 'Moderator' ORDER BY RAND() LIMIT 1";<br />    $sth = $dbh -> do_query($query);<br /><br />   list ($username) = $dbh -> fetch_array($sth);<br />


And changed the printing to this:
Code
<br />The Winner is<br /><br /><font size="3"><b>$username</b></font><br /><br /><br /><br /><br />There were <i>$count</i> users matching your criteria.<br />

c0bra #263441 11/25/2003 5:04 AM
Joined: Jan 2002
Posts: 674
Junior Member
Junior Member
Offline
Joined: Jan 2002
Posts: 674
How about a box for a specific thread? so if they post to a certain thread they will be entered. Great program... also might want to include the link to the admin menu in the directions.. Great job chuck

Kelly #263442 11/25/2003 7:34 AM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Gardener,

Probally just me messing with too many variables and meshing different things together.

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Making two queries like in my example isn't good either, since it goes through all posts since the given date twice it'll take some time if it's too far back in time. I think it should be possible to get a count somehow with only one query though I can't think of it right now. Of course, it could select all names and just choose the name in the php code as Michaels version does it.

Also, I tried adding a select box for different groups, but threads 6.1 fuds up arrays in posts so I didn't bother finishing it. Should work in later versions with get_input() I hope.

Code added above html:
Code
<br />// --------------------<br />// Get a list of groups<br />   $query = "SELECT G_Id, G_Name from {$config['tbprefix']}Groups ORDER BY G_Name ASC";<br />   $sth = $dbh -> do_query($query);<br /><br />   $groupoptions = "";<br />   while (list ($gid, $gname) = $dbh -> fetch_array($sth) ) {<br />          $groupoptions .= "<option value='$gid'>$gname</option>\n";<br />   }<br />


New table row, added above the submit button table row:
Code
<br /><tr><br /><td valign="top"><br />   Select users from the following groups:<br /></td><br /><td><br /><select name="groups[]" size="5" multiple="multiple"><br />$groupoptions<br /></select><br /></td><br /></tr><br />


There is no code for reading the info, since that didn't work on 6.1, but if anyone wants to do it, they have something to start with.

Selecting users who have posted in a thread sounds like a good idea too, although I'm not sure how it would be done. Adding a link to all threads where you can click to select a winner from those who have posted to it?

c0bra #263444 11/25/2003 11:38 AM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
yeah thats where I was went wrong. I tried to combine too many ideas into one thing and did not double check myself

I will look at your double query and see what I can do.

Sponsored Links

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
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,575
Posts293,930
Members13,823
Most Online6,139
Sep 21st, 2024
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-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)