Jump to content

Encryption/Random link ending


Bradley99

Recommended Posts

You could do a few things.

 

One thing is you could use the current timestamp as the image name. That would make duplicates almost impossible.

 

You could also take an MD5 hash of the file name, though you could run into the same file names unless you use a unique salt with every hash. You could easily just use a randomized string, or the current time stamp as the salt.

 

Of course if you can do MD5, you can also use Sha1 or any other hashing or encrypting technique.

Link to comment
Share on other sites

How would i use the timestamp? Or the easiest way? It's nothing major so don't want to spend too much time doing it. Code below

 

// App
define('APP_NAME', 'Hosting Mall'); // Your image hosting name
define('TAG_LINE', 'Image Hosting For Everyone'); // Your tagline (for doctitles and logo)
define('DESCRIPTION', 'Free Image Hosting Worldwide'); // For meta description
define('KEYWORDS', 'images, photos, image hosting, photo hosting, free image hosting'); // For meta keywords

// Folders
/* If you change this, you also must change the folders name. */
define('DIR_UP','up/');
define('DIR_IM','x!/'); // Change this to have something like /X/filename.jpg - where "X/" is the folder name. 
define('DIR_WORKING',DIR_UP.'working/');
define('DIR_TEMP',DIR_UP.'temp/');
define('DIR_TH','thumbs/');

// Min-Max values -> php.ini rules the nation...
$max_mb = '2'; // Max. image size (Mbytes)
$max_by = $max_mb*1048576; // (bytes)
$max_name = '10'; // Max. file name lenght.

// Thumbs
$mini_ancho = '150'; // Thumb width (pixels)
$mini_alto = '150'; // Thumb height (pixels)

// Resize
$lowres = '16'; // Min. resize value (pixels)
$higres = '1280'; // Max. resize value (pixels)

// Options
$lim_act = true; // true: Allows uploading just for your domain - false: Allows upload from anywhere (post from another website)
$debug_mode = false; // false: Debug OFF - true: Debug ON.
$cut_url = true; // true: Short URLs (TinyURL tr.im etc.) - false: normal url (http://mysite.com/images/image.jpg).
$cut_url_service = 'tinyurl'; // tinyurl
$cut_url_user = true; // If $cut_url = true -> true: Allows your users to cut their urls (preference) - false: Users can't choose to cut or not.
$allow_over_resize = false; // true: Allows over resize images - false: Don't allow over resize.

Link to comment
Share on other sites

well that isnt an upload script.. just seems to be some variables you are defining, but in the upload script you simply set the name of the uploaded file as th current time stamp, which can be gotten via the time() function. so for example

$filename = time();
//proceed with move_uploaded_file() function, using the filename above
//in your case, you probably have a directory included in the file name
//so it may be something like $filename = "x!/".time();

 

Link to comment
Share on other sites

Posted wrong script, isit something to do with this?

 

function ImageCreateFromBmp($filename) {
			/*** create a temp file ***/
			$tmp_name = tempnam("/tmp", "GD");
			/*** convert to gd ***/
			if(bmp2gd($filename, $tmp_name)) {
				/*** create new image ***/
				$img = imagecreatefromgd($tmp_name);
				/*** remove temp file ***/
				unlink($tmp_name);
				/*** return the image ***/
				return $img;
			}
			return false;
		}

		$bmp_img = ImageCreateFromBmp($handlework);
		unlink($handlework);

		$bmp2png = DIR_WORKING.substr($tmp_name, 0, -3).'png';
		imagepng($bmp_img, $bmp2png);

		unset($handlework); $handlework = $bmp2png;		
		unset($exten); $exten = 'png';

	}

Link to comment
Share on other sites

Do you not know your own script? Because I certainly don't.. So I can only guess. I don't know when that function is used, nor how it is used or if it is even used at all. If it is, then it seems you just have to set $handwork to the current timestamp (You may also need to concatenate the correct extension.

 

However, this is just a guess as I've said. I don't know your code, and am unfamiliar with the bmp2gd class/library/whatever it is either.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.