Changeset 1574681
- Timestamp:
- 01/14/2017 03:38:17 PM (9 years ago)
- Location:
- nxtbridge
- Files:
-
- 7 edited
- 17 copied
-
tags/0.4.0 (copied) (copied from nxtbridge/trunk)
-
tags/0.4.0/bower_components/moment (copied) (copied from nxtbridge/trunk/bower_components/moment)
-
tags/0.4.0/config.php (copied) (copied from nxtbridge/trunk/config.php) (5 diffs)
-
tags/0.4.0/img (copied) (copied from nxtbridge/trunk/img)
-
tags/0.4.0/lib (copied) (copied from nxtbridge/trunk/lib)
-
tags/0.4.0/lib/assets-auto.php (copied) (copied from nxtbridge/trunk/lib/assets-auto.php)
-
tags/0.4.0/lib/assets-graphics.php (copied) (copied from nxtbridge/trunk/lib/assets-graphics.php)
-
tags/0.4.0/lib/assets-info.php (copied) (copied from nxtbridge/trunk/lib/assets-info.php)
-
tags/0.4.0/lib/fakepage.php (copied) (copied from nxtbridge/trunk/lib/fakepage.php)
-
tags/0.4.0/lib/options.php (copied) (copied from nxtbridge/trunk/lib/options.php)
-
tags/0.4.0/nxtbridge.php (copied) (copied from nxtbridge/trunk/nxtbridge.php) (4 diffs)
-
tags/0.4.0/readme.txt (copied) (copied from nxtbridge/trunk/readme.txt) (1 diff)
-
tags/0.4.0/style.css (copied) (copied from nxtbridge/trunk/style.css) (1 diff)
-
tags/0.4.0/style.scss (copied) (copied from nxtbridge/trunk/style.scss) (1 diff)
-
tags/0.4.0/wallet (copied) (copied from nxtbridge/trunk/wallet)
-
tags/0.4.0/wallet.css (copied) (copied from nxtbridge/trunk/wallet.css)
-
tags/0.4.0/wallet.scss (copied) (copied from nxtbridge/trunk/wallet.scss)
-
tags/0.4.0/wallet/main.php (modified) (10 diffs)
-
trunk/config.php (modified) (5 diffs)
-
trunk/nxtbridge.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/style.css (modified) (1 diff)
-
trunk/style.scss (modified) (1 diff)
-
trunk/wallet/main.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nxtbridge/tags/0.4.0/config.php
r1572680 r1574681 17 17 add_action('wp_enqueue_scripts', 'nxter_scripts'); 18 18 add_action('wp_footer', 'nxter_footer'); 19 //add_action('wp', 'nxter_catch_404');20 19 21 20 register_activation_hook( __FILE__, 'nxter_activation'); … … 24 23 25 24 function nxter_scripts() { 26 wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), '', false, true); // in footer 27 wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), '', false, true); // in footer 28 wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), '', false, true); // in footer 29 //wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), '', false, true); // in footer 25 wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), array('jquery'), false, true); // in footer 26 wp_register_script('bootstrap', plugins_url('/bower_components/bootstrap/dist/js/bootstrap.min.js', __FILE__), array('jquery'), false, true); // in footer 27 wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), array('jquery'), false, true); // in footer 28 wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), array('jquery'), false, true); // in footer 29 wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), array('jquery'), false, true); // in footer 30 30 31 31 wp_enqueue_script('mdl'); 32 32 wp_enqueue_script('highstock'); 33 33 wp_enqueue_script('momentjs'); 34 //wp_enqueue_script('nxtbridge');34 wp_enqueue_script('nxtbridge'); 35 35 } 36 36 … … 38 38 function nxter_styles() { 39 39 wp_register_style('mdl', plugins_url('/bower_components/material-design-lite/material.min.css', __FILE__), '', false, 'all'); 40 wp_register_style('bootstrap', plugins_url('/bower_components/bootstrap/dist/css/bootstrap.min.css', __FILE__), '', false, 'all'); 40 41 wp_register_style('nxtbridge', plugins_url('style.css', __FILE__), '', false, 'all'); 41 42 … … 49 50 $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/'; 50 51 52 //TODO: Remove prefix 51 53 printf('<input type="hidden" id="nxter-asset-prefix" value="%s" />', $prefix); 52 54 printf('<input type="hidden" id="nxter-api" value="%s" />', $api); … … 62 64 <?php 63 65 endif; 64 }65 66 67 function nxter_catch_404() {68 if ( is_404() ) {69 $opt = get_option('NXTBridge');70 $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/';71 $default = isset( $opt['NXTBridge_top50_default'] ) ? esc_attr( $opt['NXTBridge_top50_default']) : '/';72 $url = $_SERVER["REQUEST_URI"];73 74 if ( preg_match( $prefix , $url ) == 1 ) {75 // redirect to default page76 header('HTTP/1.1 302 Moved Temporarily');77 header('Location: '.$default);78 }79 }80 66 } 81 67 -
nxtbridge/tags/0.4.0/nxtbridge.php
r1573114 r1574681 3 3 /* 4 4 Plugin Name: NXTBridge 5 Plugin URI: http ://nxter.org/nxtbridge6 Version: 0. 3.65 Plugin URI: https://nxter.org/nxtbridge 6 Version: 0.4.0 7 7 Author: scor2k 8 8 Description: Show Nxt asset information on your Wordpress sites. … … 11 11 */ 12 12 global $api; 13 $version = '0. 3.6'; // NOT FORGET TO CHANGE !!!13 $version = '0.4.0'; // NOT FORGET TO CHANGE !!! 14 14 15 15 $api = '//api.nxter.org/v1'; 16 //$api = '//nxtbridge-srv.corp.comindware.com:8080/v1';17 16 //$api = '//localhost:8080/v1'; 18 17 … … 20 19 require ('lib/assets-info.php'); // NXTBridgeAssetInfo and NXTBridgeAssetPrices and NXTBridgeTop50 21 20 require ('lib/assets-graphics.php'); // NXTBridgeAssetStock and NXTBridgeAssetCandlestick 22 require ('lib/assets-auto.php'); // NXTBridgeAuto 21 require ('lib/tip.php'); // NXTBridgeTip button 22 //require ('lib/assets-auto.php'); // NXTBridgeAuto. Disabled in 0.4 version. 23 23 /*****************************************************************************************************/ 24 24 require ('config.php'); // actions and registered scripts and hooks 25 25 /*****************************************************************************************************/ 26 require('lib/options.php'); // NXTBridge Admin settings27 require('wallet/main.php'); // NXTBridge wallet26 require('lib/options.php'); // NXTBridge Admin settings 27 require('wallet/main.php'); // NXTBridge wallet 28 28 /*****************************************************************************************************/ 29 require('lib/fakepage.php'); // NXTBridge Fake Page29 require('lib/fakepage.php'); // NXTBridge Fake Page 30 30 /*****************************************************************************************************/ 31 31 … … 37 37 add_filter('the_content', 'nxtbridge_stockchart'); 38 38 add_filter('the_content', 'nxtbridge_candlestick'); 39 add_filter('the_content', 'nxtbridge_auto'); 39 add_filter('the_content', 'nxtbridge_tip'); 40 //add_filter('the_content', 'nxtbridge_auto'); // Disabled in 0.4 version. 40 41 /*****************************************************************************************************/ 41 42 -
nxtbridge/tags/0.4.0/readme.txt
r1573114 r1574681 72 72 == Changelog == 73 73 74 = 0.4.0 = 75 * Disabled shortcut NXTBridgeAuto. Not needed with fake pages. 76 * Create new shortcut [NXTBridgeTip account=NXT-FRNZ-PDJF-2CQT-DQ4WQ]. It'll show button with input box on the page. 77 74 78 = 0.3.6 = 75 79 * Bugfix for compatibility with WPML plugin -
nxtbridge/tags/0.4.0/style.css
r1558887 r1574681 62 62 filter: alpha(opacity=100); } 63 63 64 /**************TIP******************/ 65 .NXTBridge-tip-field { 66 width: 100px !important; 67 margin-right: 0.2rem !important; } 68 69 .NXTBridge-tip-button { 70 width: 100px; } 71 64 72 /*# sourceMappingURL=style.css.map */ -
nxtbridge/tags/0.4.0/style.scss
r1558887 r1574681 102 102 } 103 103 104 105 /**************TIP******************/ 106 .NXTBridge-tip-field { 107 width: 100px !important; 108 margin-right: 0.2rem !important; 109 } 110 111 .NXTBridge-tip-button { 112 width: 100px; 113 } -
nxtbridge/tags/0.4.0/wallet/main.php
r1558887 r1574681 174 174 break; 175 175 176 case 'NXTBridge_send': 177 //var_dump($_POST); 178 179 $proto = 'http:'; if ( is_ssl() ) { $proto = 'https:'; } 180 if ( isset($_POST['recipient']) && isset($_POST['amount']) ) { 181 182 $tmp = file_get_contents( $proto . $this->api . '/peer' ); 183 $nxt_node = json_decode($tmp, true); 184 185 $user_message = ''; 186 187 if ( $nxt_node == false ) { 188 $this->log('Some error while decode API answer'); 189 $user_message = 'Error was happen while trying to decode answer from nxter API server'; 190 } else { 191 $random_node = $nxt_node['data']; 192 $url = 'http://' . $random_node . ':7876' . '/nxt?requestType=getAccountPublicKey&account=' . $this->options['account']; 193 194 $pub = file_get_contents( $url ); 195 $pub_key = json_decode($pub, true); 196 197 if ( isset($pub_key['publicKey']) ) { 198 $url = 'http://' . $random_node . ':7876/nxt'; 199 $data = array('requestType' => 'sendMoney', 'recipient' => $_POST['recipient'], 'amountNQT' => $_POST['amount'] * 100000000, 'publicKey' => $pub_key['publicKey'], 'feeNQT' => 100000000, 'deadline' => 720, 'broadcast' => 'false', 'message' => 'Sent using NXTBridge' ); 200 201 $rr = $this->sendPOST( $url, $data ); 202 203 //var_dump($rr); 204 $rr_descr = json_decode($rr, true); 205 206 if ( $rr_descr ) { 207 $rr_code = $rr_descr['errorCode']; 208 switch ($rr_code) { 209 case '4': 210 $user_message = $rr_descr['errorDescription']; 211 break; 212 213 default: 214 $user_message = print_r($rr, true); 215 } 216 217 if ( $rr_descr['unsignedTransactionBytes'] ) { 218 $user_message = $rr_descr['unsignedTransactionBytes']; 219 } 220 } 221 222 } // end isset 223 } // end esle 224 225 $this->response = $user_message; 226 //var_dump($this->response); 227 } 228 break; 176 229 177 230 default: … … 183 236 $this->page[1] = $this->agree ? '-active' : ''; 184 237 $this->page[2] = ''; 238 $this->page[3] = ''; 239 $this->page[4] = ''; 185 240 186 241 if ( $this->agree ) { … … 188 243 $this->url[2] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast'; 189 244 $this->url[3] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=ledger'; 245 $this->url[4] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=send'; 190 246 191 247 //************************************************************************************************** PAGE SWITCH THERE … … 193 249 194 250 $sub = $_GET['sub']; 195 $this->page[1] = ''; 196 $this->page[2] = ''; 251 $this->page[1] = ''; $this->page[2] = ''; $this->page[3] = ''; $this->page[4] = ''; 197 252 198 253 switch ( $sub ) { … … 209 264 break; 210 265 266 case 'send': 267 $this->page[4] = '-active'; 268 break; 269 211 270 default: 212 271 $this->page[1] = '-active'; … … 229 288 <a href='<?php echo $this->url[2]; ?>' class='nav-tab nav-tab<?php echo $this->page[2]; ?>'>Broadcast</a> 230 289 <a href='<?php echo $this->url[3]; ?>' class='nav-tab nav-tab<?php echo $this->page[3]; ?>'>Ledger</a> 290 <a href='<?php echo $this->url[4]; ?>' class='nav-tab nav-tab<?php echo $this->page[4]; ?>'>Send Nxt</a> 231 291 </h2> 232 292 … … 258 318 259 319 260 <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** WALLET?>320 <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** LEDGER ?> 261 321 <?php if ( $this->options['account'] ) : ?> 262 322 … … 267 327 268 328 <?php endif; // page[3] ?> 329 330 <?php if ( strlen($this->page[4]) > 0 ) : //******************************************************************************** SEND NXT ?> 331 <?php if ( $this->options['account'] ) : ?> 332 333 <form method='POST' action=''> 334 <?php settings_fields('NXTBridge_send'); ?> 335 <?php do_settings_sections('nxtbridge_send_account');?> 336 <?php submit_button('Generate unsigned TX bytes'); ?> 337 </form> 338 339 <?php else: ?> 340 <p>Please, enter your prefered Nxt account in Reed-Solomon style on the 'Account' page.</p> 341 <?php endif; ?> 342 343 <?php endif; // page[3] ?> 344 345 269 346 270 347 </div> … … 504 581 ); 505 582 583 //****************************************************************************************************************************** SEND NXT SECTION 584 register_setting( 585 'NXTBridge_send', // option group 586 'NXTBridge_'.$this->id, // option name 587 array( $this, 'sanitize' ) 588 ); 589 590 add_settings_section( 591 'NXTBridge_send_section', // Section name 592 'NXTBridge Send NXT section', // Section Title 593 array( $this, 'print_send_info'), // Section callback 594 'nxtbridge_send_account' // Page where Section will be display 595 ); 596 597 add_settings_field( 598 'NXTBridge_recipient_account', // Setting ID 599 'Recipient NXT account', // Setting title 600 array( $this, 'recipient_account_callback' ), // Setting callback 601 'nxtbridge_send_account', // Page where setting will be display 602 'NXTBridge_send_section' // Section name 603 ); 604 605 add_settings_field( 606 'NXTBridge_amount_account', // Setting ID 607 'Recipient NXT amount', // Setting title 608 array( $this, 'amount_account_callback' ), // Setting callback 609 'nxtbridge_send_account', // Page where setting will be display 610 'NXTBridge_send_section' // Section name 611 ); 612 613 add_settings_field( 614 'NXTBridge_tx_account', // Setting ID 615 'Unsigned TX bytes', // Setting title 616 array( $this, 'tx_account_callback' ), // Setting callback 617 'nxtbridge_send_account', // Page where setting will be display 618 'NXTBridge_send_section' // Section name 619 ); 506 620 } 507 621 … … 576 690 } 577 691 578 579 692 /*****************************************************************************************************************/ 693 // 694 // SEND NXT 695 // 696 /*****************************************************************************************************************/ 697 public function print_send_info() { 698 printf("<p>In this section you can generate unsigned TX bytes for send Nxt action. Then you should sign this bytes with <a href='https://bitbucket.org/scor2k/nxtbridge-offline/downloads/index.min.html' target=_blank>NXTBridge-offline</a> and <a href='/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast'>broadcast</a> to the Nxt network.</p>"); 699 } 700 701 public function recipient_account_callback() { 702 printf("<input name='recipient' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_addr'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_addr'] ): '' ); 703 } 704 705 public function amount_account_callback() { 706 printf("<input name='amount' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_amount'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_amount'] ): '' ); 707 } 708 709 public function tx_account_callback() { 710 printf("<textarea name='tx' rows='5' cols='30' class='large-text code' readonly>%s</textarea>", $this->response ); 711 } 580 712 } // end class 581 713 -
nxtbridge/trunk/config.php
r1572680 r1574681 17 17 add_action('wp_enqueue_scripts', 'nxter_scripts'); 18 18 add_action('wp_footer', 'nxter_footer'); 19 //add_action('wp', 'nxter_catch_404');20 19 21 20 register_activation_hook( __FILE__, 'nxter_activation'); … … 24 23 25 24 function nxter_scripts() { 26 wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), '', false, true); // in footer 27 wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), '', false, true); // in footer 28 wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), '', false, true); // in footer 29 //wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), '', false, true); // in footer 25 wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), array('jquery'), false, true); // in footer 26 wp_register_script('bootstrap', plugins_url('/bower_components/bootstrap/dist/js/bootstrap.min.js', __FILE__), array('jquery'), false, true); // in footer 27 wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), array('jquery'), false, true); // in footer 28 wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), array('jquery'), false, true); // in footer 29 wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), array('jquery'), false, true); // in footer 30 30 31 31 wp_enqueue_script('mdl'); 32 32 wp_enqueue_script('highstock'); 33 33 wp_enqueue_script('momentjs'); 34 //wp_enqueue_script('nxtbridge');34 wp_enqueue_script('nxtbridge'); 35 35 } 36 36 … … 38 38 function nxter_styles() { 39 39 wp_register_style('mdl', plugins_url('/bower_components/material-design-lite/material.min.css', __FILE__), '', false, 'all'); 40 wp_register_style('bootstrap', plugins_url('/bower_components/bootstrap/dist/css/bootstrap.min.css', __FILE__), '', false, 'all'); 40 41 wp_register_style('nxtbridge', plugins_url('style.css', __FILE__), '', false, 'all'); 41 42 … … 49 50 $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/'; 50 51 52 //TODO: Remove prefix 51 53 printf('<input type="hidden" id="nxter-asset-prefix" value="%s" />', $prefix); 52 54 printf('<input type="hidden" id="nxter-api" value="%s" />', $api); … … 62 64 <?php 63 65 endif; 64 }65 66 67 function nxter_catch_404() {68 if ( is_404() ) {69 $opt = get_option('NXTBridge');70 $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/';71 $default = isset( $opt['NXTBridge_top50_default'] ) ? esc_attr( $opt['NXTBridge_top50_default']) : '/';72 $url = $_SERVER["REQUEST_URI"];73 74 if ( preg_match( $prefix , $url ) == 1 ) {75 // redirect to default page76 header('HTTP/1.1 302 Moved Temporarily');77 header('Location: '.$default);78 }79 }80 66 } 81 67 -
nxtbridge/trunk/nxtbridge.php
r1573114 r1574681 3 3 /* 4 4 Plugin Name: NXTBridge 5 Plugin URI: http ://nxter.org/nxtbridge6 Version: 0. 3.65 Plugin URI: https://nxter.org/nxtbridge 6 Version: 0.4.0 7 7 Author: scor2k 8 8 Description: Show Nxt asset information on your Wordpress sites. … … 11 11 */ 12 12 global $api; 13 $version = '0. 3.6'; // NOT FORGET TO CHANGE !!!13 $version = '0.4.0'; // NOT FORGET TO CHANGE !!! 14 14 15 15 $api = '//api.nxter.org/v1'; 16 //$api = '//nxtbridge-srv.corp.comindware.com:8080/v1';17 16 //$api = '//localhost:8080/v1'; 18 17 … … 20 19 require ('lib/assets-info.php'); // NXTBridgeAssetInfo and NXTBridgeAssetPrices and NXTBridgeTop50 21 20 require ('lib/assets-graphics.php'); // NXTBridgeAssetStock and NXTBridgeAssetCandlestick 22 require ('lib/assets-auto.php'); // NXTBridgeAuto 21 require ('lib/tip.php'); // NXTBridgeTip button 22 //require ('lib/assets-auto.php'); // NXTBridgeAuto. Disabled in 0.4 version. 23 23 /*****************************************************************************************************/ 24 24 require ('config.php'); // actions and registered scripts and hooks 25 25 /*****************************************************************************************************/ 26 require('lib/options.php'); // NXTBridge Admin settings27 require('wallet/main.php'); // NXTBridge wallet26 require('lib/options.php'); // NXTBridge Admin settings 27 require('wallet/main.php'); // NXTBridge wallet 28 28 /*****************************************************************************************************/ 29 require('lib/fakepage.php'); // NXTBridge Fake Page29 require('lib/fakepage.php'); // NXTBridge Fake Page 30 30 /*****************************************************************************************************/ 31 31 … … 37 37 add_filter('the_content', 'nxtbridge_stockchart'); 38 38 add_filter('the_content', 'nxtbridge_candlestick'); 39 add_filter('the_content', 'nxtbridge_auto'); 39 add_filter('the_content', 'nxtbridge_tip'); 40 //add_filter('the_content', 'nxtbridge_auto'); // Disabled in 0.4 version. 40 41 /*****************************************************************************************************/ 41 42 -
nxtbridge/trunk/readme.txt
r1573114 r1574681 72 72 == Changelog == 73 73 74 = 0.4.0 = 75 * Disabled shortcut NXTBridgeAuto. Not needed with fake pages. 76 * Create new shortcut [NXTBridgeTip account=NXT-FRNZ-PDJF-2CQT-DQ4WQ]. It'll show button with input box on the page. 77 74 78 = 0.3.6 = 75 79 * Bugfix for compatibility with WPML plugin -
nxtbridge/trunk/style.css
r1558887 r1574681 62 62 filter: alpha(opacity=100); } 63 63 64 /**************TIP******************/ 65 .NXTBridge-tip-field { 66 width: 100px !important; 67 margin-right: 0.2rem !important; } 68 69 .NXTBridge-tip-button { 70 width: 100px; } 71 64 72 /*# sourceMappingURL=style.css.map */ -
nxtbridge/trunk/style.scss
r1558887 r1574681 102 102 } 103 103 104 105 /**************TIP******************/ 106 .NXTBridge-tip-field { 107 width: 100px !important; 108 margin-right: 0.2rem !important; 109 } 110 111 .NXTBridge-tip-button { 112 width: 100px; 113 } -
nxtbridge/trunk/wallet/main.php
r1558887 r1574681 174 174 break; 175 175 176 case 'NXTBridge_send': 177 //var_dump($_POST); 178 179 $proto = 'http:'; if ( is_ssl() ) { $proto = 'https:'; } 180 if ( isset($_POST['recipient']) && isset($_POST['amount']) ) { 181 182 $tmp = file_get_contents( $proto . $this->api . '/peer' ); 183 $nxt_node = json_decode($tmp, true); 184 185 $user_message = ''; 186 187 if ( $nxt_node == false ) { 188 $this->log('Some error while decode API answer'); 189 $user_message = 'Error was happen while trying to decode answer from nxter API server'; 190 } else { 191 $random_node = $nxt_node['data']; 192 $url = 'http://' . $random_node . ':7876' . '/nxt?requestType=getAccountPublicKey&account=' . $this->options['account']; 193 194 $pub = file_get_contents( $url ); 195 $pub_key = json_decode($pub, true); 196 197 if ( isset($pub_key['publicKey']) ) { 198 $url = 'http://' . $random_node . ':7876/nxt'; 199 $data = array('requestType' => 'sendMoney', 'recipient' => $_POST['recipient'], 'amountNQT' => $_POST['amount'] * 100000000, 'publicKey' => $pub_key['publicKey'], 'feeNQT' => 100000000, 'deadline' => 720, 'broadcast' => 'false', 'message' => 'Sent using NXTBridge' ); 200 201 $rr = $this->sendPOST( $url, $data ); 202 203 //var_dump($rr); 204 $rr_descr = json_decode($rr, true); 205 206 if ( $rr_descr ) { 207 $rr_code = $rr_descr['errorCode']; 208 switch ($rr_code) { 209 case '4': 210 $user_message = $rr_descr['errorDescription']; 211 break; 212 213 default: 214 $user_message = print_r($rr, true); 215 } 216 217 if ( $rr_descr['unsignedTransactionBytes'] ) { 218 $user_message = $rr_descr['unsignedTransactionBytes']; 219 } 220 } 221 222 } // end isset 223 } // end esle 224 225 $this->response = $user_message; 226 //var_dump($this->response); 227 } 228 break; 176 229 177 230 default: … … 183 236 $this->page[1] = $this->agree ? '-active' : ''; 184 237 $this->page[2] = ''; 238 $this->page[3] = ''; 239 $this->page[4] = ''; 185 240 186 241 if ( $this->agree ) { … … 188 243 $this->url[2] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast'; 189 244 $this->url[3] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=ledger'; 245 $this->url[4] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=send'; 190 246 191 247 //************************************************************************************************** PAGE SWITCH THERE … … 193 249 194 250 $sub = $_GET['sub']; 195 $this->page[1] = ''; 196 $this->page[2] = ''; 251 $this->page[1] = ''; $this->page[2] = ''; $this->page[3] = ''; $this->page[4] = ''; 197 252 198 253 switch ( $sub ) { … … 209 264 break; 210 265 266 case 'send': 267 $this->page[4] = '-active'; 268 break; 269 211 270 default: 212 271 $this->page[1] = '-active'; … … 229 288 <a href='<?php echo $this->url[2]; ?>' class='nav-tab nav-tab<?php echo $this->page[2]; ?>'>Broadcast</a> 230 289 <a href='<?php echo $this->url[3]; ?>' class='nav-tab nav-tab<?php echo $this->page[3]; ?>'>Ledger</a> 290 <a href='<?php echo $this->url[4]; ?>' class='nav-tab nav-tab<?php echo $this->page[4]; ?>'>Send Nxt</a> 231 291 </h2> 232 292 … … 258 318 259 319 260 <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** WALLET?>320 <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** LEDGER ?> 261 321 <?php if ( $this->options['account'] ) : ?> 262 322 … … 267 327 268 328 <?php endif; // page[3] ?> 329 330 <?php if ( strlen($this->page[4]) > 0 ) : //******************************************************************************** SEND NXT ?> 331 <?php if ( $this->options['account'] ) : ?> 332 333 <form method='POST' action=''> 334 <?php settings_fields('NXTBridge_send'); ?> 335 <?php do_settings_sections('nxtbridge_send_account');?> 336 <?php submit_button('Generate unsigned TX bytes'); ?> 337 </form> 338 339 <?php else: ?> 340 <p>Please, enter your prefered Nxt account in Reed-Solomon style on the 'Account' page.</p> 341 <?php endif; ?> 342 343 <?php endif; // page[3] ?> 344 345 269 346 270 347 </div> … … 504 581 ); 505 582 583 //****************************************************************************************************************************** SEND NXT SECTION 584 register_setting( 585 'NXTBridge_send', // option group 586 'NXTBridge_'.$this->id, // option name 587 array( $this, 'sanitize' ) 588 ); 589 590 add_settings_section( 591 'NXTBridge_send_section', // Section name 592 'NXTBridge Send NXT section', // Section Title 593 array( $this, 'print_send_info'), // Section callback 594 'nxtbridge_send_account' // Page where Section will be display 595 ); 596 597 add_settings_field( 598 'NXTBridge_recipient_account', // Setting ID 599 'Recipient NXT account', // Setting title 600 array( $this, 'recipient_account_callback' ), // Setting callback 601 'nxtbridge_send_account', // Page where setting will be display 602 'NXTBridge_send_section' // Section name 603 ); 604 605 add_settings_field( 606 'NXTBridge_amount_account', // Setting ID 607 'Recipient NXT amount', // Setting title 608 array( $this, 'amount_account_callback' ), // Setting callback 609 'nxtbridge_send_account', // Page where setting will be display 610 'NXTBridge_send_section' // Section name 611 ); 612 613 add_settings_field( 614 'NXTBridge_tx_account', // Setting ID 615 'Unsigned TX bytes', // Setting title 616 array( $this, 'tx_account_callback' ), // Setting callback 617 'nxtbridge_send_account', // Page where setting will be display 618 'NXTBridge_send_section' // Section name 619 ); 506 620 } 507 621 … … 576 690 } 577 691 578 579 692 /*****************************************************************************************************************/ 693 // 694 // SEND NXT 695 // 696 /*****************************************************************************************************************/ 697 public function print_send_info() { 698 printf("<p>In this section you can generate unsigned TX bytes for send Nxt action. Then you should sign this bytes with <a href='https://bitbucket.org/scor2k/nxtbridge-offline/downloads/index.min.html' target=_blank>NXTBridge-offline</a> and <a href='/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast'>broadcast</a> to the Nxt network.</p>"); 699 } 700 701 public function recipient_account_callback() { 702 printf("<input name='recipient' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_addr'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_addr'] ): '' ); 703 } 704 705 public function amount_account_callback() { 706 printf("<input name='amount' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_amount'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_amount'] ): '' ); 707 } 708 709 public function tx_account_callback() { 710 printf("<textarea name='tx' rows='5' cols='30' class='large-text code' readonly>%s</textarea>", $this->response ); 711 } 580 712 } // end class 581 713
Note: See TracChangeset
for help on using the changeset viewer.