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;
        $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);
    }
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     //未登陆直接退出
     if ($_FANWE['uid'] == 0) {
         $root['status'] = -1;
         m_display($root);
     }
     $share_id = (int) $_FANWE['requestData']['share_id'];
     //没有分享ID直接退出
     if ($share_id == 0) {
         $root['status'] = -2;
         m_display($root);
     }
     $share = FS('Share')->getShareById($share_id);
     //没有分享直接退出
     if (empty($share)) {
         $root['status'] = -3;
         m_display($root);
     }
     $check_result = FS('Share')->checkWord($_FANWE['requestData']['content'], 'content');
     if ($check_result['error_code'] == 1) {
         $root['status'] = -4;
         $root['error'] = $check_result['error_msg'];
         m_display($root);
     }
     $comment_id = FS('Share')->saveComment($_FANWE['requestData']);
     $comment = FS('Share')->getShareComment($comment_id);
     $comment['time'] = getBeforeTimelag($comment['create_time']);
     $parses = m_express(&$item['content']);
     $comment['parse_users'] = $parses['users'];
     $comment['parse_events'] = $parses['events'];
     $comment['user_name'] = $_FANWE['user_name'];
     $comment['user_avatar'] = $_FANWE['user_avatar'];
     $root['status'] = 1;
     $root['item'] = $comment;
     m_display($root);
 }
/**
 * 分享列表详细数据
 * @param array $list 分享列表
 * @param bool $is_parent 是否获取转发信息
 * @param bool $is_collect 是否获取喜欢的会员
 * @param bool $is_parent 是否获取分享标签
 * @return array
 */
function mGetShareDetailList($list, $is_parent = false, $img_width = 160, $img_height = 160)
{
    global $_FANWE;
    $shares = array();
    $share_ids = array();
    $rec_shares_ids = array();
    $share_users = array();
    foreach ($list as $item) {
        $share_id = $item['share_id'];
        if ($item['share_data'] == 'default') {
            continue;
        }
        $share_ids[] = $share_id;
        $item['cache_data'] = fStripslashes(unserialize($item['cache_data']));
        $item['time'] = getBeforeTimelag($item['create_time']);
        $item['url'] = FU('note/index', array('sid' => $share_id), true);
        if ($item['source'] == 'web') {
            $item['source'] = $_FANWE['setting']['site_name'] . '网站';
        }
        $item['imgs'] = array();
        $img = array();
        $img_sql = 'select photo_id,img,img_width,img_height from ' . FDB::table('share_photo') . ' where share_id = ' . $share_id;
        $img_data = FDB::fetchFirst($img_sql);
        $img['share_id'] = $share_id;
        $img['id'] = $img_data['photo_id'];
        $img['name'] = '';
        $img['type'] = '';
        $img['price'] = '';
        $img['goods_url'] = '';
        $img['taoke_url'] = '';
        $img['price_format'] = '';
        $img['server_code'] = '';
        $img['img_width'] = $img_data['img_width'];
        $img['img'] = FS("Image")->getImageUrl($img_data['img'], 2);
        $img['img_height'] = $img_data['img_height'];
        $img['width'] = 160;
        $img['small_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], 160, 160, 0, true), 2);
        $item['imgs'][] = $img;
        m_express(&$item, $item['content']);
        $shares[$share_id] = $item;
        unset($shares[$share_id]['cache_data']);
        $shares[$share_id]['user'] =& $share_users[$item['uid']];
        $shares[$share_id]['is_relay'] = false;
        $shares[$share_id]['is_parent'] = false;
        if ($is_parent) {
            if ($item['base_id'] > 0) {
                $shares[$share_id]['is_relay'] = true;
                $rec_shares_ids[$item['base_id']] = false;
                $shares[$share_id]['relay_share'] =& $rec_shares_ids[$item['base_id']];
            } elseif ($item['parent_id'] > 0 && $item['parent_id'] != $item['base_id']) {
                $shares[$share_id]['is_parent'] = true;
                $rec_shares_ids[$item['parent_id']] = false;
                $shares[$share_id]['parent_share'] =& $rec_shares_ids[$item['parent_id']];
            }
        }
    }
    $rec_ids = array_keys($rec_shares_ids);
    if (count($rec_ids) > 0) {
        $intersects = array_intersect($share_ids, $rec_ids);
        $temp_ids = array();
        foreach ($intersects as $share_id) {
            $rec_shares_ids[$share_id] = $shares[$share_id];
            $temp_ids[] = $share_id;
        }
        $diffs = array_diff($rec_ids, $temp_ids);
        if (count($diffs) > 0) {
            $res = FDB::query('SELECT * FROM ' . FDB::table('share') . ' WHERE share_id IN (' . implode(',', $diffs) . ')');
            while ($item = FDB::fetch($res)) {
                $share_id = $item['share_id'];
                $share_ids[] = $share_id;
                $item['cache_data'] = fStripslashes(unserialize($item['cache_data']));
                $item['time'] = getBeforeTimelag($item['create_time']);
                $item['url'] = FU('note/index', array('sid' => $share_id), true);
                if ($item['source'] == 'web') {
                    $item['source'] = $_FANWE['setting']['site_name'] . '网站';
                }
                m_express(&$item, $item['content']);
                $item['imgs'] = array();
                $img = array();
                $img_sql = 'select photo_id,img,img_width,img_height from ' . FDB::table('share_photo') . ' where share_id = ' . $share_id;
                $img_data = FDB::fetchFirst($img_sql);
                $img['share_id'] = $share_id;
                $img['id'] = $img_data['photo_id'];
                $img['name'] = '';
                $img['type'] = '';
                $img['price'] = '';
                $img['goods_url'] = '';
                $img['taoke_url'] = '';
                $img['price_format'] = '';
                $img['server_code'] = '';
                $img['img_width'] = $img_data['img_width'];
                $img['img'] = FS("Image")->getImageUrl($img_data['img'], 2);
                $img['img_height'] = $img_data['img_height'];
                $img['width'] = 160;
                $img['small_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], 160, 160, 0, true), 2);
                $item['imgs'][] = $img;
                $rec_shares_ids[$share_id] = $item;
                unset($rec_shares_ids[$share_id]['cache_data']);
                $rec_shares_ids[$share_id]['user'] =& $share_users[$item['uid']];
            }
        }
    }
    $user_ids = array_keys($share_users);
    if (count($user_ids) > 0) {
        $res = FDB::query("SELECT uid,user_name,server_code FROM " . FDB::table('user') . ' WHERE uid IN (' . implode(',', $user_ids) . ')');
        while ($item = FDB::fetch($res)) {
            $item['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($item['uid'], 'm', 1), 2);
            $share_users[$item['uid']] = $item;
        }
    }
    return $shares;
}
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     if ($_FANWE['uid'] == 0) {
         exit;
     }
     //print_r($_FANWE['requestData']); exit;
     $mlid = (int) $_FANWE['requestData']['lid'];
     $mid = (int) $_FANWE['requestData']['mid'];
     if ($mlid == 0 && $mid == 0) {
         exit;
     }
     if ($mlid > 0) {
         $mlist = FS('Message')->getListByMlid($mlid, $_FANWE['uid']);
         if (empty($mlist)) {
             exit;
         }
         $act2 = $_FANWE['requestData']['act_2'];
         if ($act2 == 'reply') {
             $message = trim($_FANWE['requestData']['message']);
             if (!empty($message)) {
                 $message = cutStr($message, 200);
                 if (FS('Message')->replyMsg($mlid, $_FANWE['uid'], $_FANWE['user_name'], $message) > 0) {
                     $mlist['num']++;
                 }
             }
         }
         $root['lid'] = $mlid;
         $page = (int) $_FANWE['requestData']['page'];
         $page = max(1, $page);
         $total = $mlist['num'];
         $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;
         $root['page'] = array("page" => $page, "page_total" => $page_total);
         $tuser = FS('User')->getUserById($mlist['tuid']);
         $tuser['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($tuser['uid'], 'm', 1), 2);
         //$root['title'] = "共有{$total}封与{$tuser['user_name']}的交流信件";
         $root['title'] = "与{$tuser['user_name']}的交流";
         $root['t_name'] = $tuser['user_name'];
         $msg_list = FS('Message')->getMsgsByMlid($mlid, $_FANWE['uid'], $limit);
         foreach ($msg_list as $msg) {
             if ($msg['uid'] == $_FANWE['uid']) {
                 $user = $_FANWE['user'];
                 $user['user_name'] = '我';
                 $msg['tuid'] = $mlist['tuid'];
                 $msg['tuser_name'] = $tuser['user_name'];
                 $msg['tuser_avatar'] = $tuser['user_avatar'];
             } else {
                 $user = $tuser;
                 $msg['tuid'] = $_FANWE['uid'];
                 $msg['tuser_name'] = '我';
                 $msg['tuser_avatar'] = $_FANWE['user']['user_avatar'];
             }
             $msg['content'] = $msg['message'];
             $msg['user_name'] = $user['user_name'];
             $msg['user_avatar'] = $user['user_avatar'];
             m_express(&$msg, $msg['message']);
             $root['msg_list'][] = $msg;
         }
     } elseif ($mid) {
         $msg = FS('Message')->getSysMsgByMid($_FANWE['uid'], $mid);
         $msg['time'] = getBeforeTimelag($msg['dateline']);
         $msg['message'] = str_replace('href="/', 'href="' . $_FANWE['site_url'], $msg['message']);
         $root['msg'] = $msg;
     }
     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 ($uid == $_FANWE['uid']) {
            FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='{$uid}' AND type=2");
        }
        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'] = FS("Image")->getImageUrl('.' . avatar($uid, 'm', 1), 2);
        }
        $page = (int) $_FANWE['requestData']['page'];
        $page = max(1, $page);
        $is_spare_flow = (int) $_FANWE['requestData']['is_spare_flow'];
        $img_width = 200;
        $max_height = 400;
        $scale = 2;
        if ($is_spare_flow == 1) {
            $img_width = 100;
            $scale = 1;
        }
        $sql = 'SELECT COUNT(DISTINCT share_id) FROM ' . FDB::table("user_collect") . ' 
			WHERE c_uid = ' . $uid;
        $total = FDB::resultFirst($sql);
        $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;
        $sql = 'SELECT DISTINCT(s.share_id),s.cache_data,s.collect_count,s.comment_count,s.content,u.user_name,u.server_code 
				FROM ' . FDB::table("user_collect") . ' AS uc 
				INNER JOIN ' . FDB::table("share") . ' as s on s.share_id=uc.share_id 
				INNER JOIN ' . FDB::table("user") . ' as u on u.uid=uc.uid  
				WHERE uc.c_uid = ' . $uid . ' 
				ORDER BY s.share_id DESC LIMIT ' . $limit;
        $res = FDB::query($sql);
        $share_list = array();
        while ($data = FDB::fetch($res)) {
            $img_sql = 'select img,img_width,img_height from ' . FDB::table('share_photo') . " where share_id = " . $data['share_id'];
            $img_data = FDB::fetchFirst($img_sql);
            unset($data['cache_data']);
            $data['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($data['uid'], 'm', 1), 2);
            $data['img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], $img_width, $max_height, 2, true), 2);
            $data['big_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], 468, 468, 1, true), 2);
            $data['height'] = $img_data['img_height'] * ($img_width / $img_data['img_width']);
            $data['height'] = $data['height'] > $max_height ? $max_height : $data['height'];
            $data['height'] = round($data['height'] / $scale);
            $data['width'] = $img_data['img_width'];
            m_express(&$data, $data['content']);
            $share_list[] = $data;
        }
        $root['return'] = 1;
        $root['item'] = $share_list;
        $root['page'] = array("page" => $page, "page_total" => $page_total);
        m_display($root);
    }
 public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     if ($_FANWE['uid'] == 0) {
         exit;
     }
     $page = (int) $_FANWE['requestData']['page'];
     $page = max(1, $page);
     $total = FS('Message')->getMsgCount($_FANWE['uid']);
     $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;
     if ($page == 1) {
         $sys_msgs = FS('Message')->getSysMsgs($_FANWE['uid']);
         foreach ($sys_msgs as $msg) {
             unset($msg['message']);
             $msg['time'] = getBeforeTimelag($msg['dateline']);
             $root['sys_msgs'][] = $msg;
         }
         $sys_notices = FS('Notice')->getList($_FANWE['uid']);
         foreach ($sys_notices as $msg) {
             $msg['content'] = str_replace('href="/', 'href="' . $_FANWE['site_url'], $msg['content']);
             $msg['time'] = getBeforeTimelag($msg['create_time']);
             $root['sys_notices'][] = $msg;
         }
     }
     $msg_list = FS('Message')->getMsgList($_FANWE['uid'], $limit);
     //print_r($msg_list);exit;
     foreach ($msg_list as $msg) {
         $data = array();
         $data['content'] = $msg['message'];
         if ($msg['msg_fuid'] == $_FANWE['uid']) {
             $data['uid'] = $_FANWE['uid'];
             $data['user_name'] = '我';
             $data['user_avatar'] = $_FANWE['user']['user_avatar'];
             $data['tuid'] = $msg['msg_tuser']['uid'];
             $data['tuser_name'] = $msg['msg_tuser']['user_name'];
             $data['tuser_avatar'] = avatar($data['tuid'], 'm', $msg['msg_tuser']['server_code'], 1, true);
         } else {
             $data['uid'] = $msg['msg_tuser']['uid'];
             $data['user_name'] = $msg['msg_tuser']['user_name'];
             $data['user_avatar'] = avatar($data['uid'], 'm', $msg['msg_tuser']['server_code'], 1, true);
             $data['tuid'] = $_FANWE['uid'];
             $data['tuser_name'] = '我';
             $data['tuser_avatar'] = $_FANWE['user']['user_avatar'];
         }
         $data['time'] = getBeforeTimelag($msg['last_update']);
         $data['mlid'] = $msg['mlid'];
         $data['msg_count'] = $msg['num'];
         m_express(&$data, $msg['message']);
         $root['msg_list'][] = $data;
     }
     FDB::query("DELETE FROM " . FDB::table('user_notice') . " WHERE uid='" . $_FANWE['uid'] . "' AND type=5");
     $root['page'] = array("page" => $page, "page_total" => $page_total);
     m_display($root);
 }
    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $share_id = (int) $_FANWE['requestData']['share_id'];
        $act2 = $_FANWE['requestData']['act_2'];
        $share = FS('Share')->getShareById($share_id);
        $max_width = 320;
        $max_height = 234;
        $scale = 2;
        if ($share) {
            switch ($act2) {
                case 'follow':
                    if ($_FANWE['uid'] > 0) {
                        FS('User')->followUser($share['uid']);
                    }
                    break;
                case 'collect':
                    if ($_FANWE['uid'] > 0 && $share['uid'] != $_FANWE['uid']) {
                        if (FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid'])) {
                            FS('Share')->deleteShareCollectUser($share_id, $_FANWE['uid']);
                        } else {
                            FS('Share')->saveFav($share);
                        }
                        $share = FDB::fetchFirst('SELECT * FROM ' . FDB::table('share') . ' WHERE share_id = ' . $share_id);
                    }
                    break;
            }
            $cache_data = fStripslashes(unserialize($share['cache_data']));
            unset($share['cache_data']);
            $share['prev_share'] = (int) FDB::resultFirst('SELECT share_id FROM ' . FDB::table('share') . ' 
				WHERE share_id < ' . $share_id . " AND share_data IN ('goods','photo','goods_photo') ORDER BY share_id DESC LIMIT 1");
            $share['next_share'] = (int) FDB::resultFirst('SELECT share_id FROM ' . FDB::table('share') . ' 
				WHERE share_id > ' . $share_id . " AND share_data IN ('goods','photo','goods_photo') ORDER BY share_id ASC LIMIT 1");
            $share['time'] = getBeforeTimelag($share['create_time']);
            $share['url'] = FU('note/index', array('sid' => $share_id), true);
            $site_url = ';网址:' . $share['url'];
            $root['share_content'] = cutStr($share['content'], 140 - getStrLen($site_url) - 3) . $site_url;
            m_express(&$share, $share['content']);
            $share_user = FS('User')->getUserById($share['uid']);
            $share['user_name'] = $share_user['user_name'];
            $share['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($share_user['uid'], 'm', 1), 2);
            if ($share['source'] == 'web') {
                $share['source'] = $_FANWE['setting']['site_name'] . '网站';
            }
            if ($_FANWE['uid'] == $share['uid']) {
                $share['is_follow_user'] = -1;
                $share['is_collect_share'] = -1;
            } else {
                if (FS('User')->getIsFollowUId($share['uid'], false)) {
                    $share['is_follow_user'] = 1;
                } else {
                    $share['is_follow_user'] = 0;
                }
                if (FS('Share')->getIsCollectByUid($share_id, $_FANWE['uid'])) {
                    $share['is_collect_share'] = 1;
                } else {
                    $share['is_collect_share'] = 0;
                }
            }
            $share['comments'] = array();
            $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);
            $limit = "0," . $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'] = FS("Image")->getImageUrl('.' . avatar($item['uid'], 'm', 1), 2);
                $item['time'] = getBeforeTimelag($item['create_time']);
                m_express(&$item, $item['content']);
                $share['comments']['list'][] = $item;
            }
            $share['comments']['page'] = array("page" => 1, "page_total" => $page_total);
            $share['collects'] = array();
            if (!empty($cache_data['collects'])) {
                $collect_ids = array_slice($cache_data['collects'], 0, 20);
                if ($share['is_follow_user'] == 1) {
                    if ($ckey = array_search($_FANWE['uid'], $collect_ids) === FALSE) {
                        array_unshift($collect_ids, $_FANWE['uid']);
                        array_pop($collect_ids);
                    } else {
                        unset($collect_ids[$ckey]);
                        array_unshift($collect_ids, $_FANWE['uid']);
                    }
                }
                $collect_ids = implode(',', $collect_ids);
                $res = FDB::query("SELECT uid,user_name,server_code FROM " . FDB::table('user') . ' 
					WHERE uid IN (' . $collect_ids . ')');
                while ($item = FDB::fetch($res)) {
                    $item['user_avatar'] = FS("Image")->getImageUrl('.' . avatar($item['uid'], 'm', 1), 2);
                    unset($item['server_code']);
                    $share['collects'][] = $item;
                }
            }
            $share['imgs'] = array();
            $img = array();
            $img_sql = 'select photo_id,img,img_width,img_height from ' . FDB::table('share_photo') . ' where share_id = ' . $share_id;
            $img_data = FDB::fetchFirst($img_sql);
            $img['share_id'] = $share_id;
            $img['id'] = $img_data['photo_id'];
            $img['name'] = '';
            $img['type'] = '';
            $img['price'] = '';
            $img['goods_url'] = '';
            $img['taoke_url'] = '';
            $img['price_format'] = '';
            $img['server_code'] = '';
            if ($img_data['img_width'] > $img_data['img_height']) {
                if ($img_data['img_width'] > $max_width) {
                    $img['img_width'] = $max_width;
                    $img['img_height'] = $img_data['img_height'] * ($max_width / $img_data['img_width']);
                }
            } else {
                if ($img_data['img_height'] > $max_height) {
                    $img['img_height'] = $max_height;
                    $img['img_width'] = $img_data['img_width'] * ($max_height / $img_data['img_height']);
                }
            }
            $img['img'] = FS("Image")->getImageUrl($img_data['img'], 2);
            $img['small_img'] = FS("Image")->getImageUrl(getImgName($img_data['img'], $img['img_width'], $img['img_height'], 0, true), 2);
            $share['imgs'][] = $img;
        }
        $root['item'] = $share;
        m_display($root);
    }
    public function run()
    {
        global $_FANWE;
        $root = array();
        $root['return'] = 1;
        $share_id = (int) $_FANWE['requestData']['share_id'];
        $share = FS('Share')->getShareById($share_id);
        if ($share) {
            $cache_data = fStripslashes(unserialize($share['cache_data']));
            unset($share['cache_data']);
            $share['time'] = getBeforeTimelag($share['create_time']);
            $share['url'] = FU('note/index', array('sid' => $share_id), true);
            $parses = m_express(&$share['content']);
            $share['parse_users'] = $parses['users'];
            $share['parse_events'] = $parses['events'];
            $share_user = FS('User')->getUserById($share['uid']);
            $share['user_name'] = $share_user['user_name'];
            $share['user_avatar'] = avatar($share_user['uid'], 'm', $share_user['server_code'], 1, true);
            if ($_FANWE['uid'] == $share['uid']) {
                $share['is_follow_user'] = -1;
            } else {
                if (FS('User')->getIsFollowUId($share['uid'])) {
                    $share['is_follow_user'] = 1;
                } else {
                    $share['is_follow_user'] = 0;
                }
            }
            $share['collects'] = array();
            if (!empty($cache_data['collects'])) {
                $collect_ids = array_slice($cache_data['collects'], 0, 20);
                if ($share['is_follow_user'] == 1) {
                    if ($ckey = array_search($_FANWE['uid'], $collect_ids) === FALSE) {
                        array_unshift($collect_ids, $_FANWE['uid']);
                        array_pop($collect_ids);
                    } else {
                        unset($collect_ids[$ckey]);
                        array_unshift($collect_ids, $_FANWE['uid']);
                    }
                }
                $collect_ids = implode(',', $collect_ids);
                $res = FDB::query("SELECT uid,user_name,server_code FROM " . FDB::table('user') . ' 
					WHERE uid IN (' . $collect_ids . ')');
                while ($item = FDB::fetch($res)) {
                    $item['user_avatar'] = avatar($item['uid'], 'm', $item['server_code'], 1, true);
                    unset($item['server_code']);
                    $share['collects'][] = $item;
                }
            }
            $share['imgs'] = array();
            if (!empty($cache_data['imgs'])) {
                foreach ($cache_data['imgs']['all'] as $img) {
                    if ($img['type'] == 'g') {
                        $img['goods_url'] = $img['url'];
                        $img['price_format'] = priceFormat($img['price']);
                    } else {
                        $img['name'] = '';
                        $img['price'] = '';
                        $img['goods_url'] = '';
                        $img['taoke_url'] = '';
                        $img['price_format'] = '';
                    }
                    unset($img['url']);
                    $img['small_img'] = getImgName($img['img'], 468, 468, 0, true);
                    $share['imgs'][] = $img;
                }
            }
        }
        $root['item'] = $share;
        m_display($root);
    }