Ignore:
Timestamp:
Nov 15, 2014 9:34:39 PM (10 years ago)
Author:
anonymous
Message:

Many auth and crypto changes; various other bugfixes while working on pulso.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Currency.inc.php

    r484 r500  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2828 * @author  Quinn Comendant <quinn@strangecode.com>
    2929 * @version 1.5
    30  * 
     30 *
    3131 * Example of use:
    3232---------------------------------------------------------------------
     
    3737---------------------------------------------------------------------
    3838 */
    39  
     39
    4040class Currency {
    4141
     
    4848        'api_key' => '', // Used only by xurrency API.
    4949    );
    50    
     50
    5151    /**
    5252     * Cart constructor.
     
    5858        // Set custom parameters.
    5959        $this->setParam($params);
    60        
     60
    6161        // Setup cache directory.
    6262        if ($this->getParam('cache_result')) {
     
    6666            }
    6767            if (!is_dir($this->getParam('cache_dir'))) {
    68                 $app->logMsg(sprintf('Creating cache_dir: %s', $this->getParam('cache_dir')), LOG_INFO, __FILE__, __LINE__);               
     68                $app->logMsg(sprintf('Creating cache_dir: %s', $this->getParam('cache_dir')), LOG_INFO, __FILE__, __LINE__);
    6969                if (!mkdir($this->getParam('cache_dir'))) {
    70                     $app->logMsg(sprintf('Could not create cache_dir: %s', $this->getParam('cache_dir')), LOG_WARNING, __FILE__, __LINE__);               
     70                    $app->logMsg(sprintf('Could not create cache_dir: %s', $this->getParam('cache_dir')), LOG_WARNING, __FILE__, __LINE__);
    7171                }
    7272            }
     
    9797    {
    9898        $app =& App::getInstance();
    99    
     99
    100100        if (array_key_exists($param, $this->_params)) {
    101101            return $this->_params[$param];
     
    105105        }
    106106    }
    107    
     107
    108108    /*
    109109    * Return the exchange value between the two given currencies for given amount.
     
    113113    * @param    string  $base   3-letter currency code to convert from.
    114114    * @param    string  $target 3-letter currency code to convert to.
    115     * @return   mixed   Float converted currency value, or false on error. 
     115    * @return   mixed   Float converted currency value, or false on error.
    116116    * @author   Quinn Comendant <quinn@strangecode.com>
    117117    * @version  1.0
     
    121121    {
    122122        if (false !== $rate = $this->getRate($base, $target)) {
    123             return abs($rate * $amount);           
     123            return abs($rate * $amount);
    124124        } else {
    125125            return false;
    126126        }
    127127    }
    128    
     128
    129129    /*
    130130    * Return the currency conversion rate as a ratio.
     
    133133    * @param    string  $base   3-letter currency code to convert from.
    134134    * @param    string  $target 3-letter currency code to convert to.
    135     * @return   mixed   Float exchange rate value, or false on error. 
     135    * @return   mixed   Float exchange rate value, or false on error.
    136136    * @author   Quinn Comendant <quinn@strangecode.com>
    137137    * @version  1.0
     
    173173        return trim($value);
    174174    }
    175    
     175
    176176    /**
    177177     * @param  string
     
    215215            $api_url = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml';
    216216            if (false === $sXML = file_get_contents($api_url)) {
    217                 $app->logMsg(sprintf('Failed to load ECB XML data from ', $api_url), LOG_WARNING, __FILE__, __LINE__);
     217                $app->logMsg(sprintf('Failed to load ECB XML data from: %s', $api_url), LOG_WARNING, __FILE__, __LINE__);
    218218                return false;
    219219            }
    220220            if (false === $oXML = simplexml_load_string($sXML)) {
    221                 $app->logMsg(sprintf('Failed to decode ECB XML data: ', truncate($sXML, 200, 'end')), LOG_WARNING, __FILE__, __LINE__);
     221                $app->logMsg(sprintf('Failed to decode ECB XML data: %s', truncate($sXML, 200, 'end')), LOG_WARNING, __FILE__, __LINE__);
    222222                return false;
    223223            }
Note: See TracChangeset for help on using the changeset viewer.