Ejemplo n.º 1
0
 public function processImageAction()
 {
     $this->_helper->layout()->disableLayout();
     $objModelAlbum = new Album_Model_Album();
     /*----------- GET LOGGEDIN USER INFORMATION ----------------------*/
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     $arrPostVal = $this->getRequest()->getParams();
     $fileName = $arrPostVal['fileName'];
     $fileSize = $arrPostVal['fileSize'];
     $fileType = $arrPostVal['fileType'];
     $album = $arrPostVal['album'];
     $quality = $arrPostVal['quality'];
     /*-------------------- GET EXTENSION OF FILE ----------------------*/
     $arrExtension = explode(".", $fileName);
     $arrExtensionSize = count($arrExtension);
     $fileType = "." . $arrExtension[$arrExtensionSize - 1];
     /*------------------- CHECK AVAILABLE USER PHOTO CAPACITY ---------*/
     $arrAlbumCapacity = $objModelAlbum->albumCapacity($userId);
     $maximumCapacity = 5368709120;
     // 5 GB
     //$maximumCapacity = 47185920;	// 45 MB
     $availableCapacity = $maximumCapacity - $arrAlbumCapacity[2];
     if ($availableCapacity < $fileSize) {
         echo 'completed';
         exit;
     } else {
         /*------------------- END AVAILABLE CHECK USER PHOTO CAPACITY -----*/
         $this->view->uploading_type = $arrPostVal['uploadingType'];
         $this->view->review_edit = $arrPostVal['review_edit'];
         $uploadedCount = $arrPostVal['uploadedCount'];
         $newPhotoName = "album_" . time() . "_" . rand(10, 99) . $fileType;
         $imagePath = PUBLIC_PATH . "/media/album/default/" . $fileName;
         $targetPath = PUBLIC_PATH . "/media/album/default/" . $newPhotoName;
         $targetPathR = PUBLIC_PATH . "/media/album/custom/" . $newPhotoName;
         $targetPathT = PUBLIC_PATH . "/media/album/thumb/" . $newPhotoName;
         set_time_limit(0);
         copy($imagePath, $targetPathR);
         rename($imagePath, $targetPath);
         $mageSize = $this->getImageSize($quality, $targetPath);
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize($mageSize['width'], $mageSize['height']);
         $thumb->save($targetPathR);
         $thumb->resize(131, 98);
         // Thumb Image
         $thumb->save($targetPathT);
         //---> Fetch Album Permission
         $valAlbum = $objModelAlbum->find($album);
         $this->view->albumPermission = $albumPermission = $valAlbum->getPermission();
         /*----------- CAPTURE TO DATABASE --------------------------------*/
         $option['albumId'] = $album;
         $option['userId'] = $userId;
         $option['image'] = $newPhotoName;
         $option['name'] = $newPhotoName;
         $option['type'] = $fileType;
         $option['size'] = filesize($targetPath);
         $option['status'] = 1;
         $option['permission'] = $albumPermission;
         $option['addedon'] = time();
         $objModelAlbumPhoto = new Album_Model_AlbumPhoto($option);
         $objModelAlbumPhoto->save();
         $objModelFriendGroup = new Application_Model_FriendGroup();
         $arrFriendGroup = $objModelFriendGroup->getPermissions();
         $this->view->arrFriendGroup = $arrFriendGroup;
         $this->view->uploadedCount = $uploadedCount;
         $this->view->album = $album;
         $objModelUserPermission = new Application_Model_UserPermission();
         $whereUserPermission = "permission_id='5' AND user_id='{$userId}'";
         $arrUserPermission = $objModelUserPermission->fetchRow($whereUserPermission);
     }
 }
Ejemplo n.º 2
0
 public function processImageAction()
 {
     $this->_helper->layout()->disableLayout();
     $arrPostVal = $this->getRequest()->getParams();
     $fileName = $arrPostVal['fileName'];
     $fileSize = $arrPostVal['fileSize'];
     $fileType = $arrPostVal['fileType'];
     $album = $arrPostVal['album'];
     $quality = $arrPostVal['quality'];
     $this->view->uploading_type = $arrPostVal['uploadingType'];
     $this->view->review_edit = $arrPostVal['review_edit'];
     $uploadedCount = $arrPostVal['uploadedCount'];
     $newPhotoName = "album_" . time() . "_" . rand(10, 99) . $fileType;
     $imagePath = PUBLIC_PATH . "/images/album/default/" . $fileName;
     $targetPath = PUBLIC_PATH . "/images/album/default/" . $newPhotoName;
     $targetPathR = PUBLIC_PATH . "/images/album/custom/" . $newPhotoName;
     $targetPathT = PUBLIC_PATH . "/images/album/thumb/" . $newPhotoName;
     copy($imagePath, $targetPathR);
     rename($imagePath, $targetPath);
     $mageSize = $this->getImageSize($quality);
     $thumb = Base_Image_PhpThumbFactory::create($targetPath);
     $thumb->resize($mageSize['width'], $mageSize['height']);
     $thumb->save($targetPathR);
     $thumb->resize(131, 98);
     // Thumb Image
     $thumb->save($targetPathT);
     /*----------- GET LOGGEDIN USER INFORMATION ----------------------*/
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     /*----------- CAPTURE TO DATABASE --------------------------------*/
     $option['albumId'] = $album;
     $option['userId'] = $userId;
     $option['image'] = $newPhotoName;
     $option['name'] = $newPhotoName;
     $option['type'] = $fileType;
     $option['size'] = filesize($targetPathR);
     $option['status'] = 1;
     $option['permission'] = 1;
     $option['addedon'] = time();
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto($option);
     $objModelAlbumPhoto->save();
     $objModelFriendGroup = new Application_Model_FriendGroup();
     $arrFriendGroup = $objModelFriendGroup->getPermissions();
     $this->view->arrFriendGroup = $arrFriendGroup;
     $this->view->uploadedCount = $uploadedCount;
     $this->view->album = $album;
 }