public function addNewFriend() { $response['signed'] = false; $response['valid'] = false; $response['succeeded'] = false; $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $user = ['requester_id' => $requester_id = $request->requester_id, 'user_id' => $user_id = $request->user_id]; $v = new Validator(); $v->required('requester_id')->digits(); $v->required('user_id')->digits(); $result = $v->validate($user); $response['valid'] = $result->isValid(); if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0) { $response['signed'] = true; if ($response['valid'] && $user['requester_id'] == $_SESSION["user_id"]) { $response['succeeded'] = addFriend($user['requester_id'], $user['user_id'], 'request', $user['requester_id']); } else { print_r($result->getFailures()); } } echo json_encode($response); }
if ($result === 0) { $errortext_contact = "you are a foe of " . $_POST["contact"] . ", you can't add " . $_POST["contact"] . " as a contact"; } else { $errortext_contact = "add contact successfully"; } } } } else { if (!empty($_POST["friend"])) { if ($_POST["friend"] === $_SESSION["username"]) { $errortext_friend = "can't add yourself"; } else { if (existUser($_POST["friend"]) === 0) { $errortext_friend = "user " . $_POST["friend"] . " doesn't exist"; } else { $result = addFriend($_SESSION["username"], $_POST["friend"]); if ($result === 0) { $errortext_friend = "you are a foe of " . $_POST["contact"] . ", you can't add " . $_POST["contact"] . " as a friend"; } else { $errortext_friend = "add contact successfully"; } } } } else { if (!empty($_POST["foe"])) { if ($_POST["foe"] === $_SESSION["username"]) { $errortext_foe = "can't add yourself"; } else { if (existUser($_POST["foe"]) === 0) { $errortext_foe = "user " . $_POST["foe"] . " doesn't exist"; } else {
<?php /** * This file is part of the OpenPNE package. * (c) OpenPNE Project (http://www.openpne.jp/) * * For the full copyright and license information, please view the LICENSE * file and the NOTICE file that were distributed with this source code. */ include dirname(__FILE__) . '/../../bootstrap/functional.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; include dirname(__FILE__) . '/../../bootstrap/util.php'; setBlogUrl(1, FEED_URL); setBlogUrl(2, FEED_URL); setBlogUrl(3, FEED_URL); addFriend(1, 2); addFriend(1, 3); addFriend(3, 1, true); Doctrine::getTable('BlogRssCache')->updateByMemberId(1); Doctrine::getTable('BlogRssCache')->updateByMemberId(2); Doctrine::getTable('BlogRssCache')->updateByMemberId(3); $test = new opTestFunctional(new sfBrowser()); $test->login('*****@*****.**', 'password'); $test->setCulture('en'); $test->get('/blog')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'index')->end()->with('response')->begin()->checkElement('h3', 'Newest blog')->end()->get('/blog/user')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'user')->end()->with('response')->begin()->checkElement('h3', 'Newest blog of OpenPNE1')->end()->get('/blog/user/2')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'user')->end()->with('response')->begin()->checkElement('h3', 'Newest blog of OpenPNE2')->end()->get('/blog/user/3')->with('response')->begin()->checkElement('h3', NULL)->end()->get('/blog/friend')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'friend')->end()->with('response')->begin()->checkElement('h3', 'Friends Newest blog')->end();
case "PATCH": $data["commentID"] = $path[1]; $results = editComment($data); break; case "DELETE": $data["commentID"] = $path[1]; $results = deleteComment($data); break; default: $results["meta"] = methodNotAllowed($method, $path); } break; case "follows": switch ($method) { case "POST": $results = addFriend($data); break; case "DELETE": $results = deleteFriend($data); break; default: $results["meta"] = methodNotAllowed($method, $path); } break; case "likes": switch ($method) { case "POST": $results = addLike($data); break; case "DELETE": $results = deleteLike($data);
} if ($action == "Activate profile") { $result = activateProfile($_SESSION['loggedInUser']['u_id']); print json_encode($result); return; } if ($action == "Accept") { $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id']); $acceptedUser = acceptFriendship($props); $result = array('u_about_myself' => $acceptedUser['u_about_myself'], 'u_id' => $acceptedUser['u_id'], 'days' => calculateDaysTillTheDate($acceptedUser['u_birthdate'])); print json_encode($result); return; } if ($action == "Add Friend") { $props = array('u_id1' => $_SESSION['loggedInUser']['u_id'], 'u_id2' => $_POST['u_id'], 'r_status' => 'REQUEST_SENT', 'r_updated_at' => date('Y-m-d H:i:s')); $addedFriend = addFriend($props); print json_encode($addedFriend); return; } if ($action == "Decline") { $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id'], 'r_updated_at' => date('Y-m-d H:i:s')); declineFriendship($props); print json_encode($_POST['u_id']); return; } if ($action == "Unfriend") { $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id']); unFriend($props); print json_encode($_POST['u_id']); return; }
case "distance": if ($lat && $lon) { $server = new Server($lobby->lobbyserver($lid)); echo GetDistance($lat, $lon, $server->latitude, $server->longitude); } break; case "balanceTeams": $players = getPlayersSkill($lid); balanceTeams($lid, $players); break; } } elseif ($uid) { switch ($request) { case "addFriend": if ($fid) { addFriend($uid, $fid); } break; case "newLobby": if (!isPlayerInLobby($uid)) { $name = $_POST['name']; $type = $_POST['type']; $address = $_POST['address']; $rcon = $_POST['rcon']; $address = explode(':', $address); $ip = gethostbyname($address[0]); $port = $address[1]; $region = ''; $map = $_POST['map']; $division = ''; if (isset($_POST['address'])) {
<?php require_once __DIR__ . '/social.php'; if (!isset($_SESSION["rol"]) || isset($_SESSION["rol"]) && $_SESSION["rol"] < 1) { header('Location:permissions.php'); } else { $id_friend = $_GET['id']; addFriend($id_friend); header('Location:' . $_SERVER['HTTP_REFERER']); }
break; case 17: //删除单个用户 var_dump(deleteUser("zhangsan")); break; case 18: //删除批量用户 var_dump(deleteUsers(2)); break; case 19: //修改昵称 var_dump(editNickname("zhangsan", "小A")); break; case 20: //添加好友---- var_dump(addFriend("zhangsan", "lisi")); break; case 21: //删除好友 var_dump(deleteFriend("zhangsan", "lisi")); break; case 22: //查看好友 var_dump(showFriends("zhangsan")); break; case 23: //查看黑名单 var_dump(getBlacklist("zhangsan")); break; case 24: //往黑名单中加人
if (isset($_REQUEST['link'])) { $profilelink = $_REQUEST['link']; } if (isset($_REQUEST['friends'])) { $friends = $_REQUEST['friends']; } if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'createuser': createUser($apikeyvalue, $username, $password, $displayname, $avatarfile, $avatarlink, $profilelink); break; case 'updateuser': updateuser($apikeyvalue, $userid, $username, $password, $newpassword, $displayname, $avatarfile, $avatarlink, $profilelink); break; case 'addfriend': addFriend($apikeyvalue, $userid, $friends); break; case 'removefriend': removeFriend($apikeyvalue, $userid, $friends); break; case 'getfriend': getfriend($apikeyvalue, $userid); break; case 'checkAPIKEY': checkAPIKEY($apikeyvalue); break; case 'checkpassword': checkpassword($apikeyvalue, $password); break; case 'authenticateUser': authenticateUser($apikeyvalue, $username, $password);
function addFriendName($uid, $name) { $name = stripslashes($name); $name = mysql_real_escape_string($name); $q = mysql_query("SELECT uid,UserName from `userList` where `UserName`='{$name}' or `Email`='{$name}'") or die(mysql_error()); $row = mysql_fetch_assoc($q); $frid = $row['uid']; if (!is_null($frid)) { if ($uid != $frid) { addFriend($uid, $frid); } else { echo "<script language=\"javascript\" type=\"text/javascript\">"; echo "alert('You Cannot add yourself as friend !')"; echo "</script>"; } } else { echo "<script language=\"javascript\" type=\"text/javascript\">"; echo "alert('User does not exist with the email or username you have given')"; echo "</script>"; } }
session_start(); if (!$_SESSION["username"]) { $url = $_SERVER['REQUEST_URI']; echo "<meta http-equiv=\"refresh\" content=\"0;url=Login.php?url={$url}\">"; } include 'connect.php'; require 'FriendHeader.php'; $username = $_SESSION['username']; $uid = $_SESSION['id']; echo "<div class='form'>"; if (isset($_GET['id']) && isset($_GET['cat'])) { $uidf = $_GET['id']; $cat = $_GET['cat']; if ($uid != $uidf) { if (strcmp($cat, 'add') == 0) { addFriend($uid, $uidf); } elseif (strcmp($cat, 'block') == 0) { blockFriend($uid, $uidf); } elseif (strcmp($cat, 'app') == 0) { appFriend($uid, $uidf); } elseif (strcmp($cat, 'ign') == 0) { ignFriend($uid, $uidf); } elseif (strcmp($cat, 'unblock') == 0) { unblockFriend($uid, $uidf); } elseif (strcmp($cat, 'unf') == 0) { ignFriend($uid, $uidf); } } else { echo "You cannot add or block yourself ;)"; } }
</head> <body> <?php require "php/topbar.php"; ?> <div class="maindiv"> <?php session_start(); require_once "php/database.php"; require_once "php/storedprocedures.php"; require_once "php/error.php"; $db = connectToDatabase(); if ($db) { if ($_POST['addfriendid']) { $results = addFriend($db, $_SESSION['id'], $_POST['addfriendid'], $_SESSION['token']); switch ($results[SP::ERROR]) { case ERR::OK: echo "<p>Friend added! <a href='friendslist.php'>See friends</a></p>"; break; case ERR::TOKEN_EXPIRED: case ERR::TOKEN_FAIL: case ERR::USER_NO_TOKEN: header("Location: logout.php?error=" . $results[SP::ERROR]); break; default: echo "<p>Could not add friend. Error: " . $ERRORS[$results[SP::ERROR]] . "</p>"; break; } } elseif ($_POST['deletefriendid']) { $results = removeFriend($db, $_SESSION['id'], $_POST['deletefriendid'], $_SESSION['token']);
{ $friendIds = array(); foreach ($friends as $value) { $friendIds[] = $value['id']; } $data = array("user_ids" => $friendIds, "notification" => array("alert" => $msg)); $data_string = json_encode($data); $ch = curl_init('https://push.ionic.io/api/v1/push'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-Ionic-Application-Id: ' . APP_ID, 'Content-Length: ' . strlen($data_string), 'Authorization: Basic ' . base64_encode(API_SECRET))); $result = curl_exec($ch); } $postdata = file_get_contents("php://input"); $request = json_decode($postdata); if (isset($request)) { $srcId = $request->srcId; $srcName = $request->srcName; $friends = $request->friends; $friendsArray = json_decode(json_encode($friends), true); foreach ($friendsArray as $val) { $targetId = $val['id']; $targetName = $val['name']; addFriend($mysqli, $srcId, $targetId, $srcName, $targetName); } addToUsers($mysqli, $srcId, $srcName, $friendsArray); fetchSync($mysqli, $srcId); } else { echo "No POST data was sent"; }
$slimApp->get('/getPopularBooks', 'getPopularBooks'); $slimApp->get('/findFriends', 'findFriends'); $slimApp->post('/friendBooks', function () { getUserBooks(); }); $slimApp->post('/lookupBook', function () { lookupBook(); }); $slimApp->post('/addBook', function () { addBook(); }); $slimApp->post('/register', function () { register(); }); $slimApp->post('/addFriend', function () { addFriend(); }); function getUserBooks() { $rtnObj = new rtnObj(); try { if (loggedIn()) { global $slimApp; $conn = dbConnect(); $request = $slimApp->request(); $body = $request->getBody(); $input = json_decode($body); $params = array($input->UserID); $query = $conn->prepare("SELECT Book.*, Inventory.StarRating, Inventory.Read, Inventory.InStock\n\t\t\t\t\t\t\t\t\t\t\tFROM Inventory\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN Book\n\t\t\t\t\t\t\t\t\t\t\tON Inventory.BookID=Book.BookID\n\t\t\t\t\t\t\t\t\t\t\tWHERE Inventory.OwnerID = ?\n\t\t\t\t\t\t\t\t\t\t\tORDER BY Book.Author asc"); $query->execute($params); $dataObj = $query->fetchAll(PDO::FETCH_ASSOC);
$blogRssCacheList = $blogRssCacheTable->getFriendBlogListByMemberId(1, 20); $t->is($blogRssCacheList->count(), 4, 'count success'); $t->is($blogRssCacheList[0]->getTitle(), 'title_2', 'title_2 success'); $t->is($blogRssCacheList[1]->getTitle(), 'title_2', 'title_2 success'); $t->is($blogRssCacheList[2]->getTitle(), 'title_1', 'title_1 success'); $t->is($blogRssCacheList[3]->getTitle(), 'title_1', 'title_1 success'); $blogRssCacheList = $blogRssCacheTable->getFriendBlogListByMemberId(2, 20); $t->is($blogRssCacheList->count(), 4, 'count success'); $t->is($blogRssCacheList[0]->getTitle(), 'title_4', 'title_4 success'); $t->is($blogRssCacheList[1]->getTitle(), 'title_3', 'title_3 success'); $t->is($blogRssCacheList[2]->getTitle(), 'title_2', 'title_2 success'); $t->is($blogRssCacheList[3]->getTitle(), 'title_1', 'title_1 success'); $blogRssCacheList = $blogRssCacheTable->getFriendBlogListByMemberId(2, 1); $t->is($blogRssCacheList->count(), 1, 'count success'); $t->is($blogRssCacheList[0]->getTitle(), 'title_4', 'title_4 success'); addFriend(2, 1, true); $blogRssCacheList = $blogRssCacheTable->getFriendBlogListByMemberId(1, 20); $t->is($blogRssCacheList->count(), 2, 'count success'); $t->is($blogRssCacheList[0]->getTitle(), 'title_2', 'title_2 success'); $t->is($blogRssCacheList[1]->getTitle(), 'title_1', 'title_1 success'); // getAllMembers $t->diag('->getAllMembers()'); $blogRssCacheList = $blogRssCacheTable->getAllMembers(40); $t->is($blogRssCacheList->count(), 22, 'count success'); $blogRssCacheList = $blogRssCacheTable->getAllMembers(5); $t->is($blogRssCacheList->count(), 5, 'count success'); $t->is($blogRssCacheList[0]->getTitle(), 'title_4', 'title_4 success'); $t->is($blogRssCacheList[1]->getTitle(), 'title_3', 'title_3 success'); $t->is($blogRssCacheList[2]->getTitle(), 'title_2', 'title_2 success'); $t->is($blogRssCacheList[3]->getTitle(), 'title_2', 'title_2 success'); $t->is($blogRssCacheList[4]->getTitle(), 'title_2', 'title_2 success');
session_start(); include_once 'include/allQueries.php'; if (!$_SESSION['login']) { header('Location:login.php'); } else { $completed = checkComplete(); if ($completed == false) { header('Location:completeAccount.php'); } } if (isset($_GET['q'])) { logout(); header("location:login.php"); } if (isset($_GET['AddId'])) { $res = addFriend($_GET['AddId']); if ($res) { header('Location:AllUsers.php'); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>All Users</title> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">