Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    27
    Plugin Contributions
    0

    Default Including application_top.php

    My zencart is installed in public_html folder.

    Inside public_html folder I created folder /feeds/.

    Inside here I created a .php file where I will generate feeds through php.

    I need to include application_top.php to be able to use zencart functions.

    I tried several combinations but they are not working.

    If I print that, I get success:

    PHP Code:
    if(file_exists("../includes/application_top.php")) { echo 'success'; } else { echo 'fail'; } 
    But if I include like this functions I get blank page.

    PHP Code:
    include('../includes/application_top.php'); 
    Where is the problem? I start to think that application_top.php can be included only from catalog root?

    THanks

  2. #2
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Including application_top.php

    If the only thing that is in your php file is to include application_top.php, then yes you will get a blank page... application_top does not actually cause any specific output...

    So the question is, what follows the request to include application_top and what error(s) are being generated?

    Generally speaking, yes the includes/application_top.php file is included or required by a file that is located in the store's root. Your feeds folder can still exist in a sub-folder with the base file in the root of the store, so there should be no hardship in further development in that way.

    But as provided/described, it appears that things are working as they should and normally do based on the limited amount of information.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,513
    Plugin Contributions
    126

    Default Re: Including application_top.php

    @jeanjean88 the easiest way for you to solve this problem is just to move the create script to the root of your cart. Put the output in feeds, but keep the create script at the same level as /includes and /admin.

    If you REALLY want to put your create script in the feeds folder, then BEFORE you include application_top, you need to chdir to the root of the cart.

    Code:
    chdir("..");
    and then you might want to chdir back after the include (use getcwd() to capture the current folder, cd back to the return value after, etc.)
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  4. #4
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,910
    Plugin Contributions
    13

    Default Re: Including application_top.php

    Quote Originally Posted by jeanjean88 View Post
    My zencart is installed in public_html folder.

    Inside public_html folder I created folder /feeds/.

    Inside here I created a .php file where I will generate feeds through php.

    I need to include application_top.php to be able to use zencart functions.

    I tried several combinations but they are not working.

    If I print that, I get success:

    PHP Code:
    if(file_exists("../includes/application_top.php")) { echo 'success'; } else { echo 'fail'; } 
    But if I include like this functions I get blank page.

    PHP Code:
    include('../includes/application_top.php'); 
    Where is the problem? I start to think that application_top.php can be included only from catalog root?

    THanks
    welcome to the wonderful world of php! best of luck.

    invest in a good IDE, and try and learn it. it will help immensely.

    include is not a function. the parenthesis are not required, and are considered bad form.... but they still work.

    you need access to your server logs. what you are doing is failing but now where you think. the include works, but if you go into application_top.php, and change

    PHP Code:
    define('DEBUG_AUTOLOAD'true); 
    on my screen, i see:

    Warning: require(includes/templates/template_default/templates/tpl_zc_install_suggested_default.php): failed to open stream: No such file or directory in /var/www/base156c/includes/application_top.php on line 114 Fatal error: require(): Failed opening required 'includes/templates/template_default/templates/tpl_zc_install_suggested_default.php' (include_path='.:/usr/share/php') in /var/www/base156c/includes/application_top.php on line 114

    good luck!
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  5. #5
    Join Date
    Oct 2008
    Posts
    27
    Plugin Contributions
    0

    Default Re: Including application_top.php

    Thanks everybody for answers.

    I didn't like to put this .php file in root just to not list too many files into root.

    For most this isn't a problem, I understand, but I like to keep things clean.

    Anyway I publish here the solution I found, some may find it usefull.

    Anyway since all I needed from application_top.php was the ability to get results from funcitons (i.e. I needed to use price functions in my feed generator).

    So I created a zencart_lookups_api.php file which stands in root and outputs a json result (according to the $_GET variables in url).

    Then my .php feed generator get those results from url and save it into $variables.

    zencart_lookups_api.php

    PHP Code:
    <?php 
    header
    ("Content-type: application/json");
    require(
    'includes/application_top.php');

    // Getting actual price when in url ?get_actual_price&products_id=...
    if(isset($_GET['get_actual_price'])) {
      if(
    $_GET['products_id']) {
        
    $products_id $_GET['products_id'];
        
        
    $tax_rate_check $db->Execute("select tax_rate 
                                      from " 
    TABLE_PRODUCTS " p, " TABLE_TAX_RATES " t 
                                      where p.products_id = '" 
    . (int)$products_id "'
                                      and t.tax_class_id = p.products_tax_class_id
                                      limit 1"
    );
        
        
    $tax_rate $tax_rate_check->fields['tax_rate'];
        
        
    $base_price number_format(zen_get_products_base_price($products_id) * (1+($tax_rate/100)), 2'.''');
        
    $special_price number_format(zen_get_products_special_price($products_idtrue) * (1+($tax_rate/100)), 2'.''');
        
    $sale_price number_format(zen_get_products_special_price($products_idfalse) * (1+($tax_rate/100)), 2'.''');


        echo 
    '{"base":"' $base_price '",
               "special":"' 
    $special_price '",
               "sale":"' 
    $sale_price '"
              }'
    ;
      }
    }
    ?>
    feed_generator.php

    PHP Code:
     // Getting actual price from zencart
          
    $server_host =  preg_replace('/^www\./','',$_SERVER['HTTP_HOST']);
          
    $get_price _zen_getURL((!empty($_SERVER['HTTPS']) ? 'https://www.' 'http://www.') . $server_host '/zencart_lookups_api.php?get_actual_price&products_id='.$products_id);
          
    $get_price json_decode($get_pricetrue);
          
          
    $base_price $get_price['base'];
          
          
    $special_price = ($get_price['special'] != '0.00' $get_price['special'] : 0);
          
    $sale_price = ($get_price['sale'] != '0.00' $get_price['sale'] : 0);
          
    $discounted_price min(array_filter([$sale_price$special_price])); 

 

 

Similar Threads

  1. Replies: 1
    Last Post: 24 Nov 2012, 05:32 PM
  2. v151 Incorrect Error 406 from application_top.php in some PHP configurations
    By steele in forum Installing on a Linux/Unix Server
    Replies: 0
    Last Post: 24 Nov 2012, 05:08 AM
  3. v150 WordPress: Including application_top fails in init_db_config_read.
    By ZeroGravity in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 31 Mar 2012, 03:23 PM
  4. Q: including application_top.php in another script
    By calguy1000 in forum General Questions
    Replies: 0
    Last Post: 15 Dec 2006, 05:34 PM
  5. application_top.php
    By teranet in forum Installing on a Windows Server
    Replies: 1
    Last Post: 28 Oct 2006, 04:09 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