Jump to content

Bug in - Configure: Contact information block [SOLVED]


EBS Developer

Recommended Posts

I have been using Prestashop for while, and love all the features which bundles with it. With the help of other this forums i was able to understand the working of prestashop.

 

Recently i had few problem with this particular plugin.

 

Plugin :

Contact Information Block

 

Problem :

This plugin allow us to show contact information of the store in the footer of the website. with the following text fields

1. Company name

2. Address

3. Phone Number

4. Email

 

When i enter the information in the particular fields till Phone Number i.e (filling Company Name, Address and Phone number only) and saving then this information is reflected on the front store.

 

But as soon as i try to enter email ID and save the front store crashes and just shows a blank page. some contact information block content.

 

i have attached the files for the reference.

 

My Site Works Well when following is configured

 

Back office : 

post-1153117-0-56624300-1458730047_thumb.png

Output:

post-1153117-0-34819500-1458729831_thumb.png

 

 

After i save the email address in configuration

Back office : 

post-1153117-0-84190300-1458730054_thumb.png

Output:

post-1153117-0-96706000-1458730059_thumb.png

 

 

I Request our community to help me solve this problem.

 

Edited by abode-developer (see edit history)
Link to comment
Share on other sites

Hello Friends,

 

I found out the solution for the same Post it here if any one caught with the same.

 

Scenario :

 

My Prestashop is installed on a shared platform with linux installation. And this servers are protected by some or other sort of Antivirus. A month ago one of my host anti virus detected [Root/tools/smarty/plugins/function.mailto.php] as a potentially Unwanted Program (PUP) or Potentially Unwanted Application (PUA).  i.e according to the antivirus function.mailto.php was a virus, which in turn blocked access port-80 to my prestashop website. To tackle the problem i was suggested either to remove the full file or code which was detected as problem.

 

Thus from various source i found out source code for function.mailto.php and replaced the same. which did solved the problem. but this broke actual code in function.mailto.php file due to which the following error

Back office : 

post-1153117-0-84190300-1458730054_thumb

Output:

post-1153117-0-96706000-1458730059_thumb

 

After heavy digging... i found the problem which was a Modified function.mailto.php file due to False Positive Detection. 

 

Solution :

If you happen to encounter the same problem, here is the solution. copy the attached function.mailto.php file and replace with your file on address

[Prestashop_Installation_Dir/tools/smarty/plugins/function.mailto.php]

<?php
/**
 * Smarty plugin
 *
 * @package    Smarty
 * @subpackage PluginsFunction
 */

/**
 * Smarty {mailto} function plugin
 * Type:     function<br>
 * Name:     mailto<br>
 * Date:     May 21, 2002
 * Purpose:  automate mailto address link creation, and optionally encode them.<br>
 * Params:
 * <pre>
 * - address    - (required) - e-mail address
 * - text       - (optional) - text to display, default is address
 * - encode     - (optional) - can be one of:
 *                             * none : no encoding (default)
 *                             * javascript : encode with javascript
 *                             * javascript_charcode : encode with javascript charcode
 *                             * hex : encode with hexidecimal (no javascript)
 * - cc         - (optional) - address(es) to carbon copy
 * - bcc        - (optional) - address(es) to blind carbon copy
 * - subject    - (optional) - e-mail subject
 * - newsgroups - (optional) - newsgroup(s) to post to
 * - followupto - (optional) - address(es) to follow up to
 * - extra      - (optional) - extra tags for the href link
 * </pre>
 * Examples:
 * <pre>
 * {mailto address="[email protected]"}
 * {mailto address="[email protected]" encode="javascript"}
 * {mailto address="[email protected]" encode="hex"}
 * {mailto address="[email protected]" subject="Hello to you!"}
 * {mailto address="[email protected]" cc="[email protected],[email protected]"}
 * {mailto address="[email protected]" extra='class="mailto"'}
 * </pre>
 *
 * @link     http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
 *           (Smarty online manual)
 * @version  1.2
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @author   credits to Jason Sweat (added cc, bcc and subject functionality)
 *
 * @param array $params parameters
 *
 * @return string
 */
function smarty_function_mailto($params)
{
    static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
    $extra = '';

    if (empty($params['address'])) {
        trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);

        return;
    } else {
        $address = $params['address'];
    }

    $text = $address;
    // netscape and mozilla do not decode %40 (@) in BCC field (bug?)
    // so, don't encode it.
    $search = array('%40', '%2C');
    $replace = array('@', ',');
    $mail_parms = array();
    foreach ($params as $var => $value) {
        switch ($var) {
            case 'cc':
            case 'bcc':
            case 'followupto':
            if (!empty($value)) {
                $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
            }
                break;

            case 'subject':
            case 'newsgroups':
                $mail_parms[] = $var . '=' . rawurlencode($value);
                break;

            case 'extra':
            case 'text':
                $$var = $value;

            default:
        }
    }

    if ($mail_parms) {
        $address .= '?' . join('&', $mail_parms);
    }

    $encode = (empty($params['encode'])) ? 'none' : $params['encode'];
    if (!isset($_allowed_encoding[$encode])) {
        trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING);

        return;
    }
    // FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
    if ($encode == 'javascript') {
        $string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';

        $js_encode = '';
        for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) {
            $js_encode .= '%' . bin2hex($string[$x]);
        }

        return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
    } elseif ($encode == 'javascript_charcode') {
        $string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';

        for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
            $ord[] = ord($string[$x]);
        }

        $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n"
            . "{document.write(String.fromCharCode("
            . implode(',', $ord)
            . "))"
            . "}\n"
            . "</script>\n";

        return $_ret;
    } elseif ($encode == 'hex') {
        preg_match('!^(.*)(\?.*)$!', $address, $match);
        if (!empty($match[2])) {
            trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);

            return;
        }
        $address_encode = '';
        for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) {
            if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) {
                $address_encode .= '%' . bin2hex($address[$x]);
            } else {
                $address_encode .= $address[$x];
            }
        }
        $text_encode = '';
        for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) {
            $text_encode .= '' . bin2hex($text[$x]) . ';';
        }

        $mailto = "mailto:";

        return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
    } else {
        // no encoding
        return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
    }
}

IMPORTANT NOTE : Before trying any solutions for your problem which ask you to modify some important files as above. take a full bakup so that if something screwed then can be restored back.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...