コード例 #1
0
ファイル: SearchBar.php プロジェクト: chiiiro/SSP-TwitterApp
 public function advancedSearch()
 {
     if (post('submitSearch')) {
         $str = post('searchInput');
         //            $str = preg_replace("#[^0-9a-z]#i","",$str);
         //parsiranje AND-ova i OR-ova
         $values = preg_split("/[\\s,]+/", $str);
         $photos = PhotoRepository::getAllPhotos();
         $tags = array();
         //svi tagovi od svih slika
         foreach ($photos as $photo) {
             array_push($tags, $photo['tags']);
         }
         //            $stack = new \SplStack();
         //
         //            foreach($values as $value) {
         //                if(strtolower($value) != "and" && strtolower($value) != "or") {
         //                    $stack->push($value);
         //                }
         //            }
         //showing results
         $main = new Main();
         $searchResults = new SearchResults();
         $searchResults->setPhotos($photos);
         echo "<div class='container'>";
         echo $main->setBody($searchResults);
     }
 }
コード例 #2
0
/**
 * 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;
}
コード例 #3
0
ファイル: RssFeed.php プロジェクト: chiiiro/SSP-TwitterApp
 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);
 }
コード例 #4
0
ファイル: AddPhoto.php プロジェクト: chiiiro/SSP-TwitterApp
 /**
  * Function adds photo to gallery.
  * Photo has user id, title, list of tags, date of creation and name of chosen picture.
  */
 public function action()
 {
     checkUnauthorizedAccess();
     $id = \dispatcher\DefaultDispatcher::instance()->getMatched()->getParam("galleryID");
     checkIntValueOfId($id);
     $gallery = GalleryRepository::getByID($id);
     if ($gallery == null) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     $main = new Main();
     $body = new \templates\AddPhoto();
     $main->setBody($body)->setPageTitle("Upload photo");
     echo $main;
     if (post('submit')) {
         $title = trim(post('title'));
         $tags = trim(post('tags'));
         $error = false;
         if (strlen($title) < 4 || strlen($title) > 25) {
             $error = true;
         }
         if (strlen($tags) < 4 || strlen($tags) > 250) {
             $error = true;
         }
         if (!$error) {
             $dir = $gallery['title'];
             $path = 'assets/images/galleries/' . $dir;
             $localPath = $path . "/" . $_FILES['file']['name'];
             $completePath = "/TwitterApp/" . $path . "/" . $_FILES['file']['name'];
             $photo = new Photo();
             $photo->setGalleryid($id);
             $photo->setTitle($title);
             $photo->setTags($tags);
             $photo->setCreated(date('Y-m-d H:i:s'));
             $photo->setImageName($_FILES['file']['name']);
             $photo->setImagePath($completePath);
             try {
                 if (!file_exists($path)) {
                     mkdir($path);
                 }
                 move_uploaded_file($_FILES['file']['tmp_name'], $localPath);
                 PhotoRepository::addPhoto($photo);
                 redirect(\route\Route::get("viewGallery")->generate(array("id" => $id)));
             } catch (\PDOException $e) {
                 $e->getMessage();
             }
         }
     }
 }
コード例 #5
0
 public function action()
 {
     $photoID = getParamFromURL("id");
     $filter = getParamFromURL("filter");
     $photo = PhotoRepository::getPhotoByID($photoID);
     $path = substr($photo['path'], 12);
     $im = null;
     $imageType = null;
     if (endsWith($photo['image'], ".jpeg") || endsWith($photo['image'], ".jpg")) {
         $im = imagecreatefromjpeg($path);
         $imageType = "jpeg";
     } else {
         if (endsWith($photo['image'], ".png")) {
             $im = imagecreatefrompng($path);
             $imageType = "png";
         }
     }
     if ($filter === "blackwhite") {
         BlackWhite::filter($im);
     } else {
         if ($filter === "brightness") {
             $brightness = post('number');
             Brightness::setBrightness($brightness);
             Brightness::filter($im);
         } else {
             if ($filter === "sepia") {
                 Sepia::filter($im);
             } else {
                 if ($filter === "blur") {
                     Blur::filter($im);
                 }
             }
         }
     }
     header('Content-Type: image/' . $imageType);
     if ($imageType === "jpeg") {
         imagejpeg($im);
         imagejpeg($im, $path);
     } else {
         imagepng($im);
     }
     imagedestroy($im);
     redirect(Route::get("viewPhoto")->generate(array("id" => $photo['photoid'])));
 }
コード例 #6
0
 public function action()
 {
     $id = getIdFromURL();
     $user = UserRepository::getUserByID($id);
     checkRequestURL($id, $user);
     $tweets = TweetRepository::getMyTweets($id);
     $userGalleries = GalleryRepository::getUserGalleries($id);
     $userPhotos = array();
     foreach ($userGalleries as $gallery) {
         $photos = PhotoRepository::getPhotosByGalleryID($gallery['galleryid']);
         foreach ($photos as $photo) {
             array_push($userPhotos, $photo);
         }
     }
     $main = new Main();
     $body = new \templates\TwitterWall();
     $body->setTweets($tweets)->setUserPhotos($userPhotos);
     echo $main->setPageTitle("TwitterApp")->setBody($body);
 }
コード例 #7
0
 /**
  * Opens selected gallery, shows gallery icon, title and date of creation.
  * Also provides option of adding a new photo to gallery.
  */
 public function action()
 {
     checkUnauthorizedAccess();
     $id = \dispatcher\DefaultDispatcher::instance()->getMatched()->getParam("id");
     if (null === $id) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     if (intval($id) < 1) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     $gallery = GalleryRepository::getByID($id);
     if ($gallery == null) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     $main = new Main();
     $body = new \templates\ViewGallery();
     $photos = PhotoRepository::getPhotosByGalleryID($id);
     $gallery = GalleryRepository::getByID($id);
     $body->setGalleryID($id)->setPhotos($photos)->setGallery($gallery);
     $main->setBody($body)->setPageTitle("View gallery");
     echo $main;
 }
コード例 #8
0
ファイル: ViewPhoto.php プロジェクト: chiiiro/SSP-TwitterApp
 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();
         }
     }
 }