示例#1
0
文件: logout.php 项目: laiello/hecart
 public function index()
 {
     $this->user->logout();
     unset($this->session->data['token']);
     wcore_utils::set_cookie('token', null);
     wcore_utils::set_cookie('vtoken', null);
     $this->redirect($this->url->link('common/login', '', 'SSL'));
 }
示例#2
0
文件: tip.php 项目: laiello/hecart
 /**
  * 手机浏览器提示并跳转指定URL地址
  *
  * @param string  $msg    提示的内容
  * @param string  $url    要跳转的URL地址
  * @param integer $second 显示多少秒
  */
 public static function mtip($msg, $url = '', $second = 3)
 {
     if (empty($url)) {
         $url = wcore_utils::get_http_referer();
     }
     if (strpos($_SERVER["HTTP_ACCEPT"], 'wap.wml') !== false) {
         $second = $second * 10;
         $msg = strip_tags($msg);
         header('Content-Type: text/vnd.wap.wml; charset=utf-8');
         echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\"";
         echo "\"http://www.wapforum.org/DTD/wml13.dtd\">\n<wml><card title=\"返回\" ontimer=\"{$url}\"><p>{$msg}</p>";
         exit("<p><a href=\"{$url}\">未自动跳转点击此处</a></p><timer value=\"{$second}\"/></card></wml>");
     } else {
         echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><html><head>";
         echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
         echo "<meta http-equiv=\"refresh\" content=\"{$second}; url={$url}\"><title>系统提示</title></head><body>";
         echo "<div style='margin:5px;padding:5px;line-height:22px;border:1px solid #FFCCBF;background-color:#FFFFE6;'>";
         echo "{$msg}</div><br/>{$second}秒未跳转,请点击<a href=\"{$url}\">快速跳转</a>";
         exit("</body></html>");
     }
 }
示例#3
0
 /**
  * 初始化SESSION
  *
  * @param string  $type   会话的存储方式
  * @param integer $ltime  会话寿命时间以分钟为单位
  * @param string  $path   会话文件存储的路径
  * @param string  $prefix 会话文件前缀
  * @param boolean $start  是否马上启用SESSION处理
  */
 public function __construct($type = 'file', $ltime = 30, $path = '', $prefix = 'ws', $start = true)
 {
     $this->_prefix = $prefix;
     $this->_type = strtolower($type);
     if ($this->_type == 'file' || $this->_type == 'dir') {
         $this->_path = $path && file_exists($path) ? $path : get_cfg_var('session.save_path');
         wcore_fso::make_dir($this->_path);
         //处理SESSION存储的路径
     }
     $this->_life_time = $ltime && is_numeric($ltime) ? $ltime * 60 : get_cfg_var('session.gc_maxlifetime');
     $this->_ip = wcore_utils::get_ip();
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     register_shutdown_function('session_write_close');
     /**
      * 是否马上启用SESSION处理
      */
     if ($start) {
         ini_set('session.use_cookies', 'On');
         ini_set('session.use_trans_sid', 'Off');
         session_set_cookie_params(0, '/');
         session_start();
     }
     $this->data =& $_SESSION;
 }
示例#4
0
 public function logout()
 {
     /**
      * 保存客户购物车中的所购买的产品与收藏产品
      */
     $ip = wcore_utils::get_ip();
     $cartlist = $this->mdb()->escape(isset($this->session->data['cart']) ? serialize($this->session->data['cart']) : '');
     $wishlist = $this->mdb()->escape(isset($this->session->data['wishlist']) ? serialize($this->session->data['wishlist']) : '');
     $this->mdb()->query_res("UPDATE " . DB_PREFIX . "customer SET cart = '{$cartlist}', wishlist = '{$wishlist}', ip = '{$ip}' WHERE customer_id = '{$this->customer_id}'");
     /**
      * 清除登录信息
      */
     $this->customer_id = '';
     $this->firstname = '';
     $this->lastname = '';
     $this->email = '';
     $this->telephone = '';
     $this->fax = '';
     $this->newsletter = '';
     $this->customer_group_id = '';
     $this->address_id = '';
     unset($this->session->data['customer_id']);
     wcore_utils::set_cookie('cust_id', null, -1);
     wcore_utils::set_cookie('cust_email', null, -1);
 }
示例#5
0
文件: index.php 项目: laiello/hecart
//Version
define('VERSION', '1.0.0');
//Configuration
define('DIR_SITE', empty($_SERVER['DOCUMENT_ROOT']) ? dirname(__FILE__) : $_SERVER['DOCUMENT_ROOT']);
define('DIR_ROOT', empty($_SERVER['DOCUMENT_ROOT']) ? dirname(dirname(__FILE__)) : dirname($_SERVER['DOCUMENT_ROOT']));
require DIR_ROOT . '/config/start.php';
//loading start for here
//Cache OR static HTML file
if (true) {
    //此处加速适合于多语言多货币
    $_GET['islogged'] = 0;
    $_GET['language'] = wcore_utils::get_var('language', 's', 'c');
    $_GET['currency'] = wcore_utils::get_var('currency', 's', 'c');
    $token = wcore_utils::get_var('token', 's', 'c');
    $vtoken = wcore_utils::get_var('vtoken', 's', 'c');
    if (!empty($token) && !empty($vtoken)) {
        $_GET['islogged'] = $vtoken == md5(substr($token, 3, 16) . SITE_MD5_KEY) ? 1 : 0;
    }
    $speed = new wcore_speed('mem');
    unset($_GET['islogged'], $_GET['language'], $_GET['currency'], $token, $vtoken);
} else {
    //此处加速仅适应于单语言单货币
    $puid = $_SERVER["REQUEST_URI"] == '/' || $_SERVER["REQUEST_URI"] == $_SERVER["SCRIPT_NAME"] ? 'index.html' : $_SERVER["REQUEST_URI"];
    $speed = new wcore_speed(strpos($puid, '?') === false ? 'file' : 'mem', 0, $puid);
}
$html = $speed->get_data();
if (!empty($html)) {
    exit($html);
}
//Startup
示例#6
0
    wcore_utils::set_cookie('language', $code, 365);
}
$config->set('config_language_id', $languages[$code]['language_id']);
$config->set('config_language', $languages[$code]['code']);
//Language
$language = new Language($languages[$code]['directory']);
$language->load($languages[$code]['filename']);
$registry->set('language', $language);
//Document
$registry->set('document', new Document());
//Customer
$registry->set('customer', new Customer($registry));
//Affiliate
$registry->set('affiliate', new Affiliate($registry));
if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
    wcore_utils::set_cookie('tracking', $request->get['tracking'], 365);
}
//Currency
$registry->set('currency', new Currency($registry));
//Tax
$registry->set('tax', new Tax($registry));
//Weight
$registry->set('weight', new Weight($registry));
//Length
$registry->set('length', new Length($registry));
//Cart
$registry->set('cart', new Cart($registry));
//Encryption
$registry->set('encryption', new Encryption($config->get('config_encryption')));
//Front Controller
$controller = new Front($registry);
示例#7
0
文件: login.php 项目: laiello/hecart
 public function index()
 {
     $this->load->language('common/login');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->user->isLogged() && isset($this->request->cookie['token']) && $this->request->cookie['token'] == $this->session->data['token']) {
         $this->redirect($this->url->link('common/home'));
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->session->data['token'] = md5(mt_rand());
         wcore_utils::set_cookie('token', $this->session->data['token']);
         wcore_utils::set_cookie('vtoken', md5(substr($this->session->data['token'], 3, 16) . SITE_MD5_KEY));
         if (isset($this->request->post['redirect'])) {
             $this->redirect($this->request->post['redirect']);
         } else {
             $this->redirect($this->url->link('common/home'));
         }
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_login'] = $this->language->get('text_login');
     $this->data['text_forgotten'] = $this->language->get('text_forgotten');
     $this->data['entry_username'] = $this->language->get('entry_username');
     $this->data['entry_password'] = $this->language->get('entry_password');
     $this->data['button_login'] = $this->language->get('button_login');
     if (isset($this->session->data['token']) && !isset($this->request->cookie['token']) || isset($this->request->cookie['token']) && (isset($this->session->data['token']) && $this->request->cookie['token'] != $this->session->data['token'])) {
         $this->error['warning'] = $this->language->get('error_token');
     }
     $this->data['error_warning'] = isset($this->error['warning']) ? $this->error['warning'] : '';
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['action'] = $this->url->link('common/login', '', 'SSL');
     if (isset($this->request->post['username'])) {
         $this->data['username'] = $this->request->post['username'];
     } else {
         $this->data['username'] = '';
     }
     if (isset($this->request->post['password'])) {
         $this->data['password'] = $this->request->post['password'];
     } else {
         $this->data['password'] = '';
     }
     if (isset($this->request->get['route'])) {
         $route = $this->request->get['route'];
         unset($this->request->get['route']);
         if (isset($this->request->cookie['token'])) {
             unset($this->request->cookie['token']);
         }
         $url = '';
         if ($this->request->get) {
             $url .= http_build_query($this->request->get);
         }
         $this->data['redirect'] = $this->url->link($route, $url, 'SSL');
     } else {
         $this->data['redirect'] = '';
     }
     $this->data['forgotten'] = $this->url->link('common/forgotten', '', 'SSL');
     $this->template = 'template/login.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
示例#8
0
 public function set($currency)
 {
     $this->code = $currency;
     wcore_utils::set_cookie('currency', $currency, 365);
 }
示例#9
0
 /**
  * 清空会话,那就意味着退出系统
  *
  */
 public static function empty_session()
 {
     wcore_utils::set_cookie('uid', null, 0);
     wcore_utils::set_cookie('uname', null, 0);
     wcore_utils::set_cookie('unick', null, 0);
     wcore_utils::set_cookie('ticket', null, 0);
     wcore_utils::set_cookie('logined', null, 0);
 }
示例#10
0
文件: utils.php 项目: laiello/hecart
 /**
  * 获取域名若未指定URL地址则获取HTTP REFERER的域名
  *
  * @param string $url 域名或URL地址
  * @return string 返回域名
  */
 public static function get_http_domain($url = '')
 {
     $url = $url ? $url : wcore_utils::get_http_referer();
     if (empty($url)) {
         return '';
     }
     $res = wcore_utils::parse_href($url);
     return $res['host'];
 }