Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: IP Log

  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IP Log

    Hey,


    I know the usual IP log script and need some help on improving on it. I have a simple file uploading script and I want to beable to view the IP of whoever uploaded a certain file.



    For example theres a file named "computer343.gif" and I want to beable to view the ip which uploaded it. Any Ideas

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    are you using a database to store the image?

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nope a directory

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    create a text file with the same name as the image (obviously a different extension, though) and store the IP in it

    of course, ideally, this would be done, as rafiki suggested, with a database

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Or store the image file path and ip address in a database and the actual image in the directory? That would probably be the better thing to do.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Or store the image file path and ip address in a database and the actual image in the directory? That would probably be the better thing to do.
    How else would you use a database?

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #7
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by whizard View Post
    How else would you use a database?

    Dan
    As opposed to storing the raw image data in the database

  • #8
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Ahhhh....

    What would be a good reason to do that - as in, why is that feature available?

    Dan
    Last edited by whizard; 06-04-2007 at 03:53 AM.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #9
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well iam not going to use a db im already done the coding, so how do you appose I do this?


    Something easy :P

  • #10
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by mr e View Post
    As opposed to storing the raw image data in the database
    Yeah I've heard good and bad things about doing that. It seems like it would take up too many resources to retrieve the image from the database. Then you have things like caching and what not.

    Quote Originally Posted by newline View Post
    Well iam not going to use a db im already done the coding, so how do you appose I do this?


    Something easy :P
    If you are wanting this to be easy then why are you even doing this at all? The easiest suggestion was that of whizard in post #4.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #11
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so have a system like when a new file is uploaded a text file is created which stores the ip?

  • #12
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    yeah...

    something like

    PHP Code:
    $fh fopen("text_ips/SAME NAME AS IMAGE HERE.txt","w");
    fwrite($fh,$_SERVER['REMOTE_ADDR']);
    fclose($fh); 
    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #13
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    then I would just use a fopen to view the I.P?

  • #14
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Actually, you could do this as well:

    (to store the IP at the same time as the photo upload)
    PHP Code:
    $fh fopen("text_ips/SAME NAME AS IMAGE HERE.inc","w");
    $data "\$ip = ".$_SERVER['REMOTE_ADDR'];
    fwrite($fh,$data);
    fclose($fh); 
    (to retrieve the IP)
    PHP Code:
    include("text_ips/SAME NAME AS IMAGE HERE.inc");
    print 
    $ip
    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #15
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Alright


    So in my upload script when the file is uploaded it will create a new .txt file which saves the ip to it.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •