Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

PHP version 5.3.29 Error: class.submit.php file line 156 #7

Closed
gutierrezgarbiero opened this issue Jul 22, 2016 · 3 comments
Closed

Comments

@gutierrezgarbiero
Copy link

Hi, i have a problem with the plugin.

I'm getting this error when i install the plugin:

Parse error: syntax error, unexpected '[' in /home/public_html/wp-content/plugins/cf7-mautic-extention/inc/class.submit.php on line 156

But it's only happening on my production server with PHP Version 5.3.29.

On my development server with PHP Version 5.6.17 the plugin fuctions perfectly.

This is the part of the code that's giving the error, file class.submit.php:

/**
 * Get User's IP
 *
 * @return string
 * @since 0.0.1
 */
private function _get_ip() {
    $ip_list = [
        'HTTP_CLIENT_IP',
        'HTTP_X_FORWARDED_FOR',
        'HTTP_X_FORWARDED',
        'HTTP_X_CLUSTER_CLIENT_IP',
        'HTTP_FORWARDED_FOR',
        'HTTP_FORWARDED'
    ];
    foreach ( $ip_list as $key ) {
        if ( ! isset( $_SERVER[ $key ] ) ) {
            continue;
        }
        $ip = esc_attr( $_SERVER[ $key ] );
        if ( ! strpos( $ip, ',' ) ) {
            $ips =  explode( ',', $ip );
            foreach ( $ips as &$val ) {
                $val = trim( $val );
            }
            $ip = end ( $ips );
        }
        $ip = trim( $ip );
        break;
    }
    return $ip;
}

}

I really don't know how to solve this, can you help me?

Thanks in advance.

@hideokamoto
Copy link
Contributor

Please upgrade PHP versions.

To run WordPress we recommend your host supports:
PHP version 5.6 or greater
MySQL version 5.6 or greater OR MariaDB version 10.0 or greater
https://wordpress.org/about/requirements/

@gutierrezgarbiero
Copy link
Author

Thanks, but in this case i cannot do that because is on a shared server... so i cannot update the php version. ¿Is there something i can do to solve this?

@hideokamoto
Copy link
Contributor

well...

Could you try to change this code?
https://github.com/amimoto-ami/cf7-mautic/blob/master/inc/class.submit.php#L156-L163

Before

    private function _get_ip() {
        $ip_list = [
            'HTTP_CLIENT_IP',
            'HTTP_X_FORWARDED_FOR',
            'HTTP_X_FORWARDED',
            'HTTP_X_CLUSTER_CLIENT_IP',
            'HTTP_FORWARDED_FOR',
            'HTTP_FORWARDED'
        ];

After

    private function _get_ip() {
        $ip_list = array(
            'HTTP_CLIENT_IP',
            'HTTP_X_FORWARDED_FOR',
            'HTTP_X_FORWARDED',
            'HTTP_X_CLUSTER_CLIENT_IP',
            'HTTP_FORWARDED_FOR',
            'HTTP_FORWARDED'
        );

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants