[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 12-20-2005, 12:20 PM   #1 (permalink)
NamePros Member
 
Join Date: Dec 2005
Posts: 186
0.00 NP$ (Donate)

chronic will become famous soon enoughchronic will become famous soon enough


[PHP] Help with Script

Can anyone help me with this? I need to make a script which gives a user +1 click everytime someone clicks a personalized link. Also, I want the script to disallow the same IP to click it more than once within a 15 minute period.

I already have a login system made but I need to add the thing where it gives the link to you when you sign up. The only problem I am going to have it how to "give" the user +1 clicks and do the 15 minute period thing.

For the disallowing clicking within 15 minute period someone came up with the idea to get the time the link was clicked and then do olddate - currentdate = $x; then do $x >= 15 and then echo that they clicked the link and whatever else. Can someone maybe make a little script like that because I don't know how to retreive a time only date.

Also, for the +1 click, I was thinking of using Javascript but since I don't know that, I might have to use PHP. I was also thinking of how to do it; I came up with updating a mysql table everytime it was clicked but I am not sure about that. Any ideas on what I can do?

Sorry that I don't have anything to offer as my PayPal is empty and anything else I can give is too much.. So if any of you could be nice and help, that would be appreciated.
__________________
DNFind.net - For sale, PM me.
chronic is offline  
Old 12-20-2005, 09:19 PM   #2 (permalink)
Awesome™
 
MasterB's Avatar
 
Join Date: May 2005
Location: Boston
Posts: 77
30.95 NP$ (Donate)

MasterB is on a distinguished road


As for time, what I would do is the following:

time() will get the time in seconds starting from the the Unix Epoch (January 1 1970 00:00:00 GMT). So, you could do something like the following:
Code:
$oldtime = $whatever_the_old_time_was;
$newtime = time();
if($newtime - $oldtime < 900) {
    // 900 Seconds = 15 Minutes
    dont_allow_the_click();
}
Reguarding the storing of the 15 mins thing. There's several ways of doing this. You could use cookies, sessions, or MySQL. Your best choice would be MySQL but if you don't have that resource available, I'd use cookies.
For MySQL, you could store the IP and time clicked in a table, and query the table every time, like below:
Code:
$ip = $_SERVER['remote_addr'];
$query = "SELECT * FROM `ip_table` WHERE ip=`" . $ip . "` LIMIT 0,1";
// connect to mysql here
$query_result = mysql_query($query);
$query_array = mysql_fetch_assoc($query_result);
$oldtime = $query_array['time'];
$newtime = time();
if($newtime - $oldtime < 900) {
    // 900 Seconds = 15 Minutes
    dont_allow_the_click();
} else {
    allow_the_click();
}
Catch my drift? If you need any help, throw some NP$ my way and I'll generously help you along with the script.

Oops! Read your post and saw that you don't have anything... well I'll be nice, if you need help just PM me . Just leave me some rep if you do.
MasterB is offline  
Old 12-20-2005, 09:57 PM   #3 (permalink)
NamePros Member
 
Join Date: Dec 2005
Posts: 186
0.00 NP$ (Donate)

chronic will become famous soon enoughchronic will become famous soon enough


Okay, thanks for all your help. I got some help on SitePoint already but you still helped me with a few things.
__________________
DNFind.net - For sale, PM me.
chronic is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 01:39 AM
Huge Xmas script pack sale $5.00 KPR Scripts For Sale 1 12-08-2005 06:25 PM
Huge Script Pack for $5 with Resale Rights dsforsaken Scripts For Sale 32 12-03-2005 08:46 PM
60.000 Templates, scripts, fonts, banners etc. $9.95 atkims Web Development Wanted 19 11-16-2004 09:48 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:58 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85