Changeset 1318607
- Timestamp:
- 12/30/2015 04:07:01 PM (10 years ago)
- Location:
- worldcurrency/trunk
- Files:
-
- 4 edited
-
ip2c/ip2c.php (modified) (21 diffs)
-
readme.txt (modified) (3 diffs)
-
worldcurrency-admin.php (modified) (5 diffs)
-
worldcurrency.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
worldcurrency/trunk/ip2c/ip2c.php
r1318554 r1318607 11 11 var $m_countriesOffset; 12 12 var $m_numCountries; 13 var $bin_file = './ip-to-country.bin'; 13 var $bin_file = './ip-to-country.bin'; 14 14 15 15 /** … … 18 18 * ip2country(Boolean true) will USE caching with default file location 19 19 */ 20 function ip2country($bin_file = './ip-to-country.bin', $caching = false) 21 { 20 function ip2country($bin_file = './ip-to-country.bin', $caching = false) 21 { 22 if ($bin_file == './ip-to-country.bin') 23 $bin_file = dirname(__FILE__).'/ip-to-country.bin'; 24 22 25 if (is_bool($bin_file)) { 23 26 // use $bin_file as caching indicator … … 26 29 $bin_file = $this->bin_file; 27 30 } 28 31 29 32 $this->caching = $caching; 30 33 31 34 $this->m_file = fopen($bin_file, "rb"); 32 if (!$this->m_file) 35 if (!$this->m_file) 33 36 { 34 37 trigger_error('Error loading '.$bin_file); … … 36 39 return; 37 40 } 38 41 39 42 if ($this->caching) { 40 43 $this->initCache($bin_file); … … 51 54 $sig = fread($f, 4); 52 55 } 53 56 54 57 if ($sig != 'ip2c') 55 58 { … … 90 93 $int_ip = ip2long($ip); 91 94 92 // happens on 64bit systems 95 // happens on 64bit systems 93 96 if ($int_ip > IP2C_MAX_INT) 94 97 { … … 118 121 } 119 122 120 function find_country_code($ip, $startIndex, $endIndex, $firstTable, $d = 0) 123 function find_country_code($ip, $startIndex, $endIndex, $firstTable, $d = 0) 121 124 { 122 125 while(1) { … … 125 128 $mip = $mp['ip']; 126 129 //echo "#$d find_country_code : [code=$ip, start=$startIndex, middle=$middle, end=$endIndex, mip=$mip]<br/>"; 127 130 128 131 if ($ip < $mip) 129 132 { … … 133 136 //return $this->find_country_code($ip, $startIndex, $middle, $firstTable, ++$d); 134 137 } 135 else 138 else 136 139 if ($ip > $mip) 137 140 { … … 163 166 $c2 = $c[1]; 164 167 $key = ord($c1) * 256 + ord($c2); 165 return $this->find_country_key($key, 0, $this->m_numCountries); 166 } 167 168 169 function find_country_key($code, $startIndex, $endIndex) 170 { 168 return $this->find_country_key($key, 0, $this->m_numCountries); 169 } 170 171 172 function find_country_key($code, $startIndex, $endIndex) 173 { 171 174 $d = 0; 172 175 while(1) { … … 176 179 return false; 177 180 } 178 181 179 182 $d++; 180 183 $middle = (int)(($startIndex + $endIndex) / 2); 181 184 $mc = $this->get_country_code($middle); 182 185 //echo "#$d find_country : [$startIndex, $endIndex, mc=$mc, code=$code]<br/>"; 183 186 184 187 if ($mc == $code) 185 188 { … … 219 222 { 220 223 $offset = $this->m_countriesOffset + $index * 10; 221 224 222 225 if ($this->caching) 223 226 { 224 227 $this->offset = $offset; 225 228 } 226 else 229 else 227 230 fseek($this->m_file, $offset); 228 231 229 232 $id2c = $this->readCountryKey(); 230 233 $id3c = $this->read3cCode(); 231 234 $nameOffset = $this->readInt(); 232 235 233 236 if ($this->caching) 234 237 { 235 238 $this->offset = $nameOffset; 236 239 } 237 else 240 else 238 241 fseek($this->m_file, $nameOffset); 239 242 240 243 $len = $this->readShort(); 241 244 $name = ''; 242 245 if ($len != 0) 243 { 244 if ($this->caching) 246 { 247 if ($this->caching) 245 248 { 246 249 for($i = 0;$i<$len;$i++) … … 249 252 } 250 253 } 251 else 254 else 252 255 $name = fread($this->m_file, $len); 253 256 } … … 258 261 { 259 262 $offset = $this->m_countriesOffset + $index * 10; 260 263 261 264 if ($this->caching) 262 265 { … … 275 278 276 279 277 function getPair($index, $firstTable) 280 function getPair($index, $firstTable) 278 281 { 279 282 $offset = 0; 280 283 if ($firstTable) 281 284 { 282 if ($index > $this->m_numRangesFirstTable) 285 if ($index > $this->m_numRangesFirstTable) 283 286 { 284 287 return array('key'=>false,'ip'=>0); … … 288 291 else 289 292 { 290 if ($index > $this->m_numRangesSecondTable) 293 if ($index > $this->m_numRangesSecondTable) 291 294 { 292 295 return array('key'=>false,'ip'=>0); … … 295 298 296 299 } 297 300 298 301 if ($this->caching) 299 302 { … … 306 309 .$this->mem[$this->offset++]); 307 310 } 308 else 311 else 309 312 { 310 313 fseek($this->m_file, $offset); … … 316 319 } 317 320 318 function readShort() 321 function readShort() 319 322 { 320 323 if ($this->caching) … … 347 350 } 348 351 349 function readCountryKey() 352 function readCountryKey() 350 353 { 351 354 if ($this->caching) … … 356 359 { 357 360 return fread($this->m_file, 2); 358 } 359 } 360 361 function readInt() 361 } 362 } 363 364 function readInt() 362 365 { 363 366 if ($this->caching) -
worldcurrency/trunk/readme.txt
r1318579 r1318607 1 === WorldCurrency ===1 === WorldCurrency === 2 2 Contributors: WhiteCubes, JonScaife 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6CUNDYFWV4NUW … … 5 5 Requires at least: 2.8.0 6 6 Tested up to: 4.4 7 Stable tag: 1.2 37 Stable tag: 1.24 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. … … 97 97 == Changelog == 98 98 99 = 1.24 (30 December 2015) = 100 * Fix: Regression in ip2c.php which resulted in incorrected region lookup 101 * Added: Settings link on the plugins page directly to the plugin settings 102 99 103 = 1.23 (30 December 2015) = 100 104 * Fix: Bug in version numbering -
worldcurrency/trunk/worldcurrency-admin.php
r1318570 r1318607 5 5 add_options_page('WorldCurrency Settings', 'WorldCurrency', 'update_plugins', basename(__FILE__), 'worldcurrency_admin_page'); 6 6 } 7 8 7 9 8 function worldcurrency_admin_page(){ … … 66 65 <p> 67 66 <h4> 68 History Exchange Rates:67 Use historic exchange rates: 69 68 <input type="checkbox" name="historic_rates" id="historic_rates" <?php if ($dt_wc_options['historic_rates']=='true') {echo 'checked="checked"';}?> /> 70 69 </h4> … … 128 127 <p> 129 128 <h4> 130 Plugin Link:129 Plugin link: 131 130 <input type="checkbox" name="plugin_link" id="plugin_link" <?php if ($dt_wc_options['plugin_link']=='true') {echo 'checked="checked"';}?> /> 132 131 </h4> … … 137 136 <p> 138 137 <h4> 139 Yahoo Link:138 Yahoo link: 140 139 <input type="checkbox" name="yahoo_link" id="yahoo_link" <?php if ($dt_wc_options['yahoo_link']=='true') {echo 'checked="checked"';}?> /> 141 140 </h4> … … 196 195 <p> 197 196 <h4> 198 Plugin Firing Priorty:197 Plugin firing priority: 199 198 <input type="text" size="4" name="plugin_priority" value="<?php echo $dt_wc_options['plugin_priority']; ?>" /> 200 199 </h4> -
worldcurrency/trunk/worldcurrency.php
r1318582 r1318607 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.2 36 Version: 1.24 7 7 Date: 30 December 2015 8 8 Author: Daniele Tieghi … … 98 98 } 99 99 100 101 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'worldcurrency_add_action_links' ); 102 function worldcurrency_add_action_links ( $links ) { 103 $mylinks = array( 104 '<a href="' . admin_url( 'options-general.php?page=worldcurrency-admin.php' ) . '">Settings</a>', 105 ); 106 return array_merge( $links, $mylinks ); 107 } 108 109 110 100 111 // Add page scripts 101 112 function dt_wc_head() {
Note: See TracChangeset
for help on using the changeset viewer.