Пример #1
0
	function _getFriends($uId, $num = DEFAULT_FRIENDNUM) {
		$friends = array();
		$ucresult = uc_friend_ls($uId, 1, $num, $num, 3);
		foreach($ucresult as $friend) {
			$friends[] = $friend['friendid'];
		}
		return $friends;
	}
Пример #2
0
	 *	关注一个用户
	 */
    public function follow_create()
    {
        if (empty($this->mid) || empty($this->user_id)) {
            return 0;
        }
        $r = uc_friend_add($this->mid, $this->user_id);
        return $r;
Пример #3
0
	function get($uIds, $friendNum = DEFAULT_FRIENDNUM) {
		$result = array();
		foreach($uIds as $uId) {
			$friends = uc_friend_ls($uId, 1, $friendNum, $friendNum, 3);
			foreach($friends as $friend) {
				$result[$friend['uid']][] = $friend['friendid'];
			}
		}
		return new APIResponse($result);
	}
Пример #4
0
function _my_are_friends($uid1, $uid2) {
	$var = "my_are_friends_{$uid1}_{$uid2}";
	if(!isset($GLOBALS[$var])) {
		require_once DISCUZ_ROOT.'./uc_client/client.php';
		$friends = uc_friend_ls($uid1, 1, 2000, 2000, 3);
		$result = FALSE;
		foreach($friends as $friend) {
			if($friend['friendid'] == $uid2) {
				$result = TRUE;
				break;
			}
		}
		$GLOBALS[$var] = $result;
	}
	return $GLOBALS[$var];
}
Пример #5
0
            $username = getcount('space', array('uid' => $uid), 'username');
            friend_update($space['uid'], $space['username'], $uid, $tospace['username'], 'add', 0);
            //我的好友申请数进行变化
            $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET addfriendnum=addfriendnum-1 WHERE uid='{$space['uid']}' AND addfriendnum>0");
            //不产生feed
            showmessage('friend_addconfirm_next', 'cp.php?ac=friend&op=addconfirm&key=' . $space['key'], 1, array($username));
        }
    }
    showmessage('do_success', 'cp.php?ac=friend&op=request', 0);
} elseif ($op == 'syn') {
    //获取用户中心我的fans列表
    if (isset($_SCOOKIE['synfriend']) || empty($_SCONFIG['uc_status'])) {
        exit;
    }
    include_once S_ROOT . './uc_client/client.php';
    $buddylist = uc_friend_ls($_SGLOBAL['supe_uid'], 1, 999, 999, 2);
    //别人加了我
    $havas = array();
    if ($buddylist && is_array($buddylist)) {
        foreach ($buddylist as $key => $buddy) {
            $uids[] = $buddy['uid'];
        }
        $members = array();
        if ($uids) {
            $query = $_SGLOBAL['db']->query("SELECT uid FROM " . tname('space') . " WHERE uid IN (" . simplode($uids) . ")");
            while ($member = $_SGLOBAL['db']->fetch_array($query)) {
                $members[] = $member['uid'];
            }
        }
        if ($members) {
            foreach ($buddylist as $key => $buddy) {
Пример #6
0
/**
 * UCenter 应用程序开发 Example
 *
 * 列出好友的 Example 代码
 * 使用到的接口函数:
 * uc_friend_totalnum()	必须,返回好友总数
 * uc_friend_ls()	必须,返回好友列表
 * uc_friend_delete()	必须,删除好友
 * uc_friend_add()	必须,添加好友
 */
if (empty($_POST['submit'])) {
    $num = uc_friend_totalnum($Example_uid);
    echo '您有 ' . $num . ' 个好友';
    echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?example=friend">';
    $friendlist = uc_friend_ls($Example_uid, 1, 999, $num);
    if ($friendlist) {
        foreach ($friendlist as $friend) {
            echo '<input type="checkbox" name="delete[]" value="' . $friend['friendid'] . '">';
            switch ($friend['direction']) {
                case 1:
                    echo '[关注]';
                    break;
                case 3:
                    echo '[好友]';
                    break;
            }
            echo $friend['username'] . ':' . $friend['comment'] . '<br>';
        }
    }
    echo '添加好友:<input name="newfriend"> 说明:<input name="newcomment"><br>';
Пример #7
0
function API_LsFriend()
{
    global $userid;
    include_once ONEZ_ROOT . './uc_client/client.php';
    $T = uc_friend_ls($userid, 1, 999, 999);
    $A = array();
    foreach ($T as $rs) {
        $A[$rs['friendid']] = $rs['friendid'];
    }
    return implode(',', array_values($A));
}
Пример #8
0
        function submenu_friend()
        {
            echo '<div class=wrap>';
            echo '<h2>' . __('Friend', 'ucenter') . '</h2>';
            global $current_user;
            wp_get_current_user();
            list($uid, $_, $_) = uc_get_user($current_user->user_login);
            $friends_per_page = 10;
            $handler = $_SERVER['PHP_SELF'] . '?page=' . $_GET['page'];
            $action = !empty($_GET['action']) ? $_GET['action'] : 'view';
            $_GET['tab'] = !empty($_GET['tab']) ? $_GET['tab'] : 'friend';
            $menu = array(array('friend', '', __('Friend', 'ucenter')), array('focus', '', __('Focus', 'ucenter')), array('add', 'action=add', __('Add Friend', 'ucenter')));
            echo '<ul class="ucenter-ul">';
            foreach ($menu as $item) {
                printf("<li><a href='{$handler}&tab={$item['0']}&{$item['1']}' %s>{$item['2']}</a></li>", $_GET['tab'] == $item[0] ? 'class="current"' : '');
            }
            echo '</ul><br /><hr />';
            switch ($action) {
                case 'view':
                    $_GET['pageid'] = !empty($_GET['pageid']) ? $_GET['pageid'] : 1;
                    $_GET['tab'] = !empty($_GET['tab']) ? $_GET['tab'] : 'friend';
                    $direction = !empty($_GET['tab']) && $_GET['tab'] == 'focus' ? 1 : 3;
                    $num = uc_friend_totalnum($uid, $direction);
                    $friendlist = uc_friend_ls($uid, $_GET['pageid'], $friends_per_page, $num, $direction);
                    if ($friendlist) {
                        echo '<ul>';
                        foreach ($friendlist as $friend) {
                            echo "<li>{$friend['username']} : {$friend['comment']} [ <a href='{$_SERVER['PHP_SELF']}?page=ucenter-mail-box&tab=send&action=send&touser={$friend['username']}'>Send Message</a> | <a href='{$handler}&action=delete&delete={$friend['friendid']}'>Delete</a> ] </li>";
                        }
                        echo '</ul>';
                    }
                    break;
                case 'add':
                    if ($_POST['newfriend'] && ($friendid = uc_get_user($_POST['newfriend']))) {
                        if (uc_friend_add($uid, $friendid[0], $_POST['newcomment'])) {
                            echo $_POST['newfriend'] . __(' has been added to your list!', 'ucenter') . '<br /><br />';
                        }
                    }
                    echo "<form method='post' action='{$handler}&action=add&tab={$_GET['tab']}'>\n\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr><td>" . __('Add Friend', 'ucenter') . '</td><td><input name="newfriend"></td></tr>
						<tr><td>' . __('Description', 'ucenter') . '</td><td><input name="newcomment"></td></tr>
					</table>
					<input name="submit" type="submit">
					</form>';
                    break;
                case 'delete':
                    if (!is_array($_GET['delete'])) {
                        $_GET['delete'] = array($_GET['delete']);
                    }
                    if (!empty($_GET['delete'])) {
                        if (uc_friend_delete($uid, $_GET['delete'])) {
                            echo __('Removed!', 'ucenter');
                        }
                    }
                    break;
            }
            echo '</div>';
        }
Пример #9
0
 if (!$allowsendpm) {
     showmessage('pm_send_disable');
 }
 if (!$adminid && $newbiespan && (!$lastpost || $timestamp - $lastpost < $newbiespan * 3600)) {
     $query = $db->query("SELECT regdate FROM {$tablepre}members WHERE uid='{$discuz_uid}'");
     if ($timestamp - $db->result($query, 0) < $newbiespan * 3600) {
         showmessage('pm_newbie_span');
     }
 }
 !($exempt & 1) && checklowerlimit($creditspolicy['sendpm'], -1);
 if (!empty($uid)) {
     $msgto = intval($uid);
 } else {
     if (!empty($msgtos)) {
         $buddynum = uc_friend_totalnum($discuz_uid, 3);
         $buddyarray = uc_friend_ls($discuz_uid, 1, $buddynum, $buddynum, 3);
         $uids = array();
         foreach ($buddyarray as $buddy) {
             $uids[] = $buddy['friendid'];
         }
         $msgto = $p = '';
         foreach ($msgtos as $uid) {
             $msgto .= in_array($uid, $uids) ? $p . $uid : '';
             $p = ',';
         }
         if (!$msgto) {
             showmessage('pm_send_nonexistence');
         }
     } else {
         if (!($uid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='******'"))) {
             showmessage('pm_send_nonexistence');
Пример #10
0
 *
 * 列出好友的 Example 代码
 * 使用到的接口函数:
 * uc_friend_totalnum()	必须,返回好友总数
 * uc_friend_ls()	必须,返回好友列表
 * uc_friend_delete()	必须,删除好友
 * uc_friend_add()	必须,添加好友
 */
require_once './config.inc.php';
include './cta_client/client.php';
include './include/cookie.php';
if (empty($_POST['fun'])) {
    switch ($_POST['fun']) {
        case 'add':
            if ($_POST['newfriend'] && ($friendid = uc_get_user($_POST['newfriend']))) {
                uc_friend_add($Cta_uid, $friendid[0], $_POST['newcomment']);
            }
            break;
        case 'del':
            if (!empty($_POST['delete']) && is_array($_POST['delete'])) {
                uc_friend_delete($Cta_uid, $_POST['delete']);
            }
            break;
        case 'frtn':
            $num = uc_friend_totalnum($Cta_uid);
            break;
        case 'frls':
            $friendlist = uc_friend_ls($Cta_uid, 1, 999, $num);
            break;
    }
}
Пример #11
0
);

$apps = $myapps;
$query = $db->query("SELECT appid FROM {$tablepre}userapp WHERE uid='$discuz_uid' AND allowfeed='0'");
if($db->num_rows($query)) {
	while($userapp = $db->fetch_array($query)) {
		unset($apps[$userapp['appid']]);
	}
	$conf['appid'] = array_keys($apps);
}

if($view == 'me') {
	$conf['uid'] = $discuz_uid;
} elseif($view == 'friend') {
	$friendnum = uc_friend_totalnum($discuz_uid, 3);
	$friends = uc_friend_ls($discuz_uid, 1, $friendnum, $friendnum, 3);
	foreach($friends as $friend) {
		$conf['uid'][] = $friend['friendid'];
	}
}

$now = $timestamp + $timeoffset * 3600;
$day1 = gmdate($dateformat, $now);
$day2 = gmdate($dateformat, $now - 86400);
$day3 = gmdate($dateformat, $now - 172800);

$feeds = get_feed($conf);
$feeddate = '';$bi = 1;
foreach($feeds['data'] as $k => $feed) {
	$trans['{addbuddy}'] = $view == 'all' && $feed['uid'] != $discuz_uid ? '<a href="my.php?item=buddylist&newbuddyid='.$feed['uid'].'&buddysubmit=yes" id="ajax_buddy_'.($bi++).'" title="Ìí¼ÓΪºÃÓÑ" onclick="ajaxmenu(this, 3000);doane(event);"><img style="vertical-align:middle" src="manyou/images/myadd.gif" /></a>' : '';
	$feeds['data'][$k]['title'] = strtr($feed['title'], $trans);
Пример #12
0
function find_buddy($ids)
{
    global $_SGLOBAL, $_IMC, $space, $groups;
    $ids = ids_array($ids);
    //删除自己
    $ids = ids_except($space['uid'], $ids);
    if (empty($ids)) {
        return array();
    }
    $ids = join(',', $ids);
    $buddies = array();
    ////
    include_once DISCUZ_ROOT . './uc_client/client.php';
    $buddynum = uc_friend_totalnum($space['uid']);
    $buddies = uc_friend_ls($space['uid'], 1, $buddynum, $buddynum);
    if ($buddies) {
        foreach ((array) $buddies as $key => $buddy) {
            $buddylist[$buddy['friendid']] = $buddy;
        }
        unset($buddies);
    }
    //
    $query = $_SGLOBAL['db']->query("SELECT m.uid, m.username,nickname FROM " . tname('members') . "  m left join " . tname('memberfields') . " mf  on m.uid=mf.uid WHERE  m.uid IN ({$ids})");
    ////
    /*$query = $_SGLOBAL['db']-> query("SELECT main.uid, main.username, main.name, f.gid, f.fuid
      FROM ".tname('space')." main
      LEFT OUTER JOIN ".tname('friend')." f ON f.uid = '$space[uid]' AND main.uid = f.fuid
      WHERE main.uid IN ($ids)");*/
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        //realname_set($value['uid'], to_utf8($value['username']));
        $id = $value['uid'];
        $nick = nick($value);
        ///
        $group = in_array($value['uid'], array_keys($buddylist)) ? 'friend' : 'stranger';
        ///
        /*$group = empty($value['fuid']) ? "stranger" : null; 
          if(empty($value['fuid'])){
                  $group = "stranger";
          }else{
                  $gid = $value['gid'];
                  $group = (empty($gid) || empty($groups[$gid])) ? "friend" : $groups[$gid];
          }*/
        //$jid = $id.'@'.$_IMC['domain'];
        //$status_time = empty($value['dateline'])?'':sgmdate('n月j日',$value['dateline'],1);
        $buddies[$id] = array('id' => $id, 'name' => to_utf8($nick), 'pic_url' => avatar($id, 'small', true), 'status' => '', 'status_time' => '', 'url' => 'space.php?uid=' . $id, 'group' => $group);
    }
    return $buddies;
}
Пример #13
0
         unset($buddies);
         $query = $db->query("SELECT m.uid, m.gender, mf.msn, s.uid AS online FROM {$tablepre}members m \r\n\t\t\t\tLEFT JOIN {$tablepre}sessions s ON s.uid=m.uid\r\n\t\t\t\tLEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid\r\n\t\t\t\tWHERE m.uid IN (" . implodeids(array_keys($buddylist)) . ")");
         while ($member = $db->fetch_array($query)) {
             $uid = $member['uid'];
             if (isset($buddylist[$uid])) {
                 $buddylist[$uid]['avatar'] = discuz_uc_avatar($uid, 'small');
                 $buddylist[$uid]['gender'] = $member['gender'];
                 $buddylist[$uid]['online'] = $member['online'];
                 $buddylist[$uid]['msn'] = explode("\t", $member['msn']);
             } else {
                 unset($buddylist[$uid]);
             }
         }
     }
 } else {
     $buddyarray = $buddynum ? uc_friend_ls($discuz_uid, 1, $buddynum, $buddynum) : array();
     if ($action == 'edit') {
         if ($comment = cutstr(dhtmlspecialchars($comment), 255)) {
             $friendid = intval($friendid);
             uc_friend_delete($discuz_uid, array($friendid));
             uc_friend_add($discuz_uid, $friendid, $comment);
         }
     } elseif ($action == 'delete') {
         $friendid = intval($friendid);
         uc_friend_delete($discuz_uid, array($friendid));
     } else {
         $buddyarraynew = array();
         if ($buddyarray) {
             foreach ($buddyarray as $buddy) {
                 $buddyarraynew[$buddy['friendid']] = $buddy;
             }
Пример #14
0
 /**
  * 获取好友列表
  * @param $uid
  * @param int $page
  * @param int $pagesize
  * @param int $totalnum
  * @param int $direction
  * @return array|mixed|string
  */
 public function friend_ls($uid, $page = 1, $pagesize = 10, $totalnum = 10, $direction = 0)
 {
     return uc_friend_ls($uid, $page, $pagesize, $totalnum, $direction);
 }