Page 1 of 1

Changing length of time between votes

Posted: Thu Feb 10, 2005 7:02 am
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;

Posted: Thu Feb 10, 2005 7:50 am
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

Posted: Thu Feb 10, 2005 6:37 pm
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?

Posted: Thu Feb 10, 2005 6:41 pm
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....

Posted: Thu Feb 10, 2005 8:26 pm
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

Posted: Thu Feb 10, 2005 8:41 pm
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.

Posted: Fri Feb 11, 2005 6:02 am
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.