SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,582
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    only run code from my computer

    I have a nice php page which I guess anyone can run. I want to make it so that only I can run it
    heres my page,
    PHP Code:
    <?php

    if(isset($_POST['submit'])) { 
        
    include 
    $_SERVER['DOCUMENT_ROOT'].'/db/config.php'

    ...
    ...

    }
    ?>
    So im thinking I need to make sure the page im coming from is mine and in order to ensure its coming from my computer (Is there a way to also check the IP address?

    Thanks...
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,578
    Mentioned
    62 Post(s)
    Tagged
    3 Thread(s)
    Try testing for $_SERVER['REQUEST_URI']

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    This is really a poormans check, but I had used this for years ....

    On your C:\ drive put an empty file named local.flag

    Then,
    Code:
    if (file_exists('/local.flag'))
       echo 'this will only run locally';

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    Or just put this script in a location not accessible to the outside world.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .htaccess for your ip only?


Bookmarks

Posting Permissions

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