Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    368
    Plugin Contributions
    0

    Default Protect my custom php files

    Hi all ,

    I have some custom json launching .php file and looking for an easy way to protect php file being accessed directly from browser . Php file is loading application_top.php in order to retrieve db connection info . Is there a session variable or something else that allows me to check if php was launched from zencart pages .. ?
    All suggestions are welcome !

    L.

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Protect my custom php files

    Quote Originally Posted by solo_400 View Post
    Hi all ,

    I have some custom json launching .php file and looking for an easy way to protect php file being accessed directly from browser . Php file is loading application_top.php in order to retrieve db connection info . Is there a session variable or something else that allows me to check if php was launched from zencart pages .. ?
    All suggestions are welcome !

    L.
    * In theory, simply placing the custom.php file into the /admin/ or /includes/ folder(s) is enough to prevent someone running it directly (see the .htaccess files in these folders for a little more info).

    If you don't think this is protection enough, then there are most certainly other methods (such as checking session variables) that will enhance the default protection mechanisms. Only you are in a position to determine which variable will best suit your needs.

    Cheers
    Rod

    I have a gut feeling I may have this a liitle wrong... (haven't been in top form lately)

  3. #3
    Join Date
    Aug 2009
    Posts
    368
    Plugin Contributions
    0

    Default Re: Protect my custom php files

    The problem is when I put myfile.php on includes directory and called from json ( includes/mycustomdir/myfile.php ) it doesn't work . When I put myfile.php on root path www.mystore.com/storename/myfile.php and called from json ( myfile.php ) is working .
    Do you know why ?

    thx

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Protect my custom php files

    Quote Originally Posted by solo_400 View Post
    The problem is when I put myfile.php on includes directory and called from json ( includes/mycustomdir/myfile.php ) it doesn't work . When I put myfile.php on root path www.mystore.com/storename/myfile.php and called from json ( myfile.php ) is working .
    Do you know why ?
    Do I know why? Not really,but there are several things that come to mind. The most obvious being file not found (incorrect path/URL) or file or folder permissions (no read access)

    The fact that in one instance you specify "includes/mycustomdir/myfile.php" (a file path) and the other instance you specify www.mystore.com/storename/myfile.php (a URL) would suggest to me that you are possibly getting these confused somehow and/or are not making the required configuration changes when placing the file into a different location.

    This is mostly speculation though.. If I were you, I'd be looking at the log files as these are sure to eliminate the guesswork I'm currently employing.

    Cheers
    Rod

  5. #5
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Protect my custom php files

    Quote Originally Posted by solo_400 View Post
    Hi all ,

    I have some custom json launching .php file and looking for an easy way to protect php file being accessed directly from browser . Php file is loading application_top.php in order to retrieve db connection info . Is there a session variable or something else that allows me to check if php was launched from zencart pages .. ?
    All suggestions are welcome !

    L.
    I think you're asking the wrong question.
    If you "custom json" is an ajax script, then it IS accessing your myfile.php script directly from the browser ... because ajax runs in your browser.

    I suspect that you really need to be building stronger security into whatever your myfile.php script is doing so that it knows the incoming request is authorized. Perhaps validating that the security token is correct, or something similar.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Aug 2009
    Posts
    368
    Plugin Contributions
    0

    Default Re: Protect my custom php files

    Thank you Dr.Byte , do you have any idea ( a piece of code ) showing how to build a security mechanism on blocking direct access on myfile.php file ? You're right , the reason for non working when I place it on /include directory is default .htaccess . I really need a technical solution .
    Last edited by solo_400; 18 Dec 2012 at 05:29 PM.

 

 

Similar Threads

  1. php files called when accessing product_listing.php page
    By Tonyy in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 4 Dec 2011, 12:46 AM
  2. I can't find the CUSTOM folder -- includes/languages/english/custom/header.php
    By Yammits in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 11 Jul 2010, 10:26 PM
  3. Using .htaccess files to protect against unwanted snooping
    By lieven23 in forum General Questions
    Replies: 7
    Last Post: 6 Mar 2010, 06:56 PM
  4. Entering HTM Code into PHP Files - Adding Live Search to search_header.php
    By Jump Network in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Sep 2007, 02:47 PM
  5. Correct way to protect dirs and files?
    By LilleyPadGifts in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 31 Jan 2007, 06:19 AM

Posting Permissions

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