Esempio n. 1
0
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);
}
Esempio n. 2
0
/**
 * 主分类最新推荐主题
 */
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);
}
    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $root['act'] = 'delcomment';
        if ($_FANWE['uid'] == 0) {
            exit;
        }
        $comment_id = intval($_FANWE['requestData']['id']);
        if ($comment_id == 0) {
            exit;
        }
        $share = FDB::fetchFirst('SELECT s.uid,s.share_id  
			FROM ' . FDB::table('share_comment') . ' AS sc 
			INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = sc.share_id 
			WHERE sc.comment_id = ' . $comment_id);
        if (empty($share)) {
            exit;
        }
        $uid = intval($share['uid']);
        if ($uid != $_FANWE['uid']) {
            exit;
        }
        FS('Share')->deleteShareComment($comment_id);
        $root['return'] = 1;
        m_display($root);
    }
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 0;
     if ($_FANWE['uid'] == 0) {
         $root['info'] = "请先登陆";
         m_display($root);
     }
     $user = FS("User")->getUserById($_FANWE['uid']);
     $data = array('oldpassword' => $_FANWE['requestData']['oldpassword'], 'newpassword' => $_FANWE['requestData']['newpassword']);
     $vservice = FS('Validate');
     $validate = array(array('oldpassword', 'required', '请输入现在的密码'), array('newpassword', 'range_length', '请输入正确的新密码', 6, 32));
     if (!$vservice->validation($validate, $data)) {
         $root['info'] = $vservice->getError();
         m_display($root);
     } else {
         if (md5($data['oldpassword']) != $user['password']) {
             $root['info'] = '原密码不正确';
             m_display($root);
         } else {
             FDB::update('user', array('password' => md5($data['newpassword'])), 'uid = ' . $_FANWE['uid']);
             $root['info'] = '修改成功';
             $user_field = $_FANWE['setting']['integrate_field_id'];
             $sql = "SELECT {$user_field} FROM " . FDB::table('user') . " WHERE uid = '{$_FANWE['uid']}'";
             $integrate_id = intval(FDB::resultFirst($sql));
             if ($integrate_id > 0) {
                 FS("Integrate")->editUser($integrate_id, $data['newpassword'], '', '');
             }
         }
     }
     $root['return'] = 1;
     m_display($root);
 }
 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 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 run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 0;
     $data = array('email' => $_FANWE['requestData']['email'], 'user_name' => $_FANWE['requestData']['user_name'], 'password' => $_FANWE['requestData']['password'], 'gender' => intval($_FANWE['requestData']['gender']));
     $vservice = FS('Validate');
     $validate = array(array('email', 'required', lang('user', 'register_email_require')), array('email', 'email', lang('user', 'register_email_error')), array('user_name', 'required', lang('user', 'register_user_name_require')), array('user_name', 'range_length', lang('user', 'register_user_name_len'), 2, 20), array('user_name', '/^[\\x{4e00}-\\x{9fa5}a-zA-Z][\\x{4e00}-\\x{9fa5}a-zA-Z0-9]+$/u', lang('user', 'register_user_name_error')), array('password', 'range_length', lang('user', 'register_password_range'), 6, 20));
     if (!$vservice->validation($validate, $data)) {
         $root['info'] = "注册失败:" . $vservice->getError();
         m_display($root);
     }
     $uservice = FS('User');
     if ($uservice->getEmailExists($data['email'])) {
         $root['info'] = "注册失败:" . lang('user', 'register_email_exist');
         m_display($root);
     }
     if ($uservice->getUserNameExists($data['user_name'])) {
         $root['info'] = "注册失败:" . lang('user', 'register_user_name_exist');
         m_display($root);
     }
     //================add by chenfq 2011-10-14 =======================
     $user_field = $_FANWE['setting']['integrate_field_id'];
     $integrate_id = FS("Integrate")->addUser($data['user_name'], $data['password'], $data['email']);
     if ($integrate_id < 0) {
         $info = FS("Integrate")->getInfo();
         $root['info'] = "注册失败:" . $info;
         m_display($root);
     }
     //================add by chenfq 2011-10-14=======================
     $user = array('email' => $data['email'], 'user_name' => $data['user_name'], 'user_name_match' => segmentToUnicode($data['user_name']), 'password' => md5($data['password']), 'status' => 1, 'email_status' => 0, 'avatar_status' => 0, 'gid' => 7, 'invite_id' => FS('User')->getReferrals(), 'reg_time' => TIME_UTC, $user_field => $integrate_id);
     $uid = FDB::insert('user', $user, true);
     if ($uid > 0) {
         $_FANWE['uid'] = $uid;
         FDB::insert('user_count', array('uid' => $uid));
         if ($user['invite_id'] > 0) {
             FS('User')->insertReferral($uid, $user['invite_id'], $user['user_name']);
         }
         FS("User")->updateUserScore($uid, 'user', 'register');
         unset($user);
         $user_profile = array('uid' => $uid, 'gender' => $data['gender']);
         FDB::insert('user_profile', $user_profile);
         unset($user_profile);
         $user_status = array('uid' => $uid, 'reg_ip' => $_FANWE['client_ip'], 'last_ip' => $_FANWE['client_ip'], 'last_time' => TIME_UTC, 'last_activity' => TIME_UTC);
         FDB::insert('user_status', $user_status);
         $root['return'] = 1;
         $root['info'] = "用户注册成功";
         $root['uid'] = $uid;
         $root['user_name'] = $data['user_name'];
         $root['user_avatar'] = avatar($uid, 'm', '', 1, true);
         $root['user_email'] = $data['email'];
         $deviceuid = addslashes(trim($_FANWE['requestData']['deviceuid']));
         $sql = "update " . FDB::table('apns_devices') . " set clientid = " . $uid . " where clientid = 0 and deviceuid = '" . $deviceuid . "'";
         FDB::query($sql);
     } else {
         $root['info'] = lang('user', 'register_error');
     }
     m_display($root);
 }
Esempio n. 8
0
 public function unBind()
 {
     global $_FANWE;
     if ($_FANWE['uid'] > 0) {
         FDB::delete('user_bind', "uid = " . $_FANWE['uid'] . " AND type = 'sina'");
     }
     fHeader("location: " . FU('settings/bind'));
 }
    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);
    }
Esempio n. 10
0
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);
}
Esempio n. 11
0
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'] = 0;
        $uid = (int) $_FANWE['requestData']['uid'];
        $cid = (int) $_FANWE['requestData']['cid'];
        $album_title = trim($_FANWE['requestData']['title']);
        $data = array('title' => $album_title, 'cid' => $cid);
        $vservice = FS('Validate');
        $validate = array(array('title', 'required', lang('album', 'name_require')), array('title', 'max_length', lang('album', 'name_max'), 60), array('cid', 'min', lang('album', 'cid_min'), 1));
        if (!$vservice->validation($validate, $data)) {
            $root['info'] = $vservice->getError();
            m_display($root);
        }
        $check_result = FS('Share')->checkWord($album_title, 'title');
        if ($check_result['error_code'] == 1) {
            $root['info'] = $check_result['error_msg'];
            m_display($root);
        }
        if ($uid > 0) {
            if (!FS('User')->getUserExists($uid)) {
                $uid = 0;
            }
        }
        if ($cid == 0) {
            $uid == 0;
        }
        if ($uid == 0) {
            $root['info'] = "请先登录";
            m_display($root);
        }
        $share_data = array();
        $share_data['uid'] = $uid;
        $share_data['type'] = 'album';
        $share_data['content'] = $album_title;
        $share = FS('Share')->submit($share_data, false, true, true);
        if ($share['status']) {
            $data = array();
            $data['title'] = htmlspecialchars($album_title);
            $data['album_title_match'] = segmentToUnicode(clearSymbol($album_title));
            $data['uid'] = $uid;
            $data['cid'] = $cid;
            $data['share_id'] = $share['share_id'];
            $data['create_day'] = getTodayTime();
            $data['create_time'] = TIME_UTC;
            $data['show_type'] = 2;
            $aid = FDB::insert('album', $data, true);
            FDB::query('UPDATE ' . FDB::table('share') . ' SET rec_id = ' . $aid . ' 
				WHERE share_id = ' . $share['share_id']);
            FDB::query("update " . FDB::table("user_count") . " set albums = albums + 1 where uid = " . $uid);
            $root['aid'] = $aid;
            $root['album_name'] = $album_title;
            $root['return'] = 1;
        }
        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);
}
    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);
    }
Esempio n. 16
0
 public function addgoods()
 {
     $share_module = FDB::fetchAll("select `name`,`class`,`icon`,`url` from " . FDB::table('sharegoods_module') . " where status = 1 and is_install = 1");
     global $_FANWE;
     $cache_file = getTplCache('inc/shareutil/addgoods');
     if (!@(include $cache_file)) {
         include template('inc/shareutil/addgoods');
     }
     display($cache_file);
 }
 /**
  * 兑换排行
  */
 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;
 }
Esempio n. 18
0
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);
}
Esempio n. 19
0
/**
 * 
 */
function getUUIndexShop()
{
    global $_FANWE;
    $args = array();
    $cache_file = getTplCache('inc/index/shop', array(), 1);
    if (getCacheIsUpdate($cache_file, 600)) {
        $args['shop_list'] = FDB::fetchAll('SELECT * FROM ' . FDB::table('shop') . ' WHERE shop_logo <>\'\' ORDER BY sort desc, shop_id asc limit 0,30 ');
    }
    return tplFetch('inc/index/shop', $args, '', $cache_file);
}
Esempio n. 20
0
    public function getList($uid)
    {
        $uid = (int) $uid;
        $list = FDB::fetchAll('SELECT *  
			FROM ' . FDB::table('sys_notice') . ' 
			WHERE uid = ' . $uid . ' 
			ORDER BY id DESC');
        FDB::query("UPDATE " . FDB::table('sys_notice') . " SET status = 1 WHERE uid='{$uid}' AND status = 0");
        return $list;
    }
 public function searchShop()
 {
     vendor("common");
     $kw = trim($_REQUEST['kw']);
     $result['kw'] = $kw;
     $shop_list = FDB::fetchAll("select * from " . FDB::table("shop") . " where shop_name like '%" . $kw . "%' order by rand() limit 20 ");
     $shop_count = intval(FDB::resultFirst("select count(*) from " . FDB::table("shop") . " where shop_name like '%" . $kw . "%'"));
     $result['shop_list'] = $shop_list;
     $result['shop_count'] = $shop_count;
     die(json_encode($result));
 }
/**
 * 热心排行榜
 */
function getHotUser()
{
    $cache_file = getTplCache('inc/ask/hot_user', array(), 1);
    if (getCacheIsUpdate($cache_file, 300)) {
        //热心排行榜
        $sql = "SELECT uc.uid,u.user_name,uc.ask,ask_posts,uc.ask_best_posts \r\n\t\t\tFROM " . FDB::table("user_count") . " AS uc \r\n\t\t\tINNER JOIN " . FDB::table("user") . " AS u ON u.uid = uc.uid \r\n\t\t\tORDER BY uc.ask_best_posts DESC ,uc.ask_posts DESC limit 10";
        $hot_users = FDB::fetchAll($sql);
        $args['hot_users'] =& $hot_users;
    }
    return tplFetch('inc/ask/hot_user', $args, '', $cache_file);
}
Esempio n. 23
0
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);
}
Esempio n. 24
0
 public function collectCates()
 {
     setTimeLimit(3600);
     $ccate = FDB::fetchFirst('SELECT * FROM ' . FDB::table('goods_cate_collect') . ' LIMIT 0,1');
     if (!$ccate) {
         return false;
     }
     FDB::query('DELETE FROM ' . FDB::table('goods_cate_collect') . " WHERE id = '{$ccate['id']}'");
     global $_FANWE;
     Cache::getInstance()->loadCache('business');
     //QQ号
     define('PAIPAI_API_UIN', trim($_FANWE['cache']['business']['paipai']['uin']));
     //令牌
     define('PAIPAI_API_APPOAUTHID', trim($_FANWE['cache']['business']['paipai']['appoauthid']));
     //APP_KEY
     define('PAIPAI_API_APPOAUTHKEY', trim($_FANWE['cache']['business']['paipai']['appoauthkey']));
     define('PAIPAI_API_ACCESSTOKEN', trim($_FANWE['cache']['business']['paipai']['accesstoken']));
     define('PAIPAI_API_USERID', trim($_FANWE['cache']['business']['paipai']['userid']));
     $sdk = new PaiPaiOpenApiOauth(PAIPAI_API_APPOAUTHID, PAIPAI_API_APPOAUTHKEY, PAIPAI_API_ACCESSTOKEN, PAIPAI_API_UIN);
     $sdk->setApiPath("/attr/getNavigationChildList.xhtml");
     $sdk->setMethod("get");
     $sdk->setCharset("utf-8");
     $sdk->setFormat("json");
     $params =& $sdk->getParams();
     $params["navigationId"] = $ccate['cid'];
     //请求数据
     $json = $sdk->invoke();
     $json = preg_replace("/[\r\n]/", '', $json);
     preg_match("/getNavigationChildListSuccess\\((.+?)\\);\\}catch\\(/", $json, $list);
     $list = json_decode($list[1], true);
     $sort_file = FANWE_ROOT . '/public/records/cate.sort.php';
     $sort = (int) @file_get_contents($sort_file);
     if (isset($list['childList'])) {
         foreach ($list['childList'] as $item) {
             $cate = array();
             $cate['type'] = 'paipai';
             $cate['id'] = (int) $item['navigationId'];
             if ($cate['id'] > 0) {
                 $cate['pid'] = $ccate['cid'] == 0 ? '' : $ccate['cid'];
                 $cate['name'] = (string) $item['navigationName'];
                 $cate['pids'] = empty($ccate['pids']) ? $cate['pid'] : $ccate['pids'] . ',' . $cate['pid'];
                 $cate['sort'] = ++$sort;
                 FDB::insert('goods_cates', $cate, false, true);
                 if ((int) $item['isClass'] == 0) {
                     FDB::insert('goods_cate_collect', array('id' => 'NULL', 'cid' => $cate['id'], 'pids' => $cate['pids']));
                 }
             }
         }
         @file_put_contents($sort_file, $sort);
     }
     return true;
 }
Esempio n. 25
0
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);
}
Esempio n. 26
0
 public function jumpUserBindReg($data, $user_name)
 {
     do {
         $max_count = FDB::resultFirst('SELECT COUNT(*) FROM ' . FDB::table("user") . " WHERE user_name = '" . $user_name . "'");
         if ($max_count > 0) {
             $user_name = $user_name . '_' . random(3);
         }
     } while ($max_count > 0);
     $data['user_name'] = $user_name;
     $data = serialize($data);
     fSetCookie('bind_user_info', authcode($data, 'ENCODE'));
     fHeader("location:" . FU('user/bind'));
 }
    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);
    }
Esempio n. 28
0
 public function unBind()
 {
     global $_FANWE;
     if ($_FANWE['uid'] > 0) {
         FDB::delete('user_bind', "uid = " . $_FANWE['uid'] . " AND type = 'taobao'");
         $update = array();
         $update['buyer_level'] = 0;
         $update['seller_level'] = 0;
         $update['is_buyer'] = 0;
         FDB::update('user', $update, 'uid = ' . $_FANWE['uid']);
     }
     $redirect_uri = urlencode($_FANWE['site_url'] . substr(FU('settings/bind'), 1));
     $url = "https://oauth.taobao.com/logoff?client_id=" . $this->config['app_key'] . "&redirect_uri=" . $redirect_uri;
     fHeader("location: " . $url);
 }
Esempio n. 29
0
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);
}
    public function deleteGoods($gid)
    {
        global $_FANWE;
        $gid = (int) $gid;
        $goods = FDB::fetchFirst('SELECT *
			FROM ' . FDB::table('second_goods') . ' WHERE gid = ' . $gid);
        if (empty($goods)) {
            return;
        }
        $share_id = $goods['share_id'];
        $share = FS('Share')->getShareById($share_id);
        FS('Share')->deleteShare($share_id);
        FDB::query('UPDATE ' . FDB::table('user') . ' SET seconds = seconds - 1 WHERE uid = ' . $share['uid']);
        FS('Medal')->runAuto($share['uid'], 'seconds');
    }