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);
                    }
                }
            }
        }
    }
}
function wp_share_button($s)
{
    global $post;
    $key_qq = 801069107;
    $key_sina = 1767202731;
    $post_title = trim(strip_tags($post->post_title));
    $post_content = trim(strip_tags($post->post_content));
    $post_excerpt = trim(strip_tags(get_the_excerpt()));
    $post_link = get_permalink($post->ID);
    $post_id = $post->ID;
    // 设置分类ID
    $url = urlencode($post_link);
    // 文章网址
    $turl = "";
    $title = urlencode($post_title);
    // 文章标题
    $content .= $post_excerpt ? $post_excerpt : $post_content;
    // 内容摘要
    // 截取字数
    $qq = urlencode(str_replace($post_link, '', wp_status($content, '', 140, 1)));
    $sina = urlencode(str_replace($post_link, '', wp_status($content, '', 140, 1)));
    //$sohu = urlencode(str_replace($post_link, '', wp_status($content, '', 140, 1)));
    //$netease = urlencode(str_replace($post_link, '', wp_status($content, '', 140)));
    $content = urlencode(str_replace($post_link, '', wp_status($content, '', 140)));
    $pic = p2_catch_that_image();
    // 第一张图
    $pic_m = p2_catch_that_image_m();
    $share = array();
    $share['sina'] = array("新浪微博", "http://service.weibo.com/share/share.php?appkey=" . $key_sina . "&title=" . $sina . "&pic=" . $pic . "&url=" . $url);
    $share['qq'] = array("腾讯微博", "http://v.t.qq.com/share/share.php?appkey=" . $key_qq . "&title=" . $qq . "&pic=" . $pic . "&url=" . $url);
    //$share['sohu'] = array("搜狐微博","http://t.sohu.com/third/post.jsp??appkey=EyXuAogJI4bhlwJYVvtZ&title=".$sohu."&pic=".$pic."&content=utf-8&url=".$url);
    //$share['baidu'] = array("百度搜藏","http://cang.baidu.com/do/add?it=".$content."&iu=".$url."&dc=&fr=ien#nw=1");
    //$share['netease'] = array("网易微博","http://t.163.com/article/user/checkLogin.do?info=".$netease." ".$url."&images=".$pic."&link=http://tmd.cc/&source=糗事微博&togImg=true");
    $share['qzone'] = array("QQ空间", "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" . $url . "&pics=" . $pic . "&title=" . $title . "&summary=" . $content);
    $share['renren'] = array("人人网", "http://share.renren.com/share/buttonshare.do?title=" . $content . "&link=" . $url . "&pic=" . $pic);
    //$share['kaixin001'] = array("开心网","http://www.kaixin001.com/repaste/bshare.php?rtitle=".$title."&rcontent=".$content."&rurl=".$url);
    //$share['douban'] = array("豆瓣","http://www.douban.com/recommend/?url=".$url."&title=".$content."&v=1");
    // 最终输出
    foreach ($share as $key => $vaule) {
        echo '<a class="left" rel="nofollow" href="' . $vaule[1] . '" title="' . $vaule[0] . '" target="_blank"><span alt="' . $vaule[0] . '" class="shareico share' . $s . '_' . $key . '"></span></a> ';
    }
}
/**
 * 同步列表
 * @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;
}
Example #4
0
function wp_connect_comment($id)
{
    global $post, $wptm_options, $wptm_connect;
    $post_id = isset($_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_url_short($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]) {
                    $token = array('access_token' => $login[0], 'expires_in' => $login[1]);
                    // V2.0
                    $content = at_username($name['sina'], $username['sina'], $wptm_connect['sina_username'], $comment_content);
                    // return var_dump($content);
                    $status = wp_status($content, urlencode($url), 140, 1);
                    $result = wp_update_t_sina($token, $status, '');
                }
            } elseif ($tid == 'qtid') {
                $login = get_user_meta($user_id, 'login_qq', true);
                if ($login[0] && $login[1]) {
                    $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                    $content = at_username($name['qq'], $username['qq'], $wptm_connect['qq_username'], $comment_content);
                    $status = wp_status($content, $url, 140, 1);
                    $result = wp_update_t_qq($token, $status, '');
                }
            } elseif ($tid == 'ntid') {
                $login = get_user_meta($user_id, 'login_netease', true);
                if ($login[0] && $login[1]) {
                    $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                    $content = at_username($name['netease'], $username['netease'], $wptm_connect['netease_username'], $comment_content);
                    $status = wp_status($content, $url, 163);
                    $result = wp_update_t_163($token, $status, '');
                }
            } elseif ($tid == 'shtid') {
                $login = get_user_meta($user_id, 'login_sohu', true);
                if ($login[0] && $login[1]) {
                    $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                    $content = at_username($name['sohu'], $username['sohu'], $wptm_connect['sohu_username'], $comment_content);
                    $status = wp_status($content, $url, 200, 1);
                    $result = wp_update_t_sohu($token, $status, '');
                }
            } elseif ($tid == 'dtid') {
                if ($login = get_user_meta($user_id, 'login_douban', true)) {
                    if ($login[0] && $login[1]) {
                        $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                        $status = wp_status($comment_content, $url, 128);
                        $result = wp_update_douban($token, $status);
                    }
                }
            }
        }
    }
}
Example #5
0
/**
 * 同步列表
 * @since 2.4.5
 */
function wp_update_list($text, $url, $pic, $account, $post_id = '')
{
    global $wptm_options;
    if (is_array($pic)) {
        // 兼容旧版本
        if ($pic[0] == 'image') {
            $pic = array($pic[1], '', '');
        } elseif ($pic[0] == 'video') {
            $pic = array('', $pic[1], '');
        } elseif ($pic[0] == 'music') {
            $pic = array('', '', $pic[1]);
        }
        if ($pic[0]) {
            // 图片
            $picture = array('image', $pic[0]);
        }
        if ($pic[1] && $pic[1] != $url) {
            // 视频
            $vurl = $pic[1];
        } elseif (is_array($pic[2])) {
            // 音乐
            if ($pic[2][1] && $pic[2][2]) {
                $vurl = '#' . $pic[2][0] . '#' . $pic[2][1] . ' ' . $pic[2][2];
                // #歌手# 歌曲 url
            } else {
                $vurl = $pic[2][0];
                // url
            }
        }
    }
    // 是否使用短网址
    if ($wptm_options['t_cn']) {
        $url = get_url_short($url);
    }
    // 处理完毕输出链接
    $postlink = trim($vurl . ' ' . $url);
    // 截取字数
    $status = wp_status($text, '', 140, 1);
    //灯鹭
    $status1 = wp_status($text, $postlink, 140);
    //网易/人人/饭否/做啥
    $status2 = wp_status($text, urlencode($postlink), 140, 1);
    //新浪/天涯
    $status3 = wp_status($text, $postlink, 140, 1);
    //腾讯/开心
    // return var_dump($status3);
    // 开始同步
    require_once dirname(__FILE__) . '/OAuth/OAuth.php';
    $output = array();
    if ($account['sina']['mediaUserID']) {
        wp_update_share($account['sina']['mediaUserID'], $status, $url, '', $pic[0], $pic[1], $post_id);
    } elseif ($account['sina']) {
        // 新浪微博 /140*
        $ms = wp_update_t_sina($account['sina'], $status2, $picture);
        $output['sina'] = $ms['mid'];
    }
    $mediaUserID = '';
    if ($account['qq']['oauth_token']) {
        // 腾讯微博 /140*
        $output['qq'] = wp_update_t_qq($account['qq'], $status3, $pic);
    } elseif ($account['qq']['mediaUserID']) {
        $mediaUserID .= $account['qq']['mediaUserID'] . ',';
    }
    if ($account['shuoshuo']) {
        // 说说 /140
        wp_post_shuoshuo($account['shuoshuo'], $status2, $pic);
    }
    if ($account['sohu']['oauth_token']) {
        // 搜狐微博 /+
        wp_update_t_sohu($account['sohu'], wp_status($text, $postlink, 200, 1), $picture);
    } elseif ($account['sohu']['mediaUserID']) {
        $mediaUserID .= $account['sohu']['mediaUserID'] . ',';
    }
    if ($account['netease']['oauth_token']) {
        // 网易微博 /163
        wp_update_t_163($account['netease'], $status1, $picture);
    } elseif ($account['netease']['mediaUserID']) {
        $mediaUserID .= $account['netease']['mediaUserID'] . ',';
    }
    if ($account['renren']['mediaUserID']) {
        $mediaUserID .= $account['renren']['mediaUserID'] . ',';
    } elseif ($account['renren']) {
        // 人人网 /140
        wp_update_renren($account['renren'], $status1);
    }
    if ($account['tianya']['oauth_token']) {
        // 天涯 /140*
        wp_update_tianya($account['tianya'], $status2, $picture);
    } elseif ($account['tianya']['mediaUserID']) {
        $mediaUserID .= $account['tianya']['mediaUserID'];
    }
    if ($mediaUserID) {
        wp_update_share(rtrim($mediaUserID, ','), $status, $url, '', $pic[0], $pic[1], $post_id);
    }
    if ($account['wbto']) {
        // 微博通 /140+
        wp_update_wbto($account['wbto'], wp_status($text, $postlink, 140, 1), $picture);
    }
    if ($account['douban']) {
        // 豆瓣 /128
        wp_update_douban($account['douban'], wp_status($text, $postlink, 128));
    }
    if ($account['twitter']) {
        // twitter /140
        wp_update_twitter($account['twitter'], wp_status($text, wp_urlencode($postlink), 140));
    }
    if ($account['kaixin001']) {
        // 开心网 /140+
        wp_update_kaixin001($account['kaixin001'], $status3, $picture);
    }
    /*
    if ($account['digu']) { // 嘀咕 /140
    	wp_update_digu($account['digu'], wp_status($text, urlencode($postlink), 140));
    } 
    if ($account['fanfou']) { // 饭否 /140
    	wp_update_fanfou($account['fanfou'], $status1);
    } 
    if ($account['renjian']) { // 人间 /+
    	wp_update_renjian($account['renjian'], wp_status($text, urlencode($postlink), 200, 1), $picture);
    } 
    if ($account['zuosa']) { // 做啥 /140
    	wp_update_zuosa($account['zuosa'], $status1);
    } 
    */
    // 钩子,方便自定义插件
    do_action('wp_update_list_update', $output, $ms, $post_id);
    return $output;
}