Hi. We are looking at setting up an a fully custom image hosting platform.

The idea is they create a free account securely, that pings an email to us. We use our Subscription gateway to them submit them a form to setup their monthly account costs.On receipt, we enable their account to begin uploading image files.

Each file is in the database and stored to their unique ID.

The issue is, if they decide to stop paying, how do we stop them from using the URL of the images they have uploaded? The only way I could think was to use hotlinking, to prevent it, but I don't know how to do that "per image".

Or, one button that would disable their access to their images screen, but also renames the file with a character at the start, thus meaning the image URL they have used somewhere, it now invalid.

Is this a good way, or is there a better way?

Once they pay again, we can click a button which would remove those first 2-3 characters off the filename and thus unlock it all.

_________________Love PHP. Love CSS. Love learning new tricks too.All the best from the United Kingdom.

Why not just move their image directory out of public or remove the symbolic link in public to their image directory. That would be faster than renaming a bunch of files. If the account is inactive it is in /inactive if it is active it is in /www. Or serve all the images through a proxy and authenticate there.

function getPaths($resize_type){// default for all paths,.$paths=array('fullsize'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'uploads','thumbnail'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'uploads',);return$paths;}

// Does the original image exist?if(file_exists($fullsize_directory.DIRECTORY_SEPARATOR.$filename)){// If it does, are we dealing with productphotos? We don't want to// accidentally delete a full-sized image from /pages or /stockbanners

// ENABLE this script when we are ready to definitely delete the old thumbnails.// if ($resize_type === 'thumbnails') {// File with the same name as the original but in the thumbs directory// $old_thumbnail = $thumbnail_directory . DIRECTORY_SEPARATOR . $filename;// Does this file exist?// if (file_exists($old_thumbnail)) {// Delete it// unlink($old_thumbnail);// }// }

// Takes input from a form post and saves original image plus all required resizesfunction resizeImage($path_to_file,$file_name,$resize_type){$imagine=new Imagine\Gd\Imagine();$paths= getPaths($resize_type);$fullsize_directory=dirname(__DIR__).$paths['fullsize'];$thumbnail_directory=dirname(__DIR__).$paths['thumbnail'];$pathinfo=pathinfo($file_name);$prefix=time();$renamed="{$prefix}_{$pathinfo['basename']}";

// Open the uploaded image with the Imagine library$image=$imagine->open($path_to_file);

// Re-open the original for scaling so we're not creating a larger image from a smaller$source=$imagine->open($path_to_original);$source->resize($scaled_box)->save($thumbnail_directory.DIRECTORY_SEPARATOR.$new_filename,$options);}return$renamed;}

// Resizes a single image to a specific size and with a specific suffixfunction resizeSingleImage($original,$suffix,$width,$save_path){$imagine=new Imagine\Gd\Imagine();

$paths= getPaths($save_path);// get the source file ready for renaming$source_directory=dirname(__DIR__).$paths['fullsize'];// where is the file going to be saved?$target_directory=dirname(__DIR__).$paths['thumbnail'];$pathinfo=pathinfo($original);

// Open the uploaded image with the Imagine library$image=$imagine->open($source_directory.DIRECTORY_SEPARATOR.$original);

function getPaths($resize_type){// default for all paths,.$paths=array('fullsize'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,'thumbnail'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,);return$paths;}...

But it doesn't work. It doesn't see the variable, so it puts the images in the images folder.

_________________Love PHP. Love CSS. Love learning new tricks too.All the best from the United Kingdom.

function getPaths($resize_type){// default for all paths,.$paths=array('fullsize'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,'thumbnail'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,);return$paths;}...

But it doesn't work. It doesn't see the variable, so it puts the images in the images folder.

That's outside the scope of any of the functions, so it's just sitting there doing nothing. If you want to use something inside a function, it needs to either be declared inside the function or passed in as an argument. This also doesn't necessarily look like the right place to be doing it.

function getPaths($resize_type){// default for all paths,.$paths=array('fullsize'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,'thumbnail'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,);return$paths;}

// Does the original image exist?if(file_exists($fullsize_directory.DIRECTORY_SEPARATOR.$filename)){// If it does, are we dealing with productphotos? We don't want to// accidentally delete a full-sized image from /pages or /stockbanners

// ENABLE this script when we are ready to definitely delete the old thumbnails.// if ($resize_type === 'thumbnails') {// File with the same name as the original but in the thumbs directory// $old_thumbnail = $thumbnail_directory . DIRECTORY_SEPARATOR . $filename;// Does this file exist?// if (file_exists($old_thumbnail)) {// Delete it// unlink($old_thumbnail);// }// }

// Takes input from a form post and saves original image plus all required resizesfunction resizeImage($path_to_file,$file_name,$resize_type){$imagine=new Imagine\Gd\Imagine();$paths= getPaths($resize_type);$fullsize_directory=dirname(__DIR__).$paths['fullsize'];$thumbnail_directory=dirname(__DIR__).$paths['thumbnail'];$pathinfo=pathinfo($file_name);$prefix=time();$renamed="{$prefix}_{$pathinfo['basename']}";

// Open the uploaded image with the Imagine library$image=$imagine->open($path_to_file);

// Re-open the original for scaling so we're not creating a larger image from a smaller$source=$imagine->open($path_to_original);$source->resize($scaled_box)->save($thumbnail_directory.DIRECTORY_SEPARATOR.$new_filename,$options);}return$renamed;}

// Resizes a single image to a specific size and with a specific suffixfunction resizeSingleImage($original,$suffix,$width,$save_path){$imagine=new Imagine\Gd\Imagine();

$paths= getPaths($save_path);// get the source file ready for renaming$source_directory=dirname(__DIR__).$paths['fullsize'];// where is the file going to be saved?$target_directory=dirname(__DIR__).$paths['thumbnail'];$pathinfo=pathinfo($original);

// Open the uploaded image with the Imagine library$image=$imagine->open($source_directory.DIRECTORY_SEPARATOR.$original);

$resize=isset($_POST['resize']) ? $_POST['resize']:null;$folder=isset($_POST['folder']) ? $_POST['folder']:null;require_once'functions/functionConsumerResize.php';// If we have an uploaded image without errorsif(!empty($_FILES)&&isset($_FILES['photoupload'])){$saved_filename= resizeImage($_FILES['photoupload']['tmp_name'],$_FILES['photoupload']['name'],$resize);}

You're calling resizeImage, so you'll need to modify that function to accept a folder as an optional parameter. If a folder is provided, you can do whatever you need with it. You could pass it through to getPaths, but I think a better option would be to leave that alone and append the folder, if you have one, inside resizeImage

How do I add that into resizeImage?Both fullsize and thumbnail are going to the same place. So sort of wondering why I am using this function at all, for this purpose. It's original purpose was to store various sizes in various folders. But now, I want to store various sizes in /images but then add on the /$folder/ on the end of it, based on the settings for each user.

_________________Love PHP. Love CSS. Love learning new tricks too.All the best from the United Kingdom.

If you're storing everything in the same directory, or all of a user's images in a directory just for them, then maybe getPaths ought to be modified. I expect most of the rest of the functionality can remain unchanged.

// Takes input from a form post and saves original image plus all required resizesfunction resizeImage($path_to_file,$file_name,$resize_type){$imagine=new Imagine\Gd\Imagine();$paths= getPaths($resize_type);$fullsize_directory=dirname(__DIR__).$paths['fullsize'];$thumbnail_directory=dirname(__DIR__).$paths['thumbnail'];.....}

I'm using these within the form:<input type='hidden' name='resize' value='thumbnails'><input type='hidden' name='folder' value='$folder'>I don't see where $resize is being fed into, as it was a while back this code was done.

I need to do $folder in the same way, and then tag it on the end of the two directories - just a bit stuck on how.

_________________Love PHP. Love CSS. Love learning new tricks too.All the best from the United Kingdom.

function getPaths($resize_type){// default for all paths,.$paths=array('fullsize'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,'thumbnail'=>DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder,);return$paths;}...

But it doesn't work. It doesn't see the variable, so it puts the images in the images folder.

That's outside the scope of any of the functions, so it's just sitting there doing nothing. If you want to use something inside a function, it needs to either be declared inside the function or passed in as an argument. This also doesn't necessarily look like the right place to be doing it.

Who is online

Users browsing this forum: No registered users and 18 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum