Plugin Directory

Changeset 1542874


Ignore:
Timestamp:
11/29/2016 06:53:52 PM (9 years ago)
Author:
MVR
Message:

tagging version 1.0.5

Location:
userecho
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • userecho/tags/1.0.5/readme.txt

    r974828 r1542874  
    11=== UserEcho for Wordpress ===
    2 Contributors: sstukov
     2Contributors: sstukov, mvr
    33Donate link: http://userecho.com/
    44Tags: feedback, users community, widget, ideas, helpdesk, livechat
    55Requires at least: 2.8
    66Tested up to: 3.9.2
    7 Stable tag: 1.0.4
     7Stable tag: 1.0.5
    88
    99Integrate UserEcho - customer feedback and helpdesk system into your blog. Using widget or link. Support SSO.
     
    5454* Some description updates
    5555* Added top & bottom positions to tab orientation settings
     56= 1.0.4 =
     57= 1.0.5 =
     58* Updated to support latest SSO version
     59* Added SSO parameter "email_verified"
     60* Updated to support last list of languages
     61* Removed "sso_token" parameter from links if empty
  • userecho/tags/1.0.5/userecho.php

    r974828 r1542874  
    22/*
    33Plugin Name: UserEcho for Wordpress - collect feedback for your blog
    4 Version: 1.0.4
     4Version: 1.0.5
    55Plugin URI: http://userecho.com
    6 Author: Jonathan Champ, Sergey Stukov
     6Author: Jonathan Champ, Sergey Stukov, Vladimir Mullagaliyev
    77Author URI: http://userecho.com
    88Description: UserEcho - feedback widget to collect and manage user feedback for your blog.
     
    5959
    6060            if ( !empty( $_POST['api_key'] ) ) { $options['api_key'] = $_POST['api_key']; }
    61             if ( !empty( $_POST['project_key'] ) ) { $options['project_key'] = $_POST['project_key']; }
    6261            if ( !empty( $_POST['domain'] ) ) { $options['domain'] = $_POST['domain']; }
    6362            if ( !empty( $_POST['language'] ) ) { $options['language'] = $_POST['language']; }
     
    6564            $options['show_tab'] = !empty( $_POST['show_tab'] );
    6665            $options['tab_icon_show'] = !empty( $_POST['tab_icon_show'] );
     66            $options['verified_email'] = !empty( $_POST['verified_email'] );
    6767            if ( !empty( $_POST['forum'] ) ) { $options['forum'] = $_POST['forum']; }
    6868            if ( !empty( $_POST['tab_corner_radius'] ) ) { $options['tab_corner_radius'] = $_POST['tab_corner_radius']; }           
     
    9595            'is' => __( 'Icelandic' ) . ' (IS)',
    9696            'et' => __( 'Estonian' ) . ' (ET)',
     97            'kk' => __( 'Kazakh' ) . ' (KK)',
     98            'pt-br' => __( 'Portugal (Brasil)' ) . ' (PT-BR)',
     99            'uk' => __( 'Ukrainian' ) . ' (UK)',
     100            'cs' => __( 'Czech' ) . ' (CS)',
     101            'da' => __( 'Danish' ) . ' (DA)',
     102            'fi' => __( 'Finnish' ) . ' (FI)',
     103            'hu' => __( 'Hungarian' ) . ' (HU)',
     104            'it' => __( 'Italian' ) . ' (IT)',
     105            'ja' => __( 'Japanese' ) . ' (JA)',
     106            'ko' => __( 'Korean' ) . ' (KO)',
     107            'sv' => __( 'Swedish' ) . ' (SV)',
     108            'tr' => __( 'Turkish' ) . ' (TR)',
     109            'zh-hans' => __( 'Chinese' ) . ' (ZH-HANS)',
     110            'ca' => __( 'Catalan' ) . ' (CA)',
     111            'pl' => __( 'Polish' ) . ' (PL)',
     112            'nb' => __( 'Norwegian Bokmal' ) . ' (NB)',
     113            'he' => __( 'Hebrew' ) . ' (HE)',
     114            'ar' => __( 'Arabic' ) . ' (AR)',
    97115        );
    98116
     
    104122        );
    105123       
    106 
    107124        if ( !empty( $options['language'] ) ) {
    108125            $language_options += array( $options['language'] => 'Custom (' + $options['language'] + ')' );
     
    223240                        </tr>
    224241                        <tr valign="top">
    225                             <th><?php _e( 'Project Key', 'UserEcho' ); ?></th>
    226                             <td>
    227                                 <input id="project_key" name="project_key" type="text" class="regular-text" value="<?php echo esc_attr( $options['project_key'] ); ?>" />
     242                            <th><?php _e( 'User email verified?', 'UserEcho' ); ?></th>
     243                            <td>
     244                                <input id="verified_email" name="verified_email" type="checkbox" value="1"<?php checked( $options['verified_email'], '1' ); ?> />
    228245                            </td>
    229246                        </tr>
     
    246263            $default = array(
    247264                'api_key' => '',
    248                 'project_key' => 'PROJECT_KEY',
    249                 'domain' => 'PROJECT_KEY.userecho.com',
     265                'domain' => 'YOUR_ALIAS.userecho.com',
    250266                'show_tab' => 1,
    251267                'language' => 'en',
     
    259275                'tab_hover_color' => '#f45c5c',
    260276                'tab_icon_show' => 1,
     277                'verified_email' => 1,
     278
    261279            );
    262280        }
     
    288306                'email' => $current_user->user_email, // User email - used for notification about changes on feedback
    289307                'locale' => $options['language'], // (Optional) User language override
     308                'verified_email' => $options['verified_email'], // (Optional) Is user's email verified?
    290309            );
    291310        }
     
    293312        return "";
    294313
    295 
    296        
    297         $api_key = $options['api_key']; // Your project personal api key
    298         $project_key = $options['project_key']; // Your project alias
    299 
    300         $message = $params + array(
    301             'expires_date' => gmdate( 'Y-m-d H:i:s', time() + 36000 ), // sso_token expiration date in format 'Y-m-d H:i:s'. Recommend set date now() + 10 hours
    302         );
    303 
    304         // random bytes value, length = 16
    305         // Recommend use random to generate $iv
    306         $iv = substr( md5( rand() ), 0, 16 );
    307 
    308         // key hash, length = 16
    309         $key_hash = substr( hash( 'sha1', $api_key . $project_key, true ), 0, 16 );
    310 
    311         $message_json = json_encode( $message );
    312 
    313         // double XOR first block message_json
    314         for ( $i = 0; $i < 16; $i++ ) {
    315             $message_json[$i] = $message_json[$i] ^ $iv[$i];
    316         }
    317 
    318         // fill tail of message_json by bytes equaled count empty bytes (to 16)
    319         $pad = 16 - ( strlen( $message_json ) % 16 );
    320         $message_json = $message_json . str_repeat( chr( $pad ), $pad );
    321 
    322         // encode json
    323         $cipher = mcrypt_module_open( MCRYPT_RIJNDAEL_128, '', 'cbc', '' );
    324         mcrypt_generic_init( $cipher, $key_hash, $iv );
    325         $encrypted_bytes = mcrypt_generic( $cipher, $message_json );
    326         mcrypt_generic_deinit( $cipher );
    327 
    328         // encode bytes to url safe string
    329         return urlencode( base64_encode( $encrypted_bytes ) );
     314        $ue_sso_cipher = new UeSsoCipher();
     315        return $ue_sso_cipher->encrypt($options['api_key'], $params);
    330316    }
    331317
     
    374360                'tab_bg_color' => $options['tab_bg_color'],
    375361                'tab_hover_color' => $options['tab_hover_color'],
    376                 'params' => array('sso_token' => $this->get_sso_token()),
    377362            );
     363
     364            $sso_token = $this->get_sso_token();
     365            if ($sso_token){
     366                $_ues = $_ues + array(
     367                    'params' => array('sso_token' => $sso_token),
     368                );
     369            }
     370
    378371            echo "<script type='text/javascript'>
    379372            var _ues = " . json_encode( $_ues ) . ";
     
    381374            (function() {
    382375                var _ue = document.createElement('script'); _ue.type = 'text/javascript'; _ue.async = true;
    383                 _ue.src = ('https:' == document.location.protocol ? 'https://s3.amazonaws.com/' : 'http://') + 'cdn.userecho.com/js/widget-1.4.gz.js';
     376                _ue.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.userecho.com/js/widget-1.4.gz.js';
    384377                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(_ue, s);
    385378            })();
     
    414407        $redirect = $base_url;
    415408
    416         $redirect .= '?sso_token=' . $this->get_sso_token();
     409        $sso_token = $this->get_sso_token();
     410        if ($sso_token){
     411            $redirect .= '?sso_token=' . $this->get_sso_token();
     412        }
    417413       
    418414        header( 'Location: ' . $redirect );
     
    487483}
    488484
     485class UeSsoCipher
     486{
     487    const BLOCK_SIZE = 16;
     488
     489    /*
     490        Generate sso_token
     491        @param  $key - your sso_key
     492        @param  $data_json - prepared data in json format
     493        @return string
     494     */
     495    public function encrypt($key, $data_json)
     496    {
     497        // add expires if does not exist
     498        if (!array_key_exists('expires',$data_json))
     499        {
     500            # add 1 hour
     501            $data_json['expires'] = time()+3600;
     502        }
     503
     504        $iv = $this->getRandomString(self::BLOCK_SIZE);
     505        $raw = $this->pad(json_encode($data_json));
     506        $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
     507        mcrypt_generic_init($cipher, $key, $iv);
     508        $encryptedBytes = mcrypt_generic($cipher, $raw);
     509        mcrypt_generic_deinit($cipher);
     510        return urlencode(base64_encode($iv . $encryptedBytes));
     511    }
     512
     513    /* Padding string */
     514    private function pad($raw)
     515    {
     516        $pad = self::BLOCK_SIZE - (strlen($raw) % self::BLOCK_SIZE);
     517        return ($pad == self::BLOCK_SIZE)? $raw : $raw . str_repeat(chr($pad), $pad);
     518    }
     519
     520    private function getRandomString($length)
     521    {
     522        $str       = 'abcdefjhigklmnopqrstuvwzxyABCDEFGHJKLMNPQRSTUVWXYZ123456789';
     523        $strLength = strlen($str);
     524        $res       = '';
     525        for ($i = 0; $i < $length; $i++) {
     526            $res .= $str[rand(0, $strLength - 1)];
     527        }
     528        return $res;
     529    }
     530}
     531
    489532$ue = new UserEcho();
  • userecho/trunk/readme.txt

    r974828 r1542874  
    11=== UserEcho for Wordpress ===
    2 Contributors: sstukov
     2Contributors: sstukov, mvr
    33Donate link: http://userecho.com/
    44Tags: feedback, users community, widget, ideas, helpdesk, livechat
    55Requires at least: 2.8
    66Tested up to: 3.9.2
    7 Stable tag: 1.0.4
     7Stable tag: 1.0.5
    88
    99Integrate UserEcho - customer feedback and helpdesk system into your blog. Using widget or link. Support SSO.
     
    5454* Some description updates
    5555* Added top & bottom positions to tab orientation settings
     56= 1.0.4 =
     57= 1.0.5 =
     58* Updated to support latest SSO version
     59* Added SSO parameter "email_verified"
     60* Updated to support last list of languages
     61* Removed "sso_token" parameter from links if empty
  • userecho/trunk/userecho.php

    r974828 r1542874  
    22/*
    33Plugin Name: UserEcho for Wordpress - collect feedback for your blog
    4 Version: 1.0.4
     4Version: 1.0.5
    55Plugin URI: http://userecho.com
    6 Author: Jonathan Champ, Sergey Stukov
     6Author: Jonathan Champ, Sergey Stukov, Vladimir Mullagaliyev
    77Author URI: http://userecho.com
    88Description: UserEcho - feedback widget to collect and manage user feedback for your blog.
     
    5959
    6060            if ( !empty( $_POST['api_key'] ) ) { $options['api_key'] = $_POST['api_key']; }
    61             if ( !empty( $_POST['project_key'] ) ) { $options['project_key'] = $_POST['project_key']; }
    6261            if ( !empty( $_POST['domain'] ) ) { $options['domain'] = $_POST['domain']; }
    6362            if ( !empty( $_POST['language'] ) ) { $options['language'] = $_POST['language']; }
     
    6564            $options['show_tab'] = !empty( $_POST['show_tab'] );
    6665            $options['tab_icon_show'] = !empty( $_POST['tab_icon_show'] );
     66            $options['verified_email'] = !empty( $_POST['verified_email'] );
    6767            if ( !empty( $_POST['forum'] ) ) { $options['forum'] = $_POST['forum']; }
    6868            if ( !empty( $_POST['tab_corner_radius'] ) ) { $options['tab_corner_radius'] = $_POST['tab_corner_radius']; }           
     
    9595            'is' => __( 'Icelandic' ) . ' (IS)',
    9696            'et' => __( 'Estonian' ) . ' (ET)',
     97            'kk' => __( 'Kazakh' ) . ' (KK)',
     98            'pt-br' => __( 'Portugal (Brasil)' ) . ' (PT-BR)',
     99            'uk' => __( 'Ukrainian' ) . ' (UK)',
     100            'cs' => __( 'Czech' ) . ' (CS)',
     101            'da' => __( 'Danish' ) . ' (DA)',
     102            'fi' => __( 'Finnish' ) . ' (FI)',
     103            'hu' => __( 'Hungarian' ) . ' (HU)',
     104            'it' => __( 'Italian' ) . ' (IT)',
     105            'ja' => __( 'Japanese' ) . ' (JA)',
     106            'ko' => __( 'Korean' ) . ' (KO)',
     107            'sv' => __( 'Swedish' ) . ' (SV)',
     108            'tr' => __( 'Turkish' ) . ' (TR)',
     109            'zh-hans' => __( 'Chinese' ) . ' (ZH-HANS)',
     110            'ca' => __( 'Catalan' ) . ' (CA)',
     111            'pl' => __( 'Polish' ) . ' (PL)',
     112            'nb' => __( 'Norwegian Bokmal' ) . ' (NB)',
     113            'he' => __( 'Hebrew' ) . ' (HE)',
     114            'ar' => __( 'Arabic' ) . ' (AR)',
    97115        );
    98116
     
    104122        );
    105123       
    106 
    107124        if ( !empty( $options['language'] ) ) {
    108125            $language_options += array( $options['language'] => 'Custom (' + $options['language'] + ')' );
     
    223240                        </tr>
    224241                        <tr valign="top">
    225                             <th><?php _e( 'Project Key', 'UserEcho' ); ?></th>
    226                             <td>
    227                                 <input id="project_key" name="project_key" type="text" class="regular-text" value="<?php echo esc_attr( $options['project_key'] ); ?>" />
     242                            <th><?php _e( 'User email verified?', 'UserEcho' ); ?></th>
     243                            <td>
     244                                <input id="verified_email" name="verified_email" type="checkbox" value="1"<?php checked( $options['verified_email'], '1' ); ?> />
    228245                            </td>
    229246                        </tr>
     
    246263            $default = array(
    247264                'api_key' => '',
    248                 'project_key' => 'PROJECT_KEY',
    249                 'domain' => 'PROJECT_KEY.userecho.com',
     265                'domain' => 'YOUR_ALIAS.userecho.com',
    250266                'show_tab' => 1,
    251267                'language' => 'en',
     
    259275                'tab_hover_color' => '#f45c5c',
    260276                'tab_icon_show' => 1,
     277                'verified_email' => 1,
     278
    261279            );
    262280        }
     
    288306                'email' => $current_user->user_email, // User email - used for notification about changes on feedback
    289307                'locale' => $options['language'], // (Optional) User language override
     308                'verified_email' => $options['verified_email'], // (Optional) Is user's email verified?
    290309            );
    291310        }
     
    293312        return "";
    294313
    295 
    296        
    297         $api_key = $options['api_key']; // Your project personal api key
    298         $project_key = $options['project_key']; // Your project alias
    299 
    300         $message = $params + array(
    301             'expires_date' => gmdate( 'Y-m-d H:i:s', time() + 36000 ), // sso_token expiration date in format 'Y-m-d H:i:s'. Recommend set date now() + 10 hours
    302         );
    303 
    304         // random bytes value, length = 16
    305         // Recommend use random to generate $iv
    306         $iv = substr( md5( rand() ), 0, 16 );
    307 
    308         // key hash, length = 16
    309         $key_hash = substr( hash( 'sha1', $api_key . $project_key, true ), 0, 16 );
    310 
    311         $message_json = json_encode( $message );
    312 
    313         // double XOR first block message_json
    314         for ( $i = 0; $i < 16; $i++ ) {
    315             $message_json[$i] = $message_json[$i] ^ $iv[$i];
    316         }
    317 
    318         // fill tail of message_json by bytes equaled count empty bytes (to 16)
    319         $pad = 16 - ( strlen( $message_json ) % 16 );
    320         $message_json = $message_json . str_repeat( chr( $pad ), $pad );
    321 
    322         // encode json
    323         $cipher = mcrypt_module_open( MCRYPT_RIJNDAEL_128, '', 'cbc', '' );
    324         mcrypt_generic_init( $cipher, $key_hash, $iv );
    325         $encrypted_bytes = mcrypt_generic( $cipher, $message_json );
    326         mcrypt_generic_deinit( $cipher );
    327 
    328         // encode bytes to url safe string
    329         return urlencode( base64_encode( $encrypted_bytes ) );
     314        $ue_sso_cipher = new UeSsoCipher();
     315        return $ue_sso_cipher->encrypt($options['api_key'], $params);
    330316    }
    331317
     
    374360                'tab_bg_color' => $options['tab_bg_color'],
    375361                'tab_hover_color' => $options['tab_hover_color'],
    376                 'params' => array('sso_token' => $this->get_sso_token()),
    377362            );
     363
     364            $sso_token = $this->get_sso_token();
     365            if ($sso_token){
     366                $_ues = $_ues + array(
     367                    'params' => array('sso_token' => $sso_token),
     368                );
     369            }
     370
    378371            echo "<script type='text/javascript'>
    379372            var _ues = " . json_encode( $_ues ) . ";
     
    381374            (function() {
    382375                var _ue = document.createElement('script'); _ue.type = 'text/javascript'; _ue.async = true;
    383                 _ue.src = ('https:' == document.location.protocol ? 'https://s3.amazonaws.com/' : 'http://') + 'cdn.userecho.com/js/widget-1.4.gz.js';
     376                _ue.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.userecho.com/js/widget-1.4.gz.js';
    384377                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(_ue, s);
    385378            })();
     
    414407        $redirect = $base_url;
    415408
    416         $redirect .= '?sso_token=' . $this->get_sso_token();
     409        $sso_token = $this->get_sso_token();
     410        if ($sso_token){
     411            $redirect .= '?sso_token=' . $this->get_sso_token();
     412        }
    417413       
    418414        header( 'Location: ' . $redirect );
     
    487483}
    488484
     485class UeSsoCipher
     486{
     487    const BLOCK_SIZE = 16;
     488
     489    /*
     490        Generate sso_token
     491        @param  $key - your sso_key
     492        @param  $data_json - prepared data in json format
     493        @return string
     494     */
     495    public function encrypt($key, $data_json)
     496    {
     497        // add expires if does not exist
     498        if (!array_key_exists('expires',$data_json))
     499        {
     500            # add 1 hour
     501            $data_json['expires'] = time()+3600;
     502        }
     503
     504        $iv = $this->getRandomString(self::BLOCK_SIZE);
     505        $raw = $this->pad(json_encode($data_json));
     506        $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
     507        mcrypt_generic_init($cipher, $key, $iv);
     508        $encryptedBytes = mcrypt_generic($cipher, $raw);
     509        mcrypt_generic_deinit($cipher);
     510        return urlencode(base64_encode($iv . $encryptedBytes));
     511    }
     512
     513    /* Padding string */
     514    private function pad($raw)
     515    {
     516        $pad = self::BLOCK_SIZE - (strlen($raw) % self::BLOCK_SIZE);
     517        return ($pad == self::BLOCK_SIZE)? $raw : $raw . str_repeat(chr($pad), $pad);
     518    }
     519
     520    private function getRandomString($length)
     521    {
     522        $str       = 'abcdefjhigklmnopqrstuvwzxyABCDEFGHJKLMNPQRSTUVWXYZ123456789';
     523        $strLength = strlen($str);
     524        $res       = '';
     525        for ($i = 0; $i < $length; $i++) {
     526            $res .= $str[rand(0, $strLength - 1)];
     527        }
     528        return $res;
     529    }
     530}
     531
    489532$ue = new UserEcho();
Note: See TracChangeset for help on using the changeset viewer.