public function unblockUser()
 {
     $profileID = getIdFromURL();
     $activeUserID = UserRepository::getIdByUsername($_SESSION['username']);
     try {
         ResctrictionRepository::removeRestriction($activeUserID, $profileID);
         redirect(Route::get("userProfile")->generate(array("id" => $profileID)));
     } catch (\PDOException $e) {
         $e->getMessage();
     }
 }
/**
 * Checks if user has permission to comment on photo or edit tags.
 * User can comment photo or edit tags if he is friend with user that posted the tweet.
 * @return true if user has permission to comment photo or edit tag
 */
function checkPermissionToCommentPhotoAndEditTags()
{
    $photoid = getIdFromURL();
    $photo = \Repository\PhotoRepository::getPhotoByID($photoid);
    $activeUserID = \Repository\UserRepository::getIdByUsername($_SESSION['username']);
    $gallery = \Repository\GalleryRepository::getByID($photo['galleryid']);
    $galleryCreatorID = $gallery['userid'];
    if ($activeUserID != $galleryCreatorID) {
        if (\Repository\FriendRepository::isFriend($activeUserID, $galleryCreatorID) == null || \Repository\ResctrictionRepository::isBlocked($galleryCreatorID, $activeUserID) != null) {
            return false;
        }
    }
    return true;
}
Exemple #3
0
 public function galleryRssFeed()
 {
     checkUnauthorizedAccess();
     $galleryID = getIdFromURL();
     checkIntValueOfId($galleryID);
     $gallery = GalleryRepository::getByID($galleryID);
     if ($gallery == null) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     $photos = PhotoRepository::getPhotosByGalleryID($galleryID);
     $title = $gallery['title'];
     $link = "http://192.168.56.101/TwitterApp/gallery/" . $galleryID;
     $description = "Images in selected gallery.";
     generateGalleryRss($title, $link, $description, $photos);
 }
Exemple #4
0
 public function readMessage()
 {
     checkUnauthorizedAccess();
     $id = getIdFromURL();
     if (null === $id) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     if (intval($id) < 1) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     //dohvati poruku preko id-a
     $message = MessageRepository::getMessageByID($id);
     //obavijesti da je poruka pročitana
     MessageRepository::setRead($id);
     $main = new Main();
     $body = new ReadMessage();
     $body->setMessage($message);
     echo $main->setPageTitle("Read Message")->setBody($body);
 }
Exemple #5
0
 public function postTweetComment()
 {
     checkUnauthorizedAccess();
     $id = getIdFromURL();
     checkIntValueOfId($id);
     if (post('comment')) {
         $tweetid = $id;
         $username = $_SESSION['username'];
         $userid = UserRepository::getIdByUsername($username);
         $content = htmlentities(trim(post('comment')));
         $comment = new TweetComment();
         $comment->setTweetid($tweetid);
         $comment->setUserid($userid);
         $comment->setContent($content);
         try {
             TweetCommentRepository::postComment($comment);
             echo json_encode(['comment' => parseText($comment->getContent()), 'user' => $username]);
         } catch (\PDOException $e) {
             $e->getMessage();
         }
     }
 }
 public function postTweet()
 {
     checkUnauthorizedAccess();
     if (post('tweet')) {
         $fromid = UserRepository::getIdByUsername($_SESSION['username']);
         $toid = getIdFromURL();
         $content = htmlentities(trim(post('content')));
         $tag = htmlentities(trim(post('tag')));
         $photo = post('selectPhoto');
         $tweet = new Tweet();
         $tweet->setFromid($fromid);
         $tweet->setToid($toid);
         $tweet->setContent($content);
         $tweet->setImage($photo);
         $tweet->setTag($tag);
         try {
             TweetRepository::postTweet($tweet);
             redirect(\route\Route::get("twitterWall")->generate(array("id" => $toid)));
         } catch (\PDOException $e) {
             $e->getMessage();
         }
     }
 }
Exemple #7
0
 public function editPhotoTags()
 {
     checkUnauthorizedAccess();
     $id = getIdFromURL();
     checkIntValueOfId($id);
     if (post('postTags')) {
         $tags = post('tags');
         try {
             PhotoRepository::editPhotoTags($tags, $id);
             redirect(\route\Route::get("viewPhoto")->generate(array("id" => $id)));
         } catch (\PDOException $e) {
             $e->getMessage();
         }
     }
 }
    protected function outputHTML()
    {
        ?>

        <div class="container">

        <?php 
        //provjera da li su prijatelji ili da li je to sam korisnik
        if (checkPermissionToTweet()) {
            //forma za dodavanje novih tweetova
            ?>

            <script src="/TwitterApp/assets/js/postTweetForm.js"></script>

            <div class="col-md-4 col-md-offset-4">
                <button id="open" class="btn btn-success btn-block">Post tweet</button>
            </div>

            <form class="form-horizontal" id="tweet-form" role="form" method="post"
                  action="<?php 
            echo \route\Route::get("postTweet")->generate(array("id" => getIdFromURL()));
            ?>
">

                <br><br>

                <div class="form-group">
                    <div class="col-md-4 col-md-offset-4">
                        <textarea class="form-control" rows="3" name="content" id="content"
                                  placeholder="What's happening?" required></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-4 col-md-offset-4">
                        <input type="text" class="form-control" name="tag" id="tag" placeholder="Enter tweet tag (optional)">
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-4 col-md-offset-4">
                        <select name="selectPhoto" id="sel1" class="form-control">
                            <option value="">Select photo...</option>
                            <?php 
            foreach ($this->userPhotos as $photo) {
                ?>
                                <option value="<?php 
                echo $photo['path'];
                ?>
"><?php 
                echo $photo['image'];
                ?>
</option>
                                <?php 
            }
            ?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-4 col-md-offset-4">
                        <div style="color: green" id="success"></div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-4 col-md-offset-4">
                        <input type="submit" class="btn btn-info btn-block" name="tweet" id="tweet" value="Tweet">
                    </div>
                </div>

            </form>

            <br><br>

            <?php 
        } else {
            ?>
            <div class="col-md-4 col-md-offset-1">
                <p>To post tweet on this wall you need to become friends.</p>
                <hr>
            </div>

            <?php 
        }
        $counter = 0;
        //prikaži sve tweetove na korisnikovom zidu
        foreach ($this->tweets as $tweet) {
            $counter++;
            $user = UserRepository::getUserByID($tweet['fromid']);
            $numberOfComments = TweetRepository::getNumberOfComments($tweet['tweetid']);
            $value = "Comments";
            if ($numberOfComments == 1) {
                $value = "Comment";
            }
            ?>

                <div class="col-md-10 col-md-offset-1">
                    <div class="panel panel-info" id="comments">
                        <div class="panel-heading">
                            <h3 class="panel-title">Posted by: <?php 
            echo $user['username'];
            ?>
</h3>
                        </div>

                        <div class="panel-body">
                            <div>
                                <?php 
            echo parseText($tweet['content']);
            ?>
                            </div>
                        </div>

                        <div class="panel-footer">
                            <div>
                                <a href="<?php 
            echo \route\Route::get("viewTweet")->generate(array("id" => $tweet['tweetid']));
            ?>
"><?php 
            echo $numberOfComments . ' ' . $value;
            ?>
</a>
                            </div>
                        </div>
                    </div>
                </div>
                <?php 
        }
        //ako nema tweetova, obavijeti korisnika
        if ($counter == 0) {
            ?>
                <div class="col-md-10 col-md-offset-1">
                    <div class="panel panel-info" id="comments">
                        <div class="panel-heading">
                            <h3 class="panel-title">Tweets</h3>
                        </div>
                        <div class="panel-body">
                            There are no tweets to show.
                        </div>
                    </div>
                </div>
                <?php 
        }
        ?>
        </div>

        <?php 
    }
<?php

session_start();
$baseURL = "../";
require $baseURL . 'functions.php';
require $baseURL . 'config.php';
$debug = 0;
if ($_POST['formSubmitted'] == "true" || (isset($_GET['id']) && is_numeric($_GET['id']) || isset($_GET['url']))) {
    if (isset($_GET['url'])) {
        $curseAddonID = getIdFromURL($_GET['url']);
    }
    if ($_POST['formSubmitted'] == "true") {
        $curseAddonID = trim($_POST['curseAddonID']);
    }
    if (isset($_GET['id'])) {
        $curseAddonID = trim($_GET['id']);
    }
    if (isset($_GET['deleteAddon']) && $_GET['deleteAddon']) {
        $deleteAddon = true;
    }
    if ($deleteAddon) {
        if (deleteAddon($curseAddonID)) {
            $_SESSION['message'] = "The Addon {$addonName} has been deleted.";
        } else {
            $_SESSION['message'] = "Deleting Addon failed.";
        }
    } else {
        if (updateAddon($curseAddonID)) {
            $_SESSION['message'] = stripslashes($addonName) . " was updated.";
        } else {
            $_SESSION['message'] = stripslashes($addonName) . " is up to date as of " . $currentDateTime[1] . ".";