//通知 notification_add($uid, 'friend', cplang('note_friend_add')); showmessage('friends_add', $_POST['refer'], 1, array($_SN[$tospace['uid']])); } else { $op = 'add2'; include_once template('cp_friend'); exit; } } } } elseif ($op == 'ignore') { //检测用户 if ($uid) { if (submitcheck('friendsubmit')) { //对方与我的关系 $fstatus = getfriendstatus($uid, $space['uid']); if ($fstatus == 1) { //取消双向好友关系 friend_update($_SGLOBAL['supe_uid'], $_SGLOBAL['supe_username'], $uid, '', 'ignore'); } elseif ($fstatus == 0) { request_ignore($uid); } showmessage('do_success', 'cp.php?ac=friend&op=request', 0); } } elseif ($_GET['key'] == $space['key']) { //批量忽略好友请求 $query = $_SGLOBAL['db']->query("SELECT uid FROM " . tname('friend') . " WHERE fuid='{$space['uid']}' AND status='0' LIMIT 0,1"); if ($value = $_SGLOBAL['db']->fetch_array($query)) { //删除 $uid = $value['uid']; $username = getcount('space', array('uid' => $uid), 'username');
function invite_update($inviteid, $uid, $username, $m_uid, $m_username, $appid=0) { global $_SGLOBAL, $_SN; if($uid && $uid != $m_uid) { $friendstatus = getfriendstatus($uid, $m_uid); if($friendstatus < 1) { friend_update($uid, $username, $m_uid, $m_username, 'invite'); //查找邀请记录 $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('invite')." WHERE uid='$m_uid' AND fuid='$uid'"); if($oldinvite = $_SGLOBAL['db']->fetch_array($query)) { //已经邀请过 return false; } //奖励积分 getreward('invitefriend', 1, $m_uid, '', 0); //feed $_SGLOBAL['supe_uid'] = $m_uid; $_SGLOBAL['supe_username'] = $m_username; //实名 realname_set($uid, $username); realname_get(); if(ckprivacy('invite', 1)) { $title_template = cplang('feed_invite'); $tite_data = array('username'=>'<a href="space.php?uid='.$uid.'">'.stripslashes($_SN[$uid]).'</a>'); feed_add('friend', $title_template, $tite_data); } //通知 $_SGLOBAL['supe_uid'] = $uid; $_SGLOBAL['supe_username'] = $username; notification_add($m_uid, 'friend', cplang('note_invite')); //更新邀请 $setarr = array('fuid'=>$uid, 'fusername'=>$username, 'appid'=>$appid); if($inviteid) { updatetable('invite', $setarr, array('id'=>$inviteid)); } else { $setarr['uid'] = $m_uid; inserttable('invite', $setarr, 0, true);//插入邀请记录 } } } }
if (empty($tospace)) { showmessage('space_does_not_exist'); } //黑名单 if (isblacklist($tospace['uid'])) { showmessage('is_blacklist'); } //用户组 $groups = getfriendgroup(); //检测现在状态 $status = getfriendstatus($_SGLOBAL['supe_uid'], $uid); if ($status == 1) { showmessage('you_have_friends'); } else { //对方是否把自己加为了好友 $fstatus = getfriendstatus($uid, $_SGLOBAL['supe_uid']); if ($fstatus == -1) { //对方没有加好友 if ($status == -1) { //检查数目 $maxfriendnum = checkperm('maxfriendnum'); if ($maxfriendnum && $space['friendnum'] >= $maxfriendnum) { showmessage('enough_of_the_number_of_friends'); } //添加单向好友 if (submitcheck('addsubmit')) { $setarr = array('uid' => $_SGLOBAL['supe_uid'], 'fuid' => $uid, 'fusername' => addslashes($tospace['username']), 'gid' => intval($_POST['gid']), 'note' => getstr($_POST['note'], 50, 1, 1), 'dateline' => $_SGLOBAL['timestamp']); inserttable('friend', $setarr); //发送邮件通知 smail($uid, '', cplang('friend_subject', array($_SN[$space['uid']], getsiteurl() . 'cp.php?ac=friend&op=request'))); showmessage('request_has_been_sent');
function ckfriend($touid, $friend, $target_ids = '') { global $_SGLOBAL, $_SC, $_SCONFIG, $_SCOOKIE, $space; //游客 if (empty($_SGLOBAL['supe_uid'])) { return $friend ? false : true; } //自己 if ($touid == $_SGLOBAL['supe_uid']) { return true; } //自己 $var = 'ckfriend_' . md5($touid . '_' . $friend . '_' . $target_ids); if (isset($_SGLOBAL[$var])) { return $_SGLOBAL[$var]; } $_SGLOBAL[$var] = false; switch ($friend) { case 0: //全站用户可见 $_SGLOBAL[$var] = true; break; case 1: //全好友可见 if ($space['uid'] == $touid) { if ($space['friends'] && in_array($_SGLOBAL['supe_uid'], $space['friends'])) { $_SGLOBAL[$var] = true; } } else { $_SGLOBAL[$var] = getfriendstatus($_SGLOBAL['supe_uid'], $touid) == 1 ? true : false; } break; case 2: //仅指定好友可见 if ($target_ids) { $target_ids = explode(',', $target_ids); if (in_array($_SGLOBAL['supe_uid'], $target_ids)) { $_SGLOBAL[$var] = true; } } break; case 3: //仅自己可见 break; case 4: //凭密码查看 $_SGLOBAL[$var] = true; break; default: break; } return $_SGLOBAL[$var]; }
$value['res'] = 'many_same_friend'; if ($value['commonfriendcount'] > 0) { $value['commonfriendstr'] = cplang('common_friends', array(implode(',', array_slice(array_values($value['commonfriends']), 0, 6)), $value['commonfriendcount'])); $list[$value['uid']] = $value; if (count($list) >= $maxnum / 2) { break; } } } } $query = $_SGLOBAL['db']->query("SELECT ihome_friend_toRecomment.uid2 as uid,ihome_friend_toRecomment.res_toRecomment as res,ihome_friend_toRecomment.other as other, ihome_friend_toRecomment.username as username FROM ihome_friend_toRecomment," . tname('space') . " where ihome_friend_toRecomment.uid1='" . $space['uid'] . "' and ihome_friend_toRecomment.uid1=" . tname('space') . ".uid;"); mysql_data_seek($query, $offset); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if (!in_array($value['uid'], $nouids) && $value['username']) { realname_set($value['uid'], $value['username']); $value['status'] = getfriendstatus($space['uid'], $value['uid']); if (!strcmp($value['res'], 'same_class_edu')) { $value['commonclassnum'] = $value['other']; $value['commonclass'] = cplang('common_class', array($value['commonclassnum'])); $list[$value['uid']] = $value; } else { if (!strcmp($value['res'], 'same_class_work')) { $value['commonclassnum'] = $value['other']; $value['commonclass'] = cplang('common_class', array($value['commonclassnum'])); $list[$value['uid']] = $value; } else { if (!strcmp($value['res'], 'same_hometown')) { $value['commonhometown'] = cplang('common_hometown', array($value['other'])); $list[$value['uid']] = $value; } }
$start = ($page - 1) * $perpage; ckstart($start, $perpage); $wheresql = ''; $_GET['key'] = stripsearchkey($_GET['key']); if ($_GET['key']) { $wheresql = " AND main.username LIKE '%{$_GET['key']}%' "; } $list = $fuids = array(); $count = 0; if ($mtag['allowview']) { $count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('tagspace') . " main WHERE main.tagid='{$tagid}' {$wheresql}"), 0); if ($count) { $query = $_SGLOBAL['db']->query("SELECT field.*, main.username, main.grade FROM " . tname('tagspace') . " main \r\n\t\t\t\t\tLEFT JOIN " . tname('spacefield') . " field ON field.uid=main.uid \r\n\t\t\t\t\tWHERE main.tagid='{$tagid}' {$wheresql} ORDER BY main.grade DESC LIMIT {$start},{$perpage}"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { realname_set($value['uid'], $value['username']); $value['fstatus'] = getfriendstatus($_SGLOBAL['supe_uid'], $value['uid']); //检测相互是否请求过好友,0为单向,1为互为好友,-1为不存在;当前用户对目标用户的好友关系; if ($_SGLOBAL['supe_uid'] == $value['uid']) { $value['fstatus'] = 1; } $value['p'] = rawurlencode($value['resideprovince']); $value['c'] = rawurlencode($value['residecity']); $fuids[] = $value['uid']; $list[] = $value; } } $ols = array(); if ($fuids) { $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('session') . " WHERE uid IN (" . simplode($fuids) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if (!$value['magichidden']) {
exit; } // if ($stopTime) { // $result = array(); // $result['status'] = '0'; // $result['version'] = $version; // } else { $q = $_SGLOBAL['db']->query("select * from " . UC_DBTABLEPRE . "pms where msgtoid='" . $_SGLOBAL['supe_uid'] . "' and related and (pmid>" . $version . " or new) order by dateline limit 100"); $data = array(); while ($r = $_SGLOBAL['db']->fetch_array($q)) { $datum = array(); $datum['id'] = $r['msgfromid']; $datum['message'] = htmlspecialchars($r['message']); $datum['time'] = $r['dateline'] . '000'; $fuid = intval($datum['id']); if (getfriendstatus($fuid, $uid) < 0) { $q1 = $_SGLOBAL['db']->query("select avatar,name,username from " . tname('space') . " where uid='{$fuid}'"); if ($r1 = $_SGLOBAL['db']->fetch_array($q1)) { $datum['name'] = empty($r1['name']) ? $r1['username'] : $r1['name']; if ($r1['avatar']) { $face = avatar($fuid, 'big', TRUE); } else { $query = $_SGLOBAL['db']->query("SELECT sex FROM " . tname('spacefield') . " WHERE uid='{$fuid}' LIMIT 1"); if ($gd = $_SGLOBAL['db']->result($query)) { if ($gd == 1) { $gender = 'm'; } else { $gender = 'f'; } } else { $gender = "m";
$touserrealname = $value['name'] ? $value['name'] : $value['username']; } else { $result = array('flag' => 'touseridnotexist'); $result = json_encode($result); $result = preg_replace("#\\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $result); echo $result; exit; } global $space; if (!$space) { $space = getspace($userid, 'uid'); } if ($touserid) { $fstatus = getfriendstatus($userid, $touserid); //检测相互是否请求过好友,0为单向,1为互为好友,-1为不存在;当前用户对目标用户的好友关系; $rfstatus = getfriendstatus($touserid, $userid); //检测相互是否请求过好友,0为单向,1为互为好友,-1为不存在;目标用户对当前用户的好友关系; $type = $_POST['type']; //$type="ignore"; if ($type == 'add') { if ($fstatus == 1) { $result = array('flag' => 'isfriends'); } else { if ($rfstatus == -1) { //对方没有加好友,我加别人 if ($fstatus == -1) { $setarr = array('uid' => $userid, 'fuid' => $touserid, 'fusername' => $tousername, 'gid' => 0, 'dateline' => time()); inserttable('friend', $setarr); //发送邮件通知 smail($touserid, '', cplang('friend_subject', array($space['name'], getsiteurl() . 'cp.php?ac=friend&op=request')), '', 'friend_add'); //增加对方好友申请数
function ckfriend($invalue) { global $_SGLOBAL, $_SC, $_SCONFIG, $_SCOOKIE, $space; if ($invalue['uid'] == $_SGLOBAL['supe_uid']) { return true; } //自己 $result = false; switch ($invalue['friend']) { case 0: //全站用户可见 $result = true; break; case 1: //全好友可见 if ($space['self']) { $result = true; } else { if ($space['uid'] == $invalue['uid']) { //是否好友 $space['isfriend'] = $space['self']; if ($space['friends'] && in_array($_SGLOBAL['supe_uid'], $space['friends'])) { $space['isfriend'] = 1; //是好友 } $isfriend = $space['isfriend']; } else { $isfriend = getfriendstatus($_SGLOBAL['supe_uid'], $invalue['uid']); } if ($isfriend) { $result = true; } } break; case 2: //仅指定好友可见 if ($invalue['target_ids']) { $target_ids = explode(',', $invalue['target_ids']); if (in_array($_SGLOBAL['supe_uid'], $target_ids)) { $result = true; } } break; case 3: //仅自己可见 break; case 4: //凭密码查看 $result = true; break; default: break; } return $result; }