Gossamer Forum
Home : Products : DBMan : Customization :

Using DBMan for contest entries?

(Page 1 of 2)
> >
Quote Reply
Using DBMan for contest entries?
I haven't been following the DBMan discussions of late, but I didn't find anything related to this by searching, so here goes.

Has anyone modified DBMan to be used for something like prediction contests? I'm pretty sure what I have in mind could be done without extensive modification, but there are a few aspects I'd rather not recreate the wheel if possible.

I currently run a free monthly contest where people fill out a form, along with their name and email address, and mail it. I then enter the predictions into an excel spreadsheet, check if they want to be added to the contest mailing list, and if they are not already listed on it, add them in. I set up the spreadsheet before hand to score the predictions (i.e. yes/no, time differences, winner's name, etc.) Pretty straight forward, but occasionally time consuming.

I would like to automate this process, and DBMan seems like a good candidate. Requiring a log in would offer the advantage of them being able to update their predictions throughout the month, avoiding the late-month rush of entries (when it's more clear who will compete in the events). Also, many people participate month-to-month, so they would already have an account set up.

I don't forsee any problems modifying DBMan's input form for each month, and I would be wiping out the database with each new contest, so the default.cfg setup would be modified to fit the questions for that month.

So far so good. Where I'm not quite sure how to approach is the issue of emails. I would like to keep it optional whether or not they are added to the list. What would be the easiest way to set it up to check, for example:

if $add_to_list = yes
then if $email_address not in list already
add $email_address to list

I'm sure this is pretty simple Perl... I imagine the list would have to be an addition to the current DBMan structure, as I would want to keep it separate from the user database.

Also, I'm somewhat competent in tinkering with Perl, but nowhere near where I would like to be in actually programming it. Frown

Thanks in advance for any help.

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
I almost forgot to mention -- I expect it would be easiest to continue to grade the contests in excel, after copying in the full list from the DBMan database. Excel formulas and macros are much easier to work with than what I've seen of Perl... Smile

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
Rather than shuffling email addresses back and forth, why not require a valid email address for every member sign-up (built into JPDeni's fabu secure password lookup mod) and then have an email list opt out field on sign-up? Search this forum for ideas on how to require new member sign-ups to automatically enter a user profile (which would include the opt out field), as well as realtnioal DB capabilities to cross-reference members DB with entires DB...

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)
Quote Reply
Re: Using DBMan for contest entries? In reply to
Also, look at the Web Mailer Mod that I wrote, which I released as a Beta release in this forum. I have not added it to the Resource Center...

Download the following .exe file:

www.anthrotech.com/cgi/dbman/mods/webmailer/webmailer.exe

I have modified this Mod to include a Permission Field in my database as the field to check against when sending the email message.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums



[This message has been edited by AnthroRules (edited February 18, 2000).]
Quote Reply
Re: Using DBMan for contest entries? In reply to
Hi guys, thanks for the responses.

oldmoney, I think you're talking about the same thing I had in mind. My current DBMan application uses JPDenn's password lookup mod (I think there might be a more recent version than the one I'm using), and that's what I intended on setting up for the contest db. Looking back at my first message, I guess I was a bit unclear on that... I meant to say that they will sign up for an account with a username and email address, and that it is optional whether or not they are added to the email list.

I was looking at the relational db mod for another possible application, but I hadn't considered trying it for this. Eliot's Web Mailer mod looks quite promising. I'll take a closer look at it -- excellent documentation! Smile I assume you were thinking that the database would also contain the email list? That might work quite nicely, containing everything in one package.

Is there anything I should be aware of that qualifies it as 'beta' and not a full-fledged mod?

By the way, why the new profile? It's not related to this afternoon's forum schizo episode, is it?

Thanks again for the suggestions,
Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
 
Quote:
Is there anything I should be aware of that qualifies it as 'beta' and not a full-fledged mod?

Other than testing it and seeing if it works for you...there are no reported bugs at this time. I have edited it as much as I can...The reason that I did not post it in the Resource Center is that I wanted people to test it before releasing the Mod formally...which will be my last formal Mod, BTW.

About the new profile...well, it seems that either my system's cookie files have become corrupted or Alex has deleted my Eliot account from the system...I tried doing a password lookup for my Eliot account and kept getting an error message stating that my email address was not found in the member database.

So, I created a new account.

Quote:
It's not related to this afternoon's forum schizo episode, is it?

What are you referring to...Other than the fact that I am getting worn out trying to help people and publicly stating this...I don't know what you are talking about.

Wink

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Using DBMan for contest entries? In reply to
I'll certainly give you feedback as far as testing the mod goes.

I was referring to several of the forum topics getting messed up somehow around 3pm PST. I looked at it on two different computers (totally removed from each other), and three or four of the forums were showing zero posts and no last post date. Some of the topics within them had no subject title or link. It all looks to be corrected now. I have no idea what it was...

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
 
Quote:
I was referring to several of the forum topics getting messed up somehow around 3pm PST. I looked at it on two different computers (totally removed from each other), and three or four of the forums were showing zero posts and no last post date. Some of the topics within them had no subject title or link. It all looks to be corrected now. I have no idea what it was...

OH...sorry for being defensive...I thought you were refering to me.

I am glad that I am not the only one who saw that...I think in the process some accounts must've got screwed up.

Hope that Gossamer Threads was not another victim of hacking...

Wink

Any feedback (constructive, mind you) is always welcome...and I will do my best to address any problems that you are come across...And I will also edit any codes that need to be edited before releasing it.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Using DBMan for contest entries? In reply to
No worries. I didn't mean to imply anything about you. When things went funny yesterday, I was hoping it was Alex fixing the Y2K broken cookie thing, but no such luck...

Question: I have added an email field, and I am using the un-secured password lookup mod (old one). I figure it's better for this project for a couple of reasons:

1) Allows instant log-in without having to wait to receive the email with a hard to remember password. I want to encourage people to participate, so the fewer delays the btter.

2) Without a valid email address, they cannot be contacted should they happen to win a prize. So, they have plenty of incentive to enter a valid address without the program having to verify it.

3) It's a little bit shorter! Smile

Anyway, back to the question... After the user logs in, they can either add, view, or modify their own record (predictions). Is it possible for their email address to automatically be inserted into the appropriate form field?

The input email field is currently VALUE="$rec{'email'}" and the account setup email field is VALUE="$in{'email'}". I'm sure this is quite simple, but I'm not having any luck passing the variable...

Thanks,
Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
  
Quote:
Is it possible for their email address to automatically be inserted into the appropriate form field?

Yes...it is..In the Secure Lookup Mod, Carol has provided codes that does this...

Quote:
###############################################################################
# script: db.cgi #
# sub get_email #
# #
# new subroutine #
# #
# What it does-- #
# Pulls the email address from the password file when a user adds a new #
# record. #
# How to use it-- #
# In sub html_record_form, after #
# my (%rec) = @_; #
# add #
# if ($in{'add_form'}) { #
# $rec{'Email'} = &get_email; #
# } #
# #
# Be sure to change the word 'Email' above to match exactly the name of the #
# field that holds the user's email address. #
# #
# Important!! #
# This only gets the email address for the currently logged in user. #
###############################################################################
- JPDeni

Hope this helps...

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums



[This message has been edited by AnthroRules (edited February 19, 2000).]
Quote Reply
Re: Using DBMan for contest entries? In reply to
That worked perfectly, thanks! I guess I should've just installed the secure mod afterall... Smile

Hmm, I just realized I need to come up with a way to deny duplicate entries per userid and email address. One hurdle left to go, but pretty smooth sailing thus far.

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
There is an old Thread in this forum that discusses the ability to check duplicates for two or more fields and an even older Thread in the Installation Forum that provides codes that you need to do this.

Also, the sub-routine that you will need to edit to do this...is the sub validate_record routine in the db.cgi script. (But I am sure you already know that.)

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums



[This message has been edited by AnthroRules (edited February 19, 2000).]
Quote Reply
Re: Using DBMan for contest entries? In reply to
I'm not having any luck finding the threads you mentioned... Don't suppose you remember 'roughly' when they were discussed or some keywords that would help me locate them? The closest I could find were a couple other threads referencing the old ones...

Is there a way I could just make the email field the $db_key? That's the only part I really care about it being unique. So far, all of my experiments with trying to switch the $db_key from ID to email have led to "ID cannot be left blank" errors.

Thanks,
Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
The old Thread in the Installation Forum was posted during the Summer of 1999. The old Thread in the Discussion Forum was posted as recent as three months ago.

Either use the Last Year option in the forum's drop-down menu or search the forums for "check" "duplicate" "fields".

And yes, using the Email Field would reduce duplicate records by Email...But you stated earlier that you do want to check two fields, RIGHT?

Wink

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Using DBMan for contest entries? In reply to
Whew, I finally got it!!! Smile

http://www.gossamer-threads.com/...um5/HTML/001370.html

That sounds too simple for what you were referring to, but it appears to work. I was trying to make the email field unique instead of the Userid. I would think either one would work, but I may have had the $auth_user_field wrong.

The reason I was starting to think that I could get by checking just email (or Userid, as the two are matched to each other) is that I only care that each person cannot add more than one record. The record ID# is not important in this case.

I'll have to do some testing and thinking to make sure there aren't ways for people to circumvent this system... They could always sign up with a new email address and a fake name, but the script can't be expected to catch that any better than if I were accepting entries manually.

Thanks for pointing me in the right direction.

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
This one looks more like what you were talking about:

http://www.gossamer-threads.com/...um5/HTML/001295.html

I sure hope that's the one, because my eyes have gone blurry from looking through pages of old threads...

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
The second one is the one I was thinking of.

Glad you found it.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Using DBMan for contest entries? In reply to
 
Quote:
I would be wiping out the database with each new contest
Ah, crud... Here I go and get everything working the way I want, only to realize at the last minute that I forgot about my original criteria.

When someone adds a record, their mail notification preference is stored in default.db. However, I will be deleting default.db after each contest to allow for new entries and question formatting. How hard would it be to write the mail preference to default.pass? I sort of missed it the first time around, but I believe that's what oldmoney was saying. Wink

I assume webmailer could pull from the appropriate fields in default.pass just as easily as it could pull from default.db?

Maybe it would be easiest to automatically set their mail preference to 'yes' and then have a link in the footer to turn off notification?

Thanks,
Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
Oh yeah, I ended up going with the secure password lookup mod after all. That probably makes a little difference as to what I'll need to change. I decided it would be good to allow users to modify their own email addresses and take the burden off of me having to do so...

I'm guessing the following is where I'll need to make the changes for adding the email notification field to default.pass:
Code:
#### Following line added for secure_password_lookup mod
$in{'pw'} = &generate_password;
$in{'email'} = lc($in{'email'});
# Add the userid into the file with signup permissions.
open (PASS, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($in{'pw'}, $salt);
my $permissions = join (":", @auth_signup_permissions);

#### Following line changed for secure_password_lookup mod
print PASS "$in{'userid'}:$encrypted:$permissions:$in{'email'}\n";

close PASS;
That looks pretty simple. I imagine I'll be able to find an example elsewhere in the script for modifying it, probably in the email modify routine...

Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
Dan,

I posted codes for the Mass Mailer, which is the script that Web Mailer is based on, for pulling the email address out of the default.pass file rather than the default.db file about two months ago.

Quick and dirty...

Do the following:

1) Specify the default.pass file in the following variable in the mailer.cfg file:

Code:
$db_file_name = "";

2) Specify the email field in the default.pass file as the following in the mailer.cfg file:

Code:
$mailfield = 7;

3) Leave the $confirmfield variable blank.

4) Then in the mailer.cgi file, change the following codes in the sub mailing routine:

Code:
@data = split /\|/, $line;

to the following:

Code:
@data = split /:/, $line;

Or you may have to include the escape character, like the following:

Code:
@data = split /\:/, $line;

Then edit the following codes:

Code:
if (($data[$mailfield]) and ($data[$confirmfield] eq 'Yes')) {

to the following:

Code:
if ($data[$mailfield]) {

Delete the following codes:

Code:
push (@confirm,$data[$confirmfield]);

That should do it.

Regards,

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Using DBMan for contest entries? In reply to
Thanks for posting that; it's more involved than I would have guessed.

Adding the notification default to the password file turned out to be quite easy, but getting the subscribe/unscubribe routine added in will take a bit longer... I'm thinking change_password is a better example to follow than change_email, as it's significantly shorter.

Thanks,
Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
Well, whatever works. If you want the "subscribe/unsubscribe" field and base the mailings on that...Then disregard the edits to the mailing sub that deals with deleting the confirmfield stuff. Leave it in there, but you will need to specify the field column number for the $confirmfield that you are placing in the .pass file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Using DBMan for contest entries? In reply to
Hi Eliot,

I'm having second thoughts about the direction I'm going with this... Just to clarify, with the changes you posted above, were you thinking that the webmailer script would mail to everyone in the default.pass file, regardless of their receive_mail setting?

As I look at how much will have to be changed throughout db.cgi and html.pl to incorporate the notification option into default.pass, the more I think I will just have everyone with an account receive mail...

If I were to do that, I would need to give people the option of deleting their account in order to opt out of receiving email. I found this thread which is somewhat related:

http://www.gossamer-threads.com/...m12/HTML/001132.html

but it seems more geared toward deleting a record. With my setup, they may or may not have a record to delete when they delete their id/password. I currently have "delete record" disabled, which would keep that mod from being accessible, but I don't see any reason why I couldn't enable it.

What I'm looking for is more along the lines of:

http://www.gossamer-threads.com/...m12/HTML/001070.html

i.e. delete an account (id/password) and then a record if there is one corresponding to the userid. Can the Auto Deletion Mod accomplish this?

Thanks,
Dan
Quote Reply
Re: Using DBMan for contest entries? In reply to
Dan,

I think you have found a better route...which is to delete the record and corresponding record. A clear solution has not been identified, but you could use the Thread that you found as a starting point.

BTW: The auto-deletion Mod that Carol wrote and I adapted to work with Cron only works with the default.db and does not delete associate records in other database files, like the default.pass file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 28, 2000).]
Quote Reply
Re: Using DBMan for contest entries? In reply to
I've sort of stalled out here... Setting up the section to delete .db records and corresponding .pass accounts wasn't a problem. However, I haven't managed to make it possible to delete a .pass account if there is not a .db record for that userid.

It seems like I should be able to use this section from sub admin_display in db.cgi:
Code:
# If we've been passed in delete, then we are removing a user. Check
# to make sure a user was selected then try and remove him.
$in{'delete'} and do {
unless ($in{'username'}) {
$message = "No username selected to delete.";
last CASE;
}
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@lines = <PASS>;
close PASS;

open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
my $found = 0;
foreach $line (@lines) {
($line =~ /^$in{'username'}:/) ?
($found = 1) :
print PASS $line;
}
close PASS;
$found ?
($message = "User: $in{'username'} deleted.") :
($message = "Unable to find userid: $in{'username'} in password file.");
last CASE;
};
I think the difficulty lies in how to pass the userid to that routine and how to tie it into the other part which first deletes the record, then the account. Optimally, it would check the first part -- delete the record then the account (I'll post it below so it's easier to follow) -- and if there is no record, to move to the second part which simply deletes the account. Any ideas how to put the two together?

Here's the code for the first part:
Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@passlines = <PASS>;
close PASS;

open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
my $found = 0;
foreach $passline (@passlines) {
($passline =~ /^$data[$auth_user_field]:/) ?
($found = 1) :
print PASS $passline;
}
close PASS;
}
else {
$output .= $line . "\n";
}
}
The structure of the two looks pretty similar, so I imagine it wouldn't be too tough for someone with better programming skills than myself. Smile

If I don't get this aspect working, my backup plan is to have people simply email me if they want their account deleted and don't have a current record to allow them to do so.

Thanks,
Dan
> >