public function run() { global $_FANWE; $root = array(); $root['return'] = 0; FanweService::instance()->cache->loadCache(array('mindex', 'madv')); $advs = $_FANWE['cache']['madv']['index']; if ($advs) { foreach ($advs as $adv) { $adv['img'] = FS("Image")->getImageUrl($adv['img'], 2); if ($adv['type'] == 1) { $tag_count = count($adv['data']['tags']); unset($adv['data']); $adv['data']['count'] = $tag_count; } elseif ($adv['type'] != 2 && $adv['type'] != 8) { unset($adv['data']); } unset($adv['sort'], $adv['status'], $adv['page']); $root['advs'][] = $adv; } } foreach ($_FANWE['cache']['mindex'] as $index) { $index['img'] = FS("Image")->getImageUrl($index['img'], 2); if ($index['type'] == 1) { $tag_count = count($index['data']['tags']); unset($index['data']); $index['data']['count'] = $tag_count; } elseif ($index['type'] != 2 && $index['type'] != 8) { unset($index['data']); } unset($index['sort'], $index['status']); $root['indexs'][] = $index; } m_display($root); }
function bindCacheGoodscate() { $categorys = array(); $res = FDB::query("SELECT * FROM " . FDB::table('goods_category') . " WHERE status = 1 ORDER BY sort ASC"); while ($data = FDB::fetch($res)) { $tags = array(); $tres = FDB::query('SELECT gt.* FROM ' . FDB::table('goods_category_tags') . ' AS gct INNER JOIN ' . FDB::table('goods_tags') . ' AS gt ON gt.tag_id = gct.tag_id WHERE gct.cate_id = ' . $data['cate_id'] . ' ORDER BY gt.sort ASC,gt.tag_id ASC'); while ($tag = FDB::fetch($tres)) { $tag['url_tag'] = urlencode($tag['tag_name']); $tags[] = $tag; } FanweService::instance()->cache->saveCache('goods_category_tags_' . $data['cate_id'], $tags); $categorys['all'][$data['cate_id']] = $data; if ($data['is_root'] == 1) { $categorys['root'] = $data['cate_id']; } elseif ($data['parent_id'] == 0) { $categorys['parent'][] = $data['cate_id']; } if ($data['is_index'] == 1) { $categorys['index'][] = $data['cate_id']; } if (!empty($data['cate_code'])) { $categorys['cate_code'][$data['cate_code']] = $data['cate_id']; } } foreach ($categorys['all'] as $key => $val) { if ($val['parent_id'] > 0) { $categorys['all'][$val['parent_id']]['child'][] = $key; } } FanweService::instance()->cache->saveCache('goods_category', $categorys); }
function m_getMConfig() { global $_FANWE; //FanweService::instance()->cache->loadCache("m_config"); $m_config = $_FANWE['cache']['m_config']; if ($m_config == false) { //init_config_data();//检查初始化数据 $m_config = array(); $list = FDB::fetchAll("select code,val from " . FDB::table("m_config")); foreach ($list as $item) { $m_config[$item['code']] = $item['val']; } //新闻公告 $sql = "select code as title, title as content from " . FDB::table("m_config_list") . " where `group` = 4 and is_verify = 1 order by id desc"; $list = FDB::fetchAll($sql); $newslist = array(); foreach ($list as $item) { $newslist[] = array("title" => $item['title'], "content" => str_replace("/public/upload/images/", $_FANWE['site_url'] . "public/upload/images/", $item['content'])); } $m_config['newslist'] = $newslist; //print_r($addrtlist);exit; FanweService::instance()->cache->saveCache("m_config", $m_config); } //print_r($m_config); return $m_config; }
public function __construct($url) { global $_FANWE; FanweService::instance()->cache->loadCache('business'); $rs = preg_match("/^(http:\\/\\/|https:\\/\\/)/", $url, $match); if (intval($rs) == 0) { $url = "http://" . $url; } $rs = parse_url($url); $scheme = isset($rs['scheme']) ? $rs['scheme'] . "://" : "http://"; $host = isset($rs['host']) ? $rs['host'] : "none"; $host = explode('.', $host); $host = array_slice($host, -2, 2); $domain = implode('.', $host); $class = FDB::fetchFirst("select `class` from " . FDB::table('sharegoods_module') . " where domain like '%" . $domain . "%' and status = 1 limit 1"); $class = $class['class']; $file = FANWE_ROOT . "core/class/sharegoods/" . $class . "_sharegoods.class.php"; require_once FANWE_ROOT . "core/class/sharegoods/sharegoods.php"; require_once FANWE_ROOT . "core/class/string.class.php"; if (file_exists($file) && isset($_FANWE['cache']['business'][$class])) { require_once $file; $class_name = $class . "_sharegoods"; if (class_exists($class_name)) { $this->share_module = new $class_name(); } } $this->url = $url; }
public function photo() { global $_FANWE; if ($_FANWE['uid'] == 0) { $redir_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; fSetCookie('redir_url', $redir_url, time() + 3600); require_once fimport('dynamic/user'); include template('page/user/user_login'); } else { FanweService::instance()->cache->loadCache('albums'); $imgs = $_FANWE['request']['imgUrl']; $pageUrl = $_FANWE['request']['pageUrl']; $img_list = explode(",", $imgs); $count_img = count($img_list); $videos = $_FANWE['request']['videoUrl']; $video_list = explode(",", $videos); $count_video = count($video_list); if ($_FANWE['request']['showType'] == 1) { include template("page/collection/collection_photos"); } else { include template("page/collection/collection_photo"); } } display(); }
function bindCacheLogin() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('login_module') . " WHERE status = 1 AND app_key <> '' AND app_secret <> '' ORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $list[$data['code']] = $data; } FanweService::instance()->cache->saveCache('logins', $list); }
function bindCacheSecond() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('second') . " WHERE status = 1 ORDER BY sort ASC,sid ASC"); while ($data = FDB::fetch($res)) { $list[$data['sid']] = $data; } FanweService::instance()->cache->saveCache('seconds', $list); }
function bindCacheSetting() { global $_FANWE; $settings = array(); $js_settings = array(); $res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $name = strtolower($data['name']); $settings[$name] = $data['val']; if ($data['is_js'] == 1) { $js_settings[$name] = $data['val']; } } $settings['site_title'] .= ' - ' . 'F' . 'A' . 'N' . 'W' . 'E'; $settings['footer_html'] .= '<' . 'p' . '>' . '<' . 'a' . ' ' . 'h' . 'r' . 'e' . 'f' . '=' . '"' . 'h' . 't' . 't' . 'p' . ':' . '/' . '/' . 'w' . 'w' . 'w' . '.' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'c' . 'o' . 'm' . '"' . ' ' . 't' . 'a' . 'r' . 'g' . 'e' . 't' . '=' . '"' . '_' . 'b' . 'l' . 'a' . 'n' . 'k' . '"' . '>' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'i' . 'n' . 'c' . '<' . '/' . 'a' . '>' . '<' . '/' . 'p' . '>'; writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';'); $config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php'); $config_file = trim($config_file); $config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file); $config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file); @file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file); unset($config_file); $lang_arr = array(); $lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php'); foreach ($lang_files as $lang_file) { if (@(include $lang_file)) { foreach ($lang as $lkey => $lval) { $lang_pre = strtolower(substr($lkey, 0, 3)); if ($lang_pre == 'js_') { $lang_key = substr($lkey, 3); if ($lang_key != '') { $lang_arr[$lang_key] = $lval; } } } } } writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';'); clearDir(FANWE_ROOT . './public/data/tpl/css/'); clearDir(FANWE_ROOT . './public/data/tpl/js/'); $css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/'; $css_cache_dir = FANWE_ROOT . './public/data/tpl/css/'; $css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/'; $directory = dir($css_dir); while ($entry = $directory->read()) { if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) { $css_path = $css_dir . $entry; $css_content = @file_get_contents($css_path); $css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content); $css_cache_path = $css_cache_dir . '/' . $entry; writeFile($css_cache_path, $css_content); } } $directory->close(); FanweService::instance()->cache->saveCache('setting', $settings); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $key = 'm/sharecate'; $cache_list = getCache($key); if ($cache_list !== NULL || TIME_UTC - $cache_list['cache_time'] > 600) { $cate_list = array(); $min_time = $this->getQuarterMinTime(); $max_time = getTodayTime(); FanweService::instance()->cache->loadCache('albums'); $album_cate = $_FANWE['cache']['albums']['category']; foreach ($album_cate as $k => $v) { $cate = array(); $cate['cate_id'] = $v['id']; $cate['cate_name'] = $v['name']; $cate['short_name'] = $v['name']; $cate['cate_code'] = $v['cate_code']; $cate['cate_icon'] = FS("Image")->getImageUrl($v['img'], 2); $cate['desc'] = $v['desc']; $cate['create_time'] = $v['create_time']; //获取本季分享数量 $share_count_sql = 'select count(DISTINCT s.share_id) from ' . FDB::table("share") . ' as s INNER JOIN ' . FDB::table("album_share") . ' as al on s.share_id = al.share_id where al.cid = ' . $v['id'] . " and s.day_time >= {$min_time} AND s.day_time <= {$max_time} "; $cate['share_count'] = FDB::resultFirst($share_count_sql); $cate['img_tags'] = array(); $img_size = 320; $sql = 'select s.share_id,al.title,sp.img from ' . FDB::table("share") . ' as s INNER JOIN ' . FDB::table("album_share") . ' as als ON s.share_id = als.share_id INNER JOIN ' . FDB::table("album") . ' as al ON als.album_id = al.id INNER JOIN ' . FDB::table("share_photo") . " as sp ON s.share_id = sp.share_id \r\n\t\t\t\t\tWHERE s.day_time >= {$min_time} AND s.day_time <= {$max_time} AND als.cid = " . $v['id'] . " GROUP BY s.share_id ORDER BY s.share_id desc limit 5"; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $img_data = array(); $img_data['share_id'] = $data['share_id']; $img_data['tag_name'] = $data['title']; $img_data['is_tag'] = 0; $img_data['img'] = FS("Image")->getImageUrl(getImgName($data['img'], $img_size, $img_size, 1, true), 2); $img_data['url_tag'] = urlencode($data['title']); $cate['img_tags'][] = $img_data; $img_size = 160; } $cate['txt_tags'] = array(); $cate_list[] = $cate; } $cache_list = array(); $cache_list['cate_list'] = $cate_list; $cache_list['cache_time'] = TIME_UTC; setCache($key, $cache_list); } else { $cate_list = $cache_list['cate_list']; } $root['item'] = $cate_list; m_display($root); }
function bindCacheAsk() { $asks = array(); $res = FDB::query("SELECT a.* FROM " . FDB::table('ask') . " as a \r\n\t\t\t\tWHERE status = 1"); while ($data = FDB::fetch($res)) { $data['url'] = FU('ask/forum', array('aid' => $data['aid'])); $asks[$data['aid']] = $data; } FanweService::instance()->cache->saveCache('asks', $asks); }
function bindCacheBusiness() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('sharegoods_module') . " \r\n\t\tWHERE status = 1 ORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $api_data = unserialize($data['api_data']); unset($data['api_data']); $data = array_merge($data, $api_data); $list[$data['class']] = $data; } FanweService::instance()->cache->saveCache('business', $list); }
public function getConfig($type) { static $configs = NULL; if ($configs === NULL) { global $_FANWE; if (!isset($_FANWE['cache']['logins'])) { FanweService::instance()->cache->loadCache('logins'); } $configs = $_FANWE['cache']['logins']; } return $configs[$type]; }
function bindCacheUsercate() { $categorys = array(); $res = FDB::query("SELECT * FROM " . FDB::table('user_category') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $data['tags'] = FDB::fetchAll('SELECT ut.* FROM ' . FDB::table('user_category_tags') . ' AS uct INNER JOIN ' . FDB::table('user_tags') . ' AS ut ON ut.tag_id = uct.tag_id WHERE uct.cate_id = ' . $data['id'] . ' ORDER BY ut.sort ASC,ut.tag_id ASC'); $categorys[$data['id']] = $data; } FanweService::instance()->cache->saveCache('usertagcate', $categorys); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $list = array(); FanweService::instance()->cache->loadCache('msearchcate'); foreach ($_FANWE['cache']['msearchcate'] as $cate) { $cate['bg'] = FS("Image")->getImageUrl($cate['bg'], 2); $list[] = $cate; } $root['item'] = $list; m_display($root); }
function bindCacheLink() { global $_FANWE; $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('friend_link') . " WHERE status = 1 ORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $list['all'][$data['id']] = $data; if (empty($data['img'])) { $list['texts'][] = $data['id']; } else { $list['imgs'][] = $data['id']; } } FanweService::instance()->cache->saveCache('links', $list); }
function bindCacheIpbanned() { FDB::query("DELETE FROM " . FDB::table('ip_banned') . " WHERE expiration<'" . TIME_UTC . "'"); $data = array(); $query = FDB::query("SELECT ip1, ip2, ip3, ip4, expiration FROM " . FDB::table('ip_banned')); if (FDB::numRows($query)) { $data['expiration'] = 0; $data['regexp'] = $separator = ''; } while ($banned = FDB::fetch($query)) { $data['expiration'] = !$data['expiration'] || $banned['expiration'] < $data['expiration'] ? $banned['expiration'] : $data['expiration']; $data['regexp'] .= $separator . ($banned['ip1'] == '-1' ? '\\d+\\.' : $banned['ip1'] . '\\.') . ($banned['ip2'] == '-1' ? '\\d+\\.' : $banned['ip2'] . '\\.') . ($banned['ip3'] == '-1' ? '\\d+\\.' : $banned['ip3'] . '\\.') . ($banned['ip4'] == '-1' ? '\\d+' : $banned['ip4']); $separator = '|'; } FanweService::instance()->cache->saveCache('ipbanned', $data); }
function bindCacheCity() { $citys = array(); $res = FDB::query("SELECT * FROM " . FDB::table('region') . " ORDER BY id ASC"); while ($data = FDB::fetch($res)) { if ($data['parent_id'] == 0) { $citys['province'][] = $data['id']; } elseif ($data['parent_id'] > 0) { $citys['city'][$data['parent_id']][] = $data['id']; } $citys['all'][$data['id']] = $data; } include_once fimport('class/json'); $json = new JSON(); writeFile(PUBLIC_ROOT . './js/city.js', 'var CITYS = ' . $json->encode($citys) . ';'); FanweService::instance()->cache->saveCache('citys', $citys); }
function bindCacheMedal() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('medal') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $data['big_img'] = './public/medal/big/' . $data['image']; $data['small_img'] = './public/medal/small/' . $data['image']; $list['all'][$data['mid']] = $data; if ($data['give_type'] == 0) { $list['auto'][] = $data['mid']; $list[$data['conditions']][] = $data['mid']; } else { $list['manual'][] = $data['mid']; } } FanweService::instance()->cache->saveCache('medals', $list); }
function bindCacheAlbum() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('album_category') . " WHERE status = 1 ORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $data['url'] = FU('album/category', array('id' => $data['id'])); $list['category'][$data['id']] = $data; } $res = FDB::query("SELECT name,val FROM " . FDB::table('sys_conf') . " WHERE group_id = 8"); while ($data = FDB::fetch($res)) { if ($data['name'] == 'ALBUM_DEFAULT_TAGS') { $data['val'] = unserialize($data['val']); } $data['name'] = strtolower($data['name']); $list['setting'][$data['name']] = $data['val']; } FanweService::instance()->cache->saveCache('albums', $list); }
function bindCacheForum() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('forum') . " AS f \r\n\t\t LEFT JOIN " . FDB::table('forum_fields') . " AS ff USING(fid) \r\n\t\t WHERE f.status = 1 ORDER BY f.sort ASC"); while ($data = FDB::fetch($res)) { $data['url'] = FU('club/forum', array('fid' => $data['fid'])); $list['all'][$data['fid']] = $data; } $list['root'] = array(); foreach ($list['all'] as $cate) { if ($cate['parent_id'] > 0) { $list['all'][$cate['parent_id']]['childs'][] = $cate['fid']; } else { $list['root'][] = $cate['fid']; } } FanweService::instance()->cache->saveCache('forums', $list); }
function bindCacheShop() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('shop_category') . " \r\n\t\tORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $data['url'] = FU('shop/index', array('cid' => $data['id'])); $list['all'][$data['id']] = $data; } $list['root'] = array(); foreach ($list['all'] as $cate) { if ($cate['parent_id'] > 0) { $list['all'][$cate['parent_id']]['childs'][] = $cate['id']; } else { $list['root'][] = $cate['id']; } } FanweService::instance()->cache->saveCache('shops', $list); }
function getCatalogArray() { global $_FANWE; $categorylist = $_FANWE['cache']['merchant_category']; if ($categorylist == false) { //init_config_data();//检查初始化数据 $categorylist = array(); //$region_lv2 = array(); $list = FDB::fetchAll("select * from " . FDB::table("merchant_category") . " where status = 1"); //print_r($list);exit foreach ($list as $item) { $categorylist[] = array("id" => $item['id'], "name" => $item['name'], "icon" => $_FANWE['site_url'] . $item['icon']); } //print_r($categorylist);exit; FanweService::instance()->cache->saveCache("merchant_category", $categorylist); } return $categorylist; }
function bindCacheImageservers() { $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('share_image_sizes') . " WHERE status = 1"); while ($data = FDB::fetch($res)) { $list[] = array($data['width'], $data['height'], $data['is_cut'], $data['is_water']); } FanweService::instance()->cache->saveCache('image_sizes', $list); $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('image_servers')); while ($data = FDB::fetch($res)) { $parse_url = parse_url($data['url']); $scheme = $parse_url['scheme']; $host = $parse_url['host']; $port = (int) $parse_url['port']; $path = $parse_url['path']; $data['host'] = $host; $data['host_port'] = $host; if ($port > 0) { $data['port'] = $port; $data['host_port'] .= ':' . $port; } else { $data['port'] = 80; } if (!empty($path)) { $paths = explode('/', $path); $path = '/'; foreach ($paths as $pval) { if (!empty($pval)) { $path .= $pval . '/'; } } } else { $path = '/'; } $data['path'] = $path; $data['url'] = $scheme . '://' . $data['host_port'] . $path; $list['all'][$data['code']] = $data; if ($data['status'] == 1) { $list['active'][$data['code']] = $data; } } FanweService::instance()->cache->saveCache('image_servers', $list); }
function bindCacheWord() { $list = array(); $res = FDB::query("SELECT w.* FROM " . FDB::table('word') . " AS w \r\n\t\tLEFT JOIN " . FDB::table('word_type') . " AS wt ON wt.id = w.cid \r\n\t\tWHERE w.status = 1 AND (w.cid = 0 OR wt.status = 1)"); while ($data = FDB::fetch($res)) { if (preg_match('/^\\/(.+?)\\/$/', $data['word'], $a)) { switch ($data['type']) { case 1: $list['banned'][] = $data['word']; break; default: $list['filter']['find'][] = $data['word']; $list['filter']['replace'][] = preg_replace("/\\((\\d+)\\)/", "\\\\1", $data['replacement']); break; } } else { $data['word'] = preg_replace("/\\\\{(\\d+)\\\\}/", ".{0,\\1}", preg_quote($data['word'], '/')); switch ($data['type']) { case 1: $banned[] = $data['word']; $bannednum++; if ($bannednum == 1000) { $list['banned'][] = '/(' . implode('|', $banned) . ')/i'; $banned = array(); $bannednum = 0; } break; default: $list['filter']['find'][] = '/' . $data['word'] . '/i'; $list['filter']['replace'][] = $data['replacement']; break; } } } if ($banned) { $list['banned'][] = '/(' . implode('|', $banned) . ')/i'; } FanweService::instance()->cache->saveCache('words', $list); }
public function index() { global $_FANWE; if ($_FANWE['uid'] == 0) { fHeader("location: " . FU('user/login', array('refer' => FU('invite/index')))); } FanweService::instance()->cache->loadCache('medals'); $medal_list = array(); foreach ($_FANWE['cache']['medals']['referrals'] as $id) { $medal = $_FANWE['cache']['medals']['all'][$id]; $medal_list[] = $medal; } $invite_title = $_FANWE['setting']['site_title']; $invite_content = lang('invite', 'invite_content'); $invite_content = sprintf($invite_content, $_FANWE['setting']['site_name']); $invite_url = $_FANWE['site_url'] . '?invite=' . $_FANWE['uid']; $invite_types = array('kaixin', 'renren', 'sina', 'tqq', 'douban', 'qzone', 'baidu'); $invite_pic = $_FANWE['site_url'] . $_FANWE['setting']['site_logo']; $sns_links = getSnsLink($invite_types, $invite_title, $invite_url, $invite_content, $invite_pic); include template('page/invite/invite_index'); display(); }
function bindCacheNav() { global $_FANWE; $list = array(); $res = FDB::query("SELECT * FROM " . FDB::table('nav_category') . " WHERE status = 1 ORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $list['all'][$data['id']] = $data; } $list['root'] = array(); foreach ($list['all'] as $cate) { if ($cate['parent_id'] > 0) { $list['all'][$cate['parent_id']]['childs'][] = $cate['id']; } else { $list['root'][] = $cate['id']; } } $res = FDB::query("SELECT * FROM " . FDB::table('nav') . " WHERE status = 1 ORDER BY sort ASC,id ASC"); while ($data = FDB::fetch($res)) { $list['navs'][$data['id']] = $data; $list['all'][$data['cid']]['navs'][] = $data['id']; } FanweService::instance()->cache->saveCache('navs', $list); }
<?php define('FANWE_ROOT', str_replace('services/fanwe.php', '', str_replace('\\', '/', __FILE__))); require FANWE_ROOT . 'core/fanwe.php'; @set_include_path(FANWE_ROOT . 'services/'); require "Zend/Amf/Server.php"; require "fanwe.service.php"; $fanwe =& FanweService::instance(); $fanwe->initialize(); $server = new Zend_Amf_Server(); $server->setClass('FanweAmfService'); echo $server->handle();
/** * 缓存处理 * @param string $cmd 操作类型 * @param string $key 键名 * @param mixed $value 数据 * @param int $ttl 缓存时间(秒) * @return mixed */ public function memoryHandler($cmd, $key = '', $value = '', $ttl = 0) { $fanwe =& FanweService::instance(); if ($cmd == 'check') { return $fanwe->memory->enable ? $fanwe->memory->type : ''; } elseif ($fanwe->memory->enable && in_array($cmd, array('set', 'get', 'rm'))) { switch ($cmd) { case 'set': return $fanwe->memory->set($key, $value, $ttl); break; case 'get': return $fanwe->memory->get($key); break; case 'rm': return $fanwe->memory->rm($key); break; } } return NULL; }
private function getList() { global $_FANWE; $_FANWE['user_click_share_id'] = (int) $_FANWE['request']['sid']; unset($_FANWE['request']['sid']); $cache_file = getTplCache('page/book/book_index', $_FANWE['request'], 2); if (getCacheIsUpdate($cache_file, BOOK_CACHE_PAGE_TIME)) { $category = urldecode($_FANWE['request']['cate']); $is_root = false; $page_args = array(); if (isset($_FANWE['cache']['goods_category']['cate_code'][$category])) { $page_args['cate'] = $_FANWE['request']['cate']; $cate_id = $_FANWE['cache']['goods_category']['cate_code'][$category]; $goods_cate_code = $category; } else { $is_root = true; $cate_id = $_FANWE['cache']['goods_category']['root']; } $sort = $_FANWE['request']['sort']; $sort = !empty($sort) ? $sort : "pop"; $category_data = $_FANWE['cache']['goods_category']['all'][$cate_id]; $category_tags = array(); $_FANWE['nav_title'] = $category_data['cate_name']; if (!empty($category_data['seo_keywords'])) { $_FANWE['seo_keywords'] = $category_data['seo_keywords']; $_FANWE['setting']['site_keywords'] = ''; } if (!empty($category_data['seo_desc'])) { $_FANWE['seo_description'] = $category_data['seo_desc']; $_FANWE['setting']['site_description'] = ''; } $child_ids = array(); if (isset($category_data['child'])) { $child_ids = $category_data['child']; if (!$is_root) { $tagurlpara['cate'] = urlencode($category_data['cate_code']); } foreach ($category_data['child'] as $child_id) { $child_cate = $_FANWE['cache']['goods_category']['all'][$child_id]; $tag_key = 'goods_category_tags_' . $child_id; FanweService::instance()->cache->loadCache($tag_key); foreach ($_FANWE['cache'][$tag_key] as $k => $tag) { $tagurlpara['tag'] = urlencode($tag['tag_name']); $tag['url'] = FU("book/" . ACTION_NAME, $tagurlpara); $child_cate['tags'][] = $tag; if ($k > 16) { break; } } $category_tags[] = $child_cate; } } $hot_tags = array(); if (!$is_root) { $child_ids[] = $cate_id; require fimport("function/share"); $hot_tags = getHotTags($child_ids, $category, 10); } $condition = " WHERE s.share_data IN ('goods','photo','goods_photo')"; if (!$is_root) { $cids = array(); FS('Share')->getChildCids($cate_id, $cids); $condition .= " AND sc.cate_id IN (" . implode(',', $cids) . ")"; } $title = $category_data['short_name']; $is_match = false; $tag = urldecode($_FANWE['request']['kw']); if (!empty($tag)) { $_FANWE['nav_title'] = $tag . ' - ' . $_FANWE['nav_title']; $title = htmlspecialchars($tag); $is_match = true; //$match_key = FS('Words')->segment($tag,10); //$match_key = tagToUnicode($match_key,'+'); $match_key = segmentToUnicode($tag, '+'); $condition .= " AND match(sm.content_match) against('" . $match_key . "' IN BOOLEAN MODE) "; $page_args['tag'] = urlencode($tag); } //输出排序URL $sort_page_args = $page_args; $sort_page_args['sort'] = 'hot7'; $hot7_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'hot7') { $hot7_url['act'] = 1; } $sort_page_args['sort'] = 'hot30'; $hot30_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'hot30') { $hot30_url['act'] = 1; } $sort_page_args['sort'] = 'new'; $new_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'new') { $new_url['act'] = 1; } $sort_page_args['sort'] = 'pop'; $pop_url['url'] = FU('book/' . ACTION_NAME, $sort_page_args); if ($sort == 'pop') { $pop_url['act'] = 1; } if (!empty($_FANWE['request']['sort'])) { $page_args['sort'] = $sort; } else { $page_args['sort'] = 'pop'; } $today_time = getTodayTime(); switch ($sort) { //7天最热 点击次数 case 'hot7': $day7_time = $today_time - 604800; $field = ",(s.create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.click_count DESC"; break; //30天最热 点击次数 //30天最热 点击次数 case 'hot30': $day30_time = $today_time - 2592000; $field = ",(s.create_time > {$day30_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.click_count DESC"; break; //最新 //最新 case 'new': $field = ''; $sort = " ORDER BY s.share_id DESC"; break; //潮流 喜欢人数 //潮流 喜欢人数 case 'pop': default: $day7_time = $today_time - 604800; $field = ",(s.create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,s.collect_count DESC"; break; } $sql = 'SELECT DISTINCT(s.share_id),s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data ' . $field . ' FROM ' . FDB::table('share') . ' AS s '; if (!$is_root) { $sql .= 'INNER JOIN ' . FDB::table('share_category') . ' AS sc ON s.share_id = sc.share_id '; } if ($is_match) { $sql .= 'INNER JOIN ' . FDB::table('share_match') . ' AS sm ON sm.share_id = s.share_id '; } $sql .= $condition . $sort; $sql_count = 'SELECT COUNT(DISTINCT s.share_id) FROM ' . FDB::table('share') . ' AS s '; if (!$is_root) { $sql_count .= 'INNER JOIN ' . FDB::table('share_category') . ' AS sc ON s.share_id = sc.share_id '; } if ($is_match) { $sql_count .= 'INNER JOIN ' . FDB::table('share_match') . ' AS sm ON sm.share_id = s.share_id '; } $sql_count .= $condition; $page_size = 50; $max_page = 100; $count = FDB::resultFirst($sql_count); if ($count > $max_page * $page_size) { $count = $max_page * $page_size; } if ($_FANWE['page'] > $max_page) { $_FANWE['page'] = $max_page; } $pager = buildPage('book/' . $action, $page_args, $count, $_FANWE['page'], $page_size, '', 3); $share_datas = array(); $sql = $sql . ' LIMIT ' . $pager['limit']; $share_list = FDB::fetchAll($sql); $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $col = 4; $index = 0; $share_display = array(); foreach ($share_list as $share) { $mod = $index % $col; $share_display['col' . $mod][] = $share; $index++; } include template('page/book/book_index'); display($cache_file); exit; } else { include $cache_file; display(); } }
<?php define('MODULE_NAME', 'Second'); $actions = array('index', 'create', 'save'); $action = 'index'; if (isset($_REQUEST['action'])) { $action = strtolower($_REQUEST['action']); if (!in_array($action, $actions)) { $action = 'index'; } } define('ACTION_NAME', $action); require dirname(__FILE__) . '/core/fanwe.php'; $fanwe =& FanweService::instance(); $fanwe->cache_list[] = 'seconds'; $fanwe->initialize(); require fimport('module/second'); $_FANWE['nav_title'] = lang('common', 'second'); switch (ACTION_NAME) { case 'index': FanweService::instance()->cache->loadCache('citys'); SecondModule::index(); break; case 'create': SecondModule::create(); break; case 'save': SecondModule::save(); break; }