Changeset 1066181
- Timestamp:
- 01/12/2015 04:43:14 PM (11 years ago)
- Location:
- worldcurrency/trunk
- Files:
-
- 4 edited
-
ip2c/ip-to-country.bin (modified) (previous)
-
readme.txt (modified) (3 diffs)
-
worldcurrency.php (modified) (19 diffs)
-
yahoofinance.class.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
worldcurrency/trunk/readme.txt
r557301 r1066181 1 === WorldCurrency ===2 Contributors: WhiteCubes 1 === WorldCurrency === 2 Contributors: WhiteCubes, JonScaife 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6CUNDYFWV4NUW 4 4 Tags: currency, exchange rates, currency converter, currency rates, travel, financial, eCommerce 5 5 Requires at least: 2.8.0 6 Tested up to: 3.3.27 Stable tag: 1.1 56 Tested up to: 4.1 7 Stable tag: 1.16 8 8 9 9 Recognises users by IP address and shows them converted values in their local currency, you can write post/pages in multiple currencies. … … 56 56 57 57 = Compatibility: = 58 * This plugin is written and tested on Wordpress 3.2.1 and Wordpress 3.3.1, but I think it will work on many other versions.58 * This plugin is tested on Wordpress 4.1, but I think it will work on many other versions. 59 59 60 60 = Support: = … … 97 97 98 98 == Changelog == 99 100 = 1.16 (12 January 2015) = 101 * Fix: getting rates from yahoo has been fixed 102 * Fix: Getting currency rates over SSL address had extra s (httpss), now correctly https 103 * Added: Wrapper function for cases where jQuery is loaded defer or async 104 * Change: by default a dot is now used for decimal, and comma for thousand separator 105 * Change: by default jQuery is used in no conflict mode 106 * Change: the default format of output is smaller and tidier with just symbol and value (e.g. $40) 107 * Change: Updated the ip2c database from http://software77.net/geo-ip/ 99 108 100 109 = 1.15 (13 June 2012) = -
worldcurrency/trunk/worldcurrency.php
r557301 r1066181 4 4 Plugin URI: http://www.cometicucinoilweb.it/blog/en/worldcurrency-plugin-for-wordpress/ 5 5 Description: Recognises users by IP address and shows them converted values in their local currency, you can write post/pages in multiple currencies. 6 Version: 1.1 57 Date: 1 3 June 20126 Version: 1.16 7 Date: 12 Jamuary 2015 8 8 Author: Daniele Tieghi 9 9 Author URI: www.cometicucinoilweb.it/blog/en/who-we-are/daniele-tieghi/ 10 10 11 11 Copyright 2012 - 2012 Daniele Tieghi (email: daniele.tieghi(at)gmail.com) 12 12 … … 24 24 along with this program; if not, write to the Free Software 25 25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 26 27 27 Built on ideas and small code portions from LocalCurrency (http://www.jobsinchina.com/resources/wordpress-plugin-localcurrency) 28 28 Uses IP2C (http://firestats.cc/wiki/ip2c) to determine user's country 29 29 Uses Yahoo! Finance (http://finance.yahoo.com) for conversion rates 30 Updates since version 1.16 by Jon Scaife (https://jonscaife.com, https://diymediahome.org) 30 31 */ 31 32 // Loads currency infos … … 44 45 add_shortcode('worldcurrencybox', 'dt_wc_shortcode_box'); 45 46 add_filter('the_content', 'dt_wc_content', $dt_wc_options['plugin_priority']); 46 47 47 48 add_action( 'wp_ajax_nopriv_worldcurrency', 'dt_wc_ajaxGetExchangeRate' ); 48 add_action( 'wp_ajax_worldcurrency', 'dt_wc_ajaxGetExchangeRate' ); 49 add_action( 'wp_ajax_worldcurrency', 'dt_wc_ajaxGetExchangeRate' ); 49 50 add_action( 'wp_ajax_nopriv_worldcurrencybox', 'dt_wc_ajaxGetCurrencySelectionBox' ); 50 add_action( 'wp_ajax_worldcurrencybox', 'dt_wc_ajaxGetCurrencySelectionBox' ); 51 51 add_action( 'wp_ajax_worldcurrencybox', 'dt_wc_ajaxGetCurrencySelectionBox' ); 52 52 53 // Register Widget 53 54 require_once 'worldcurrency.widget.php'; … … 55 56 // Create options on Activation 56 57 function dt_wc_createOptions($force = false) { 57 58 58 59 $dt_wc_options = get_option('$dt_wc_options'); 59 60 60 61 if ($force || !isset($dt_wc_options['plugin_link'])) $dt_wc_options['plugin_link'] = 'true'; 61 62 if ($force || !isset($dt_wc_options['yahoo_link'])) $dt_wc_options['yahoo_link'] = 'true'; … … 64 65 if ($force || !isset($dt_wc_options['historic_rates'])) $dt_wc_options['historic_rates'] = 'false'; 65 66 if ($force || !isset($dt_wc_options['hide_if_same'])) $dt_wc_options['hide_if_same'] = 'true'; 66 if ($force || !isset($dt_wc_options['output_format'])) $dt_wc_options['output_format'] = '(~%to_value%%to_symbol% %to_code%)'; 67 if ($force || !isset($dt_wc_options['thousands_separator'])) $dt_wc_options['thousands_separator'] = '.'; 68 if ($force || !isset($dt_wc_options['decimal_separator'])) $dt_wc_options['decimal_separator'] = ','; 69 if ($force || !isset($dt_wc_options['output_format'])) $dt_wc_options['output_format'] = '(~%to_value%%to_symbol% %to_code%)'; 67 if ($force || !isset($dt_wc_options['output_format'])) $dt_wc_options['output_format'] = ' (%to_symbol%%to_value%)'; 68 if ($force || !isset($dt_wc_options['thousands_separator'])) $dt_wc_options['thousands_separator'] = ','; 69 if ($force || !isset($dt_wc_options['decimal_separator'])) $dt_wc_options['decimal_separator'] = '.'; 70 70 if ($force || !isset($dt_wc_options['bottom_select'])) $dt_wc_options['bottom_select'] = 'true'; 71 71 if ($force || !isset($dt_wc_options['include_jquery'])) $dt_wc_options['include_jquery'] = 'true'; 72 72 if ($force || !isset($dt_wc_options['include_always'])) $dt_wc_options['include_always'] = 'false'; 73 if ($force || !isset($dt_wc_options['jquery_no_conflict'])) $dt_wc_options['jquery_no_conflict'] = ' false';73 if ($force || !isset($dt_wc_options['jquery_no_conflict'])) $dt_wc_options['jquery_no_conflict'] = 'true'; 74 74 if ($force || !isset($dt_wc_options['ajax_over_ssl'])) $dt_wc_options['ajax_over_ssl'] = 'false'; 75 75 if ($force || !isset($dt_wc_options['plugin_priority'])) $dt_wc_options['plugin_priority'] = 10; … … 89 89 } 90 90 EOT; 91 91 92 92 update_option('dt_wc_options', $dt_wc_options); 93 93 } 94 94 95 95 // Create the options page 96 96 function dt_wc_adminPage() { 97 97 require_once('worldcurrency-admin.php'); 98 98 } 99 99 100 100 // Add page scripts 101 101 function dt_wc_head() { 102 102 global $post; 103 103 104 104 $dt_wc_options = get_option('dt_wc_options'); 105 105 106 106 $jQuerySymbol = $dt_wc_options['jquery_no_conflict'] == 'true' ? 'jQuery' : '$'; 107 107 108 108 // Include the script only if necessary 109 109 if ($dt_wc_options['include_always'] == 'true' || get_post_meta($post->ID, 'wc_force', true) == 1 || strpos($post->post_content, 'worldcurrency') !== false) { 110 110 111 111 $usercurrency = dt_wc_userlocation(); 112 112 if (!$usercurrency) {$usercurrency = 'EUR';} 113 113 114 114 echo "\n<!-- DT WorldCurrency Code -->\n"; 115 115 116 116 // Include jQuery if needed 117 117 if ($dt_wc_options['include_jquery'] == 'true') 118 118 echo "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>\n"; 119 119 120 120 if ($dt_wc_options['ajax_over_ssl'] == 'true') { 121 $ajax_url = wp_nonce_url(str_replace('http ','https', admin_url('admin-ajax.php')), 'worldcurrency_safe');121 $ajax_url = wp_nonce_url(str_replace('http:','https:', admin_url('admin-ajax.php')), 'worldcurrency_safe'); 122 122 } else { 123 $ajax_url = wp_nonce_url(str_replace('https ','http', admin_url('admin-ajax.php')), 'worldcurrency_safe');123 $ajax_url = wp_nonce_url(str_replace('https:','http:', admin_url('admin-ajax.php')), 'worldcurrency_safe'); 124 124 } 125 125 126 126 ?> 127 127 <script type="text/javascript"> 128 128 <!-- 129 129 130 function worldCurInit() { 131 130 132 <?php if ($dt_wc_options['jquery_no_conflict'] == 'true'): ?> 131 133 jQuery.noConflict(); 132 134 <?php endif; ?> 133 135 134 136 dt_worldCurrency_update = function(userCurrency) { 135 137 // For each worldcurrency <span> get the value 136 138 <?php echo $jQuerySymbol; ?>('.worldcurrency').each(function() { 137 139 138 140 var theSpan = <?php echo $jQuerySymbol; ?>(this); 139 141 <?php echo $jQuerySymbol; ?>.ajax({ … … 148 150 alert(textStatus + ': ', + errorThrown); 149 151 } 150 }); 151 }); 152 }); 153 }); 152 154 153 155 // For each Currency selection box, chose the right value 154 156 <?php echo $jQuerySymbol; ?>('.worldcurrency_select').val(userCurrency); 155 157 156 158 } 157 159 158 160 // When the page is loaded 159 161 <?php echo $jQuerySymbol; ?>(document).ready(function() { … … 166 168 // Render Currency selection boxes 167 169 <?php echo $jQuerySymbol; ?>('.worldcurrency_selection_box_placeholder').each(function() { 168 170 169 171 var theDiv = <?php echo $jQuerySymbol; ?>(this); 170 172 <?php echo $jQuerySymbol; ?>.ajax({ … … 187 189 alert(textStatus + ': ', + errorThrown); 188 190 } 189 }); 190 }); 191 }); 192 }); 191 193 192 194 dt_worldCurrency_update('<?php echo $usercurrency; ?>'); 193 195 194 196 }); 195 197 198 } 199 200 function runWCWhenJQueryIsLoaded() { 201 if (window.jQuery){ 202 worldCurInit(); 203 } else { 204 setTimeout(runWCWhenJQueryIsLoaded, 5); 205 } 206 } 207 208 runWCWhenJQueryIsLoaded(); 209 196 210 --> 197 211 </script> … … 199 213 <?php echo $dt_wc_options['additional_css']; ?> 200 214 </style> 201 <!-- End of LocalCurrency DT Extension Code -->215 <!-- End of WorldCurrency DT Extension Code --> 202 216 <?php 203 204 } 205 } 206 217 218 } 219 } 220 207 221 // Retrieve user location via IP2C 208 222 function dt_wc_userlocation() { 209 223 global $dt_wc_locationlist; 210 224 require_once dirname(__FILE__).'/ip2c/ip2c.php'; 211 225 212 226 $ip2c = new ip2country(); 213 227 $res = $ip2c->get_country($_SERVER['REMOTE_ADDR']); 214 228 215 229 if ($res == false) { 216 230 return false; … … 219 233 } 220 234 } 221 235 222 236 /** 223 237 * Handler for [worldcurrency] shortcode 224 * 238 * 225 239 * USAGE: 226 * 240 * 227 241 * [worldcurrency cur="EUR" value="25"] 228 * in united states will show: 242 * in united states will show: 229 243 * 30 USD 230 * 244 * 231 245 * Parameters: 232 * 246 * 233 247 * curr="***" -> the name of the value currency 234 248 * target="***" -> the name of the target currency (if you want to force it) 235 249 * value="***" -> the value used for exchange 236 250 * historic="true|false" -> (optional) override main plugin setting 237 * 251 * 238 252 * @param array $attr 239 253 */ 240 254 function dt_wc_shortcode($attr) { 241 255 global $post; 242 256 243 257 if (!isset($attr['curr']) || !isset($attr['value'])) 244 258 return '[worldcurrency error: curr="" and value="" parameters needed]'; 245 259 246 260 $out = '<span class="worldcurrency" postId="'.$post->ID.'" curr="'.$attr['curr'].'" value="'.$attr['value'].'" '; 247 261 248 262 if (isset($attr['historic'])) $out .= 'historic="'.$attr['historic'].'" '; 249 263 if (isset($attr['target'])) $out .= 'target="'.$attr['target'].'" '; 250 264 251 265 $out .= '></span>'; 252 266 253 267 return $out; 254 268 } 255 269 256 270 /** 257 271 * Handler for [worldcurrencybox] shortcode that shows the currency selection box … … 260 274 return dt_wc_getCurrencySelectionBox(); 261 275 } 262 276 263 277 /** 264 278 * On publishing/updating post/page saves the current currency conversion rates for future historic uses … … 266 280 function dt_wc_publish() { 267 281 global $post; 268 282 269 283 // Check if there are rates attached to the post or else saves them 270 284 if (!($serializedQuotes = get_post_meta($post->ID, 'wc_rates', true))) { 271 285 272 286 // Include our Yahoo!Finance class 273 287 require_once 'yahoofinance.class.php'; 274 288 $YahooFinance = new yahoofinance(); 275 289 276 290 update_post_meta($post->ID, 'wc_rates', $serializedQuotes = $YahooFinance->getSerializedQuotes()); 277 291 update_post_meta($post->ID, 'wc_rates_date', time()); 278 279 } 280 } 281 292 293 } 294 } 295 282 296 /** 283 297 * Adds a currecy selection box at the end of the page/post if needed … … 290 304 return $theContent; 291 305 } 292 293 306 307 294 308 /** 295 309 * Generate and returns the HTML for the currency selection box … … 297 311 function dt_wc_getCurrencySelectionBox() { 298 312 $out = ''; 299 313 300 314 // Include our Yahoo!Finance class 301 315 require_once 'currencies.inc.php'; 302 316 global $dt_wc_currencylist; 303 317 304 318 // Retrieve current WC saved options from Wordpress 305 319 $dt_wc_options = get_option('dt_wc_options'); 306 320 307 321 $out .= '<div class="worldcurrency_selection_box">'; 308 322 309 323 // Renders the select box 310 324 $out .= '<div style="float:left;margin-right:4px;">Show currencies in:</div>'; … … 315 329 } 316 330 $out .= '</select>'; 317 331 318 332 // Renders the credits 319 333 if ($dt_wc_options['plugin_link'] == 'true' || $dt_wc_options['yahoo_link'] == 'true') $out .= '<div class="credits">Powered by'; … … 321 335 if ($dt_wc_options['yahoo_link'] == 'true') $out .= ' <a href="http://finance.yahoo.com" title="Visit Yahoo! Finance" target="_blank">Yahoo! Finance</a> for the rates.'; 322 336 if ($dt_wc_options['plugin_link'] == 'true' || $dt_wc_options['yahoo_link'] == 'true') $out .= '</div>'; 323 337 324 338 $out .= '</div>'."\n"; 325 339 326 340 return $out; 327 341 } 328 342 329 343 function dt_wc_ajaxGetCurrencySelectionBox() { 330 344 // Make sure there's nothing bad in the URL 331 foreach ($_GET as $key => $value) 332 $_GET[$key] = htmlentities(stripslashes($value)); 333 345 foreach ($_GET as $key => $value) 346 $_GET[$key] = htmlentities(stripslashes($value)); 347 334 348 // Don't proceed if we don't have enough info or if the nonce fails 335 if (!check_admin_referer('worldcurrency_safe')) 349 if (!check_admin_referer('worldcurrency_safe')) 336 350 die(); 337 351 338 352 echo dt_wc_getCurrencySelectionBox(); 339 353 340 354 exit; 341 355 } 342 356 343 357 function dt_wc_ajaxGetExchangeRate() { 344 358 345 359 // Make sure there's nothing bad in the URL 346 foreach ($_GET as $key => $value) 347 $_GET[$key] = htmlentities(stripslashes($value)); 348 360 foreach ($_GET as $key => $value) 361 $_GET[$key] = htmlentities(stripslashes($value)); 362 349 363 // Don't proceed if we don't have enough info or if the nonce fails 350 if (!isset($_GET['value']) || !isset($_GET['historic']) || !isset($_GET['from']) || !isset($_GET['to']) || !check_admin_referer('worldcurrency_safe')) 364 if (!isset($_GET['value']) || !isset($_GET['historic']) || !isset($_GET['from']) || !isset($_GET['to']) || !check_admin_referer('worldcurrency_safe')) 351 365 exit; 352 366 353 367 // Include our Yahoo!Finance class 354 368 require_once 'yahoofinance.class.php'; 355 369 global $dt_wc_currencylist; 356 370 $YahooFinance = new yahoofinance(); 357 371 358 372 // Retrieve current WC saved options from Wordpress 359 373 $dt_wc_options = get_option('dt_wc_options'); 360 361 // Check if we need only historic rates 374 375 // Check if we need only historic rates 362 376 if ($_GET['historic'] == 'true' && isset($_GET['postId'])) { 363 377 364 378 // Check if there are rates attached to the post or else saves them 365 379 if (!($serializedQuotes = get_post_meta($_GET['postId'], 'wc_rates', true))) { … … 367 381 update_post_meta($_GET['postId'], 'wc_rates_date', time()); 368 382 } 369 383 370 384 } else { 371 372 // We need current rates, check if we have them stored in options 385 386 // We need current rates, check if we have them stored in options 373 387 if (!!$dt_wc_options['cache_rates'] && $dt_wc_options['cache_time'] >= (time() - 86400)) { 374 388 // Fetch Rates from options if they are fresh … … 380 394 update_option('dt_wc_options', $dt_wc_options); 381 395 } 382 383 } 384 396 397 } 398 385 399 // Get the separators format 386 400 $thousands_separator = isset($dt_wc_options['thousands_separator']) ? $dt_wc_options['thousands_separator'] : '.'; 387 401 $decimals_separator = isset($dt_wc_options['decimal_separator']) ? $dt_wc_options['decimal_separator'] : ','; 388 402 389 403 390 404 // Load the quotes obtained 391 405 $YahooFinance->loadSerializedQuotes($serializedQuotes); 392 406 393 407 // Fetch the desired exchange rate and prepare all the parameters 394 408 395 409 $exchange_rate = $YahooFinance->getExchangeRate($_GET['from'], $_GET['to']); 396 410 397 411 $from_code = $_GET['from']; 398 412 $from_value = $_GET['value']; 399 413 $from_name = $dt_wc_currencylist[$from_code]['name']; 400 414 $from_symbol = $dt_wc_currencylist[$from_code]['symbol']; 401 415 402 416 $to_code = $_GET['to']; 403 417 $to_value = $from_value * $exchange_rate; 404 418 $to_name = $dt_wc_currencylist[$to_code]['name']; 405 419 $to_symbol = $dt_wc_currencylist[$to_code]['symbol']; 406 420 407 421 // Round the numbers 408 422 $exchange_rate = number_format($exchange_rate,2,',','.'); 409 423 $from_value = $from_value > 100 ? number_format($from_value,0,$decimals_separator,$thousands_separator) : number_format($from_value, 2,$decimals_separator,$thousands_separator); 410 424 $to_value = $to_value > 100 ? number_format($to_value,0,$decimals_separator,$thousands_separator) : number_format($to_value, 2,$decimals_separator,$thousands_separator); 411 425 412 426 // Do not show conversions to the same currency 413 427 if ($dt_wc_options['hide_if_same'] == 'true' && $from_code == $to_code) 414 428 exit; 415 429 416 430 // Echo in the required format 417 431 echo str_replace(array('%exchange_rate%','%from_code%','%from_value%','%from_name%','%from_symbol%','%to_code%','%to_value%','%to_name%','%to_symbol%'), array($exchange_rate,$from_code,$from_value,$from_name,$from_symbol,$to_code,$to_value,$to_name,$to_symbol), $dt_wc_options['output_format']); 418 432 419 433 exit; 420 434 } 421 -
worldcurrency/trunk/yahoofinance.class.php
r511695 r1066181 2 2 3 3 require_once 'currencies.inc.php'; 4 4 5 5 /** 6 6 * Class used to get informations from yahoo finance or to load them from a serialized string 7 7 * Used by WordCurrency plugin for Wordpress 8 * 8 * 9 9 * @author Daniele Tieghi 10 10 */ 11 11 class yahoofinance { 12 12 13 13 /** 14 14 * Array with informations about all the currencies … … 17 17 */ 18 18 private $currencyList = array(); 19 19 20 20 /** 21 21 * Array with quote couple names (ie: USDEUR, USDTHB) … … 23 23 */ 24 24 private $quoteCouples = array(); 25 25 26 26 /** 27 27 * All the quotes received from Yahoo!Finance (or loaded from saved data) … … 29 29 */ 30 30 private $quotes = array(); 31 32 31 32 33 33 ////////////////////////////////////////////////////////////////////////////////// 34 34 ////////////////////////////////////////////////////////////////////////////////// 35 35 36 36 /** 37 37 * Build basic data … … 42 42 $this->buildUSDQuoteCouples(); 43 43 } 44 44 45 45 /** 46 46 * Build all the quote couples (with USD as a base) that we need to get from Yahoo!Finance … … 55 55 return $this->quoteCouples; 56 56 } 57 57 58 58 /** 59 59 * Calls the Yahoo!Finance service and gets the quotes for every quote couple we need 60 60 */ 61 61 private function getCurrentQuotesFromYahooFinance() { 62 62 63 63 // Build the query parameters 64 64 $parameters = array( … … 67 67 'e=.csv', // The format we want (not needed) 68 68 ); 69 69 70 70 // Use a Socket connection to call Yahoo!Finance service 71 71 $host="download.finance.yahoo.com"; 72 72 $fp = @fsockopen($host, 80, $errno, $errstr, 30); 73 73 74 74 // Check if the socket is working 75 75 if (!$fp) { 76 76 return array(); 77 77 } else { 78 78 79 79 // Send the request 80 80 $out = "GET /d/quotes.csv?".implode('&', $parameters)." HTTP/1.0\r\n"; 81 $out .= "Host: www.yahoo.com\r\n";81 $out .= "Host: download.finance.yahoo.com\r\n"; 82 82 $out .= "Connection: Close\r\n\r\n"; 83 83 @fputs($fp, $out); 84 84 85 85 // Read the answer 86 86 $data = ''; … … 89 89 } 90 90 @fclose($fp); 91 91 92 92 // Parse the answer 93 93 $quotes = array(); … … 97 97 } 98 98 $quotes['USDUSD'] = 1.0; // Add conversion from USD to USD 99 99 100 100 $this->quotes = $quotes; 101 101 return $quotes; 102 102 } 103 103 } 104 104 105 105 /** 106 106 * Checks if there are quotes present … … 110 110 $this->getCurrentQuotesFromYahooFinance(); 111 111 } 112 112 113 113 /** 114 114 * Returns a serialized version of the quotes for storing … … 119 119 return serialize($this->quotes); 120 120 } 121 121 122 122 /** 123 123 * Load some stored serialized quotes … … 127 127 $this->quotes = unserialize($serializedQuotes); 128 128 } 129 129 130 130 public function getExchangeRate($from, $to) { 131 131 $this->getQuotesIfNeeded(); 132 132 133 133 // if currencies or rates are missing return 0 134 134 if (!isset($this->quotes['USD'.$from]) || $this->quotes['USD'.$from] == 0 || !isset($this->quotes['USD'.$to]) || $this->quotes['USD'.$to] == 0) 135 135 return 0; 136 136 137 137 return $this->quotes['USD'.$to] / $this->quotes['USD'.$from]; 138 138 } 139 139 140 140 } 141 142 143 141 142
Note: See TracChangeset
for help on using the changeset viewer.