public function deleteAlbum($aid, $is_delete_share = false) { $aid = (int) $aid; if (!$aid) { return false; } $album = AlbumService::getAlbumById($aid); if (empty($album)) { return false; } if ($is_delete_share) { $res = FDB::query('SELECT share_id FROM ' . FDB::table('album_share') . ' WHERE album_id = ' . $aid); while ($data = FDB::fetch($res)) { AlbumService::deleteAlbumItem($data['share_id'], false); } } FDB::delete('album', 'id = ' . $aid); FDB::delete('album_best', 'album_id = ' . $aid); FDB::delete('album_share', 'album_id = ' . $aid); FDB::delete('album_tags_related', 'album_id = ' . $aid); if (!empty($album['flash_img'])) { @unlink(FANWE_ROOT . $album['flash_img']); } if (!empty($album['best_img'])) { @unlink(FANWE_ROOT . $album['best_img']); } if (!empty($album['tags'])) { FDB::query('UPDATE ' . FDB::table('album_tags') . " SET album_count = album_count - 1 WHERE tag_name " . FDB::createIN($album['tags'])); } FS('Share')->deleteShare($album['share_id']); FDB::query('UPDATE ' . FDB::table('user_count') . ' SET albums = albums - 1 WHERE uid = ' . $album['uid']); FDB::query('UPDATE ' . FDB::table('share') . " SET type = 'default' \r\n\t\t\tWHERE rec_id = " . $aid . " AND type IN ('album_item','album_best','album_rec')"); FS('Medal')->runAuto($album['uid'], 'albums'); }
public function maybe() { global $_FANWE; $home_uid = $_FANWE['home_uid']; $home_user = FS('User')->getUserById($home_uid); $user_names = FS('User')->getUserShowName($home_uid); FanweService::instance()->cache->loadCache('forums'); $page_args = array('uid' => $home_uid); $current_menu = 'topic'; $follow_uids = array(); $sql = 'SELECT uid FROM ' . FDB::table('user_follow') . ' WHERE f_uid = ' . $home_uid . ' GROUP BY uid'; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $follow_uids[] = $data['uid']; } if (count($follow_uids) > 0) { $sql = 'SELECT COUNT(tid) FROM ' . FDB::table('forum_thread') . ' WHERE uid ' . FDB::createIN($follow_uids); $count = FDB::resultFirst($sql); $pager = buildPage('u/' . ACTION_NAME, $page_args, $count, $_FANWE['page'], 10); $thread_list = array(); $res = FDB::query('SELECT ft.*,s.cache_data FROM ' . FDB::table('forum_thread') . ' AS ft INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id = ft.share_id WHERE ft.uid ' . FDB::createIN($follow_uids) . ' ORDER BY ft.tid DESC LIMIT ' . $pager['limit']); while ($thread = FDB::fetch($res)) { $thread['cache_data'] = fStripslashes(unserialize($thread['cache_data'])); $thread['url'] = FU('club/detail', array('tid' => $thread['tid'])); $thread['time'] = getBeforeTimelag($thread['create_time']); $thread['cate'] = $_FANWE['cache']['forums']['all'][$thread['fid']]; FS('Share')->shareImageFormat($thread); unset($thread['cache_data']); $thread_list[$thread['share_id']] = $thread; } } include template('page/u/u_topic'); display(); }
/** * 根据会员名称获取会员列表 * @param array $user_names 名称数组 * @return array */ public function getUsersByName($user_names) { if (is_array($user_names)) { return FDB::fetchAll('SELECT uid,user_name FROM ' . FDB::table('user') . ' WHERE user_name ' . FDB::createIN($user_names)); } else { return FDB::fetchFirst('SELECT uid,user_name FROM ' . FDB::table('user') . "\r\n\t\t\t\tWHERE user_name = '{$user_names}'"); } }
function m_express($obj, $content) { global $_FANWE; $obj['parse_expres'] = array(); $express = getCache('m_emotion_express_cache'); //缓存过的表情hash if ($express === NULL) { $express = array(); $res = FDB::query("select `emotion`,concat('" . $_FANWE['site_url'] . "public/expression/',`type`,'/',`filename`) as fname from " . FDB::table('expression')); while ($data = FDB::fetch($res)) { $express[$data['emotion']] = $data['fname']; } setCache('m_emotion_express_cache', $express); } preg_match_all("/(\\[[^\f\n\r\t\v\\[\\] ]{2,20}?\\])/", $content, $exps); if (!empty($exps[1])) { $exps = array_unique($exps[1]); foreach ($exps as $exp) { if (!empty($exp) && isset($express[$exp])) { //$obj['parse_expres'][$exp] = $express[$exp]; $obj['parse_expres'][] = array('key' => $exp, 'value' => $express[$exp], 'width' => 24, 'height' => 24); } } } $obj['parse_user'] = array(); preg_match_all("/@([^\f\n\r\t\v@<> ]{2,20}?)(?:\\:| )/", $content, $users); if (!empty($users[1])) { $patterns = array(); $replace = array(); $users = array_unique($users[1]); $arr = array(); foreach ($users as $user) { if (!empty($user)) { $arr[] = addslashes($user); } } $res = FDB::query('SELECT uid,user_name FROM ' . FDB::table('user') . ' WHERE user_name ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { //$obj['parse_user'][$data['user_name']] = $data['uid']; $obj['parse_user'][] = array('key' => $data['user_name'], 'value' => $data['uid']); } } $obj['parse_events'] = array(); preg_match_all("/#([^\f\n\r\t\v]{1,80}?)#/", $content, $events); if (!empty($events[1])) { $patterns = array(); $replace = array(); $events = array_unique($events[1]); $arr = array(); foreach ($events as $event) { if (!empty($event)) { $arr[] = addslashes($event); } } $res = FDB::query('SELECT id,title FROM ' . FDB::table('event') . ' WHERE title ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { //$obj['parse_events'][$data['title']] = $data['id']; $obj['parse_events'][] = array('key' => $data['title'], 'value' => $data['id']); } } }
/** * 显示指定ID的广告位ID * @param string $id 广告位 * @param int $count 显示数量 * @param string $target 关键字 * @return array */ function getAdvPosition($id, $count = '', $target = '') { global $_FANWE; $ap = FDB::fetchFirst('SELECT * FROM ' . FDB::table('adv_position') . ' WHERE id =' . $id); if (!$ap) { return ''; } if ($target != '') { $target = explode(',', $target); } $where = "status = 1 AND position_id = '{$id}'"; if ($target != '') { $where .= ' AND target_key' . FDB::createIN($target); } $sql = 'SELECT * FROM ' . FDB::table('adv') . ' WHERE ' . $where . ' ORDER BY sort ASC,id DESC'; if ($count > 0) { $sql .= ' LIMIT 0,' . $count; } $adv_res = FDB::query($sql); $adv_list = array(); while ($adv = FDB::fetch($adv_res)) { $adv['html'] = getAdvHTML($adv, $ap); $adv['durl'] = FU("adv/show", array("id" => $adv['id'])); $adv['turl'] = $adv['url']; $adv['url'] = urlencode(FU("adv/show", array("id" => $adv['id']))); $adv_list[] = $adv; } $ap['adv_list'] = $adv_list; return $ap; }
/** * 保存分享数据 * 注:所有图片地址经处理过并转存过的临时图片或远程图片 * $data = array( //分享的基本数据 * 'share'=>array( * 'uid'=> xxx, //分享的会员ID * 'parent_id' => xxx //转发的分享ID * 'content' => xxx //分享的内容 * 'type'=> xxx //分享的来源,默认为default * 'title' => xxx //分享的标题 * 'base_id' => xxx //原创ID * ), * * 'share_photo'=>array( //图库 #可选# * array( //多张图 * 'img' => xxx //原图 * ) * ), * 'share_goods'=>array( //分享的商品 #可选# * array( * 'img' => xxx //商品图 * 'name' => xxx //品名 * 'url' => xxx //商品地址 * 'price' => xxx //价格 * 'shop_name' => xxx //商户名称 * 'shop_logo' => xxx //商户的logo * 'shop_url' => xxx //商户地址 * ) //多个商品 * ), * 'share_tag' => array(xxx,xxx,xxx), //该分享的标签 * ); * * 返回 * array( * 'status' => xxx 状态 bool * 'share_id' => share_id * ) */ public function save($data, $is_score = true) { global $_FANWE; //保存分享数据 $share_data = $data['share']; $share_album_id = (int) $share_data['albumid']; unset($share_data['albumid']); $share_data['create_time'] = TIME_UTC; $share_data['day_time'] = getTodayTime(); $share_id = FDB::insert('share', $share_data, true); if (intval($share_id) > 0) { $share_data_now_type = $share_data['type']; $share_data_rec_id = $share_data['rec_id']; $share_server_code = array(); if (empty($share_data_now_type)) { $share_data_now_type = 'default'; } /*//是否是回复 是的 话 添加评论消息提示 if(intval($share_data['parent_id']) > 0) { $base_share_id = FDB::resultFirst("select uid from ".FDB::table('share')." where share_id = ".$share_data['parent_id']); $result = FDB::query("INSERT INTO ".FDB::table('user_notice')."(uid, type, num, create_time) VALUES('$base_share_id',3,1,'".TIME_UTC."')", 'SILENT'); if(!$result) FDB::query("UPDATE ".FDB::table('user_notice')." SET num = num + 1, create_time='".TIME_UTC."' WHERE uid='$base_share_id' AND type=3"); }*/ //保存话题 $is_event = false; $event_list = array(); $pattern = "/#([^\f\n\r\t\v]{1,80}?)#/"; preg_match_all($pattern, $share_data['content'], $event_list); if (!empty($event_list[1])) { array_unique($event_list[1]); foreach ($event_list[1] as $v) { $event_id = (int) FDB::resultFirst("select id from " . FDB::table("event") . " where `title`='" . $v . "'"); if ($event_id == 0) { $event_data = array(); $event_data['uid'] = $share_data['uid']; $event_data['title'] = $v; $event_data['share_id'] = $share_id; $event_data['create_time'] = TIME_UTC; $event_data['last_share'] = $share_id; $event_data['last_time'] = TIME_UTC; FDB::insert("event", $event_data); } else { $event_data = array(); $event_data['event_id'] = $event_id; $event_data['uid'] = $share_data['uid']; $event_data['share_id'] = $share_id; FDB::insert("event_share", $event_data); FDB::query("update " . FDB::table("event") . " set thread_count = thread_count+1,last_share=" . $share_id . ",last_time=" . TIME_UTC . " where id = {$event_id}"); } } } $share_cates = array(); $result['status'] = true; $result['share_id'] = $share_id; /*$content_match = FS('Words')->segment(clearExpress($share_data['content']),100); $title_tags = FS('Words')->segment($share_data['title'],100); if(!empty($title_tags)) $content_match = array_merge($content_match, $title_tags);*/ $content_match = clearExpress($share_data['content']); $content_match .= $share_data['title']; $is_rel_imgage = false; $weibo_img = ''; $weibo_img_sort = 100000; $photo_count = 0; $server_args = array(); FS("Image")->getImageArgs(&$server_args); //保存分享图片 $share_photo = $data['share_photo']; foreach ($share_photo as $k => $photo) { if ($photo_count >= $_FANWE['setting']['share_pic_count']) { break; } $o_img = false; if (FS("Image")->getIsServer() && !empty($photo['server_code'])) { $server = FS("Image")->getServer($photo['server_code']); if (!empty($server)) { $server_args['share_id'] = $share_id; $server_args['img_path'] = $photo['img']; $server = FS("Image")->getImageUrlToken($server_args, $server, 1); $body = FS("Image")->sendRequest($server, 'saveshare', true); if (!empty($body)) { $o_img = unserialize($body); FS("Image")->setServerUploadCount($o_img['server_code']); $share_server_code[] = $o_img['server_code']; $o_img['url'] = str_replace('./', './' . $o_img['server_code'] . '/', $o_img['url']); $weibo_img_url = FS("Image")->getImageUrl($o_img['url'], 1); } } } else { $o_img = copyImage($photo['img'], array(), 'share', true, $share_id); $weibo_img_url = FS("Image")->getImageUrl($o_img['url'], 1); } if (!empty($o_img)) { if ($photo['sort'] < $weibo_img_sort) { $weibo_img = $weibo_img_url; $weibo_img_sort = $photo['sort']; } $share_photo_data['uid'] = $_FANWE['uid']; $share_photo_data['share_id'] = $share_id; $share_photo_data['img'] = $o_img['url']; $share_photo_data['type'] = $photo['type']; $share_photo_data['sort'] = $photo['sort']; $share_photo_data['img_width'] = $o_img['width']; $share_photo_data['img_height'] = $o_img['height']; $share_photo_data['server_code'] = $photo['server_code']; FDB::insert('share_photo', $share_photo_data, true); $photo_count++; } } //保存引用图片 if (isset($data['rel_photo'])) { $share_photo = $data['rel_photo']; foreach ($share_photo as $share_photo_data) { if ($photo_count >= $_FANWE['setting']['share_pic_count']) { break; } $is_rel_imgage = true; if ($share_photo_data['sort'] < $weibo_img_sort) { $weibo_img = FS("Image")->getImageUrl($share_photo_data['img'], 1); $weibo_img_sort = $share_photo_data['sort']; } $share_photo_data['uid'] = $_FANWE['uid']; $share_photo_data['share_id'] = $share_id; FDB::insert('share_photo', $share_photo_data, true); $photo_count++; } } $shop_ids = array(); $goods_count = 0; //保存分享的商品 if (isset($data['share_goods'])) { $share_goods = $data['share_goods']; foreach ($share_goods as $goods) { if ($goods_count >= $_FANWE['setting']['share_goods_count']) { break; } $shop_id = 0; if (!empty($goods['shop_url'])) { $shop_id = FDB::resultFirst('SELECT shop_id FROM ' . FDB::table('shop') . ' WHERE shop_url = \'' . $goods['shop_url'] . '\''); if (intval($shop_id) == 0) { $content_match .= $goods['shop_name']; $shop_logo['url'] = ''; if (!empty($goods['shop_logo'])) { if (FS("Image")->getIsServer() && !empty($goods['shop_server_code'])) { $server = FS("Image")->getServer($goods['shop_server_code']); if (!empty($server)) { $args = array(); $args['pic_url'] = $goods['shop_logo']; $server = FS("Image")->getImageUrlToken($args, $server, 1); $body = FS("Image")->sendRequest($server, 'saveshop', true); if (!empty($body)) { $shop_logo = unserialize($body); FS("Image")->setServerUploadCount($shop_logo['server_code']); $shop_logo['url'] = str_replace('./', './' . $shop_logo['server_code'] . '/', $shop_logo['url']); } } } else { $shop_logo = copyFile($goods['shop_logo'], 'shop', true); } } $shop_data['shop_name'] = $goods['shop_name']; $shop_data['shop_logo'] = $shop_logo['url']; $shop_data['server_code'] = $goods['shop_server_code']; $shop_data['shop_url'] = $goods['shop_url']; $shop_data['taoke_url'] = $goods['shop_taoke_url']; $shop_id = FDB::insert('shop', $shop_data, true); } if ($shop_id > 0) { $shop_ids[] = $shop_id; } } if (FS("Image")->getIsServer() && !empty($goods['server_code'])) { $server = FS("Image")->getServer($goods['server_code']); if (!empty($server)) { $server_args['share_id'] = $share_id; $server_args['img_path'] = $goods['img']; $server = FS("Image")->getImageUrlToken($server_args, $server, 1); $body = FS("Image")->sendRequest($server, 'saveshare', true); if (!empty($body)) { $goods_img = unserialize($body); FS("Image")->setServerUploadCount($goods_img['server_code']); $share_server_code[] = $goods_img['server_code']; $goods_img['url'] = str_replace('./', './' . $goods_img['server_code'] . '/', $goods_img['url']); $weibo_img_url = FS("Image")->getImageUrl($goods_img['url'], 1); } } } else { $goods_img = copyImage($goods['img'], array(), 'share', true, $share_id); $weibo_img_url = FS("Image")->getImageUrl($goods_img['url'], 1); } if (!empty($goods_img)) { if ($goods['sort'] < $weibo_img_sort) { $weibo_img = $weibo_img_url; $weibo_img_sort = $goods['sort']; } $shop_id = intval($shop_id); //开始保存分享的商品 $share_goods_data['uid'] = $_FANWE['uid']; $share_goods_data['share_id'] = $share_id; $share_goods_data['shop_id'] = $shop_id; $share_goods_data['img'] = $goods_img['url']; $share_goods_data['name'] = $goods['name']; $share_goods_data['url'] = $goods['url']; $share_goods_data['price'] = $goods['price']; $share_goods_data['sort'] = $goods['sort']; $share_goods_data['taoke_url'] = $goods['taoke_url']; $share_goods_data['goods_key'] = $goods['goods_key']; $share_goods_data['img_width'] = $goods_img['width']; $share_goods_data['img_height'] = $goods_img['height']; $share_goods_data['server_code'] = $goods['server_code']; FDB::insert('share_goods', $share_goods_data, true); $goods_tags = FS('Words')->segment($goods['name'], 10); if (!empty($goods_tags)) { $share_cates[] = ShareService::getCateByTags($goods_tags); } $content_match .= $goods['name']; $goods_count++; } } } //保存引用商品 if (isset($data['rel_goods'])) { $share_goods = $data['rel_goods']; foreach ($share_goods as $share_goods_data) { if ($goods_count >= $_FANWE['setting']['share_goods_count']) { break; } $is_rel_imgage = true; $shop_ids[] = $share_goods_data['shop_id']; if ($share_goods_data['sort'] < $weibo_img_sort) { $weibo_img = $weibo_img = FS("Image")->getImageUrl($share_goods_data['img'], 1); $weibo_img_sort = $share_goods_data['sort']; } $share_goods_data['uid'] = $_FANWE['uid']; $share_goods_data['share_id'] = $share_id; FDB::insert('share_goods', $share_goods_data, true); $goods_tags = FS('Words')->segment($goods['name'], 10); if (!empty($goods_tags)) { $share_cates[] = ShareService::getCateByTags($goods_tags); } $content_match .= $goods['name']; $goods_count++; } } if ($goods_count > 0 && $photo_count > 0) { $share_data_type = 'goods_photo'; } elseif ($goods_count > 0) { $share_data_type = 'goods'; } elseif ($photo_count > 0) { $share_data_type = 'photo'; } else { $share_data_type = 'default'; } $update_share = array(); $update_share['share_data'] = $share_data_type; if (count($share_server_code) > 0) { $share_server_code = array_unique($share_server_code); $update_share['server_code'] = implode(',', $share_server_code); } if ($share_album_id > 0 && in_array($share_data_type, array('goods', 'photo', 'goods_photo'))) { $album = FDB::fetchFirst('SELECT cid,id,title FROM ' . FDB::table('album') . ' WHERE id = ' . $share_album_id); if ($album) { $update_share['type'] = 'album_item'; $share_data_now_type = 'album_item'; $share_data_rec_id = $album['id']; $share_data_rec_cate = $album['cid']; $update_share['rec_id'] = $album['id']; $update_share['title'] = addslashes($album['title']); } else { $update_share['rec_id'] = 0; $share_data_rec_id = 0; } } else { $share_data_rec_id = 0; } FDB::update("share", $update_share, "share_id=" . $share_id); //更新会员统计 FDB::query('UPDATE ' . FDB::table('user_count') . ' SET shares = shares + 1,goods = goods + ' . $goods_count . ',photos = photos + ' . $photo_count . ' WHERE uid = ' . $share_data['uid']); FS('Medal')->runAuto($share_data['uid'], 'shares'); FS('User')->medalBehavior($share_data['uid'], 'continue_share'); switch ($share_data_type) { case 'goods_photo': FS('Medal')->runAuto($share_data['uid'], 'goods'); FS('User')->medalBehavior($share_data['uid'], 'continue_goods'); FS('Medal')->runAuto($share_data['uid'], 'photos'); FS('User')->medalBehavior($share_data['uid'], 'continue_photo'); break; case 'goods': FS('Medal')->runAuto($share_data['uid'], 'goods'); FS('User')->medalBehavior($share_data['uid'], 'continue_goods'); break; case 'photo': FS('Medal')->runAuto($share_data['uid'], 'photos'); FS('User')->medalBehavior($share_data['uid'], 'continue_photo'); break; } if (in_array($share_data_type, array('goods', 'photo', 'goods_photo'))) { //更新会员发布的有图分享编号 //FS('User')->setShareIds($share_data['uid'],$share_id); if (!empty($share_cates)) { $cids = ShareService::getCidsByCates($share_cates); } if (!empty($data['share_tag'])) { if (empty($cids)) { $share_cates = array(); $share_cates[] = ShareService::getCateByTags($data['share_tag']); $cids = ShareService::getCidsByCates($share_cates); } //$content_match = array_merge($content_match, $data['share_tag']); } //保存标签 $share_tags = array(); foreach ($data['share_tag'] as $tag) { if (trim($tag) != '' && !in_array($tag, $share_tags)) { array_push($share_tags, $tag); //为已存在的tags更新统计 FDB::query('UPDATE ' . FDB::table('goods_tags') . ' SET count = count + 1 WHERE tag_name = \'' . $tag . '\''); //数量大于100时为热门标签 FDB::query('UPDATE ' . FDB::table('goods_tags') . ' SET is_hot = 1 WHERE tag_name = \'' . $tag . '\' AND count >= 100'); $content_match .= $tag; $tag_data = array(); $tag_data['share_id'] = $share_id; $tag_data['tag_name'] = $tag; FDB::insert('share_tags', $tag_data); } } unset($share_tags); if (!empty($cids)) { foreach ($cids as $cid) { $cate_data = array(); $cate_data['share_id'] = $share_id; $cate_data['cate_id'] = $cid; FDB::insert('share_category', $cate_data); } } //保存匹配查询 $share_match['share_id'] = $share_id; $share_match['content_match'] = segmentToUnicode(clearSymbol($content_match)); FDB::insert("share_match", $share_match); } ShareService::updateShareCache($share_id); if ($share_data_rec_id > 0) { $album_share = array(); $album_share['album_id'] = $share_data_rec_id; $album_share['share_id'] = $share_id; $album_share['cid'] = $share_data_rec_cate; $album_share['create_day'] = getTodayTime(); FDB::insert("album_share", $album_share); FS('Album')->updateAlbumByShare($share_data_rec_id, $share_id); FS('Album')->updateAlbum($share_data_rec_id); } if (count($shop_ids) > 0) { FS("Shop")->updateShopStatistic($shop_ids); } //保存提到我的 $atme_share_type = FDB::resultFirst("select `type` from " . FDB::table("share") . " where `share_id`='" . $share_id . "'"); if ($atme_share_type != "fav") { $atme_list = array(); $pattern = "/@([^\f\n\r\t\v@ ]{2,20}?)(?:\\:| )/"; preg_match_all($pattern, $share_data['content'], $atme_list); if (!empty($atme_list[1])) { $atme_list[1] = array_unique($atme_list[1]); $users = array(); foreach ($atme_list[1] as $user) { if (!empty($user)) { $users[] = $user; } } $res = FDB::query('SELECT uid FROM ' . FDB::table('user') . ' WHERE user_name ' . FDB::createIN($users)); while ($data = FDB::fetch($res)) { FS("User")->setUserTips($data['uid'], 4, $share_id); } } } if ($is_score && !in_array($share_data_now_type, array('fav', 'album_best', 'album_rec'))) { if (!$is_rel_imgage && in_array($share_data_type, array('goods', 'photo', 'goods_photo'))) { FS("User")->updateUserScore($share_data['uid'], 'share', 'image', $share_data['content'], $share_id); } else { FS("User")->updateUserScore($share_data['uid'], 'share', 'default', $share_data['content'], $share_id); } } if ($data['pub_out_check']) { $weibo = array(); $weibo['content'] = $share_data['content']; $weibo['img'] = $weibo_img; $weibo['ip'] = $_FANWE['client_ip']; $weibo['url'] = $_FANWE['site_url'] . FU('note/index', array('sid' => $share_id)); $weibo['url'] = str_replace('//', '/', $weibo['url']); $weibo['url'] = str_replace(':/', '://', $weibo['url']); $weibo = base64_encode(serialize($weibo)); if (empty($share_data['type'])) { $share_data['type'] = 'default'; } //转发到外部微博 $uid = $_FANWE['uid']; $user_binds = FS("User")->getUserBindList($uid); $is_open = false; foreach ($user_binds as $class => $bind) { if ($bind['sync'] && file_exists(FANWE_ROOT . "login/" . $class . ".php")) { $check_field = ""; if (in_array($share_data['type'], array('bar', 'ask'))) { $check_field = "topic"; } elseif ($share_data['type'] == 'default') { $check_field = "weibo"; } if ($bind['sync'][$check_field] == 1) { $is_open = true; //开始推送 $schedule['uid'] = $uid; $schedule['type'] = $class; $schedule['data'] = $weibo; $schedule['pub_time'] = TIME_UTC; FDB::insert('pub_schedule', $schedule, true); } } } if ($is_open) { $fp = fsockopen($_SERVER['HTTP_HOST'], 80, &$errno, &$errstr, 5); if ($fp) { $request = "GET " . SITE_URL . "login.php?loop=true&uid=" . $uid . " HTTP/1.0\r\n"; $request .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($fp, $request); while (!feof($fp)) { fgets($fp, 128); break; } fclose($fp); } } } } else { $result['status'] = false; } return $result; }
/** * 发送信息 * @param int $fuid 发信会员编号 * @param string $fusername 发信会员名称 * @param array $tuids 收信会员编号数组 * @param string $subject 信件主题 * @param string $message 信件内容 * @param int $type 信件类型 * @return int */ public function sendMsg($fuid, $fusername, $tuids, $subject, $message, $type = 0) { if (empty($fuid) || empty($fusername) || empty($tuids) || empty($message)) { return 0; } //清除重复会员编号 $tuids = array_unique($tuids); $relations = $mlids = array(); $tmp_tuids = $tuids; foreach ($tmp_tuids as $key => $uid) { if ($fuid == $uid || empty($uid)) { unset($tuids[$key]); continue; } $relations[$uid] = MessageService::getRelation($fuid, $uid); } if (empty($tuids)) { return MSG_SEND_NONE_ERROR; } if (!$subject) { $subject = htmlspecialchars(cutStr(clearExpress(trim($message)), 80)); } else { $subject = htmlspecialchars($subject); } $last_msg = htmlspecialchars(cutStr(clearExpress(trim($message)), 150)); $type = 0; if ($type == 0) { $res = FDB::query('SELECT mlid,min_max FROM ' . FDB::table('user_msg_list') . " WHERE min_max" . FDB::createIN($relations)); while ($data = FDB::fetch($res)) { $mlids[$data['min_max']] = $data['mlid']; } $msg_config = array('last_uid' => $fuid, 'last_user_name' => $fusername, 'last_msg' => $last_msg); $msg_config = addslashes(serialize($msg_config)); foreach ($relations as $key => $value) { if (!isset($mlids[$value])) { FDB::query("INSERT INTO " . FDB::table('user_msg_list') . "(uid,type,subject,members,min_max,dateline,msg_config) VALUES('{$fuid}', '1', '{$subject}', 2, '{$value}', '" . TIME_UTC . "', '{$msg_config}')"); $mlid = FDB::insertId(); FDB::query("INSERT INTO " . FDB::table('user_msg_index') . "(mlid) VALUES('{$mlid}')"); $miid = FDB::insertId(); FDB::query("INSERT INTO " . MessageService::getTablaName($mlid) . "(miid,mlid,uid,message,dateline,status) VALUES('{$miid}', '{$mlid}', '{$fuid}', '{$message}', '" . TIME_UTC . "', 0)"); FDB::query("INSERT INTO " . FDB::table('user_msg_member') . "(mlid, uid, is_new, num, last_update, last_dateline) VALUES('{$mlid}', '{$key}', '1', '1', '0', '" . TIME_UTC . "')"); FDB::query("INSERT INTO " . FDB::table('user_msg_member') . "(mlid, uid, is_new, num, last_update, last_dateline) VALUES('{$mlid}', '{$fuid}', '0', '1', '" . TIME_UTC . "', '" . TIME_UTC . "')"); } else { $mlid = $mlids[$value]; FDB::query("INSERT INTO " . FDB::table('user_msg_index') . "(mlid) VALUES('{$mlid}')"); $miid = FDB::insertId(); FDB::query("INSERT INTO " . MessageService::getTablaName($mlid) . "(miid,mlid,uid,message,dateline,status) VALUES('{$miid}', '{$mlid}', '{$fuid}', '{$message}', '" . TIME_UTC . "', 0)"); $result = FDB::query("INSERT INTO " . FDB::table('user_msg_member') . "(mlid, uid, is_new, num, last_update, last_dateline) VALUES('{$mlid}', '{$key}', '1', '1', '0', '" . TIME_UTC . "')", 'SILENT'); if (!$result) { FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new = 1, num = num + 1, last_dateline='" . TIME_UTC . "' WHERE mlid='{$mlid}' AND uid='{$key}'"); } $result = FDB::query("INSERT INTO " . FDB::table('user_msg_member') . "(mlid, uid, is_new, num, last_update, last_dateline) VALUES('{$mlid}', '{$fuid}', '0', '1', '" . TIME_UTC . "', '" . TIME_UTC . "')", 'SILENT'); if (!$result) { FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new = 1, num = num + 1, last_update='" . TIME_UTC . "', last_dateline='" . TIME_UTC . "' WHERE mlid='{$mlid}' AND uid='{$fuid}'"); } FDB::query("UPDATE " . FDB::table('user_msg_list') . " SET msg_config='{$msg_config}' WHERE mlid='{$mlid}'"); } } } else { } foreach ($tuids as $uid) { $result = FDB::query("INSERT INTO " . FDB::table('user_notice') . "(uid, type, num, create_time) VALUES('{$uid}',5,1,'" . TIME_UTC . "')", 'SILENT'); if (!$result) { FDB::query("UPDATE " . FDB::table('user_notice') . " SET num = num + 1, create_time='" . TIME_UTC . "' WHERE uid='{$uid}' AND type=5"); } } return $miid; }
GROUP BY parent_id ORDER BY parent_id DESC LIMIT ' . $limit; $next_sql = 'SELECT parent_id FROM ' . FDB::table("share") . ' WHERE type = \'fav\' AND uid = ' . $home_uid . ' GROUP BY parent_id ORDER BY parent_id DESC LIMIT ' . $next_limit; $res = FDB::query($sql); while ($data = FDB::fetch($res)) { $fav_share_ids[] = $data['parent_id']; } $share_list = array(); if (count($fav_share_ids) > 0) { $sql = 'SELECT * FROM ' . FDB::table("share") . ' WHERE share_id ' . FDB::createIN($fav_share_ids) . ' and share_data <> ' . " 'default' \r\n\t\t\t\tGROUP BY share_id ORDER BY share_id DESC LIMIT 0,10"; $share_list = FDB::fetchAll($sql); $share_list = FS('Share')->getShareDetailList($share_list, true, true, true); } $hasNextPage = FDB::fetchAll($next_sql); if ($hasNextPage) { $is_next = 1; } else { $is_next = 0; } $share_list = FDB::fetchAll($sql); $scale = 1; if ($share_list) { $share_list = FS('Share')->getShareDetailList($share_list, false, false, false, true, 2); $list = array(); $current_user = array();
function m_express($content) { global $_FANWE; $express = getCache('m_emotion_express_cache'); //缓存过的表情hash if (!$express) { $express_rs = FDB::fetchAll("select `emotion`,concat('" . $_FANWE['site_url'] . "public/expression/',`type`,'/',`filename`) as fname from " . FDB::table('expression')); foreach ($express_rs as $k => $row) { $express[0][] = $row['emotion']; $express[1][] = "<img src='" . $row['fname'] . "' title='" . preg_replace("/[\\[\\]]/", '', $row['emotion']) . "' />"; } setCache('m_emotion_express_cache', $express); } $content = str_replace($express[0], $express[1], $content); $parse_user = array(); preg_match_all("/@([^\f\n\r\t\v@<> ]{2,20}?)(?:\\:| )/", $content, $users); if (!empty($users[1])) { $patterns = array(); $replace = array(); $users = array_unique($users[1]); $arr = array(); foreach ($users as $user) { if (!empty($user)) { $arr[] = addslashes($user); } } $res = FDB::query('SELECT uid,user_name FROM ' . FDB::table('user') . ' WHERE user_name ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { $parse_user[$data['user_name']] = $data['uid']; } } $parse_events = array(); preg_match_all("/#([^\f\n\r\t\v]{1,80}?)#/", $content, $events); if (!empty($events[1])) { $patterns = array(); $replace = array(); $events = array_unique($events[1]); $arr = array(); foreach ($events as $event) { if (!empty($event)) { $arr[] = addslashes($event); } } $res = FDB::query('SELECT id,title FROM ' . FDB::table('event') . ' WHERE title ' . FDB::createIN($arr)); while ($data = FDB::fetch($res)) { $parse_events[$data['title']] = $data['id']; } } return array("users" => $parse_user, "events" => $parse_events); }