function &select($sql) { if ($this->_rw_lnk) { $db_lnk =& $this->_rw_lnk; } else { if ($this->_ro_lnk) { $db_lnk =& $this->_ro_lnk; } else { $db_lnk =& $this->_ro_conn(); } } if (cachemgr::check_current_co_depth() > 0 && preg_match('/FROM\\s+([]0-9a-z_:"`.@[-]*)/is', $sql, $matchs)) { if (isset($matchs[1])) { $table = strtoupper(trim(str_replace(array('`', '"', '\''), array('', '', ''), $matchs[1]))); if (!cachemgr::check_current_co_objects_exists('DB', $table)) { cachemgr::check_expries('DB', $table); } } } $rs = $this->exec($sql, false, $db_lnk); $data = array(); while ($row = mysql_fetch_assoc($rs['rs'])) { $data[] = $row; } mysql_free_result($rs['rs']); return $data; }
function show($gid, &$aGoods = null) { $render = $this->app->render(); if (!$aGoods) { $o = kernel::single('b2c_goods_model'); $aGoods = $o->getGoods($gid); } if (!$aGoods['images']) { $render->pagedata['noimage'] = 'true'; $imageDefault = app::get('image')->getConf('image.set'); $aGoods['images'][]['image_id'] = $imageDefault['M']['default_image']; $aGoods['goods']['image_default_id'] = $imageDefault['M']['default_image']; } else { $oImage = app::get('image')->model('image'); $imageDefault = app::get('image')->getConf('image.set'); foreach ($aGoods['images'] as $k => $v) { //todo 暂时cache 处理,以后优化的时候在storager中判断 //判断是否对应的图片是否存在,不存在则用默认图片显示 if (!cachemgr::get('goods_image' . intval($v['image_id']), $image_id)) { cachemgr::co_start(); $image_id = $oImage->getList("image_id", array('image_id' => $v['image_id'])); cachemgr::set('goods_image' . intval($v['image_id']), $image_id, cachemgr::co_end()); } if (!$image_id) { if ($aGoods['image_default_id'] == $v['image_id']) { $aGoods['image_default_id'] = $imageDefault['M']['default_image']; } $aGoods['images'][$k]['image_id'] = $imageDefault['M']['default_image']; } } } $render->pagedata['goods'] = $aGoods; return $render->fetch('site/product/goodspic.html'); }
public function display_admin_widget($tpl, $fetch = false, $widgets_app) { $this->_vars = $this->pagedata; $tmpl_file = realpath($tpl); $cur_theme = kernel::single('site_theme_base')->get_default(); if ($tmpl_file || ECAE_MODE) { $last_modified = filemtime($tmpl_file); $compile_id = $this->compile_id($cur_theme . $tpl); if ($this->force_compile || !cachemgr::get($compile_id . $last_modified, $compile_code)) { $file_content = kernel::single('site_theme_tmpl_file')->get_widgets_content($cur_theme, $tpl, $widgets_app); $compile_code = $this->_compiler()->compile($file_content); if ($compile_code !== false) { base_kvstore::instance('cache/theme_admin_widget')->store($compile_id, $compile_code); } } ob_start(); eval('?>' . $compile_code); $content = ob_get_contents(); ob_end_clean(); $this->pre_display($content); } else { $obj = kernel::single('base_render'); $obj->pagedata['tpl'] = $tpl; $content = $obj->fetch('admin/theme/widgets_tpl_lost.html', 'site'); //todo: 无模板提示 } if ($fetch === true) { return $content; } else { echo $content; } }
public function display_admin_widget($tpl, $fetch = false, $widgets_app) { $this->_vars = $this->pagedata; $tmpl_file = realpath($tpl); $cur_theme = kernel::single('wap_theme_base')->get_default(); if ($tmpl_file || ECAE_MODE) { $last_modified = filemtime($tmpl_file); $compile_id = $this->compile_id($cur_theme . $tpl); if ($this->force_compile || !cachemgr::get($compile_id . $last_modified, $compile_code)) { $file_content = kernel::single('wap_theme_file')->get_widgets_content($cur_theme, $tpl, $widgets_app); $compile_code = $this->_compiler()->compile($file_content); if ($compile_code !== false) { base_kvstore::instance('cache/theme_admin_widget')->store($compile_id, $compile_code); } } ob_start(); eval('?>' . $compile_code); $content = ob_get_contents(); ob_end_clean(); $this->pre_display($content); } else { $obj = kernel::single('base_render'); $content = "<p class='notice' style='margin:0.3em'>{$tpl}<strong><{t app='wap'}>模板不存在,请重新编辑<{/t}></strong></p>"; } if ($fetch === true) { return $content; } else { echo $content; } }
function result() { $oSearch =& $this->app->model('search'); $emu_static = $this->app->getConf('system.seo.emuStatic'); $cat_id = $_POST['cat_id']; unset($_POST['cat_id']); foreach ($_POST as $k => $v) { if ($k == "name" && $_POST[$k][0]) { $_POST[$k][0] = str_replace('_', '%xia%', $_POST[$k][0]); } if ($k == "price" && $_POST[$k][1]) { $_POST[$k][0] = floatval($_POST[$k][0]); $_POST[$k][1] = floatval($_POST[$k][1]); } } if (isset($_POST['filter']) && ($filter = $oSearch->decode($_POST['filter'], $path))) { $filter = array_merge($filter, $_POST); } else { $filter = $_POST; } unset($_POST['filter']); $filter = $oSearch->encode($filter); if (empty($cat_id) && empty($filter)) { $args = null; } else { $args = array($cat_id, $filter); } cachemgr::clean($msg); $this->sredirect(array('app' => 'b2c', 'ctl' => 'site_gallery', 'act' => 'index', 'args' => $args)); }
/** * ShopEx licence * * @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn) * @license http://ecos.shopex.cn/ ShopEx License */ function theme_widget_articles(&$setting, &$smarty) { $setting['order'] or $setting['order'] = 'desc'; $setting['order_type'] or $setting['order_type'] = 'pubtime'; $func = array('asc' => 'ksort', 'desc' => 'krsort'); $mdl_memberLv = app::get('b2c')->model('member_lv'); $default_member_lv = $mdl_memberLv->dump(array('default_lv' => '1'), 'member_lv_id'); $member_level = $default_member_lv['member_lv_id']; //默认等级 $obj_members = app::get('b2c')->model('members'); $memberTmp = $obj_members->get_current_member(); $member_type = '1'; if (isset($memberTmp['member_lv'])) { $member_level = $memberTmp['member_lv']; $member_type = $memberTmp['member_type']; } //$member_type = '2'; $oAN = kernel::single("content_article_node"); $oMAI = app::get('content')->model('article_indexs'); $objrequest = kernel::single("base_component_request"); $article_id = $objrequest->get_param(0); if (isset($setting['upto_articleid']) && $setting['upto_articleid'] == "1" && $article_id > 0) { //获取父节点id $nodeinfo = $oMAI->getList("node_id", array("article_id" => $article_id)); $iNodeId = $nodeinfo[0]['node_id']; } if (!$iNodeId) { $iNodeId = $setting['node_id']; } $lv = $setting['lv']; $limit = $setting['limit']; $tmp = $oAN->get_node($iNodeId, false, $member_type); article_foost($lv, $iNodeId, $limit, $setting['showallart'], $oAN, $oMAI, $tmp['child'], $setting, $member_type); //error_log(var_export($tmp,true),3,DATA_DIR.'/pansen.dd.txt'); $html = array(); article_showst($smarty, $tmp['child'], $setting, $html, 0, $limit); if (!$setting['shownode']) { $func[$setting['order']]($html); } $html = implode(' ', $html); $filter = array(); $filter['ifpub'] = 'true'; $filter['pubtime|than'] = time(); $arr = $oMAI->getList('pubtime', $filter, 0, 1, ' pubtime ASC'); if ($arr) { //设置缓存过期时间 reset($arr); $arr = current($arr); cachemgr::set_expiration($arr['pubtime']); } $tmp['__html'] = $html; $tmp['__shownode'] = $setting['shownode']; $tmp['__stripparenturl'] = $setting['stripparenturl']; if ($tmp['homepage'] == 'true') { $tmp['node_url'] = app::get('site')->router()->gen_url(array('app' => 'content', 'ctl' => 'site_article', 'act' => 'nodeindex', 'arg0' => $setting['node_id'])); } else { $tmp['node_url'] = app::get('site')->router()->gen_url(array('app' => 'content', 'ctl' => 'site_article', 'act' => 'lists', 'arg0' => $setting['node_id'])); } return $tmp; }
function cachedir() { $system =& $GLOBALS['system']; $this->db =& $system->database(); $this->totalBytes = 15 << 20; $row = $this->db->selectrow('select sum(cache_size) as size from sdb_cachedir'); if (false === $row) { $this->db->exec('drop table if exists sdb_cachedir', 1, 1); $sql = <<<EOF create table sdb_cachedir ( cache_file varchar(32) not null, cache_size mediumint unsigned not null, last_update int unsigned not null, primary key (cache_file) )type = MyISAM EOF; $this->db->exec($sql, 1, 1); } else { $this->curBytes = $row['size']; if ($row['size'] > $this->totalBytes) { $this->_free(10, $row['size'] - $this->totalBytes); } } parent::cachemgr(); }
function _get_goods($gid) { $render = $this->app->render(); $objGoods = $this->app->model('goods'); $aGoods_list = $objGoods->getList("goods_id,name,bn,brief,brand_id,type_id,unit,params,p_1,p_2,p_3,p_4,p_5,p_6,p_7,p_8,p_9,p_10,p_11,p_12,p_13,p_14,p_15,p_16,p_17,p_18,p_19,p_20,p_21,p_22,p_23,p_24,p_25,p_26,p_27,p_28,p_29,p_30,p_31,p_32,p_33,p_34,p_35,p_36,p_37,p_38,p_39,p_40,p_41,p_42,p_43,p_44,p_45,p_46,p_47,p_48,p_49,p_50", array('goods_id' => $gid)); $aGoods['name'] = $aGoods_list[0]['name']; $aGoods['bn'] = $aGoods_list[0]['bn']; $aGoods['brief'] = $aGoods_list[0]['brief']; $aGoods['params'] = $aGoods_list[0]['params']; $goods_type = app::get("b2c")->model("goods_type"); cachemgr::co_start(); if (!cachemgr::get("goods_type_props_value_list2dump" . $aGoods_list[0]['type_id'], $goods_type_data)) { $goods_type_data = $goods_type->dump($aGoods_list[0]['type_id']); cachemgr::set("goods_type_props_value_list2dump" . $aGoods_list[0]['type_id'], $goods_type_data, cachemgr::co_end()); } $aGoods['type'] = $goods_type_data; $brand_row = $goods_type->db->selectrow("select brand_id,brand_name from sdb_b2c_brand where brand_id=" . intval($aGoods_list[0]['brand_id'])); $aGoods['brand'] = $brand_row; foreach ($aGoods_list[0] as $aGoods_k => $aGoods_v) { if (strpos($aGoods_k, "p_") === 0) { $aGoods['props'][$aGoods_k]['value'] = $aGoods_v; } } return $aGoods; }
protected function check_vary_list() { if (!isset($this->_vary_list)) { $this->_vary_list = cachemgr::fetch_vary_list(); if (empty($this->_vary_list)) { $this->_vary_list = cachemgr::fetch_vary_list(true); } } }
public function clean() { $this->pagedata['clean'] = 'current'; $this->index(); if (cachemgr::clean($msg)) { echo '<p class="notice">' . ($msg ? $msg : '清空缓存完成') . '</p>'; } else { echo '<p class="notice">' . ($msg ? $msg : '清空缓存失败') . '</p>'; } }
public function getCacheInfo() { if (!defined("CACHE_STORAGE")) { return false; } $aTmp = explode("_", CACHE_STORAGE); $msg = false; cachemgr::status($msg); $aResult = array("name" => $aTmp[count($aTmp) - 1], "status" => $msg); return $aResult; }
function __construct() { if (!kernel::is_online()) { die('error'); } else { require ROOT_DIR . '/config/config.php'; @(include APP_DIR . '/base/defined.php'); } cachemgr::init(); cacheobject::init(); }
function __construct() { if (!kernel::is_online()) { die('error'); } else { @(include APP_DIR . '/base/defined.php'); } cachemgr::init(); cacheobject::init(); self::$is_start = true; }
function memcached() { if (!class_exists('Memcache')) { trigger_error('Missing php_memcache module', E_USER_ERROR); } $this->obj = new Memcache(); if (!$this->obj->connect(MEMCACHED_HOST, MEMCACHED_PORT)) { trigger_error('Can\'t connect memcached server', E_USER_ERROR); } parent::cachemgr(); }
function display($tmpl_file, $app_id = null, $fetch = false, $is_theme = false) { array_unshift($this->_files, $tmpl_file); $this->_vars = $this->pagedata; if ($p = strpos($tmpl_file, ':')) { $object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p)); if ($object) { $tmpl_file_path = substr($tmpl_file, $p + 1); $last_modified = $object->last_modified($tmpl_file_path); } } else { if (defined('CUSTOM_CORE_DIR') && file_exists(CUSTOM_CORE_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file)) { $tmpl_file = CUSTOM_CORE_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file; } else { if (!$is_theme) { $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file); } else { $tmpl_file = realpath(THEME_DIR . '/' . $tmpl_file); } } $last_modified = filemtime($tmpl_file); } if (!$last_modified) { //无文件 } $this->tmpl_cachekey('__temp_lang', kernel::get_lang()); //设置模版所属语言包 $this->tmpl_cachekey('__temp_app_id', $app_id ? $app_id : $this->app->app_id); $compile_id = $this->compile_id($tmpl_file); #if($this->force_compile || base_kvstore::instance('cache/template')->fetch($compile_id, $compile_code, $last_modified) === false){ if ($this->force_compile || !cachemgr::get($compile_id . $last_modified, $compile_code)) { if ($object) { $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path)); } else { $compile_code = $this->_compiler()->compile_file($tmpl_file); } if ($compile_code !== false) { #base_kvstore::instance('cache/template')->store($compile_id,$compile_code); cachemgr::co_start(); cachemgr::set($compile_id . $last_modified, $compile_code, cachemgr::co_end()); } } ob_start(); eval('?>' . $compile_code); $content = ob_get_contents(); ob_end_clean(); array_shift($this->_files); $this->pre_display($content); if ($fetch === true) { return $content; } else { echo $content; } }
function __construct() { if (!kernel::is_online()) { die('error'); } else { @(include APP_DIR . '/base/defined.php'); } cachemgr::init(); cacheobject::init(); self::$is_start = true; //@file_put_contents(ROOT_DIR.'/api_post_log.txt', json_encode($_POST)); }
public function getListAll() { if (!cachemgr::get('member_lv_info_all', $data)) { cachemgr::co_start(); $memberLvData = $this->getList('*'); foreach ($memberLvData as $row) { $data[$row['member_lv_id']] = $row; } cachemgr::set('member_lv_info_all', $data, cachemgr::co_end()); } return $data; }
function post_update($params) { $dbver = $params['dbver']; if (version_compare($dbver, '1.0.6', '<')) { //更新widgets css最后更新时间 site_widgets::set_last_modify(); //重新创建module sitemap kernel::single('site_module_base')->create_site_config(); //缓存全部更新, 改造了缓存机制 cachemgr::clean($msg); } }
public function display($tmpl_file, $app_id = null, $fetch = false, $is_theme = false) { array_unshift($this->_files, $tmpl_file); $this->_vars = $this->pagedata; if ($p = strpos($tmpl_file, ':')) { $object = vmc::service('tpl_source.' . substr($tmpl_file, 0, $p)); if ($object) { $tmpl_file_path = substr($tmpl_file, $p + 1); $last_modified = $object->last_modified($tmpl_file_path); } } else { if (defined('EXTENDS_DIR') && file_exists(EXTENDS_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file)) { $tmpl_file = EXTENDS_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file; } else { if (!$is_theme) { $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file); } else { $tmpl_file = realpath(THEME_DIR . '/' . $tmpl_file); } } $last_modified = filemtime($tmpl_file); } if (!$last_modified) { trigger_error('未知VIEW', E_USER_ERROR); } $this->tmpl_cachekey('__temp_lang', vmc::get_lang()); //设置模版所属语言包 $this->tmpl_cachekey('__temp_app_id', $app_id ? $app_id : $this->app->app_id); $compile_id = $this->compile_id($tmpl_file); if ($this->force_compile || !cachemgr::get($compile_id . $last_modified, $compile_code)) { if ($object) { $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path)); } else { $compile_code = $this->_compiler()->compile_file($tmpl_file); } if ($compile_code !== false) { cachemgr::co_start(); cachemgr::set($compile_id . $last_modified, $compile_code, cachemgr::co_end()); } } ob_start(); eval('?>' . $compile_code); $content = ob_get_contents(); ob_end_clean(); array_shift($this->_files); $this->pre_display($content); if ($fetch === true) { return $content; } else { echo $content; } }
function cache_memcache() { if (!class_exists('Memcache')) { trigger_error('Missing php_memcache module', E_USER_ERROR); } $this->obj = new Memcache(); $ports = explode(',', MEMCACHED_PORT); foreach (explode(',', MEMCACHED_HOST) as $i => $h) { if (!$this->obj->addServer($h, $ports[0])) { trigger_error('Can\'t connect memcached server', E_USER_ERROR); } } $this->obj->pconnect(); parent::cachemgr(); }
public function init() { cachemgr::init(false); set_error_handler(array(&$this, '_errorHandler')); $demo_dir = ROOT_DIR . '/demodata'; if (is_dir($demo_dir)) { $handle = opendir($demo_dir); while ($file = readdir($handle)) { $realfile = $demo_dir . '/' . $file; $data_arr = array(); $data = null; if (is_file($realfile)) { list($app_id, $model, $ext) = explode('.', $file); switch ($ext) { case 'sdf': $this->init_sdf($app_id, $model, $realfile); break; case 'php': $setting = (include $realfile); $this->init_setting($app_id, $setting); case 'json': $json_str = file_get_contents($realfile); $json_str = $this->json_fix($json_str); $data = json_decode($json_str, true); $data && ($data_arr = $data['data']); if (count($data_arr) > 0) { $this->init_json($app_id, $model, $data_arr); } else { if ($json_str) { echo "---{$realfile}---JSON STR BEGIN------\n\n"; echo $json_str; echo "---{$realfile}---JSON STR END------\n\n"; logger::info($realfile . ' JSON_DECODE ERROR'); } else { logger::info($realfile . ' NO DATA'); } } break; default: # code... break; } } } restore_error_handler(); closedir($handle); } }
public function set_page_data($gid, $object) { $enable = app::get('site')->model('modules')->getList('enable', array('app' => 'groupactivity')); foreach ($enable as $v) { $able = $v['enable']; } $object->pagedata['enable'] = $able; $object->pagedata['purchase'] = $arr = kernel::single("groupactivity_purchase")->_get_dump_data($gid); if ($arr) { if ($arr['act_open'] == 'false' || $arr['max_buy'] <= $arr['buy'] && $arr['max_buy'] != 0) { $object->pagedata['purchase'] = null; } $object->pagedata['group_url'] = app::get('site')->router()->gen_url(array('app' => 'groupactivity', 'ctl' => 'site_cart', 'act' => 'index', 'arg0' => $arr['act_id'])); cachemgr::set_expiration($arr['end_time']); } #$this->_response->set_header('Cache-Control', 'no-store'); }
function index() { $get = $this->_request->get_params(); $pid = intval($get[0]); #活动类型 $stype_id = $get[1]; $this->pagedata['imageDefault'] = app::get('image')->getConf('image.set'); $GLOBALS['runtime']['path'] = $this->runtime_path($stype_id, $pid); $special_goods = $this->mdl_special_goods->getRow('*', array('product_id' => $pid)); $goodsdata = $this->special_pro->getdetailParams($special_goods); //没有默认货品图片则显示商品所有图片,否则显示关联货品图片 if (empty($goodsdata['images'])) { $goodsImages = $this->_get_goods_image($goodsdata['goods']['goods_id']); $productBasic['images'] = $goodsImages; //商品图片 $productBasic['image_default_id'] = $goodsdata['goods']['image_default_id']; //商品图片 } else { $productBasic['images'] = $goodsdata['images']; $productBasic['image_default_id'] = $goodsdata['images'][0]['image_id']; //商品图片 } $this->pagedata['page_product_basic'] = $productBasic; $this->pagedata['goodsdata'] = $goodsdata; $this->pagedata['stypeid'] = $stype_id; $this->pagedata['member_id'] = $this->userObject->get_member_id() ? $this->userObject->get_member_id() : 0; $this->pagedata['nowtime'] = time(); //社会化分享 $goodsshare = kernel::single('b2c_goods_share')->get_share($productBasic); $this->pagedata['goods_share'] = $goodsshare; //是否开启商品推荐 $setting['recommend'] = app::get('b2c')->getConf('goods.recommend'); $this->pagedata['setting'] = $setting; //已发布未开始页面缓存 if ($this->pagedata['nowtime'] >= $goodsdata['release_time'] && $this->pagedata['nowtime'] < $goodsdata['begin_time']) { //活动开始的时候缓存过期 cachemgr::set_expiration($goodsdata['begin_time']); } elseif ($this->pagedata['nowtime'] >= $goodsdata['begin_time'] && $this->pagedata['nowtime'] < $goodsdata['end_time']) { //活动结束的时候缓存过期 cachemgr::set_expiration($goodsdata['end_time']); } $this->page('site/product/index.html'); }
function show($gid, &$aGoods = null, $siteMember = null) { $render = $this->app->render(); if (!$aGoods) { $o = kernel::single('b2c_goods_model'); $aGoods = $o->getGoods($gid); } if ($aGoods['product']) { if (empty($siteMember)) { $siteMember = $this->app->model("members")->get_current_member(); } $priceArea = array(); if ($siteMember['member_lv']) { $mlv = $siteMember['member_lv']; } else { $level =& $this->app->model('member_lv'); $mlv = $level->get_default_lv(); } if ($mlv) { $aConfig = kernel::single('b2c_cart_prefilter_promotion_goods')->_init_rule_public(array($gid), array('member_lv' => 'false')); foreach ($aGoods['product'] as $gpk => &$gpv) { $promotion_price = kernel::single('b2c_goods_promotion_price')->process($gpv, $aConfig); $gpv['price']['price']['current_price'] = empty($promotion_price['price']) ? $gpv['price']['price']['current_price'] : $promotion_price['price']; $gpv['price']['price']['price'] = empty($promotion_price['price']) ? $gpv['price']['price']['price'] : $promotion_price['price']; if (is_array($gpv['price']['member_lv_price'])) { foreach ($gpv['price']['member_lv_price'] as $mk => &$mv) { $mv['price'] = empty($promotion_price['price']) ? $mv['price'] : $promotion_price['price']; } } } } } $oMlv = $this->app->model('member_lv'); if (!cachemgr::get('member_evel_list', $mLevelList)) { cachemgr::co_start(); $mLevelList = $oMlv->getList('*', '', 0, -1); cachemgr::set('member_evel_list', $mLevelList, cachemgr::co_end()); } $render->pagedata['mLevel'] = $mLevelList; $render->pagedata['goods'] = $aGoods; return $render->fetch('site/product/mlv_price.html'); }
public function install() { $dbschema = $this->getPathname(); if (is_file($dbschema)) { require $dbschema; foreach ($db as $key => $val) { if ($val['ignore_cache'] !== true) { $data['type'] = 'DB'; $data['app'] = $this->target_app->app_id; $data['name'] = strtoupper($this->target_app->app_id . "_" . $key); $data['expire'] = time(); logger::info('Installing Cache_Expires DB:' . $data['name']); app::get('base')->model('cache_expires')->replace($data, array('type' => $data['type'], 'app' => $data['app'], 'name' => $data['name'])); } break; } logger::info('UPDATE CACHE EXPIRES KV DATA'); cachemgr::store_vary_list(cachemgr::fetch_vary_list(true)); //更新kv } }
/** * 商品列表. */ public function gallery($params = array()) { $default_params = array('page_size' => 20, 'page_index' => 1, 'orderby' => ''); if (!is_array($params)) { $params = array(); } $params = array_merge($default_params, $params, $this->req_params); if ($params['orderby']) { $params['orderby'] = str_replace('-', ' ', $params['orderby']); } $cache_key = utils::array_md5($params); //优先从缓存读取 if (cachemgr::get($cache_key, $gallery_data)) { $this->success($gallery_data); } cachemgr::co_start(); $filter = $params['filter']; if (!is_array($filter)) { $filter = array(); } $filter['marketable'] = 'true'; $obj_goods_stage = vmc::singleton('b2c_goods_stage'); //set_member if ($this->app->member_id = vmc::singleton('b2c_user_object')->get_member_id()) { $obj_goods_stage->set_member($this->app->member_id); } $mdl_goods = app::get('b2c')->model('goods'); $goods_cols = 'goods_id,gid,name,type_id,cat_id,brand_id,nostore_sell,brief,image_default_id,goods_setting'; $goods_list = $mdl_goods->getList($goods_cols, $filter, $params['page_size'] * ($params['page_index'] - 1), $params['page_size'], $params['orderby']); if (!$goods_list) { $this->failure(); } $total = $mdl_goods->count($filter); $obj_goods_stage->gallery($goods_list); //引用传递 $page_total = $total ? ceil($total / $the_params['page_size']) : 1; $gallery_data = array('page_total' => $page_total > 0 ? $page_total : 1, 'goods_list' => array_values($goods_list)); cachemgr::set($cache_key, $gallery_data, cachemgr::co_end()); $this->success($gallery_data); }
/** * ShopEx licence * * @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn) * @license http://ecos.shopex.cn/ ShopEx License */ function theme_widget_index_news(&$setting,&$smarty){ $setting['order'] or $setting['order'] = 'desc'; $setting['order_type'] or $setting['order_type'] = 'pubtime'; $func = array('asc'=>'ksort','desc'=>'krsort'); $oAN = kernel::single("content_article_node"); $oMAI = app::get('content')->model('article_indexs'); $iNodeId = $setting['node_id']; $lv = $setting['lv']; $limit = $setting['limit']; $tmp = $oAN->get_node($iNodeId, true); article_new_foo($lv, $iNodeId, $limit, $setting['showallart'], $oAN, $oMAI, $tmp['child'], $setting); $html = array(); article_new_show($smarty, $tmp['child'], $setting, $html, 0, $limit); if( !$setting['shownode'] ) { $func[$setting['order']]($html); } $html = implode(' ',$html); $filter = array(); $filter['ifpub'] = 'true'; $filter['pubtime|than'] = time(); $arr = $oMAI->getList( 'pubtime',$filter,0,1,' pubtime ASC' ); if( $arr ) { //设置缓存过期时间 reset( $arr ); $arr = current($arr); cachemgr::set_expiration($arr['pubtime']); } $tmp['__html'] = $html; $tmp['__shownode'] = $setting['shownode']; $tmp['__stripparenturl'] = $setting['stripparenturl']; if( $tmp['homepage']=='true' ) $tmp['node_url'] = app::get('site')->router()->gen_url( array('app'=>'content', 'ctl'=>'site_article', 'act'=>'i', 'arg0'=>$setting['node_id']) ); else $tmp['node_url'] = app::get('site')->router()->gen_url( array('app'=>'content', 'ctl'=>'site_article', 'act'=>'l', 'arg0'=>$setting['node_id']) ); return $tmp; }
private function _list($filter, $page, $orderby) { $cache_key = utils::array_md5(func_get_args()); if (cachemgr::get($cache_key, $return)) { return $return; } cachemgr::co_start(); $goods_cols = '*'; $mdl_goods = $this->app->model('goods'); $goods_list = $mdl_goods->getList($goods_cols, $filter, $page['size'] * ($page['index'] - 1), $page['size'], $orderby); $obj_goods_stage = vmc::singleton('b2c_goods_stage'); //set_member if ($this->app->member_id = vmc::singleton('b2c_user_object')->get_member_id()) { $obj_goods_stage->set_member($this->app->member_id); } $obj_goods_stage->gallery($goods_list); //引用传递 $total = $mdl_goods->count($filter); $return = array('data' => $goods_list, 'count' => count($goods_list), 'all_count' => $total, 'page_info' => array('total' => $total ? ceil($total / $page['size']) : 1, 'current' => intval($page['index']))); cachemgr::set($cache_key, $return, cachemgr::co_end()); return $return; }
/** * 展示特定类型的文章列表 * @access public */ public function lists() { $this->begin($this->gen_url(array('app' => 'welcome', 'ctl' => 'index'))); $info_list_id = $this->_request->get_param(0); if (empty($info_list_id)) { $this->end(false, app::get('cps')->_('访问出错')); } $filter = array('i_type' => $info_list_id); //每页条数 $pageLimit = $this->app->getConf('gallery.display.listnum'); $pageLimit = $pageLimit ? $pageLimit : 10; //当前页 $page = (int) $this->_request->get_param(1); $page or $page = 1; $filter['ifpub'] = 'true'; $filter['pubtime|sthan'] = time(); $infoObj = $this->app->model('info'); //总数 $count = $infoObj->count($filter); $arr_infos = $infoObj->getInfoList('*', $filter, $pageLimit * ($page - 1), $pageLimit, 'pubtime DESC'); //标识用于生成url $token = md5("page{$page}"); $this->pagedata['pager'] = array('current' => $page, 'total' => ceil($count / $pageLimit), 'link' => $this->gen_url(array('app' => 'cps', 'ctl' => 'site_info', 'act' => 'lists', 'arg0' => $info_list_id, 'arg2' => $token)), 'token' => $token); $filter = array(); $filter['ifpub'] = 'true'; $filter['pubtime|than'] = time(); $arr = $infoObj->getInfoList('pubtime', $filter, 0, 1, ' pubtime ASC'); if ($arr) { //设置缓存过期时间 reset($arr); $arr = current($arr); cachemgr::set_expiration($arr['pubtime']); } $this->pagedata['info_type'] = $info_list_id; $this->pagedata['infos'] = $arr_infos; $this->set_tmpl('cps_common'); $this->page('site/notice/list.html'); }
public function run() { ignore_user_abort(false); ob_implicit_flush(1); ini_set('implicit_flush', true); cachemgr::init(false); if (strpos(strtolower(PHP_OS), 'win') === 0) { if (function_exists('mb_internal_encoding')) { mb_internal_encoding('UTF-8'); mb_http_output('GBK'); ob_start('mb_output_handler', 2); } elseif (function_exists('iconv_set_encoding')) { iconv_set_encoding('internal_encoding', 'UTF-8'); iconv_set_encoding('output_encoding', 'GBK'); ob_start('ob_iconv_handler', 2); } } if (isset($_SERVER['argv'][1])) { $args = array_shift($_SERVER['argv']); $rst = $this->exec_command(implode(' ', $_SERVER['argv'])); if ($rst === false) { exit(-1); } } else { $this->interactive(); } }