function render($twig, $sdata = array())
{
    if (!isset($_GET['steamid'])) {
        // no steamid given, f**k off
        echo $twig->render('404.php', $sdata);
        return false;
    }
    if ($_GET['steamid'] == $_SESSION['steamid'] || $_SESSION['admin'] === true) {
        // if you're looking at yourself you get your full history
        // same goes for admins
        $player = new Player(array('search' => $_GET['steamid'], 'fullhistory' => true));
    } else {
        // otherwise it's just the latest 10 runs
        $player = new Player(array('search' => $_GET['steamid']));
    }
    if ($player->steamid == false) {
        // no player found
        echo $twig->render('404.php', $sdata);
        return false;
    }
    // is this player our friend?
    $f = new Friends();
    $is_friend = $f->checkFriend($_SESSION['steamid'], $player->steamid);
    // add or remove him from our friends list
    if (isset($_GET['friend']) && !$is_friend) {
        $f->addFriend($_SESSION['steamid'], $player->steamid);
        $is_friend = !$is_friend;
        header("Location: /player/" . $player->steamid);
    } elseif (isset($_GET['friend']) && $is_friend) {
        $f->removeFriend($_SESSION['steamid'], $player->steamid);
        $is_friend = !$is_friend;
        header("Location: /player/" . $player->steamid);
    }
    // get followers
    $followers = $f->getFollowersForSteamId($player->steamid);
    // send out to render
    $data = array('player' => $player, 'is_friend' => $is_friend, 'followers' => $followers, 'stats' => $player->stats);
    if (isset($_GET['json'])) {
        print json_encode($data);
    } else {
        echo $twig->render('player.php', array_merge($sdata, $data));
    }
}
Example #2
0
        $msg = 'Failed to add this friend to your friends list.';
        return;
    }
    if (empty($add)) {
        event::fire('USER_ADD_FRIEND');
        $msg = "An email has been sent to your friend for confirmation!";
        $friends->sendFriendVerification($userid, $id);
    } else {
        $msg = $add;
    }
    return $msg;
}
if ($action == "remove") {
    $id = (int) $_GET['friendid'];
    $userid = $_SESSION['userid'];
    $add = $friends->removeFriend($id, $userid);
    if ($remove < 0) {
        $msg = 'Failed to remove this friend from your friends list.';
        return;
    }
    if (empty($remove)) {
        event::fire('USER_REMOVE_FRIEND');
        $msg = "Removed friend successfully.";
    } else {
        $msg = $add;
    }
    return $msg;
}
if ($action == "confirmFriend") {
    $id = $_GET['friendid'];
    $userid = $_GET['userid'];
Example #3
0
 */
require_once "../../config/db.php";
require_once "Friends.php";
if (isset($_POST["search"])) {
    $friends = new Friends();
    $result = $friends->searchFriend();
    echo $result;
}
if (isset($_POST["addFriend"])) {
    $friends = new Friends();
    $result = $friends->addFriend();
    echo $result;
}
if (isset($_POST["removeFriend"])) {
    $friends = new Friends();
    $result = $friends->removeFriend();
    echo $result;
}
if (isset($_POST["isFriend"])) {
    $friends = new Friends();
    $result = $friends->isFriend();
    echo $result;
}
if (isset($_POST["editFriend"])) {
    $friends = new Business();
    $result = $friends->editFriend();
    echo $result;
}
if (isset($_POST["getFeed"])) {
    $friends = new Friends();
    $result = $friends->getFeed();