Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2017-03-21 06:33:44

qasimraf
Member
Registered: 2017-03-21
Posts: 3

Help required in PHP coding

Hi to all experts here.

Please check this code below. THE ISSUE IS THAT I AM RECEIVING THIS ERROR "strpos(): Empty needle in" ON LINE 8. So please let me know what should be the remedy.

<?php   
class ControllerCommonHeader extends Controller {
    protected function index() {
        $this->data['title'] = $this->document->getTitle();
       
        if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
            $server = $this->config->get('config_ssl');
        } else {
            $server = $this->config->get('config_url');
        }

        $this->data['base'] = $server;
        $this->data['description'] = $this->document->getDescription();
        $this->data['keywords'] = $this->document->getKeywords();
        $this->data['links'] = $this->document->getLinks();    
        $this->data['styles'] = $this->document->getStyles();
        $this->data['scripts'] = $this->document->getScripts();
        $this->data['lang'] = $this->language->get('code');
        $this->data['direction'] = $this->language->get('direction');
        $this->data['google_analytics'] = html_entity_decode($this->config->get('config_google_analytics'), ENT_QUOTES, 'UTF-8');
        $this->data['name'] = $this->config->get('config_name');
       
        if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
            $this->data['icon'] = $server . 'image/' . $this->config->get('config_icon');
        } else {
            $this->data['icon'] = '';
        }
       
        if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
            $this->data['logo'] = $server . 'image/' . $this->config->get('config_logo');
        } else {
            $this->data['logo'] = '';
        }       
       
        $this->language->load('common/header');
       
        $this->data['text_home'] = $this->language->get('text_home');
        $this->data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
        $this->data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
        $this->data['text_search'] = $this->language->get('text_search');
        $this->data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
        $this->data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(), $this->url->link('account/logout', '', 'SSL'));
        $this->data['text_account'] = $this->language->get('text_account');
        $this->data['text_checkout'] = $this->language->get('text_checkout');
       
        // Custom Add by Harnish Design
        $this->data['text_information'] = $this->language->get('text_information');
        $this->data['text_contact'] = $this->language->get('text_contact');
        $this->data['text_account'] = $this->language->get('text_account');
        $this->data['text_order'] = $this->language->get('text_order');
        $this->data['text_newsletter'] = $this->language->get('text_newsletter');
        $this->language->load('module/category');       
        $this->data['heading_title'] = $this->language->get('heading_title');
        // End
       
        $this->data['home'] = $this->url->link('common/home');
        $this->data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL');
        $this->data['logged'] = $this->customer->isLogged();
        $this->data['account'] = $this->url->link('account/account', '', 'SSL');
        $this->data['shopping_cart'] = $this->url->link('checkout/cart');
        $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
       
        // Custom Add by Harnish Design
        $this->load->model('catalog/information');
        $this->data['informations'] = array();
        foreach ($this->model_catalog_information->getInformations() as $result) {
            if ($result['bottom']) {
                $this->data['informations'][] = array(
                    'title' => $result['title'],
                    'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
                );
            }
        }
        $this->data['contact'] = $this->url->link('information/contact');
        $this->data['account'] = $this->url->link('account/account', '', 'SSL');
        $this->data['order'] = $this->url->link('account/order', '', 'SSL');
        $this->data['newsletter'] = $this->url->link('account/newsletter', '', 'SSL');
        // End
       
        // Daniel's robot detector
        $status = true;
       
        if (isset($this->request->server['HTTP_USER_AGENT'])) {
            $robots = explode("\n", trim($this->config->get('config_robots')));

            foreach ($robots as $robot) {
                if ($robot && strpos($this->request->server['HTTP_USER_AGENT'], trim($robot)) !== false) {
                    $status = false;

                    break;
                }
            }
        }
       
        // A dirty hack to try to set a cookie for the multi-store feature
        $this->load->model('setting/store');
       
        $this->data['stores'] = array();
       
        if ($this->config->get('config_shared') && $status) {
            $this->data['stores'][] = $server . 'catalog/view/javascript/crossdomain.php?session_id=' . $this->session->getId();
           
            $stores = $this->model_setting_store->getStores();
                   
            foreach ($stores as $store) {
                $this->data['stores'][] = $store['url'] . 'catalog/view/javascript/crossdomain.php?session_id=' . $this->session->getId();
            }
        }
               
        // Search       
        if (isset($this->request->get['search'])) {
            $this->data['search'] = $this->request->get['search'];
        } else {
            $this->data['search'] = '';
        }
       
        // Menu
        $this->load->model('catalog/category');
       
        $this->load->model('catalog/product');
       
        $this->data['categories'] = array();
                   
        $categories = $this->model_catalog_category->getCategories(0);
       
        foreach ($categories as $category) {
            if ($category['top']) {
                // Level 2
                $children_data = array();
               
                $children = $this->model_catalog_category->getCategories($category['category_id']);
               
                foreach ($children as $child) {
                    $data = array(
                        'filter_category_id'  => $child['category_id'],
                        'filter_sub_category' => true
                    );
                   
                    $product_total = $this->model_catalog_product->getTotalProducts($data);
                                   
                    $children_data[] = array(
                        'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
                        'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
                    );                       
                }
               
                // Level 1
                $this->data['categories'][] = array(
                    'name'     => $category['name'],
                    'children' => $children_data,
                    'column'   => $category['column'] ? $category['column'] : 1,
                    'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
                );
               
            }
        }
       
        $this->children = array(
            'module/language',
            'module/currency',
            'module/cart'
        );
               
        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
        } else {
            $this->template = 'default/template/common/header.tpl';
        }
       
        $this->render();
    }    
}
?>

Thank you.

Offline

#2 2017-03-21 06:38:04

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Help required in PHP coding

Hi qasimraf,
welcome in the live helper chat forum.

Sorry but your post is not a good post so I cannot help you.
No steps to understand where and when you have this error.
This seems maybe can be an issue in your specific server.

A good post is not only copy and paste but has description about what happen and when the error occurs, also where you see this error.
This is not a live helper chat error, maybe your page is printing code and this is error of your server configuration.


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

#3 2017-03-21 06:47:21

qasimraf
Member
Registered: 2017-03-21
Posts: 3

Re: Help required in PHP coding

ok. Let me check on server side.
I will get back to you if needed.

Thank You.

Offline

#4 2017-03-21 06:52:14

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Help required in PHP coding

You are welcome.
Please made more complete post.
Details is essential to help you.

Have a nice time!  smile


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

#5 2017-03-21 07:21:01

qasimraf
Member
Registered: 2017-03-21
Posts: 3

Re: Help required in PHP coding

Sir
Do you know how to disable debug mode in opencart admin?

Offline

#6 2017-03-21 07:25:07

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Help required in PHP coding

No sorry smile but you can Google it
Example: opencart disable debug mode

This is live helper chat help forum  smile


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

Board footer