We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Adding more privacy to the plugin photo | Forum

Antonio
Antonio Oct 3 '11
.

First, sorry for my bad English.

I've been testing ways to add more privacy to this plugin, and I made a small hack that could be interesting.

The problem I found is that while a picture is marked as private, could always be seen by accessing the full path.

http://www.domain.tld/ow_userfiles/plugins/photo/photo_preview_ [num]. jpg

To avoid this, I thought that could change the controller "photo.php" by adding a function like this:

public function imgToFile(array $params) {
$contentOwner = $this->photoService->findPhotoOwner($params['id']);
$userId = OW::getUser()->getId();
$modPermissions = OW::getUser()->isAuthorized('photo');
$ownerMode = $contentOwner == $userId;
if ( !$ownerMode && !$modPermissions ) {
$privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId);
$event = new OW_Event('privacy_check_permission', $privacyParams);
OW::getEventManager()->trigger($event);
}
$imageFileName='nombre-imagen.jpg';
header("Content-type: image/jpg");
//This is incorrect, only for testing
$imageFileName = '/[oxwall_dir]/ow_userfiles/plugins/photo/photo_' . $params['id']. '.jpg';
readfile($imageFileName);
exit;
}

Thus, even be checked by directly accessing security.

Then it would be necessary to modify the "public function view (array $ params)" by modifying the line:

$ this-> assign ('url', $ this-> PhotoService-> getPhotoUrlExtra ($ photo-> id));

by:

$ this-> assign ('url', OW: getRoute () -> urlForRoute ('photo_list_testing_antonio', array ('id' => $ photo)));

Finally, we add the "init.php" the route:

OW:: getRoute () -> addRoute (new OW_Route ('photo_list_testing_antonio', 'photopath /: id /', 'PHOTO_CTRL_Photo', 'imgToFile'));

I understand that this is still far to be correct, but I wonder if in the future could be added to the official plugin changes.

If necessary, I agree to have a full version to make it easy to include.

I like to help more, but unfortunately there is very little documentation available for developers.

Regards, Antonio

Michael I.
Michael I. Dec 20 '12
Topic was moved from Plugins.
matt
matt Jan 1 '15
Bump! Asset security is a must for commercial websites. The option to enable it for securing assests, for those that need to: or have it disabled for those who do not wish secure asset and prefer the speed gain.