private function _userDelFriendSetting($res, $delFriendUid) { require_once libfile('function/friend'); friend_delete($delFriendUid); $params['noError'] = 1; return $this->makeErrorInfo($res, 'do_success', $params); }
private function _adminUser($act, $uid) { global $_G; $errorMsg = ''; require_once libfile('function/spacecp'); require_once libfile('function/home'); require_once libfile('function/friend'); if (friend_request_check($uid) && $act == 'add') { $act = 'add2'; } if ($act == 'add' || $act == 'add2') { if ($uid == $_G['uid']) { $list = $this->makeErrorInfo($res, 'friend_self_error'); $this->_exitWithHtmlAlert($list['errcode']); } if (friend_check($uid)) { $list = $this->makeErrorInfo($res, 'you_have_friends'); $this->_exitWithHtmlAlert($list['errcode']); } $tospace = getuserbyuid($uid); if (empty($tospace)) { $list = $this->makeErrorInfo($res, 'space_does_not_exist'); $this->_exitWithHtmlAlert($list['errcode']); } if (isblacklist($tospace['uid'])) { $list = $this->makeErrorInfo($res, 'is_blacklist'); $this->_exitWithHtmlAlert($list['errcode']); } space_merge($space, 'count'); space_merge($space, 'field_home'); $maxfriendnum = checkperm('maxfriendnum'); if ($maxfriendnum && $space['friends'] >= $maxfriendnum + $space['addfriend']) { if ($_G['magic']['friendnum']) { $list = $this->makeErrorInfo($res, 'enough_of_the_number_of_friends_with_magic'); $this->_exitWithHtmlAlert($list['errcode']); } else { $list = $this->makeErrorInfo($res, 'enough_of_the_number_of_friends'); $this->_exitWithHtmlAlert($list['errcode']); } } if ($act == 'add') { if (!checkperm('allowfriend')) { $list = $this->makeErrorInfo($res, 'no_privilege_addfriend'); $this->_exitWithHtmlAlert($list['errcode']); } if (C::t('home_friend_request')->count_by_uid_fuid($uid, $_G['uid'])) { $list = $this->makeErrorInfo($res, 'waiting_for_the_other_test'); $this->_exitWithHtmlAlert($list['errcode']); } } } require_once libfile('function/friend'); require_once libfile('function/spacecp'); if (!empty($_POST)) { switch ($act) { case 'add': $note = $_GET['note']; if (!friend_request_check($uid)) { $_POST['gid'] = $gid; $_POST['note'] = censor(htmlspecialchars(cutstr($note, strtolower(CHARSET) == 'utf-8' ? 30 : 20, ''))); friend_add($uid, $_POST['gid'], $_POST['note']); $note = array('uid' => $_G['uid'], 'url' => 'home.php?mod=spacecp&ac=friend&op=add&uid=' . $_G['uid'] . '&from=notice', 'from_id' => $_G['uid'], 'from_idtype' => 'friendrequest', 'note' => !empty($_POST['note']) ? lang('spacecp', 'friend_request_note', array('note' => $_POST['note'])) : ''); notification_add($uid, 'friend', 'friend_request', $note); // ios push UserUtils::pushIOSMessage($uid, 'friend', $_G['username'] . WebUtils::t(' 请求加您为好友') . $note['note']); require_once libfile('function/mail'); $values = array('username' => $tospace['username'], 'url' => getsiteurl() . 'home.php?mod=spacecp&ac=friend&op=request'); sendmail_touser($uid, lang('spacecp', 'friend_subject', $values), '', 'friend_add'); $list = $this->makeErrorInfo($res, 'request_has_been_sent'); $this->_exitWithHtmlAlert($list['errcode']); } $this->_exitWithHtmlAlert($res['errcode']); case 'add2': global $_G; require_once libfile('function/home'); $_POST['gid'] = intval($gid); friend_add($uid, $uid); if (ckprivacy('friend', 'feed')) { require_once libfile('function/feed'); feed_add('friend', 'feed_friend_title', array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">{$tospace['username']}</a>")); } notification_add($uid, 'friend', 'friend_add'); // showmessage('friends_add', dreferer(), array('username' => $tospace['username'], 'uid'=>$uid, 'from' => $_GET['from']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true)); $list = $this->makeErrorInfo($res, 'friends_add', array('{username}' => $tospace['username'])); $this->_exitWithHtmlAlert($list['errcode']); break; case 'ignore': global $_G; require_once libfile('function/friend'); friend_delete($uid); $params['noError'] = 1; $list = $this->makeErrorInfo($res, 'do_success', $params); $this->_exitWithHtmlAlert($list['errcode']); break; case 'shield': global $_G, $space; // $type = empty($_GET['type'])?'':preg_replace("/[^0-9a-zA-Z\_\-\.]/", '', $_GET['type']); // if(submitcheck('ignoresubmit')) { $authorid = empty($_POST['authorid']) ? 0 : intval($_POST['authorid']); $type = 'friend'; if ($type) { $type_uid = $type . '|' . $authorid; if (empty($space['privacy']['filter_note']) || !is_array($space['privacy']['filter_note'])) { $space['privacy']['filter_note'] = array(); } $space['privacy']['filter_note'][$type_uid] = $type_uid; privacy_update(); } $this->_exitWithHtmlAlert('do_success'); // showmessage('do_success', dreferer(), array(), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true)); // } $formid = random(8); break; default: $errorMsg = '错误的动作参数'; break; } } else { if ($act == 'add') { require_once libfile('function/friend'); $groups = $this->_getFriendGroupList(); $tospace = getuserbyuid($uid); } elseif ($act == 'add2') { require_once libfile('function/friend'); $groups = $this->_getFriendGroupList(); $tospace = $this->_getFriendUserByUid($uid); } } $this->getController()->renderPartial('userAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('user/useradminview', array('uid' => $uid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'groups' => $groups, 'tospace' => $tospace)); }
} elseif ($op == 'blacklist') { if ($_GET['subop'] == 'delete') { $_GET['uid'] = intval($_GET['uid']); DB::query("DELETE FROM " . DB::table('home_blacklist') . " WHERE uid='{$space['uid']}' AND buid='{$_GET['uid']}'"); showmessage('do_success', "home.php?mod=space&uid={$_G['uid']}&do=friend&view=blacklist&quickforward=1&start={$_GET['start']}"); } if (submitcheck('blacklistsubmit')) { $_POST['username'] = trim($_POST['username']); $query = DB::query("SELECT * FROM " . DB::table('common_member') . " WHERE username='******'username']}'"); if (!($tospace = DB::fetch($query))) { showmessage('space_does_not_exist'); } if ($tospace['uid'] == $space['uid']) { showmessage('unable_to_manage_self'); } friend_delete($tospace['uid']); DB::insert('home_blacklist', array('uid' => $space['uid'], 'buid' => $tospace['uid'], 'dateline' => $_G['timestamp']), 0, true); showmessage('do_success', "home.php?mod=space&uid={$_G['uid']}&do=friend&view=blacklist&quickforward=1&start={$_GET['start']}"); } } elseif ($op == 'rand') { $userlist = $randuids = array(); space_merge($space, 'count'); if ($space['friends'] < 5) { $query = DB::query("SELECT uid FROM " . DB::table('common_session') . " LIMIT 0,100"); } else { $query = DB::query("SELECT fuid as uid FROM " . DB::table('home_friend') . " WHERE uid='{$_G['uid']}'"); } while ($value = DB::fetch($query)) { if ($value['uid'] != $space['uid']) { $userlist[] = $value['uid']; }
function friend_add_delete($from, $to) { if ($from == $to) { return ''; } switch (friend_exists($from, $to)) { case 0: friend_insert($from, $to); return FRIEND_YES; case 1: friend_insert($from, $to, -1); return FRIEND_IGNORE; case -1: friend_delete($from, $to); return FRIEND_NO; } }