Page 1 of 3 123 LastLast
Results 1 to 10 of 29
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Cannot modify header information - headers already sent

    I have installed the Manufacturers About module and its working on Zen Cart 1.5.5, however I am trying to get it to work with CK Editor.

    I've added the code:

    include('includes/ckeditor.php');

    After

    require('includes/application_top.php');

    CKEditor loads, however as soon as I hit 'Save' it goes to a White Screen.

    I have looked in the logs and I am getting this error.

    [24-Mar-2017 18:17:18 UTC] Request URI: /~zendev/MYURL/MYadmin/manufacturers.php?page=1&mID=57&action=save, IP address: 00.00.00.000
    #1 header() called at [/home/zendev/public_html/MYURL/MYadmin/includes/functions/general.php:26]
    #2 zen_redirect() called at [/home/zendev/public_html/MYURL/MYadmin/manufacturers.php:87]

    [24-Mar-2017 18:17:18 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/zendev/public_html/MYURL/MYadmin/includes/ckeditor.php:22) in /home/zendev/public_html/MYURL/MYadmin/includes/functions/general.php on line 26

    Also see attached. I have also attached a Zip of the mod files without the CKEditor edit. I had this working on 1.5.3 and 1.5.4 but can't remember what I had to do exactly.


    Attachment 17004

    Attachment 17005
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

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

    Default Re: Manufacturers About

    There's a FAQ regarding that particular error message, but what it looks like is that the ckeditor code sends something to the "html", but then a condition was met to cause a redirect which modifies the headers, but can't do so because there is already html going out. Suggest moving your ckeditor include to near the end of the header file for about_manufacturer...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Manufacturers About

    I'll give that a try, thank you.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  4. #4
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Manufacturers About

    Ok well that worked but now I have another issue which I thought I had resolved. I need the 'manufacturers about' on the front end to read as text and images. At the moment it is rendering as HTML code after saving which means nothing to the person viewing the site unless you understand HTML.

    This piece of code appears to be the place where I would need to make an edit in the manufacturers.php file (you will need to download the mod from my first post in this thread):

    // start manufacturers_about edit

    $manufacturer_inputs_string = '';
    $languages = zen_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
    $manufacturer_inputs_string .= '<br>' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_textarea_field('manufacturers_about[' . $languages[$i]['id'] . ']', 'soft', '70', '20', zen_get_manufacturer_about($mInfo->manufacturers_id, $languages[$i]['id'])) ;

    }
    $contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_ABOUT . $manufacturer_inputs_string);

    // end manufacturers_about edit


    It appears to need something like:

    htmlspecialchars(stripslashes($products_description[$languages[$i]['id']]), ENT_COMPAT, CHARSET, TRUE) : htmlspecialchars(zen_get_products_description($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE));

    Which appears in the collect_info.php file for saving product descriptions.

    echo zen_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '30', (isset($products_description[$languages[$i]['id']])) ? htmlspecialchars(stripslashes($products_description[$languages[$i]['id']]), ENT_COMPAT, CHARSET, TRUE) : htmlspecialchars(zen_get_products_description($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE)); //,'id="'.'products_description' . $languages[$i]['id'] . '"');
    }

    Not sure how to apply this into the manufacturers.php file though.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  5. #5
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Manufacturers About

    So took a lap through the referenced files, and while there may be something associated with the plugin itself regarding capturing/providing data, it looks to me like sanitization of the manufacturers data wasn't fully captured as one might expect. Ie. If you take a look at admin/includes/init_includes/init_sanitize.php you will see that things such as products_description, products_name and products_url are each provided through a sanitizer applicable to that data type of data to be captured/sanitized. But there is nothing related to manufacturer entered "text". Now, add to that this plugin (applicable download location with associated thread is: https://www.zen-cart.com/downloads.php?do=file&id=1966) uses additional fields to store information in the database, these too need to be sanitized "properly" instead of blanketly which might be why you are seeing raw HTML (as the default sanitization will "disable" html) instead of the expected/desired information.

    I provide below a partial "patch" to the sanitization issue, but two things should happen. One the ZC code should be updated in the area of admin/includes/init_includes/init_sanitize.php to capture the fields in the applicable/desired standard sanitizer, and two the plugin should be updated to capture the sanitization applicable to the fields that are added in the admin side. Then, there is somewhat what you referred to regarding the admin side display of the information so that it is not all HTML-ly. :) (Nice word no?)

    For immediate "gratification":
    add this and any additional directions within the file to address other applicable fields

    admin/includes/extra_datafiles/manufacturers_all_about_sanitize.php
    Code:
    if (class_exists('AdminRequestSanitizer')) {
        $sanitizer = AdminRequestSanitizer::getInstance();
        $group = array(
    // BOF items that should be incorporated/addressed in base ZC code at admin/includes/init_includes/init_sanitize.php
            'manufacturers_name' => array(
                                       'sanitizerType' => 'PRODUCT_NAME_DEEP_REGEX', 
                                       'method' => 'post', 
                                       'pages' => array('manufacturers')
                                       ),
            'manufacturers_image_manual' => array(
                                 'sanitizerType' => 'FILE_DIR_REGEX', 
                                 'method' => 'post', 
                                 'pages' => array('manufacturers')
                                 ),
            'manufacturers_url' => array(
                                 'sanitizerType' => 'PRODUCT_URL_REGEX', 
                                 'method' => 'post', 
                                 'pages' => array('manufacturers')
                                 ),
    // EOF items that should be incorporated/addressed in base ZC code at admin/includes/init_includes/init_sanitize.php
    
    // BOF items to remain in this file even after the above are addressed, because these support the plugins new admin entries.
            'manufacturers_status' => array(
                                 'sanitizerType' => 'SIMPLE_ALPHANUM_PLUS', 
                                 'method' => 'post', 
                                 'pages' => array('manufacturers')
                                 ),
            'manufacturers_sort_order' => array(
                                 'sanitizerType' => 'SIMPLE_ALPHANUM_PLUS', 
                                 'method' => 'post', 
                                 'pages' => array('manufacturers')
                                 ),
            'manufacturers_about' => array(
                                 'sanitizerType' => 'PRODUCT_DESC_REGEX', 
                                 'method' => 'post', 
                                 'pages' => array('manufacturers')
                                 )
    
    // EOF items to remain in this file even after the above are addressed, because these support the plugins new admin entries.
        );
        $sanitizer->addComplexSanitization($group);
    }
    Now, I included a check for the AdminSanitizer class, though really all versions of 1.5.x ZC should have this class installed or get it installed. It may require "manual" installation at this point for older systems, but it really should be present for any system out there as advised in the forum. So, for those that wish to be alerted that there is a problem, remove the "if (class_exists..." line and the final closing right curly parenthesis. Then if there is an issue that the class does not exist, there will be errors generated in the logs directory.

    So, the other "issue" that I think was being referenced is the "recreation" of the information in a way similar to what is done with products_description.

    So this code in the modified admin/manufacturers.php file:
    Code:
          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
            $manufacturer_inputs_string_about .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_textarea_field('manufacturers_about[' . $languages[$i]['id'] . ']', 'soft', '70', '10', zen_get_manufacturer_about($mInfo->manufacturers_id, $languages[$i]['id']));
          }
    Likely would be better if:
    Code:
          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
            $manufacturer_inputs_string_about .= '<br />' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_textarea_field('manufacturers_about[' . $languages[$i]['id'] . ']', 'soft', '70', '10', htmlspecialchars( (isset($manufacturers_about[$languages[$i]['id']]) ? stripslashes($manufacturers_about[$languages[$i]['id']]): zen_get_manufacturer_about($mInfo->manufacturers_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE));
          }
    And something similar would need to be done for manufacturers_name and at least manufacturers_url.

    These few things together should support display of the information both on the admin and the store/catalog side. As far as I have looked, I believe no further catalog side modifications are necessary to regain "readable" text. It's that the data getting to the database and used on the admin side is not properly handling the information. I could be wrong, but this really should be an issue brought up in the applicable thread and potentially incorporated into both the plugin as well as the ZC code where applicable.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Manufacturers About

    Just managed to have a quick look at this and there isn't a file in the module named admin/includes/extra_datafiles/manufacturers_all_about_sanitize.php

    So where does the code actually go?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  7. #7
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Manufacturers About

    You need to create that file
    Quote Originally Posted by Nick1973 View Post
    Just managed to have a quick look at this and there isn't a file in the module named admin/includes/extra_datafiles/manufacturers_all_about_sanitize.php

    So where does the code actually go?

  8. #8
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Manufacturers About

    Ok I did that and it didn't work
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  9. #9
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Manufacturers About

    Quote Originally Posted by Nick1973 View Post
    Ok I did that and it didn't work
    Where can the results of "not working" be seen? Also, it didn't sem like previously the modification(s) being performed are provided. Ie. The data may be being overly sanitized which is why it appears as html on the page. The above sanitize file is supposed to prevent/protect that from happening when the data is inserted into the database so that the data can be retrieved and then "simply" displayed without further sanitization.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Manufacturers About

    you want the url?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 Cannot modify header information - headers already sent by ,,,
    By mespe in forum General Questions
    Replies: 9
    Last Post: 2 Oct 2015, 08:27 PM
  2. Cannot modify header information - headers already sent
    By billc108 in forum General Questions
    Replies: 3
    Last Post: 21 Oct 2009, 10:14 AM
  3. Cannot modify header information - headers already sent
    By Fred5550 in forum General Questions
    Replies: 2
    Last Post: 12 Feb 2009, 04:38 PM
  4. Cannot modify header information - headers already sent by
    By laserayaneh in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 6 Sep 2006, 12:14 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR