Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limit access to X-times per day and per IP

Status
Not open for further replies.

Solibra

Technical User
Feb 18, 2003
3
0
0
DE
Hi everyone,

I have written a php script that enables users of our lan network to send sms messages to mobile phones.

Now i want to limit the sending of sms to 2 sms per day and per ip.

can anyone help to set this up?

i thought about a plain file solution as the number of clients in our lan is limited to about 50. but if you have an easy solution with database....

i need some help to get this started.
maybee you could give me some code parts especially how to write and read out the db file.

i appreciate your ideas!

Maximilian
 
I'd use a database server. It'll be easier than managing text files. It'll scale better, too.

Assuming that your database server is MySQL, I'd create a table of the form:
create table foo (address varchar(15) not null, message_sent timestamp)

The script logic would be:

- Perform garbage collection on the database
Either remove all entries older than the previous midnight or older than 24 hours old
- Check for the number of times an SMS message has been sent from that IP
Select a count of message_sent records where address = $_SERVER['REMOTE_ADDR']
- if the count is < 2 then
send message
insert a new record for the remote address.
else
display an error.
Want the best answers? Ask the best questions: TANSTAAFL!
 
Maybe you could use cookies to administrate howmany times a message has been send from a pc. Then you don't need a database, a mysql server or the knowledge of database reading and writing.

Doesn't work if the people are smart enough to delete cookies. Can't help you on how to create cookies, just working no that myself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top