[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 currencies.php

Zen Cart 源代码 currencies.php




下载文件

文件名: currencies.php
文件类型: PHP文件
文件大小: 4.64 KiB
MD5: bf01968f994495f7b963391839dbe648

currencies.php - 关闭高亮
  1. <?php
  2. /**
  3.  * currencies Class.
  4.  *
  5.  * @package classes
  6.  * @copyright Copyright 2003-2010 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version $Id: currencies.php 15880 2010-04-11 16:24:30Z wilt $
  10.  */
  11. if (!defined('IS_ADMIN_FLAG')) {
  12.   die('Illegal Access');
  13. }
  14. /**
  15.  * currencies Class.
  16.  * Class to handle currencies
  17.  *
  18.  * @package classes
  19.  */
  20. class currencies extends base {
  21.   var $currencies;
  22.  
  23.   // class constructor
  24.   function currencies() {
  25.     global $db;
  26.     $this->currencies = array();
  27.     $currencies_query = "select code, title, symbol_left, symbol_right, decimal_point,
  28.                                  thousands_point, decimal_places, value
  29.                          from " . TABLE_CURRENCIES;
  30.  
  31.     $currencies = $db->Execute($currencies_query);
  32.  
  33.     while (!$currencies->EOF) {
  34.       $this->currencies[$currencies->fields['code']] = array('title' => $currencies->fields['title'],
  35.       'symbol_left' => $currencies->fields['symbol_left'],
  36.       'symbol_right' => $currencies->fields['symbol_right'],
  37.       'decimal_point' => $currencies->fields['decimal_point'],
  38.       'thousands_point' => $currencies->fields['thousands_point'],
  39.       'decimal_places' => $currencies->fields['decimal_places'],
  40.       'value' => $currencies->fields['value']);
  41.  
  42.       $currencies->MoveNext();
  43.     }
  44.   }
  45.  
  46.   // class methods
  47.   function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
  48.  
  49.     if (empty($currency_type)) $currency_type = $_SESSION['currency'];
  50.  
  51.     if ($calculate_currency_value == true) {
  52.       $rate = (zen_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
  53.       $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  54.     } else {
  55.       $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(zen_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  56.     }
  57.  
  58.     if ((DOWN_FOR_MAINTENANCE=='true' and DOWN_FOR_MAINTENANCE_PRICES_OFF=='true') and (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR']))) {
  59.       $format_string= '';
  60.     }
  61.  
  62.     return $format_string;
  63.   }
  64.  
  65.   function rateAdjusted($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
  66.  
  67.     if (empty($currency_type)) $currency_type = $_SESSION['currency'];
  68.  
  69.     if ($calculate_currency_value == true) {
  70.       $rate = (zen_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
  71.       $result = zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']);
  72.     } else {
  73.       $result = zen_round($number, $this->currencies[$currency_type]['decimal_places']);
  74.     }
  75.     return $result;
  76.   }
  77.  
  78.   function value($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
  79.  
  80.     if (empty($currency_type)) $currency_type = $_SESSION['currency'];
  81.  
  82.     if ($calculate_currency_value == true) {
  83.       if ($currency_type == DEFAULT_CURRENCY) {
  84.         $rate = (zen_not_null($currency_value)) ? $currency_value : 1/$this->currencies[$_SESSION['currency']]['value'];
  85.       } else {
  86.         $rate = (zen_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
  87.       }
  88.       $currency_value = zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']);
  89.     } else {
  90.       $currency_value = zen_round($number, $this->currencies[$currency_type]['decimal_places']);
  91.     }
  92.  
  93.     return $currency_value;
  94.   }
  95.  
  96.   function is_set($code) {
  97.     if (isset($this->currencies[$code]) && zen_not_null($this->currencies[$code])) {
  98.       return true;
  99.     } else {
  100.       return false;
  101.     }
  102.   }
  103.  
  104.   function get_value($code) {
  105.     return $this->currencies[$code]['value'];
  106.   }
  107.  
  108.   function get_decimal_places($code) {
  109.     return $this->currencies[$code]['decimal_places'];
  110.   }
  111.  
  112.   function display_price($products_price, $products_tax, $quantity = 1) {
  113.     return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
  114.   }
  115. }
  116. ?>


cron