<?php
// +----------------------------------------------------------------------
// | 云业内容管理系统 (云业CMS或yunyecms)
// +----------------------------------------------------------------------
// | Copyright (c) 2016-2030 http://www.yunyecms.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 洛阳云业信息科技有限公司 <15003219@qq.com>
// +----------------------------------------------------------------------
//YmM0OWM5ZWY1ODk5ZGRkNzM0NUxxUjVMaWE1WWFGNWE2NTU2Nmg1NUNHNTdPNzU3dWZJQ2prdXBIa3VKcERUVlBtaUpaNWRXNTVaV050Y3lrc1EyOXdlWEpwWjJoMElDaGpLU0F5TURFMkxUSXdNekFnYUhSMGNEb3ZMM2QzZHk1NWRXNTVaV050Y3k1amIyMGdRV3hzSUhKcFoyaDBjeUJ5WlhObGNuWmxaQzRnUVhWMGFHOXlPaURsaUpqbW1aUHBvNTRnUERFMU1EQXpNakU1UUhGeExtTnZiVDQ9OGQ3ZTc5OTU5YjQ0MmEyNWQxNGVlMzg2ZmQyODM2OTkzNGE
//MD5:c610bc3d074f2ea0c833d32de3bfa0c3
// +----------------------------------------------------------------------
defined('IN_YUNYECMS') or exit('No direct script access allowed');
session_save_path(YUNYECMS_SESSION);
session_start();
class addons {
	public $lang;
	public $cat;
	public $rootcat;
	public $cfg;
	public $member;
	public $db;
    function __construct() {
		 header("Content-type: text/html; charset=utf-8"); 
		 global $lang;
		 global $cfg;
	     $this->db = core::load_model('common');
		 $this->cfg=getcfg();
		 if(!empty($_REQUEST['lang'])&&is_numeric($_REQUEST['lang'])){
	        $this->lang=getcurlang(usafestr(trim($_REQUEST['lang'])));
		}else{
	        $this->lang=getdefaultlang();
		}
		$this->lang=dolang($this->lang,$this->cfg);
		$this->lang['logo']=dopic($this->lang['logo']);
		$this->lang['icon']=dopic($this->lang['icon']);
		$this->lang['qrcode']=dopic($this->lang['qrcode']);
		$this->lang['copyright']=doimgs($this->lang['copyright']);
		$lang=$this->lang;
		$cfg=$this->cfg;
        define('LAN',empty($this->lang['landir'])?"cn":$this->lang['landir']);
		define('ADDONS_TPL',ADDONS.ROUTE_M."/tpl/".LAN."/");
	    if(!empty($_REQUEST['catid'])){
			  $catid=trim($_REQUEST['catid']);
			  if(!is_numeric($catid)){
				   messagebox("错误的参数","back",'warn');
			  }
		   $catid=usafestr($catid);
		   $catid=getreal_catid($catid,$this->lang['id'],'category',$this->db);
		   $this->cat=getbyid($catid);
		   $this->rootcat=getbyid(getppid($catid));
				if(strlen(RD)>0&&stripos($this->rootcat["pic"],RD)===FALSE){
					$this->rootcat["pic"]=!empty($this->rootcat["pic"])?RD.$this->rootcat["pic"]:''; RD.$this->rootcat["pic"];
				};
	    }
		if($this->cfg['isclose']==1){
			include tpl("closesite");
			exit;
		}
	    $userid=usafestr(yunyecms_strdecode(ugetcookie("userid")));
		if($userid&&is_numeric($userid)){
		    $this->member=getbyid($userid,"member");
			if($this->member["id"]){
			  $this->member['cartnum']=getcount("select count(*) from `#yunyecms_cart` where userid={$this->member["id"]}");
		      $this->member['ordernum']=getcount("select count(*) from `#yunyecms_orders` where userid={$this->member["id"]}");	
			}
		    $this->member['noticenum']=getcount("select count(*) from `#yunyecms_notice` where status=1");
		}
    }
}