public function updateUserStatistics($uid) { $uid = (int) $uid; if (!$uid) { return array(); } $bln = false; $today_time = getTodayTime(); $res = FDB::query('SELECT * FROM ' . FDB::table('user_statistics') . ' WHERE uid = ' . $uid); while ($data = FDB::fetch($res)) { if ($data['last_time'] < $today_time && $data['type'] != 1) { $change_day = ($today_time - $data['last_time']) / 86400; $change = $change_day == 1 ? 1 : 2 - $change_day; $new_num = $statistic['num'] + $change; if ($new_num <= 0) { $new_num = 1; } StatisticsService::update(array('last_time' => $today_time, 'num' => $new_num), $uid, $data['type']); $bln = true; } } if ($bln) { StatisticsService::getUserStatistics($uid, true); } }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $share_id = (int) $_FANWE['requestData']['share_id']; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $sql_count = "SELECT COUNT(DISTINCT comment_id) FROM " . FDB::table("share_comment") . " WHERE share_id = " . $share_id; $total = FDB::resultFirst($sql_count); $page_size = PAGE_SIZE; $page_total = ceil($total / $page_size); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $sql = 'SELECT c.*,u.user_name,u.server_code FROM ' . FDB::table('share_comment') . ' AS c INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = c.uid WHERE c.share_id = ' . $share_id . ' ORDER BY c.comment_id DESC LIMIT ' . $limit; $res = FDB::query($sql); $list = array(); while ($item = FDB::fetch($res)) { $item['user_avatar'] = avatar($item['uid'], 'm', $item['server_code'], 1, true); $item['time'] = getBeforeTimelag($item['create_time']); m_express(&$item, $item['content']); $list[] = $item; } $root['item'] = $list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
public function all() { global $_FANWE; $is_best = false; $is_all = true; $_FANWE['nav_title'] = lang('common', 'daren'); $count = FDB::resultFirst('SELECT COUNT(uid) FROM ' . FDB::table('user_daren') . ' WHERE status = 1'); $pager = buildPage('daren/all', array(), $count, $_FANWE['page'], 18); $col = 3; $index = 0; $list = array(); $today_time = getTodayTime(); $sql = 'SELECT ud.*,u.user_name,u.server_code,uc.fans,uc.goods,uc.shares, up.reside_province,up.reside_city,up.introduce FROM ' . FDB::table('user_daren') . ' AS ud INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = ud.uid INNER JOIN ' . FDB::table('user_count') . ' AS uc ON uc.uid = u.uid INNER JOIN ' . FDB::table('user_profile') . ' AS up ON up.uid = ud.uid WHERE ud.status = 1 ORDER BY ud.day_time DESC,ud.id DESC LIMIT ' . $pager['limit']; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['today_best'] = false; $data['url'] = FU('u/index', array('uid' => $data['uid'])); $province = $_FANWE['cache']['citys']['all'][$data['reside_province']]['name']; $city = $_FANWE['cache']['citys']['all'][$data['reside_city']]['name']; $data['city'] = $province . ' ' . $city; $list[$index % $col][] = $data; $index++; } include template('page/daren'); display(); }
/** * 主分类最新推荐主题 */ function getRootForumBests() { global $_FANWE; $args = array(); $cache_file = getTplCache('inc/club/forum_list', array(), 1); if (getCacheIsUpdate($cache_file, 300)) { $res = FDB::query('SELECT fid,thread_count FROM ' . FDB::table('forum') . ' WHERE parent_id = 0'); while ($data = FDB::fetch($res)) { $_FANWE['cache']['forums']['all'][$data['fid']]['thread_count'] = $data['thread_count']; } $forum_list = array(); $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'); $fids = $_FANWE['cache']['forums']['root']; $forum_index = 0; foreach ($fids as $fid) { $forum = $_FANWE['cache']['forums']['all'][$fid]; $forum['char'] = $chars[$forum_index]; $forum['topics'] = FS('Topic')->getImgTopic('best', 5, 3, $fid); $forum_list[] = $forum; $forum_index++; } $forum_list = array_chunk($forum_list, 2); $args['forum_list'] =& $forum_list; } return tplFetch('inc/club/forum_list', $args, '', $cache_file); }
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 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); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 1; $is_hot = (int) $_FANWE['requestData']['is_hot']; $is_new = (int) $_FANWE['requestData']['is_new']; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $today_time = getTodayTime(); $field = ''; $whrer = ''; $book_photo_goods = (int) $_FANWE['setting']['book_photo_goods']; if ($book_photo_goods == 0) { $whrer = " WHERE share_data IN ('goods','photo','goods_photo')"; } elseif ($book_photo_goods == 1) { $whrer = " WHERE share_data IN ('photo','goods_photo')"; } elseif ($book_photo_goods == 2) { $whrer = " WHERE share_data IN ('goods','goods_photo')"; } if ($is_hot == 1) { $day7_time = $today_time - 604800; $field = ",(create_time > {$day7_time}) AS time_sort "; $sort = " ORDER BY time_sort DESC,collect_count DESC"; } if ($is_new == 1) { $sort = " ORDER BY share_id DESC"; } $sql_count = "SELECT COUNT(DISTINCT share_id) FROM " . FDB::table("share"); $total = FDB::resultFirst($sql_count); $page_size = PAGE_SIZE; $max_page = 100; if ($total > $max_page * $page_size) { $total = $max_page * $page_size; } if ($page > $max_page) { $page = $max_page; } $page_total = ceil($total / $page_size); $limit = ($page - 1) * $page_size . "," . $page_size; $sql = 'SELECT DISTINCT(share_id),cache_data ' . $field . ' FROM ' . FDB::table('share') . $whrer . $sort . ' LIMIT ' . $limit; $res = FDB::query($sql); $share_list = array(); while ($item = FDB::fetch($res)) { $cache_data = fStripslashes(unserialize($item['cache_data'])); $img = current($cache_data['imgs']['all']); $data = array(); $data['share_id'] = $item['share_id']; $data['img'] = getImgName($img['img'], 100, 999, 0, true); $data['height'] = $img['height'] * (100 / $img['width']); $share_list[] = $data; } $root['item'] = $share_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
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); }
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); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = (int) $_FANWE['requestData']['uid']; if ($uid > 0) { if (!FS('User')->getUserExists($uid)) { $uid = 0; } } if ($uid == 0) { $uid = $_FANWE['uid']; $root['home_user'] = $_FANWE['user']; } if ($uid == 0) { $root['info'] = "请选择要查看的会员"; m_display($root); } if (!isset($root['home_user'])) { $root['home_user'] = FS("User")->getUserById($uid); unset($root['home_user']['user_name_match'], $root['home_user']['password'], $root['home_user']['active_hash'], $root['home_user']['reset_hash']); $root['home_user']['user_avatar'] = avatar($uid, 'm', $root['home_user']['server_code'], 1, true); } $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $is_spare_flow = (int) $_FANWE['requestData']['is_spare_flow']; $img_size = 200; $scale = 2; if ($is_spare_flow == 1) { $img_size = 100; $scale = 1; } $total = FDB::resultFirst('SELECT COUNT(photo_id) FROM ' . FDB::table('share_photo') . ' WHERE uid = ' . $uid); $page_size = 20; //PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $photo_list = array(); $res = FDB::query('SELECT photo_id,share_id,img FROM ' . FDB::table('share_photo') . ' WHERE uid = ' . $uid . ' ORDER BY photo_id DESC LIMIT ' . $limit); while ($photo = FDB::fetch($res)) { $photo['img'] = getImgName($photo['img'], $img_size, $img_size, 1, true); $photo['height'] = round($img_size / $scale); $photo['url'] = FU('note/m', array('sid' => $photo['share_id'], 'id' => $photo['photo_id']), true); $photo_list[] = $photo; } $root['return'] = 1; $root['item'] = $photo_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
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); }
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); }
/** * 兑换排行 */ public function getExchangeTop($num = 10) { $sql = "SELECT o.uid,o.user_name,SUM(o.data_num) AS sum_count " . 'FROM ' . FDB::table('order') . ' AS o ' . "GROUP BY o.uid ORDER BY sum_count DESC LIMIT 0,{$num}"; $list = array(); $query = FDB::query($sql); while ($data = FDB::fetch($query)) { $list[] = $data; } return $list; }
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); }
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; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $total = FDB::resultFirst('SELECT COUNT(id) FROM ' . FDB::table('user_daren') . ' WHERE status = 1'); $page_size = PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $user_follows = array(); $res = FDB::query('SELECT u.uid,u.user_name,u.server_code,uc.fans,ud.reason,up.introduce FROM ' . FDB::table('user_daren') . ' AS ud INNER JOIN ' . FDB::table('user') . ' AS u ON u.uid = ud.uid INNER JOIN ' . FDB::table('user_count') . ' AS uc ON uc.uid = ud.uid INNER JOIN ' . FDB::table('user_profile') . ' AS up ON up.uid = ud.uid WHERE ud.status = 1 ORDER BY ud.id DESC LIMIT ' . $limit); while ($data = FDB::fetch($res)) { $data['user_avatar'] = avatar($data['uid'], 'm', $data['server_code'], 1, true); $data['desc'] = $data['introduce']; if (!empty($data['reason'])) { $data['desc'] = $data['reason']; } unset($data['server_code'], $data['introduce'], $data['reason']); if ($data['uid'] == $_FANWE['uid']) { $data['is_follow'] = -1; } else { $user_follows[$data['uid']] = 0; $data['is_follow'] = 0; } $user_list[$data['uid']] = $data; } $uids = array_keys($user_follows); $uids = implode(',', $uids); $uids = str_replace(',,', ',', $uids); if (!empty($uids)) { $res = FDB::query("SELECT uid FROM " . FDB::table('user_follow') . ' WHERE f_uid = ' . $_FANWE['uid'] . ' AND uid IN (' . $uids . ')'); while ($item = FDB::fetch($res)) { $user_list[$item['uid']]['is_follow'] = 1; } } $root['item'] = array_slice($user_list, 0); $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
/** * 分类最新的主题 */ function getIndexTopic() { global $_FANWE; $args = array(); $cache_file = getTplCache('inc/index/new_topic', array(), 1); if (getCacheIsUpdate($cache_file, 600)) { $res = FDB::query('SELECT fid,thread_count FROM ' . FDB::table('forum') . ' WHERE parent_id = 0'); while ($data = FDB::fetch($res)) { $_FANWE['cache']['forums']['all'][$data['fid']]['thread_count'] = $data['thread_count']; } $args['new_list'] = FS('Topic')->getImgTopic('new', 7, 4); $args['ask_list'] = FS('Ask')->getImgAsk('new', 2, 1); } return tplFetch('inc/index/topics', $args, '', $cache_file); }
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); }
/** * * @param $cids 分类ID数组 * @param $limit */ function getHotTags($cids = array(), $cate_code, $limit) { $hot_tags = array(); $sql = 'SELECT gt.tag_name,gt.tag_code,gt.count,gt.is_hot FROM ' . FDB::table('goods_tags') . ' as gt INNER JOIN ' . FDB::table("goods_category_tags") . ' AS gct ON gct.tag_id = gt.tag_id WHERE gct.cate_id IN (' . implode(',', $cids) . ') ORDER BY gt.count DESC,gt.sort ASC LIMIT 0,' . $limit; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['url'] = FU("book/cate", array('cate' => $cate_code, 'tag' => urlencode($data['tag_name']))); $hot_tags[] = $data; } return $hot_tags; }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = $_FANWE['uid']; if ($uid == 0) { $root['info'] = "请先登陆"; m_display($root); } $root['home_user'] = $_FANWE['user']; $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $uids = array(); //获取我关注的会员编号 $sql = 'SELECT uid FROM ' . FDB::table('user_follow') . ' WHERE f_uid = ' . $uid; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $uids[] = (int) $data['uid']; } if (count($uids) > 0) { $sql = 'SELECT COUNT(share_id) FROM ' . FDB::table("share") . ' WHERE uid IN (' . implode(',', $uids) . ')'; $total = FDB::resultFirst($sql); $page_size = PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $share_list = array(); $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE uid IN (' . implode(',', $uids) . ') ORDER BY share_id DESC LIMIT ' . $limit; $share_list = FDB::fetchAll($sql); $share_list = mGetShareDetailList($share_list, true); } else { $page_total = 0; $share_list = array(); } $root['return'] = 1; if (count($share_list) > 0) { $root['item'] = array_slice($share_list, 0); } else { $root['item'] = array(); } $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
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); }
public function addAction() { global $_F; $_F["debug"] = true; if ($this->isPost()) { $manager = $_POST['manager']; $password = FRequest::getPostString('password'); $manager['password'] = md5($password); if (trim($manager[username]) == '') { return $this->error('用户名不能为空!', '/admin/manager/edit'); } if (trim($manager[email]) == '') { return $this->error('邮箱不能为空!', '/admin/manager/edit'); } if ($password == '') { return $this->error('密码不能为空!', '/admin/manager/edit'); } $username = FDB::fetch("select username from manager where username ='******'"); if ($username) { return $this->error('用户名重复!', '/admin/manager/edit'); } $email = FDB::fetch("select email from manager where email ='" . trim($manager[email]) . "'"); if ($email) { return $this->error('邮箱重复!', '/admin/manager/edit'); } // 添加管理员用户 $user_id = Service_Edit::addUser(); if ($user_id <= 0) { return $this->error('添加管理员失败', '/admin/manager/edit'); } $manager["user_id"] = $user_id; $quanxianid = FRequest::getPostString('quanxianid'); $quanxianidx = FRequest::getPostString('quanxianidx'); if ($quanxianid && count($quanxianid) > 0) { $top_menus_id = implode(",", $quanxianid); } if ($quanxianidx && count($quanxianidx) > 0) { $left_menus_id = implode(",", $quanxianidx); } $manager['top_menus_id'] = $top_menus_id; $manager['left_menus_id'] = $left_menus_id; $result = $this->db_manager->insert($manager); if ($result) { return $this->success('添加成功!', '/admin/manager/list'); } } }
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 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); }
public function run() { global $_FANWE; $root = array(); $root['return'] = 0; $uid = $_FANWE['uid']; if ($uid == 0) { $root['info'] = "请先登陆"; m_display($root); } $root['home_user'] = $_FANWE['user']; FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='{$uid}' AND type=3"); $page = (int) $_FANWE['requestData']['page']; $page = max(1, $page); $sql = 'SELECT COUNT(sc.comment_id) FROM ' . FDB::table("share") . ' AS s INNER JOIN ' . FDB::table("share_comment") . ' AS sc ON sc.share_id = s.share_id WHERE s.uid = ' . $uid; $total = FDB::resultFirst($sql); $page_size = PAGE_SIZE; $page_total = max(1, ceil($total / $page_size)); if ($page > $page_total) { $page = $page_total; } $limit = ($page - 1) * $page_size . "," . $page_size; $comment_list = array(); $sql = 'SELECT sc.*,s.content as scontent,u.user_name,u.server_code FROM ' . FDB::table("share") . ' AS s INNER JOIN ' . FDB::table("share_comment") . ' AS sc ON sc.share_id = s.share_id INNER JOIN ' . FDB::table("user") . ' AS u ON u.uid = sc.uid WHERE s.uid = ' . $uid . ' ORDER BY comment_id DESC LIMIT ' . $limit; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $data['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($data['uid'], 'm', 1), 2); $data['time'] = getBeforeTimelag($data['create_time']); $data['url'] = FU('note/index', array('sid' => $data['share_id']), true); m_express(&$data, $data['content'] . $data['scontent']); $comment_list[] = $data; } $root['return'] = 1; $root['item'] = $comment_list; $root['page'] = array("page" => $page, "page_total" => $page_total); m_display($root); }
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 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 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 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); }
public function run() { $crons = array(); $res = FDB::query("SELECT * FROM " . FDB::table('cron') . " WHERE run_time <= '" . TIME_UTC . "' ORDER BY run_time DESC"); while ($data = FDB::fetch($res)) { $crons[$data['type']][] = $data; } if (count($crons) > 0) { $query = FDB::query("DELETE FROM " . FDB::table('cron') . " WHERE run_time <= '" . TIME_UTC . "'"); if ($query !== FALSE && FDB::affectedRows() > 0) { @set_time_limit(1800); if (function_exists('ini_set')) { ini_set('max_execution_time', 1800); } foreach ($crons as $ctype => $cron_list) { FS($ctype)->runCron($cron_list); } } } }