Invite::checkValidity PHP Method

checkValidity() public method

public checkValidity ( $secret )
    public function checkValidity($secret)
    {
        $sth = $this->db->prepare('SELECT * FROM invites WHERE secret = ?');
        $sth->bindParam(1, $secret, PDO::PARAM_STR);
        $sth->execute();
        if (!$sth->fetch()) {
            throw new Exception(L::get("INVITE_NOT_FOUND"), 404);
        }
    }

Usage Example

Example #1
0
/* Routes acceptable not logged in */
try {
    switch (true) {
        case validateRoute('GET', 'auth'):
            $user->login($_GET["username"], $_GET["password"]);
            httpResponse($user->getStatus());
            break;
        case validateRoute('POST', 'auth'):
            httpResponse($user->create($postdata));
            break;
        case validateRoute('POST', 'recover/by-passkey'):
            httpResponse($user->recoverByPasskey($postdata));
            break;
        case validateRoute('GET', 'invite-validity'):
            $invite = new Invite($db, $user);
            httpResponse($invite->checkValidity($_GET["secret"]));
            break;
        case validateRoute('POST', 'recover/by-email'):
            httpResponse($user->recoverByEmail($postdata));
            break;
        case validateRoute('GET', 'recover/by-email'):
            httpResponse($user->gotRecoverByEmail($_GET["secret"]));
            break;
        case validateRoute('GET', 'torrents-matcher/torrents'):
            $torrentsMatcher = new TorrentsMatcher($db);
            httpResponse($torrentsMatcher->getTorrents($_GET["passkey"]));
            break;
        case validateRoute('GET', 'torrents-matcher/configs'):
            $torrentsMatcher = new TorrentsMatcher($db);
            httpResponse($torrentsMatcher->getSettings($_GET["passkey"]));
            break;