function _get_goods_history($id, $num = 9) { $goods_list = array(); $goods_ids = ecm_getcookie('goodsBrowseHistory'); $goods_ids = $goods_ids ? explode(',', $goods_ids) : array(); if ($goods_ids) { $rows = $this->_goods_mod->find(array('conditions' => $goods_ids, 'fields' => 'goods_name,default_image')); foreach ($goods_ids as $goods_id) { if (isset($rows[$goods_id])) { empty($rows[$goods_id]['default_image']) && ($rows[$goods_id]['default_image'] = Conf::get('default_goods_image')); $goods_list[] = $rows[$goods_id]; } } } $goods_ids[] = $id; if (count($goods_ids) > $num) { unset($goods_ids[0]); } ecm_setcookie('goodsBrowseHistory', join(',', array_unique($goods_ids))); return $goods_list; }
/** * 从文件或数组中定义常量 * * @author Garbin * @param mixed $source * @return void */ function ecm_define($source) { if (is_string($source)) { /* 导入数组 */ $source = (include $source); } if (!is_array($source)) { /* 不是数组,无法定义 */ return false; } foreach ($source as $key => $value) { if (is_string($value) || is_numeric($value) || is_bool($value) || is_null($value)) { /* 如果是可被定义的,则定义 */ if (strtoupper($key) != 'LANG') { define(strtoupper($key), $value); } } } //LLL 现在设置语言 if (isset($_COOKIE['my_language'])) { $my_language = strtolower(trim($_COOKIE['my_language'])); define('LANG', $my_language); } else { define('LANG', $source['LANG']); ecm_setcookie('my_language', $source['LANG']); } }
function _set_goods_history($id, $num = 5) { $goods_ids = ecm_getcookie('goodsBrowseHistory'); $goods_ids = $goods_ids ? explode(',', $goods_ids) : array(); $goods_ids[] = $id; if (count($goods_ids) > $num) { unset($goods_ids[0]); } ecm_setcookie('goodsBrowseHistory', join(',', array_unique($goods_ids))); return true; }
/** * 登出 * * @author Garbin * @return void */ function logout() { unset($_SESSION[$this->_info_key]); unset($_SESSION['openid']); ecm_setcookie("MALL[mall_uname]", "", -1); }
function _get_history() { $goods_list = array(); $goods_ids = ecm_getcookie('goodsBrowseHistory'); $goods_ids = $goods_ids ? explode(',', $goods_ids) : array(); $goods =& m('goods'); if ($goods_ids) { $rows = $goods->find(array('conditions' => $goods_ids, 'fields' => 'goods_name,default_image,price', 'limit' => 5)); foreach ($goods_ids as $goods_id) { if (isset($rows[$goods_id])) { empty($rows[$goods_id]['default_image']) && ($rows[$goods_id]['default_image'] = Conf::get('default_goods_image')); $goods_list[] = $rows[$goods_id]; } } } ecm_setcookie('goodsBrowseHistory', join(',', array_unique($goods_ids))); return $goods_list; }