function wp_connect_comment($id)
{
    global $siteurl, $post, $wptm_options, $wptm_connect, $wptm_advanced;
    $post_id = $_POST['comment_post_ID'] ? $_POST['comment_post_ID'] : $post->ID;
    if (!$post_id) {
        return;
    }
    @ini_set("max_execution_time", 60);
    $comments = get_comment($id);
    $user_id = $comments->user_id;
    $comment_content = wp_replace($comments->comment_content);
    $parent_id = $comments->comment_parent;
    if ($user_id) {
        if ($parent_id) {
            $comment_parent = get_comment($parent_id);
            $parent_uid = $comment_parent->user_id;
            $name = get_user_meta($parent_uid, 'login_name', true);
        }
        $tid = $_POST['sync_comment'];
        if ($tid) {
            if (!is_object($post)) {
                $post = get_post($post_id);
            }
            $url = get_permalink($post_id) . '#comment-' . $id;
            if ($wptm_options['t_cn']) {
                $url = get_t_cn(urlencode($url));
            }
            $title = wp_replace($post->post_title);
            $username = get_user_meta($user_id, 'login_name', true);
            require_once dirname(__FILE__) . '/OAuth/OAuth.php';
            if ($tid == 'stid') {
                $login = get_user_meta($user_id, 'login_sina', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('sinaOAuth')) {
                        include dirname(__FILE__) . '/OAuth/sina_OAuth.php';
                    }
                    $to = new sinaClient(SINA_APP_KEY, SINA_APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['sina'], $username['sina'], $wptm_connect['sina_username'], $comment_content);
                    //return var_dump($content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, urlencode($url), 140, 1);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'qtid') {
                $login = get_user_meta($user_id, 'login_qq', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('qqOAuth')) {
                        include dirname(__FILE__) . '/OAuth/qq_OAuth.php';
                    }
                    $to = new qqClient(QQ_APP_KEY, QQ_APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['qq'], $username['qq'], $wptm_connect['qq_username'], $comment_content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, $url, 140, 1);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'ntid') {
                $login = get_user_meta($user_id, 'login_netease', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('neteaseOAuth')) {
                        include dirname(__FILE__) . '/OAuth/netease_OAuth.php';
                    }
                    $to = new neteaseClient(APP_KEY, APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['netease'], $username['netease'], $wptm_connect['netease_username'], $comment_content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, $url, 163);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'shtid') {
                $login = get_user_meta($user_id, 'login_sohu', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('sohuOAuth')) {
                        include dirname(__FILE__) . '/OAuth/sohu_OAuth.php';
                    }
                    $to = new sohuClient(SOHU_APP_KEY, SOHU_APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['sohu'], $username['sohu'], $wptm_connect['sohu_username'], $comment_content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, urlencode($url), 140, 1);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'dtid') {
                if ($login = get_user_meta($user_id, 'login_douban', true)) {
                    if ($login[0] && $login[1]) {
                        if (!class_exists('doubanOAuth')) {
                            include dirname(__FILE__) . '/OAuth/douban_OAuth.php';
                        }
                        $to = new doubanClient(DOUBAN_APP_KEY, DOUBAN_APP_SECRET, $login[0], $login[1]);
                        $status = wp_status('评论《' . $title . '》: ' . $comment_content, $url, 128);
                        $result = $to->update($status);
                    }
                }
            }
        }
    }
}
/**
 * 同步列表
 * @since 1.9.10
 */
function wp_update_list($title, $postlink, $pic, $account)
{
    global $wptm_options;
    if ($pic[0] == 'video' && $pic[1]) {
        // 是否有视频
        $vurl = $pic[1];
        $url = $postlink;
    } elseif ($pic[0] == 'music' && $pic[1]) {
        if ($pic[2] && $pic[3]) {
            $vurl = '#' . $pic[1] . '#' . $pic[2] . ' ' . $pic[3];
            // #歌手# 歌曲 url
        } else {
            $vurl = $pic[1];
            // url
        }
        $url = $postlink;
    } else {
        $url = $postlink;
    }
    // 是否使用t.cn短网址
    if ($wptm_options['t_cn']) {
        $url = get_t_cn(urlencode($url));
    }
    // 处理完毕输出链接
    $postlink = trim($vurl . ' ' . $url);
    // 截取字数
    $status = wp_status($title, $postlink, 140);
    //网易/人人/饭否/做啥/雷猴
    $status2 = wp_status($title, $postlink, 200, 1);
    //搜狐/follow5
    $sina = wp_status($title, urlencode($postlink), 140, 1);
    //新浪
    $qq = wp_status($title, $postlink, 140, 1);
    //腾讯
    //$kaixin001 = wp_status($title, $postlink, 200); //开心
    $digu = wp_status($title, urlencode($postlink), 140);
    //嘀咕
    $twitter = wp_status($title, wp_urlencode($postlink), 140);
    //Twitter
    $wbto = wp_status($title, $postlink, 140, 1);
    //微博通
    $douban = wp_status($title, $postlink, 128);
    //豆瓣
    $renjian = wp_status($title, urlencode($postlink), 200, 1);
    //人间网
    // 开始同步
    require_once dirname(__FILE__) . '/OAuth/OAuth.php';
    $output = array();
    if ($account['sina']) {
        $ms = wp_update_t_sina($account['sina'], $sina, $pic);
        $output['sina'] = $ms['mid'];
    }
    //140*
    if ($account['qq']) {
        $output['qq'] = wp_update_t_qq($account['qq'], $qq, $pic);
    }
    //140*
    if ($account['netease']) {
        wp_update_t_163($account['netease'], $status, $pic);
    }
    //163
    if ($account['sohu']) {
        wp_update_t_sohu($account['sohu'], $status2, $pic);
    }
    //+
    if ($account['douban']) {
        wp_update_douban($account['douban'], $douban);
    }
    //128
    if ($account['digu']) {
        wp_update_digu($account['digu'], $digu);
    }
    //140
    if ($account['fanfou']) {
        wp_update_fanfou($account['fanfou'], $status);
    }
    //140
    if ($account['renjian']) {
        wp_update_renjian($account['renjian'], $renjian, $pic);
    }
    //+
    if ($account['zuosa']) {
        wp_update_zuosa($account['zuosa'], $status);
    }
    //140
    if ($account['wbto']) {
        wp_update_wbto($account['wbto'], $wbto, $pic);
    }
    //140+
    if ($account['tianya']) {
        wp_update_tianya($account['tianya'], $sina, $pic);
    }
    //140*
    if ($account['twitter']) {
        wp_update_twitter($account['twitter'], $twitter);
    }
    if ($account['renren']) {
        wp_update_renren($account['renren'], $status);
    }
    //140
    if ($account['kaixin001']) {
        wp_update_kaixin001($account['kaixin001'], $qq, $pic);
    }
    //140+
    return $output;
}