Changing length of time between votes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dsdc
Forum Newbie
Posts: 4
Joined: Thu Feb 10, 2005 6:32 am

Changing length of time between votes

Post by dsdc »

I apologize if this is a really simple question, but I've been Googling and trial-and-erroring for a week now with no results. Before I pull out my last hair, can somebody help me with this?

I have a voting script that allows only one vote per ip per day. I want to change this to one vote per week. I've been trial-and-erroring myself crazy, and still can't change this, nor do I even know where to look.

I'm pretty sure the answer is somewhere in the section pasted below. Can someone help?

Code: Select all

function dbget_exec_SetUserOff($current_id){ 

if(!dbsec_no_injection("$current_id,0")) return false; 

db_exec("UPDATE pv_sessions_simple SET offline='0',time_end=NOW() WHERE id='$current_id' OR TO_DAYS(NOW())-TO_DAYS(time_start)>1"); 

return 0; 

} 
return 1;
Last edited by dsdc on Fri Feb 11, 2005 11:27 am, edited 4 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Looking at at quickly and possibly not looking properly try changing

Code: Select all

WHERE id='$current_id' OR TO_DAYS(NOW())-TO_DAYS(time_start)>1");
[
to

Code: Select all

WHERE id='$current_id' OR TO_DAYS(NOW())-TO_DAYS(time_start)>7");
But to be honest I might be wrong there
dsdc
Forum Newbie
Posts: 4
Joined: Thu Feb 10, 2005 6:32 am

Post by dsdc »

That was one of my first attempts. It however, just kept people from voting more than once for a couple of hours. People can still vote again after that.

Thanks for the idea.

Any other ideas?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

you can search this forum on "one vote script" or something alike....

each approach (ip - cookie - username) has it's advantages and disadvantages....
dsdc
Forum Newbie
Posts: 4
Joined: Thu Feb 10, 2005 6:32 am

Post by dsdc »

how would the code I pasted be modified to accomplish this?

It has to be easy for someone familiar with php. As it turns out, that is not me.

You, however, are a guru. Can you tell me what to change in the code I pasted up there to make this work?

It already limits things so people can't vote right away. All I want to do is to extend the time to one week.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

this doesn't feel like the code to me. I mean, there's one query that deals with the user's ip. A different query that deals with date stuff, and another that seems to do voting (yet doesn't store ip).. this doesn't make much sense.

FYI title of Guru is 1000 - 2499 posts.
dsdc
Forum Newbie
Posts: 4
Joined: Thu Feb 10, 2005 6:32 am

Post by dsdc »

feyd -

thanks for helping me narrow things down. I found the answer in a different file. Thanks for your help.

Also, thanks for the guru explanation. I didn't realize it was a function of the number of posts.
Post Reply