0

I want to add ip address permission to my document file by PHP code. For example i have a document 'myDocument.doc', I run my php code to add ip address access permission on this file, By this, that particular ip address can opens my document, If any other ip wants to open this file a alert message will be shown.

Can any body tell me this is possible or not, If this is possible how i can do this.

Explanation:- If i restrict a file for a particular ip. That ip can download that file and read this, This is ok. But if user send this file to another user, they also can open this file because there is no restrication for their ip after download that file. I want another users cant use that file, Because he doesn't pay for this. May be now you understand what i want to do

Mangita
  • 595
  • 6
  • 24
  • See this http://stackoverflow.com/questions/2882472/php-send-file-to-user. Basically, add your checking or restriction first before the code. You also have to move your document to a non-accessible folder. – noia_0328 May 30 '14 at 04:12

1 Answers1

0

IP addresses should not being used for authentication as it is insecure or not practicable because of many reasons. For example:

  • Others could spoof their IP and pretend to be someone else
  • Your IP might change (even frequently)
  • Organizations usually use a single public IP for all clients from their network. In this case you won't have a chance to identify a single user anymore.
  • ...

I suggest you protect those file with a username and a password. If you are using the apache webserver for example you might configure this in the .htaccess file.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • Ya, I am agree with you, But my client requirement is this, And i dont know how to achieve this. That's why i ask here. – Mangita May 30 '14 at 04:18
  • Do you use the apache webserver? If so, you can use the `allow` and `deny` directives in your .htaccess file. http://httpd.apache.org/docs/current/mod/mod_access_compat.html#deny . You need to `deny from all` to disable general access and `allow from ` to allow access from a certain IP. – hek2mgl May 30 '14 at 04:23
  • Ya, I am using. I know what you want to say, But client not want this. Let me explain you. If i restrict a file for a particular ip. That ip can download that file and read this, This is ok. But if user send this file to another user, they also can open this file because there is no restrication for their ip after download that file. I want another users cant use that file, Because he doesn't pay for this. May be now you understand what i want to do. – Mangita May 30 '14 at 04:29