Plugin Directory

Changeset 1318607


Ignore:
Timestamp:
12/30/2015 04:07:01 PM (10 years ago)
Author:
jonscaife
Message:

v1.24: Add settings page link, fix regression of ip2c.php and correct more typos

Location:
worldcurrency/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • worldcurrency/trunk/ip2c/ip2c.php

    r1318554 r1318607  
    1111    var $m_countriesOffset;
    1212    var $m_numCountries;
    13     var $bin_file = './ip-to-country.bin';     
     13    var $bin_file = './ip-to-country.bin';
    1414
    1515    /**
     
    1818     * ip2country(Boolean true) will USE caching with default file location
    1919     */
    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
    2225        if (is_bool($bin_file)) {
    2326            // use $bin_file as caching indicator
     
    2629            $bin_file = $this->bin_file;
    2730        }
    28        
     31
    2932        $this->caching = $caching;
    30        
     33
    3134        $this->m_file = fopen($bin_file, "rb");
    32         if (!$this->m_file) 
     35        if (!$this->m_file)
    3336        {
    3437            trigger_error('Error loading '.$bin_file);
     
    3639            return;
    3740        }
    38        
     41
    3942        if ($this->caching) {
    4043            $this->initCache($bin_file);
     
    5154            $sig = fread($f, 4);
    5255        }
    53        
     56
    5457        if ($sig != 'ip2c')
    5558        {
     
    9093        $int_ip =  ip2long($ip);
    9194
    92         // happens on 64bit systems 
     95        // happens on 64bit systems
    9396        if ($int_ip > IP2C_MAX_INT)
    9497        {
     
    118121    }
    119122
    120     function find_country_code($ip, $startIndex, $endIndex, $firstTable, $d = 0) 
     123    function find_country_code($ip, $startIndex, $endIndex, $firstTable, $d = 0)
    121124    {
    122125        while(1) {
     
    125128            $mip = $mp['ip'];
    126129            //echo "#$d find_country_code : [code=$ip, start=$startIndex, middle=$middle, end=$endIndex, mip=$mip]<br/>";
    127    
     130
    128131            if ($ip < $mip)
    129132            {
     
    133136                //return $this->find_country_code($ip, $startIndex, $middle, $firstTable, ++$d);
    134137            }
    135             else 
     138            else
    136139                if ($ip > $mip)
    137140                {
     
    163166        $c2 = $c[1];
    164167        $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    {
    171174        $d = 0;
    172175        while(1) {
     
    176179                return false;
    177180            }
    178            
     181
    179182            $d++;
    180183            $middle = (int)(($startIndex + $endIndex) / 2);
    181184            $mc = $this->get_country_code($middle);
    182185            //echo "#$d find_country : [$startIndex, $endIndex, mc=$mc, code=$code]<br/>";
    183    
     186
    184187            if ($mc == $code)
    185188            {
     
    219222    {
    220223        $offset = $this->m_countriesOffset + $index * 10;
    221        
     224
    222225        if ($this->caching)
    223226        {
    224227            $this->offset = $offset;
    225228        }
    226         else 
     229        else
    227230            fseek($this->m_file, $offset);
    228        
     231
    229232        $id2c = $this->readCountryKey();
    230233        $id3c = $this->read3cCode();
    231234        $nameOffset = $this->readInt();
    232        
     235
    233236        if ($this->caching)
    234237        {
    235238            $this->offset = $nameOffset;
    236239        }
    237         else 
     240        else
    238241            fseek($this->m_file, $nameOffset);
    239        
     242
    240243        $len = $this->readShort();
    241244        $name = '';
    242245        if ($len != 0)
    243         { 
    244             if ($this->caching) 
     246        {
     247            if ($this->caching)
    245248            {
    246249                for($i = 0;$i<$len;$i++)
     
    249252                }
    250253            }
    251             else 
     254            else
    252255                $name = fread($this->m_file, $len);
    253256        }
     
    258261    {
    259262        $offset = $this->m_countriesOffset + $index * 10;
    260        
     263
    261264        if ($this->caching)
    262265        {
     
    275278
    276279
    277     function getPair($index, $firstTable) 
     280    function getPair($index, $firstTable)
    278281    {
    279282        $offset = 0;
    280283        if ($firstTable)
    281284        {
    282             if ($index > $this->m_numRangesFirstTable) 
     285            if ($index > $this->m_numRangesFirstTable)
    283286            {
    284287                return array('key'=>false,'ip'=>0);
     
    288291        else
    289292        {
    290             if ($index > $this->m_numRangesSecondTable) 
     293            if ($index > $this->m_numRangesSecondTable)
    291294            {
    292295                return array('key'=>false,'ip'=>0);
     
    295298
    296299        }
    297        
     300
    298301        if ($this->caching)
    299302        {
     
    306309                                    .$this->mem[$this->offset++]);
    307310        }
    308         else 
     311        else
    309312        {
    310313            fseek($this->m_file, $offset);
     
    316319    }
    317320
    318     function readShort() 
     321    function readShort()
    319322    {
    320323        if ($this->caching)
     
    347350    }
    348351
    349     function readCountryKey() 
     352    function readCountryKey()
    350353    {
    351354        if ($this->caching)
     
    356359        {
    357360            return fread($this->m_file, 2);
    358         }       
    359     }
    360 
    361     function readInt() 
     361        }
     362    }
     363
     364    function readInt()
    362365    {
    363366        if ($this->caching)
  • worldcurrency/trunk/readme.txt

    r1318579 r1318607  
    1 === WorldCurrency ===
     1=== WorldCurrency ===
    22Contributors: WhiteCubes, JonScaife
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6CUNDYFWV4NUW
     
    55Requires at least: 2.8.0
    66Tested up to: 4.4
    7 Stable tag: 1.23
     7Stable tag: 1.24
    88
    99Recognises users by IP address and shows them converted values in their local currency, you can write post/pages in multiple currencies.
     
    9797== Changelog ==
    9898
     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
    99103= 1.23 (30 December 2015) =
    100104* Fix: Bug in version numbering
  • worldcurrency/trunk/worldcurrency-admin.php

    r1318570 r1318607  
    55        add_options_page('WorldCurrency Settings', 'WorldCurrency', 'update_plugins', basename(__FILE__), 'worldcurrency_admin_page');
    66    }
    7 
    87
    98    function worldcurrency_admin_page(){
     
    6665                        <p>
    6766                            <h4>
    68                                 History Exchange Rates:
     67                                Use historic exchange rates:
    6968                                <input type="checkbox" name="historic_rates" id="historic_rates" <?php if ($dt_wc_options['historic_rates']=='true') {echo 'checked="checked"';}?> />
    7069                            </h4>
     
    128127                        <p>
    129128                            <h4>
    130                                 Plugin Link:
     129                                Plugin link:
    131130                                <input type="checkbox" name="plugin_link" id="plugin_link" <?php if ($dt_wc_options['plugin_link']=='true') {echo 'checked="checked"';}?> />
    132131                            </h4>
     
    137136                        <p>
    138137                            <h4>
    139                                 Yahoo Link:
     138                                Yahoo link:
    140139                                <input type="checkbox" name="yahoo_link" id="yahoo_link" <?php if ($dt_wc_options['yahoo_link']=='true') {echo 'checked="checked"';}?> />
    141140                            </h4>
     
    196195                        <p>
    197196                            <h4>
    198                                 Plugin Firing Priorty:
     197                                Plugin firing priority:
    199198                                <input type="text" size="4" name="plugin_priority" value="<?php echo $dt_wc_options['plugin_priority']; ?>" />
    200199                            </h4>
  • worldcurrency/trunk/worldcurrency.php

    r1318582 r1318607  
    44Plugin URI: http://www.cometicucinoilweb.it/blog/en/worldcurrency-plugin-for-wordpress/
    55Description: 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.23
     6Version: 1.24
    77Date: 30 December 2015
    88Author: Daniele Tieghi
     
    9898        }
    9999
     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
    100111    // Add page scripts
    101112        function dt_wc_head() {
Note: See TracChangeset for help on using the changeset viewer.