Restrict access to php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkf
    New Member
    • Dec 2006
    • 2

    Restrict access to php script

    Hi All,

    I have a simple php script:

    [PHP]
    Header("content-type: application/x-javascript");
    $serverIP=$_SER VER['REMOTE_ADDR'];
    echo "document.write (\"Your IP address has been <font color='red'>tra cked and logged:</font> <b>" . $serverIP . "</b>\")";
    [PHP]

    That is called via javascript, "script type="text/javascript" src="ip.php"></script>", in order to discourage folder-peekers on my site.

    But the following text:

    document.write( "Your IP address has been <font color='red'>tra cked and logged:</font> <b>xxx.xxx.xxx. xx</b>")

    ...shows when you call the script through a browser (Note, script does NOT actually log the IP address).

    I've tried changing the file permissions, but the only thing that happens is the script stops working.

    Question is: What code can I add to prevent this part of the script from being revealed?

    If there is something, I need the actual code.

    Thanks much,

    Newbie Steph
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I am not sure what part of the code you are talking about, but when it is HTML or JavaScript or any other client-side code, you cannot reveal it. Not even after trying to block right-clicks. "What runs on my machine is mine"

    Ronald :cool:

    Comment

    • mkf
      New Member
      • Dec 2006
      • 2

      #3
      Originally posted by ronverdonk
      I am not sure what part of the code you are talking about, but when it is HTML or JavaScript or any other client-side code, you cannot reveal it. Not even after trying to block right-clicks. "What runs on my machine is mine"

      Ronald :cool:
      Hi Ronald,

      If you load the address:

      www.mydomain.co m/PersonTryingToA ccessThisFolder/ip.php

      ...into a browser, the page that comes up says:

      "document.write ("Your IP address has been <font color='red'>tra cked and logged:</font> <b>xxx.xxx.xxx. xx</b>")"

      Which is the "document.write " portion of my PHP script, and I do not want people to see this.

      I wish to add some code so that this "document.write " portion of my "ip.php" script (shown above) does not show in the browser window.

      My question re-stated:

      What code can I add to prevent the doc.write portion of the script from showing in the browser window?

      Comment

      Working...