public function currencies()
 {
     $post = $_POST;
     $currencies = get_currencies_arr();
     foreach ($currencies as $k => $v) {
         if ($v['symbol'] == $post['currencies']) {
             session('currency', $v);
         }
     }
     header('location: ' . $_SERVER['HTTP_REFERER']);
 }
 public function Currencies()
 {
     $currencies = get_currencies_arr();
     for ($row = 0; $row < count($currencies); $row++) {
         if ($currencies[$row]['symbol'] == $_POST['Currencies']) {
             $_SESSION['currency'] = $currencies[$row];
         }
     }
     //print_r($_SESSION ['currency']);
     //echo "<script>history.go(-1);</script>";
     header('location: ' . $_SERVER['HTTP_REFERER']);
 }
 public function _initialize()
 {
     header("Content-Type:text/html; charset=utf-8");
     //是否关闭网站
     if (GetValue('close_site') == 1) {
         header("HTTP/1.1 500 Internal Server Error");
         header("Status: 500 Internal Server Error");
         die('<div style="margin: 10px; text-align: center; font-size: 14px"><p>The temporary closure of this site, you can not access!</p><p>' . GetValue('close_site_content') . '</p></div>');
     }
     //IP封锁
     if (isset($_COOKIE['ipblock']) && $_COOKIE['ipblock'] == 0) {
     } elseif (isset($_COOKIE['ipblock']) && $_COOKIE["ipblock"] == 1 || GetValue('ipblock') == 1 && GetValue('ipblock_pwd') != '') {
         $ipblock = new Home\Controller\IpblockController();
         $ipblock->index();
     }
     //货币初始化
     $currencies = get_currencies_arr();
     if (!isset($_SESSION['currency'])) {
         for ($i = 0; $i < count($currencies); $i++) {
             if ($currencies[$i]['symbol'] == C('DEFAULT_CURRENCIES_SYMBOL')) {
                 session('currency', $currencies[$i]);
             }
         }
     }
     $this->assign('currencies', $currencies);
     //生产一个唯一的session id
     $this->sessionID = cookie('sessionID');
     if (!$this->sessionID) {
         $this->sessionID = create_session_id();
         cookie('sessionID', $this->sessionID);
     }
     //读取用户id
     $auth_cookie = cookie('auth');
     if (empty($auth_cookie)) {
         $this->memberID = 0;
     } else {
         $auth = daddslashes(explode("\t", authcode($auth_cookie, 'DECODE', C('AUTHKEY'))));
         list($member_id, $member_email) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
         if (!empty($member_id)) {
             $this->memberID = $member_id;
         }
     }
     cookie('memberID', $this->memberID);
     if ($this->memberID) {
         //读取用户信息
         $this->mid = $this->memberID;
         $this->member_Info = D("Members")->where("id=" . $this->memberID)->find();
         $this->assign('member_Info', $this->member_Info);
         $this->member_ShippingAddress = D("Shippingaddress")->get_shippingaddress($this->memberID);
     }
     $this->assign('memberID', $this->memberID);
     $referer = '';
     if (isset($_GET['referer']) && $_GET['referer']) {
         $referer = $_GET['referer'];
     } else {
         if (cookie('referer')) {
             $referer = cookie('referer');
         }
     }
     $this->referer = $referer;
     //当前月份
     $today = getdate();
     $this->month = $today['month'];
     //会员等级
     $this->memberGropuInfo = get_members_group($this->memberID);
     $this->isVip = $this->memberGropuInfo ? 1 : 0;
     $this->ProModel = D('Products');
     $this->assign('catetree', get_catetree());
     $this->assign('itemCount', itemCount());
     $this->assign('copyright', GetValue('footer_content'));
     $this->assign('tongji', GetValue('footcode'));
 }
示例#4
0
 function _initialize()
 {
     header("Content-Type:text/html; charset=utf-8");
     L('_OPERATION_SUCCESS_', "Operation Success");
     L('_OPERATION_FAIL_', 'Operation Fail');
     //是否关闭网站
     if (GetValue('close_site') == 1) {
         header("HTTP/1.1 500 Internal Server Error");
         header("Status: 500 Internal Server Error");
         die('<div style="margin: 10px; text-align: center; font-size: 14px"><p>The temporary closure of this site, you can not access!</p><p>' . GetValue('close_site_content') . '</p></div>');
     }
     //IP封锁
     if (isset($_COOKIE['ipblock']) && $_COOKIE['ipblock'] == 0) {
     } elseif (isset($_COOKIE['ipblock']) && $_COOKIE["ipblock"] == 1 || GetValue('ipblock') == 1 && GetValue('ipblock_pwd') != '') {
         import('@.Action.Home.IpblockAction');
         $ipblock = new IpblockAction();
         $ipblock->index();
     }
     $this->ProModel = D('Products');
     //多主题
     if ($this->theme = GetValue('theme')) {
         setcookie('think_template', $this->theme, time() + 3600, '/');
     } else {
         setcookie('think_template', 'default', time() + 3600, '/');
     }
     //多语言
     /*$lang=GetValue('lang');
     		if('auto'!=$lang){
     		setcookie('think_language',$lang?$lang:'en-us',time()+3600,'/');
     		}*/
     //浏览历史
     $this->product_history = product_history();
     //货币初始化
     $this->currencies = $currencies = get_currencies_arr();
     if (!isset($_SESSION['currency'])) {
         for ($row = 0; $row < count($currencies); $row++) {
             if ($currencies[$row]['symbol'] == C('DEFAULT_CURRENCIES_SYMBOL')) {
                 $_SESSION['currency'] = $currencies[$row];
             }
         }
     }
     //生产一个唯一的session id
     $this->sessionID = Cookie::get('sessionID');
     if (!$this->sessionID) {
         $this->sessionID = create_session_id();
         Cookie::set('sessionID', $this->sessionID);
     }
     //读取用户id
     $auth_cookie = Cookie::get('auth');
     if (empty($auth_cookie)) {
         $this->memberID = 0;
     } else {
         $auth = daddslashes(explode("\t", authcode($auth_cookie, 'DECODE', C('AUTHKEY'))));
         list($member_id, $member_email) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
         if (!empty($member_id)) {
             $this->memberID = $member_id;
         }
     }
     Cookie::set('memberID', $this->memberID);
     if ($this->memberID) {
         //读取用户信息
         $this->mid = $this->memberID;
         self::$Model = D("Members");
         $this->memberInfo = self::$Model->where("id=" . $this->memberID)->find();
         $this->member_Info = $this->memberInfo;
         self::$Model = D("Shippingaddress");
         $this->memberShippingAddress = self::$Model->where("id=" . $this->memberID)->find();
         Cookie::set('memberShippingAddress', $this->memberShippingAddress);
         $this->member_ShippingAddress = $this->memberShippingAddress;
         /*$this->_365call="
         		<script type=\"text/javascript\">
         		//<![CDATA[
         		var _365call_memberID  = \"{$this->memberInfo['email']}\"; //  char(20)  账号(会员号)
         		var _365call_clientName= \"{$this->memberInfo['firstname']}{$this->memberInfo['lastname']}\"; //  char(50)  用户名(姓名)
         		var _365call_email     = \"{$this->memberInfo['email']}\"; //  char(50)  邮件地址
         		var _365call_phone     = \"{$this->memberShippingAddress['telphone']}\"; //  char(20)  联系电话
         		var _365call_msn       = \"\"; //  char(50)  MSN
         		var _365call_qq        = \"\"; //  char(20)  QQ
         		var _365call_note      = \"{$this->memberShippingAddress['address']}\"; //  char(100) 其他
         		//]]>
         		</script>";*/
     }
     //当前月份
     $today = getdate();
     $this->month = $today['month'];
     //总重量
     self::$Model = D("Cart");
     $this->Total_weight = self::$Model->cart_total_weight($this->sessionID);
     //购物车商品
     $this->cart_list = self::$Model->cart_list($this->sessionID);
     $this->item_count = itemCount();
     $this->total_count = TotalCount();
     //会员等级
     $this->memberGropuInfo = get_members_group($this->memberID);
     if (get_members_group($this->memberID)) {
         $this->isVip = 1;
     } else {
         $this->isVip = 0;
     }
     /**
      * bof缓存模板变量
      */
     //全局模板变量
     if (F('Common_Cache') == '') {
         F('Common_Cache', $this->_Common_Cache());
     }
     $this->assign(F('Common_Cache'));
     //产品缓存
     if (F('Products_Cache') == '') {
         F('Products_Cache', $this->_Products_Cache());
     }
     //打乱随机显示
     $Products_Cache = F('Products_Cache');
     //$Products_Cache['FeaturedProducts']=$this->ProModel->rand($Products_Cache['FeaturedProducts']);
     //$Products_Cache['HotProducts']=$this->ProModel->rand($Products_Cache['HotProducts']);
     //$Products_Cache['NewProducts']=$this->ProModel->rand($Products_Cache['NewProducts']);
     //$Products_Cache['SpeProducts']=$this->ProModel->rand($Products_Cache['SpeProducts']);
     $this->assign($Products_Cache);
     /**
      * eof缓存模板变量
      */
 }
示例#5
0
/**
 * 获取价格
 *
 * @param Integer $price 价格
 * @param Integer $spe 特价
 */
function getprice($price, $spe, $discount = true)
{
    //如果没有选择汇率,读取系统默认汇率
    $currencies = get_currencies_arr();
    if (!isset($_SESSION['currency'])) {
        for ($row = 0; $row < count($currencies); $row++) {
            if ($currencies[$row]['symbol'] == C('DEFAULT_CURRENCIES_SYMBOL')) {
                $_SESSION['currency'] = $currencies[$row];
            }
        }
    }
    if ($spe >= $price) {
        //货币汇率
        $re = $_SESSION['currency']['code'] . $spe * $_SESSION['currency']['rate'];
        $r_price = $price;
    } else {
        $price *= $_SESSION['currency']['rate'];
        $spe *= $_SESSION['currency']['rate'];
        if ($discount) {
            $re = '<span style="color:red;text-decoration: line-through;">' . $_SESSION['currency']['code'] . $price . '</span>&nbsp;&nbsp;&nbsp;<span style="color:red;">' . $_SESSION['currency']['code'] . $spe . '</span><br />Save:' . number_format(($price - $spe) / $price * 100, 0) . '% off';
        } else {
            $re = $_SESSION['currency']['code'] . $spe;
        }
        $r_price = $spe;
    }
    $memberID = Session::get('memberID');
    //在价格里头显示vip价格
    if (!$memberID) {
        $memberID = 0;
    }
    $ginfo = get_members_group($memberID);
    if ($ginfo) {
        if ($discount) {
            return $re . " " . $ginfo["name"] . ":" . $_SESSION['currency']['code'] . $r_price * $ginfo["discount"];
        } else {
            return $re;
        }
    }
    return $re;
}