function wp_connect_avatar($avatar, $id_or_email = '', $size = '32') { global $comment; if (is_numeric($id_or_email)) { $uid = $userid = (int) $id_or_email; $user = get_userdata($uid); if ($user) { $email = $user->user_email; } } elseif (is_object($comment)) { $uid = $comment->user_id; $email = $comment->comment_author_email; } elseif (is_object($id_or_email)) { $uid = $id_or_email->user_id; $email = $id_or_email->user_email; } else { $uid = email_exists($id_or_email); $email = $id_or_email; } if (!$email) { return $avatar; } if ($uid) { $tname = array('@t.sina.com.cn' => 'stid', '@t.qq.com' => 'qtid', '@renren.com' => 'rtid', '@kaixin001.com' => 'ktid', '@douban.com' => 'dtid', '@t.sohu.com' => 'shtid', '@t.163.com' => 'ntid', '@baidu.com' => 'bdtid', '@tianya.cn' => 'tytid', '@twitter.com' => 'ttid'); $tmail = strstr($email, '@'); $tid = ifab(get_user_meta($uid, 'last_login', true), $tname[$tmail]); if ($tid) { if ($head = get_user_meta($uid, $tid, true)) { $weibo = get_weibo($tid); $out = $weibo[5] ? str_replace('[head]', $head, $weibo[5]) : $head; $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; if ($weibo[3]) { $username = get_user_meta($uid, $weibo[1] . 'id', true); if ($username) { $url = $weibo[3] . $username; if (is_admin()) { if (!is_admin_footer()) { $avatar = "<a href='{$url}' target='_blank'>{$avatar}</a>"; } } elseif (!$userid) { $avatar = "<a href='{$url}' target='_blank'>{$avatar}</a>"; } } } } } elseif ($out = get_user_meta($uid, 'qqtid', true)) { $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; } elseif ($out = get_user_meta($uid, 'tbtid', true)) { $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; } } return $avatar; }
function save_dengluComment($comment, $parent = 0) { global $wpdb; if ($commentID = $comment['sourceID']) { // 以前导入到灯鹭服务器记录的本地评论ID return $commentID; } $cid = $comment['cid']; if ($ret = get_commentID($cid)) { return $ret; } $weiboinfo = get_weiboInfo($comment['mediaID']); $mid = $weiboinfo[0] . 'mid'; $id = $weiboinfo[1]; if (empty($comment['email'])) { if (in_array($comment['mediaID'], array(3, 4, 5, 6, 7, 8, 9, 13, 17, 28))) { if ($comment['url']) { $weibo_uid = str_replace($weiboinfo[3], '', $comment['url']); } elseif ($id = 'qqid') { $path = explode('/', $comment['head']); $weibo_uid = $path[4] . '/' . $path[5]; } $user_id = get_user_by_meta_value($id, $weibo_uid); } $domain = ifab($weiboinfo[2], '@denglu.cc'); $email = $weibo_uid ? $weibo_uid . $domain : $comment['uid'] . $domain; } else { //if ($id = 'facebookid' && $comment['url']) { // $weibo_uid = str_replace($weiboinfo[3], '', $comment['url']); //} $email = $comment['email']; } if (!$user_id) { $user_id = get_user_by_meta_value($mid, $comment['uid']); } $commentdata = array('comment_post_ID' => $comment['postid'], 'comment_author' => $comment['nick'], 'comment_author_email' => $email, 'comment_author_url' => $comment['url'], 'comment_content' => $comment['content'], 'comment_type' => '', 'comment_parent' => $parent, 'user_id' => $user_id ? $user_id : 0, 'comment_author_IP' => $comment['ip'], 'comment_agent' => 'Denglu_' . $cid, 'comment_date' => $comment['date'], 'comment_approved' => dcState($comment['state'])); $commentID = get_commentID($cid); if (!$commentID) { $commentID = wp_insert_comment($commentdata); do_action('save_denglu_comment', $commentID, $comment, $weibo_uid, $user_id); } return $commentID; }
function wp_connect_avatar($avatar, $id_or_email = '', $size = '32') { global $comment, $parent_file, $wp_version; if (is_numeric($id_or_email)) { $uid = $userid = (int) $id_or_email; $user = get_userdata($uid); if ($user) { $email = $user->user_email; } } elseif (is_object($comment)) { $uid = $comment->user_id; $email = $comment->comment_author_email; $author_url = $comment->comment_author_url; if ($author_url && strpos($author_url, 'http://weibo.com/') === 0) { $weibo_uid = ltrim($author_url, 'http://weibo.com/'); $out = 'http://tp' . rand(1, 4) . '.sinaimg.cn/' . $weibo_uid . '/50/0/1'; return "<a href='{$author_url}' rel='nofollow' target='_blank'><img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' /></a>"; } if ($uid) { $user = get_userdata($uid); } } elseif (is_object($id_or_email)) { $user = $id_or_email; $uid = $user->user_id; $email = ifab($user->comment_author_email, $user->user_email); } else { $email = $id_or_email; if ($parent_file != 'options-general.php') { $user = get_user_by_email($email); $uid = $user->ID; } } if (!$email) { return $avatar; } if ($uid) { $tid = $user->last_login; if (!$tid) { $tname = array('@t.sina.com.cn' => 'stid', '@weibo.com' => 'stid', '@t.qq.com' => 'qtid', '@renren.com' => 'rtid', '@kaixin001.com' => 'ktid', '@douban.com' => 'dtid', '@t.sohu.com' => 'shtid', '@t.163.com' => 'ntid', '@baidu.com' => 'bdtid', '@tianya.cn' => 'tytid', '@twitter.com' => 'ttid'); $tmail = strstr($email, '@'); $tid = $tname[$tmail]; } if ($tid) { if ($tid == 'qqtid' && !$user->qqid || $tid == 'tbtid' && !$user->taobaoid) { return $avatar; } if ($head = $user->{$tid}) { $weibo = get_weibo($tid); $out = $weibo[5] ? str_replace('[head]', $head, $weibo[5]) : $head; $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; if ($weibo[3]) { $oid = $weibo[1] . 'id'; $username = $user->{$oid}; if ($username) { $url = $weibo[3] . $username; if ($userid) { if (is_admin()) { if (version_compare($wp_version, '3.4', '<')) { if (!is_admin_footer()) { $avatar = "<a href='{$url}' target='_blank'>{$avatar}</a>"; } } else { if (is_admin_footer()) { $avatar = "<a href='{$url}' target='_blank'>{$avatar}</a>"; } } } } else { $avatar = "<a href='{$url}' rel='nofollow' target='_blank'>{$avatar}</a>"; } } } } } elseif ($user->qqid && ($out = $user->qqtid)) { $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; } elseif ($user->taobaoid && ($out = $user->tbtid)) { $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; } } return $avatar; }
function get_appkey() { global $wptm_connect; $sohu = get_option('wptm_opensohu'); $netease = get_option('wptm_opennetease'); return array('2' => array($wptm_connect['msn_api_key'], $wptm_connect['msn_secret']), '5' => array($sohu['app_key'], $sohu['secret']), '6' => array(ifab($netease['app_key'], '9fPHd1CNVZAKGQJ3'), ifab($netease['secret'], 'o98cf9oY07yHwJSjsPSYFyhosUyd43vO')), '7' => array($wptm_connect['renren_api_key'], $wptm_connect['renren_secret']), '8' => array($wptm_connect['kaixin001_api_key'], $wptm_connect['kaixin001_secret']), '13' => array($wptm_connect['qq_app_id'], $wptm_connect['qq_app_key']), '16' => array($wptm_connect['taobao_api_key'], $wptm_connect['taobao_secret']), '17' => array(TIANYA_APP_KEY, TIANYA_APP_SECRET), '19' => array($wptm_connect['baidu_api_key'], $wptm_connect['baidu_secret']), '28' => array(T_APP_KEY, T_APP_SECRET)); }
function get_appkey() { // v1.9.12 global $wptm_connect; $sohu = get_option('wptm_opensohu'); $netease = get_option('wptm_opennetease'); return array('2' => array($wptm_connect['msn_api_key'], $wptm_connect['msn_secret']), '5' => array(ifab($sohu['app_key'], 'O9bieKU1lSKbUBI9O0Nf'), ifab($sohu['secret'], 'k328Nm7cfUq0kY33solrWufDr(Tsordf1ek=bO5u')), '6' => array(ifab($netease['app_key'], '9fPHd1CNVZAKGQJ3'), ifab($netease['secret'], 'o98cf9oY07yHwJSjsPSYFyhosUyd43vO')), '7' => array($wptm_connect['renren_api_key'], $wptm_connect['renren_secret']), '8' => array($wptm_connect['kaixin001_api_key'], $wptm_connect['kaixin001_secret']), '9' => array(DOUBAN_APP_KEY, DOUBAN_APP_SECRET), '13' => array($wptm_connect['qq_app_id'], $wptm_connect['qq_app_key']), '16' => array($wptm_connect['taobao_api_key'], $wptm_connect['taobao_secret']), '17' => array(TIANYA_APP_KEY, TIANYA_APP_SECRET), '19' => array($wptm_connect['baidu_api_key'], $wptm_connect['baidu_secret'])); }
break; case "twitter": $to = new twitterClient(WEIBO_APP_KEY, WEIBO_SECRET, $last_key['oauth_token'], $last_key['oauth_token_secret']); $result = $to->verify_credentials(); $result = json_decode($result, true); $only_id = $username = $at = $result['screen_name']; // $only_id = $result['id_str']; // return var_dump($result); if ($only_id) { $tid = "ttid"; $id = 'twitterid'; $email = $only_id . '@twitter.com'; $name = $at = $result['name']; $url = 'http://twitter.com/' . $only_id; $head = $result['profile_image_url']; $uid = ifab(get_user_by_meta_value($id, $only_id), email_exists($email)); } break; default: } $_SESSION['wp_url_login'] = ""; if (!$only_id) { return var_dump($result); } if (!is_user_logged_in()) { // 登录 $userinfo = array($tid, $username, $name, $head, $url, $only_id, $oauth_token); // return var_dump($userinfo); if ($uid) { wp_connect_login($userinfo, $email, $uid); } else {