Changeset 1542874
- Timestamp:
- 11/29/2016 06:53:52 PM (9 years ago)
- Location:
- userecho
- Files:
-
- 4 edited
- 1 copied
-
tags/1.0.5 (copied) (copied from userecho/trunk)
-
tags/1.0.5/readme.txt (modified) (2 diffs)
-
tags/1.0.5/userecho.php (modified) (14 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/userecho.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
userecho/tags/1.0.5/readme.txt
r974828 r1542874 1 1 === UserEcho for Wordpress === 2 Contributors: sstukov 2 Contributors: sstukov, mvr 3 3 Donate link: http://userecho.com/ 4 4 Tags: feedback, users community, widget, ideas, helpdesk, livechat 5 5 Requires at least: 2.8 6 6 Tested up to: 3.9.2 7 Stable tag: 1.0. 47 Stable tag: 1.0.5 8 8 9 9 Integrate UserEcho - customer feedback and helpdesk system into your blog. Using widget or link. Support SSO. … … 54 54 * Some description updates 55 55 * 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 2 2 /* 3 3 Plugin Name: UserEcho for Wordpress - collect feedback for your blog 4 Version: 1.0. 44 Version: 1.0.5 5 5 Plugin URI: http://userecho.com 6 Author: Jonathan Champ, Sergey Stukov 6 Author: Jonathan Champ, Sergey Stukov, Vladimir Mullagaliyev 7 7 Author URI: http://userecho.com 8 8 Description: UserEcho - feedback widget to collect and manage user feedback for your blog. … … 59 59 60 60 if ( !empty( $_POST['api_key'] ) ) { $options['api_key'] = $_POST['api_key']; } 61 if ( !empty( $_POST['project_key'] ) ) { $options['project_key'] = $_POST['project_key']; }62 61 if ( !empty( $_POST['domain'] ) ) { $options['domain'] = $_POST['domain']; } 63 62 if ( !empty( $_POST['language'] ) ) { $options['language'] = $_POST['language']; } … … 65 64 $options['show_tab'] = !empty( $_POST['show_tab'] ); 66 65 $options['tab_icon_show'] = !empty( $_POST['tab_icon_show'] ); 66 $options['verified_email'] = !empty( $_POST['verified_email'] ); 67 67 if ( !empty( $_POST['forum'] ) ) { $options['forum'] = $_POST['forum']; } 68 68 if ( !empty( $_POST['tab_corner_radius'] ) ) { $options['tab_corner_radius'] = $_POST['tab_corner_radius']; } … … 95 95 'is' => __( 'Icelandic' ) . ' (IS)', 96 96 '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)', 97 115 ); 98 116 … … 104 122 ); 105 123 106 107 124 if ( !empty( $options['language'] ) ) { 108 125 $language_options += array( $options['language'] => 'Custom (' + $options['language'] + ')' ); … … 223 240 </tr> 224 241 <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' ); ?> /> 228 245 </td> 229 246 </tr> … … 246 263 $default = array( 247 264 'api_key' => '', 248 'project_key' => 'PROJECT_KEY', 249 'domain' => 'PROJECT_KEY.userecho.com', 265 'domain' => 'YOUR_ALIAS.userecho.com', 250 266 'show_tab' => 1, 251 267 'language' => 'en', … … 259 275 'tab_hover_color' => '#f45c5c', 260 276 'tab_icon_show' => 1, 277 'verified_email' => 1, 278 261 279 ); 262 280 } … … 288 306 'email' => $current_user->user_email, // User email - used for notification about changes on feedback 289 307 'locale' => $options['language'], // (Optional) User language override 308 'verified_email' => $options['verified_email'], // (Optional) Is user's email verified? 290 309 ); 291 310 } … … 293 312 return ""; 294 313 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); 330 316 } 331 317 … … 374 360 'tab_bg_color' => $options['tab_bg_color'], 375 361 'tab_hover_color' => $options['tab_hover_color'], 376 'params' => array('sso_token' => $this->get_sso_token()),377 362 ); 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 378 371 echo "<script type='text/javascript'> 379 372 var _ues = " . json_encode( $_ues ) . "; … … 381 374 (function() { 382 375 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'; 384 377 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(_ue, s); 385 378 })(); … … 414 407 $redirect = $base_url; 415 408 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 } 417 413 418 414 header( 'Location: ' . $redirect ); … … 487 483 } 488 484 485 class 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 489 532 $ue = new UserEcho(); -
userecho/trunk/readme.txt
r974828 r1542874 1 1 === UserEcho for Wordpress === 2 Contributors: sstukov 2 Contributors: sstukov, mvr 3 3 Donate link: http://userecho.com/ 4 4 Tags: feedback, users community, widget, ideas, helpdesk, livechat 5 5 Requires at least: 2.8 6 6 Tested up to: 3.9.2 7 Stable tag: 1.0. 47 Stable tag: 1.0.5 8 8 9 9 Integrate UserEcho - customer feedback and helpdesk system into your blog. Using widget or link. Support SSO. … … 54 54 * Some description updates 55 55 * 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 2 2 /* 3 3 Plugin Name: UserEcho for Wordpress - collect feedback for your blog 4 Version: 1.0. 44 Version: 1.0.5 5 5 Plugin URI: http://userecho.com 6 Author: Jonathan Champ, Sergey Stukov 6 Author: Jonathan Champ, Sergey Stukov, Vladimir Mullagaliyev 7 7 Author URI: http://userecho.com 8 8 Description: UserEcho - feedback widget to collect and manage user feedback for your blog. … … 59 59 60 60 if ( !empty( $_POST['api_key'] ) ) { $options['api_key'] = $_POST['api_key']; } 61 if ( !empty( $_POST['project_key'] ) ) { $options['project_key'] = $_POST['project_key']; }62 61 if ( !empty( $_POST['domain'] ) ) { $options['domain'] = $_POST['domain']; } 63 62 if ( !empty( $_POST['language'] ) ) { $options['language'] = $_POST['language']; } … … 65 64 $options['show_tab'] = !empty( $_POST['show_tab'] ); 66 65 $options['tab_icon_show'] = !empty( $_POST['tab_icon_show'] ); 66 $options['verified_email'] = !empty( $_POST['verified_email'] ); 67 67 if ( !empty( $_POST['forum'] ) ) { $options['forum'] = $_POST['forum']; } 68 68 if ( !empty( $_POST['tab_corner_radius'] ) ) { $options['tab_corner_radius'] = $_POST['tab_corner_radius']; } … … 95 95 'is' => __( 'Icelandic' ) . ' (IS)', 96 96 '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)', 97 115 ); 98 116 … … 104 122 ); 105 123 106 107 124 if ( !empty( $options['language'] ) ) { 108 125 $language_options += array( $options['language'] => 'Custom (' + $options['language'] + ')' ); … … 223 240 </tr> 224 241 <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' ); ?> /> 228 245 </td> 229 246 </tr> … … 246 263 $default = array( 247 264 'api_key' => '', 248 'project_key' => 'PROJECT_KEY', 249 'domain' => 'PROJECT_KEY.userecho.com', 265 'domain' => 'YOUR_ALIAS.userecho.com', 250 266 'show_tab' => 1, 251 267 'language' => 'en', … … 259 275 'tab_hover_color' => '#f45c5c', 260 276 'tab_icon_show' => 1, 277 'verified_email' => 1, 278 261 279 ); 262 280 } … … 288 306 'email' => $current_user->user_email, // User email - used for notification about changes on feedback 289 307 'locale' => $options['language'], // (Optional) User language override 308 'verified_email' => $options['verified_email'], // (Optional) Is user's email verified? 290 309 ); 291 310 } … … 293 312 return ""; 294 313 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); 330 316 } 331 317 … … 374 360 'tab_bg_color' => $options['tab_bg_color'], 375 361 'tab_hover_color' => $options['tab_hover_color'], 376 'params' => array('sso_token' => $this->get_sso_token()),377 362 ); 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 378 371 echo "<script type='text/javascript'> 379 372 var _ues = " . json_encode( $_ues ) . "; … … 381 374 (function() { 382 375 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'; 384 377 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(_ue, s); 385 378 })(); … … 414 407 $redirect = $base_url; 415 408 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 } 417 413 418 414 header( 'Location: ' . $redirect ); … … 487 483 } 488 484 485 class 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 489 532 $ue = new UserEcho();
Note: See TracChangeset
for help on using the changeset viewer.