Home > database >  error when installing modifiers for ocstore 3
error when installing modifiers for ocstore 3

Time:11-10

Warning: DOMDocument::loadXML(): CData section not finished public function add() { $this->load->language(' in Entity, line: 584 in /home/s/syperdgq/syperdgq.beget.tech/public_html/admin/controller/marketplace/modification.php on line 467Warning: DOMDocument::loadXML(): Premature end of data in tag add line 371 in Entity, line: 584 in /home/s/syperdgq/syperdgq.beget.tech/public_html/admin/controller/marketplace/modification.php on line 467Warning: DOMDocument::loadXML(): Premature end of data in tag operation line 367 in Entity, line: 584 in /home/s/syperdgq/syperdgq.beget.tech/public_html/admin/controller/marketplace/modification.php on line 467Warning: DOMDocument::loadXML(): Premature end of data in tag file line 44 in Entity, line: 584 in /home/s/syperdgq/syperdgq.beget.tech/public_html/admin/controller/marketplace/modification.php on line 467Warning: DOMDocument::loadXML(): Premature end of data in tag modification line 2 in Entity, line: 584 in /home/s/syperdgq/syperdgq.beget.tech/public_html/admin/controller/marketplace/modification.php on line 467Notice: Trying to get property 'textContent' of non-object in /home/s/syperdgq/syperdgq.beget.tech/public_html/admin/controller/marketplace/modification.php on line 470

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Modification Manager</name>
    <code>modification_manager</code>
    <version>3.0.4</version>
    <author>Opencart-templates</author>
    <link>http://www.opencart-templates.co.uk/modification-manager</link>

    <file path="admin/language/en-gb/marketplace/modification.php">
        <operation>
            <search index="0"><![CDATA[<?php]]></search>
            <add position="after"><![CDATA[
$_['tab_error'] = 'Error';
$_['tab_files'] = 'Files';

$_['text_add'] = 'Add Modification';
$_['text_edit'] = 'Edit Modification: %s';

$_['text_enabled'] = 'Enabled';
$_['text_disabled'] = 'Disabled';

$_['entry_author'] = 'Author';
$_['entry_name'] = 'Name';
$_['entry_xml'] = 'XML';

$_['button_filter'] = 'Filter';
$_['button_reset'] = 'Reset';
$_['button_download'] = 'Download';

$_['column_date_modified'] = 'Last Modified';

$_['error_warning'] = 'There has been an error. Please check your data and try again';
$_['error_required'] = 'This field is required';
$_['error_name'] = 'Missing name tag';
$_['error_code'] = 'Missing code tag';
$_['error_exists'] = 'Modification \'%s\' is already using the same code: %s!';]]></add>
        </operation>
    </file>

    <file path="admin/controller/marketplace/modification.php">
        <operation>
            <search index="0"><![CDATA[public function index() {]]></search>
            <add position="after"><![CDATA[         $this->load->model('extension/module/modification_manager');

        $this->model_extension_module_modification_manager->install();
]]></add>
        </operation>
        <operation>
            <search><![CDATA[$this->model_setting_modification]]></search>
            <add position="before"><![CDATA[$this->load->model('extension/module/modification_manager');
]]></add>
        </operation>
        <operation>
            <search><![CDATA[$this->model_setting_modification->]]></search>
            <add position="replace"><![CDATA[$this->model_extension_module_modification_manager->]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$sort = 'name';]]></search>
            <add position="replace"><![CDATA[$sort = 'date_modified';]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$order = 'ASC';]]></search>
            <add position="replace"><![CDATA[$order = 'DESC';]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$handle = fopen(DIR_LOGS . 'ocmod.log', 'w ');]]></search>
            <add position="before"><![CDATA[        fclose($handle);
            
                    $handle = fopen(DIR_LOGS . 'ocmod_error.log', 'w ');]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$maintenance = $this->config->get('config_maintenance');]]></search>
            <add position="after"><![CDATA[
            // Clear logs on refresh
            $handle = fopen(DIR_LOGS . 'ocmod.log', 'w ');
            fclose($handle);

            $handle = fopen(DIR_LOGS . 'ocmod_error.log', 'w ');
            fclose($handle);
]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$data['breadcrumbs'] = array();]]></search>
            <add position="before"><![CDATA[        $this->load->model('extension/module/modification_manager');

        if (isset($this->request->get['filter_name'])) {
            $filter_name = $this->request->get['filter_name'];
        } else {
            $filter_name = null;
        }

        if (isset($this->request->get['filter_xml'])) {
            $filter_xml = $this->request->get['filter_xml'];
        } else {
            $filter_xml = null;
        }

        if (isset($this->request->get['filter_author'])) {
            $filter_author = $this->request->get['filter_author'];
        } else {
            $filter_author = null;
        }

        $url = $this->getListUrlParams();

        $data['add'] = $this->url->link('marketplace/modification/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
        $data['clear_log'] = $this->url->link('marketplace/modification/clearlog', 'user_token=' . $this->session->data['user_token'] . $url, true);
        $data['filter_action'] = $this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'], true);
        $data['reset_url'] = $this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'], true);

        $data['tab_files'] = $this->language->get('tab_files');
        $data['tab_error'] = $this->language->get('tab_error');]]></add>
        </operation>
        
        <operation>
            <search index="0"><![CDATA[$data['sort_name'] =]]></search>
            <add position="before"><![CDATA[        if (isset($this->request->get['filter_name'])) {
            $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
        }

        if (isset($this->request->get['filter_author'])) {
            $url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8'));
        }

        if (isset($this->request->get['filter_xml'])) {
            $url .= '&filter_xml=' . urlencode(html_entity_decode($this->request->get['filter_xml'], ENT_QUOTES, 'UTF-8'));
        }

        $data['sort_date_modified'] = $this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'] . '&sort=date_modified' . $url, true);]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$filter_data = array(]]></search>
            <add position="after"><![CDATA[         'filter_name'     => $filter_name,
            'filter_author'   => $filter_author,
            'filter_xml'      => $filter_xml,]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$data['modifications'][] = array(]]></search>
            <add position="after"><![CDATA[             'date_modified'      => $result['date_modified'] && $result['date_modified'] != '0000-00-00 00:00:00' ? date(date('Ymd') == date('Ymd', strtotime($result['date_modified'])) ? 'G:i' : $this->language->get('date_format_short'), strtotime($result['date_modified'])) : null,
                'edit'               => $this->url->link('marketplace/modification/edit', 'user_token=' . $this->session->data['user_token'] . '&modification_id=' . $result['modification_id'] . $url, true),
                'download'           => $this->url->link('marketplace/modification/download', 'user_token=' . $this->session->data['user_token'] . '&modification_id=' . $result['modification_id'] , true),]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$pagination = new Pagination();]]></search>
            <add position="before"><![CDATA[        if (isset($this->request->get['filter_name'])) {
            $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
        }

        if (isset($this->request->get['filter_author'])) {
            $url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8'));
        }

        if (isset($this->request->get['filter_xml'])) {
            $url .= '&filter_xml=' . urlencode(html_entity_decode($this->request->get['filter_xml'], ENT_QUOTES, 'UTF-8'));
        }]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$data['clear_log'] =]]></search>
            <add position="before"><![CDATA[        $data['filter_name'] = $filter_name;
        $data['filter_author'] = $filter_author;
        $data['filter_xml'] = $filter_xml;

        $data['modified_files'] = array();

        $modified_files = self::modifiedFiles(DIR_MODIFICATION);

        $modification_files = $this->getModificationXmlFiles();

        foreach($modified_files as $modified_file) {
            if(isset($modification_files[$modified_file])){
                $modifications = $modification_files[$modified_file];
            } else {
                $modifications = array();
            }

            $data['modified_files'][] = array(
                'file' => $modified_file,
                'modifications' => $modifications
            );
        }

        // Error log
        $error_file = DIR_LOGS . 'ocmod_error.log';

        if (file_exists($error_file)) {
            $data['error_log'] = htmlentities(file_get_contents($error_file, FILE_USE_INCLUDE_PATH, null));
        } else {
            $data['error_log'] = '';
        }
        ]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$this->load->view('marketplace/modification']]></search>
            <add position="replace"><![CDATA[$this->load->view('extension/module/modification_manager/list']]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$this->response->redirect($this->url->link(!empty($data['redirect']) ? $data['redirect'] : 'marketplace/modification', 'user_token=' . $this->session->data['user_token'] . $url, true));]]></search>
            <ignoreif position="replace"><![CDATA[if (!empty($data['redirect'])) {]]></ignoreif>
            <add position="replace"><![CDATA[$url = $this->getListUrlParams();

            if (!empty($data['redirect'])) {
                $redirect = $data['redirect'];
            } elseif (!empty($this->request->get['redirect'])) {
                $redirect = $this->request->get['redirect'];
            } else {
                $redirect = 'marketplace/modification';
            }

            $this->response->redirect($this->url->link($redirect, 'user_token=' . $this->session->data['user_token'] . $url, true));]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[if ($this->validate()) {]]></search>
            <add position="after"><![CDATA[             $error_log = array();

            // Clear vqmod cache
            $vqmod_path = substr(DIR_SYSTEM, 0, -7) . 'vqmod/';

            if (file_exists($vqmod_path)) {
                $vqmod_cache = glob($vqmod_path.'vqcache/vq*');

                if ($vqmod_cache) {
                    foreach ($vqmod_cache as $file) {
                        if (file_exists($file)) {
                            @unlink($file);
                        }
                    }
                }

                if (file_exists($vqmod_path.'mods.cache')) {
                    @unlink($vqmod_path.'mods.cache');
                }

                if (file_exists($vqmod_path.'checked.cache')) {
                    @unlink($vqmod_path.'checked.cache');
                }
            }
]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$log[] = 'MOD:]]></search>
            <add position="after"><![CDATA[             $error_log_mod = 'MOD: ' . $dom->getElementsByTagName('name')->item(0)->textContent;
]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$operations = $file->getElementsByTagName('operation');]]></search>
            <add position="after"><![CDATA[             
                    $file_error = $file->getAttribute('error');]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$files = glob($path, GLOB_BRACE);]]></search>
            <add position="after"><![CDATA[                         if (!$files) {
                                if ($file_error != 'skip') {
                                    $error_log[] = '----------------------------------------------------------------';
                                    $error_log[] = $error_log_mod;
                                    $error_log[] = 'MISSING FILE!';
                                    $error_log[] = $path;                                   
                                }
                            }]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[if (!$status) {]]></search>
            <add position="after"><![CDATA[                                         if ($error != 'skip') {
                                                $error_log[] = "\n";
                                                $error_log[] = $error_log_mod;
                                                $error_log[] = 'NOT FOUND!';
                                                $error_log[] = 'CODE: ' . $search;
                                                $error_log[] = 'FILE: ' . $key;
                                            }]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[$ocmod->write(implode("\n", $log));]]></search>
            <add position="after"><![CDATA[
            if ($error_log) {
                $ocmod = new Log('ocmod_error.log');
                $ocmod->write(implode("\n", $error_log));
            }]]></add>
        </operation>
        <operation>
            <search index="0"><![CDATA[protected function validate(]]></search>
            <add position="before"><![CDATA[

public function add() {
        $this->load->language('marketplace/modification');

        $this->load->model('extension/module/modification_manager');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
            $xml = html_entity_decode($this->request->post['xml'], ENT_QUOTES, 'UTF-8');

            $dom = new DOMDocument('1.0', 'UTF-8');
            $dom->preserveWhiteSpace = false;
            $dom->loadXml($xml);

            $data = array(
                'version' => '',
                'author' => '',
                'link' => '',
                'status' => 1
            );

            $data['xml'] = $xml;

            $data['name'] = $dom->getElementsByTagName('name')->item(0)->textContent;

            $data['code'] = $dom->getElementsByTagName('code')->item(0)->textContent;

            if ($dom->getElementsByTagName('version')->length) {
                $data['version'] = $dom->getElementsByTagName('version')->item(0)->textContent;
            }

            if ($dom->getElementsByTagName('author')->length) {
                $data['author'] = $dom->getElementsByTagName('author')->item(0)->textContent;
            }

            $this->model_extension_module_modification_manager->addModification($data);

            $modification_id = $this->db->getLastId();

            $this->session->data['success'] = $this->language->get('text_success');

            $this->response->redirect($this->url->link('marketplace/modification/edit', 'user_token=' . $this->session->data['user_token'] . $this->getListUrlParams(array('modification_id' => $modification_id)), true));
        }

        $this->getForm();
    }

    public function edit() {
        $this->load->language('marketplace/modification');

        $this->load->model('extension/module/modification_manager');
        
        if (($this->request->server['REQUEST_METHOD'] == 'POST') && !empty($this->request->get['modification_id']) && $this->validateForm()) {
            $modification_id = $this->request->get['modification_id'];

            $xml = html_entity_decode($this->request->post['xml'], ENT_QUOTES, 'UTF-8');

            $dom = new DOMDocument('1.0', 'UTF-8');
            $dom->preserveWhiteSpace = false;
            $dom->loadXml($xml);

            $data = array();

            $data['xml'] = $xml;

            $data['name'] = $dom->getElementsByTagName('name')->item(0)->textContent;

            $data['code'] = $dom->getElementsByTagName('code')->item(0)->textContent;

            if ($dom->getElementsByTagName('version')->length) {
                $data['version'] = $dom->getElementsByTagName('version')->item(0)->textContent;
            } else {
                $data['version'] = '';
            }

            if ($dom->getElementsByTagName('author')->length) {
                $data['author'] = $dom->getElementsByTagName('author')->item(0)->textContent;
            } else {
                $data['author'] = '';
            }

            if ($dom->getElementsByTagName('link')->length) {
                $data['link'] = $dom->getElementsByTagName('link')->item(0)->textContent;
            } else {
                $data['link'] = '';
            }

            $this->model_extension_module_modification_manager->editModification($modification_id, $data);

            $url = $this->getListUrlParams(array('modification_id' => $modification_id));

            if (isset($this->request->get['refresh'])) {
                $this->response->redirect($this->url->link('marketplace/modification/refresh', 'user_token=' . $this->session->data['user_token'] . $url, true));
            }

            if ($this->db->countAffected()) {
                $this->session->data['success'] = $this->language->get('text_success');

                $this->response->redirect($this->url->link('marketplace/modification/edit', 'user_token=' . $this->session->data['user_token'] . $url, true));
            }
        }

        $this->getForm();
    }
    
    public function download() {
        
        if (!$this->user->hasPermission('modify', 'marketplace/modification')) {
            $this->response->redirect($this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'], true));
        }

        if (isset($this->request->get['modification_id'])) {
            $modification_id = $this->request->get['modification_id'];
        } else {
            $modification_id = 0;
        }
        
        $this->load->model('extension/module/modification_manager');
        $modification = $this->model_extension_module_modification_manager->getModification($modification_id);

        if ($modification) {
            $filename = $modification['code'] . '.ocmod.xml';
            $file = $modification['xml'];

            ob_start();
            echo $file;
            $download = ob_get_contents();
            $size = ob_get_length();
            ob_end_clean();
            
            if (!headers_sent()) {
                if (!empty($modification['xml'])) {
                    header('Content-Type: application/octet-stream');
                    header('Content-Disposition: attachment; filename="' . $filename . '"');
                    header('Content-Transfer-Encoding: binary');
                    header('Expires: 0');
                    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                    header('Pragma: public');
                    header('Content-Length: ' . $size);

                    if (ob_get_level()) {
                        ob_end_clean();
                    }

                    echo $download;

                    exit();
                } else {
                    exit($this->language->get('error_file'));
                }
            } else {
                exit($this->language->get('error_headers'));
            }
        } else {
            $this->response->redirect($this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'] . $url, true));
        }
    }
    
    public function getForm() {
        $data['heading_title'] = $this->language->get('heading_title');

        $data['text_enabled'] = $this->language->get('text_enabled');
        $data['text_disabled'] = $this->language->get('text_disabled');

        $data['button_save'] = $this->language->get('button_save');
        $data['button_download'] = $this->language->get('button_download');
        $data['button_refresh'] = $this->language->get('button_refresh');
        $data['button_cancel'] = $this->language->get('button_cancel');

        if (isset($this->error['warning'])) {
            $data['error_warning'] = $this->error['warning'];
        } elseif (!empty($this->error)) {
            $data['error_warning'] = $this->language->get('error_warning');
        } else {
            $data['error_warning'] = '';
        }

        if (isset($this->session->data['success'])) {
            $data['success'] = $this->session->data['success'];

            unset($this->session->data['success']);
        } else {
            $data['success'] = false;
        }

        if (isset($this->error['xml'])) {
            $data['error_xml'] = $this->error['xml'];
        }

        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_home'),
            'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
        );

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('heading_title'),
            'href' => $this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'] . $this->getListUrlParams(), true)
        );

        if (isset($this->request->get['modification_id'])) {
            $this->load->model('extension/module/modification_manager');

            $modification_info = $this->model_extension_module_modification_manager->getModification($this->request->get['modification_id']);
            if (!$modification_info) exit;

            $data['text_form'] = sprintf($this->language->get('text_edit'), $modification_info['name']);

            $data['action'] = $this->url->link('marketplace/modification/edit', '&modification_id=' . $modification_info['modification_id'] . '&user_token=' . $this->session->data['user_token'], true);

            $data['refresh'] = $this->url->link('marketplace/modification/edit', '&modification_id=' . $modification_info['modification_id'] . '&refresh=1&user_token=' . $this->session->data['user_token'], true);

            $this->document->setTitle($modification_info['name'] . ' 

CodePudding user response:

I have not checked whole code, but you can not replace part of the string...

<operation>
            <search index="0"><![CDATA[$this->load->view('marketplace/modification']]></search>
            <add position="replace"><![CDATA[$this->load->view('extension/module/modification_manager/list']]></add>
        </operation>

To check if the code properly added or replaced by xml, find modified files and check your code.

CodePudding user response:

Disable ocmod extensions one by one, then refresh to find the problem.

You can clear the cache in the storage folder and disable them, or log in to your MySQL and set them all off manually.

It seems one extension is causing you an issue.

  •  Tags:  
  • xml
  • Related