/** * follow or unfollow other users * @author Kydz * @param int $id target id * @return json n/a */ public function follow($id) { $u_id = Input::get('u_id'); $token = Input::get('token'); $type = Input::get('type'); $target = User::find($id); if (!isset($target->u_id)) { return Response::json(['result' => 2001, 'data' => [], 'info' => '您关注的用户不存在']); } if ($id == $u_id) { return Response::json(['result' => 2001, 'data' => [], 'info' => '您不能关注自己']); } try { $user = User::chkUserByToken($token, $u_id); if ($type == 1) { $msg = '关注成功'; User::follow($user, $target); } elseif ($type == 2) { $msg = '取消关注成功'; User::unfollow($user, $target); } $re = ['result' => 2000, 'data' => [], 'info' => $msg]; } catch (Exception $e) { $code = 2001; if ($e->getCode() > 2000) { $code = $e->getCode(); } $re = ['result' => $code, 'data' => [], 'info' => $e->getMessage()]; } return Response::json($re); }
$tpl->assign('oNoRecent', true); } if ($user->GetTopPubs(5) !== null) { $tpl->assign('oTopPubs', true); $tpl->assign('iTopPubs', $user->GetTopPubs(5)); } else { $tpl->assign('oNoTopPubs', true); } $tpl->assign('fb_uid', $user->fb_uid); $tpl->assign('name', $user->first_name . ' ' . $user->last_name); $tpl->assign('user_id', $user->user_id); // if user is logged in and it's not his own profile show add as friend button if (SpoonSession::exists('public_uid') && SpoonSession::get('public_uid') != $user->user_id) { $loggedInUser = new User(SpoonSession::get('public_uid'), null, ''); if (!$loggedInUser->isFriend($user->user_id)) { $tpl->assign('oAddFriend', true); } else { $tpl->assign('oDeleteFriend', true); } } if (SpoonFilter::getGetValue('follow', null, '') == 'true') { $loggedInUser->follow($user->user_id); SpoonHTTP::redirect('/users/' . $user->user_id); } if (SpoonFilter::getGetValue('follow', null, '') == 'false') { $loggedInUser->unfollow($user->user_id); SpoonHTTP::redirect('/users/' . $user->user_id); } // show the output $tpl->assign('content', $tpl->getContent('templates/userDetail.tpl')); $tpl->display('templates/layout.tpl');
switch ($action) { // follow a user case 'follow': $userID = $_POST['id']; $follow = User::follow($userID); if ($follow === true) { die(json_encode(['status' => true])); } else { die(json_encode(['status' => false, 'err' => $follow])); } break; // unfollow a user // unfollow a user case 'unfollow': $userID = $_POST['id']; $unfollow = User::unfollow($userID); if ($unfollow === true) { die(json_encode(['status' => true])); } else { die(json_encode(['status' => false])); } break; // get user profile card // get user profile card case 'profile_card': $uid = $_POST['id']; die(View::userCard($uid)); break; case 'feed_post': $id = $_GET['id']; die(View::getFeedPost($id));
$mailcontent = str_replace("#sitename#", $sitename); $mailcontent = str_replace("#baseurl#", $baseurl); if (isset($email_settings['smtp']) && $email_settings['smtp']) { $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 0; $mail->SMTPAuth = true; if ($email_settings['smtp_security'] == "ssl") { $mail->SMTPSecure = "ssl"; } $mail->Host = $email_settings['smtp_host']; $mail->Port = $email_settings['smtp_port']; $mail->Username = $email_settings['smtp_user']; $mail->Password = $email_settings['smtp_password']; $mail->SetFrom($email_settings['sender_email'], $email_settings['sender_name']); $mail->Subject = "=?UTF-8?B?" . base64_encode($mailsubject) . "?="; //$mail->Subject = $mailsubject; $mail->MsgHTML($mailcontent); $mail->IsHTML(true); $mail->AddAddress($target_user['email']); $mail->send(); } else { $headers = "Content-type: text/plain\nFrom: {$email_settings['sender_name']} <{$email_settings['sender_email']}>"; @mail($target_user['email'], $mailsubject, $mailcontent, $headers); } } } else { $user->unfollow($_SESSION['loggeduser_id'], $target_id); } }