Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    2
    Plugin Contributions
    0

    Default Permission Denied When Using Javascript to Call a Template File

    Hi all:

    I have a template file (includes/templates/theme_name/templates/tpl_index_quicksearch.php) that displays a few subcategory names as links.

    I have another file in the same folder named 'tpl_subcats_ajax.php' that displays the subcategory description and products based on the category number passed to it. I know the code works, because when I include it in tpl_index_quicksearch.php, there are no problems.

    Using jQuery.get(), I'm trying to call 'tpl_subcats_ajax.php' but nothing happens. My javascript is as follows:

    Code:
    $.get('includes/templates/theme_name/templates/tpl_subcats_ajax.php', { subcat: $(this).attr('id') }, function(data) {
    	$('#quicksearch_content_desc').html(data);
    });
    Nothing is happening because I get a permission denied error when I try to access http://mydomain.com/shop/includes/te...bcats_ajax.php

    If I place 'tpl_subcats_ajax.php' in the root of the shop/ folder, the jQuery call works but I cannot access the ZenCart DB from that location.

    Is there a specific place I should be putting the 'tpl_subcats_ajax.php' file that won't give me a permission denied message and still allow me to access the DB?

    Thanks!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Permission Denied When Using Javascript to Call a Template File

    For very important security reasons, you CANNOT access PHP files under the /includes/ folder from a browser, and that includes ajax, javascript, and any other means.
    You'll need to put your scripts someplace above the includes folder, perhaps just in the root of your store.

    And, the location of the file has nothing to do with whether the database can be accessed.
    .

    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.

  3. #3
    Join Date
    Jul 2010
    Posts
    2
    Plugin Contributions
    0

    Default Re: Permission Denied When Using Javascript to Call a Template File

    Quote Originally Posted by DrByte View Post
    For very important security reasons, you CANNOT access PHP files under the /includes/ folder from a browser, and that includes ajax, javascript, and any other means.
    You'll need to put your scripts someplace above the includes folder, perhaps just in the root of your store.

    And, the location of the file has nothing to do with whether the database can be accessed.
    Thanks for the reply!

    I inserted the following code into my script and now it works to access the database; please let me know if this is a security problem.

    PHP Code:
    require_once('includes/application_top.php'); 

    -Brandon

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Permission Denied When Using Javascript to Call a Template File

    That's the most appropriate way.
    .

    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.

 

 

Similar Threads

  1. 403 Permission Denied
    By kjharrison in forum Setting Up Categories, Products, Attributes
    Replies: 9
    Last Post: 26 Sep 2010, 06:25 PM
  2. 13 permission denied
    By M.Int in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 11 May 2010, 12:56 AM
  3. permission denied error
    By Muzz in forum Installing on a Linux/Unix Server
    Replies: 4
    Last Post: 5 May 2010, 11:59 PM
  4. Tools Template Selection Preview No Show - permission denied
    By TedW in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 29 Sep 2007, 06:21 AM
  5. Permission Denied?
    By oamurai in forum Installing on a Windows Server
    Replies: 2
    Last Post: 21 May 2007, 04:03 PM

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