4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: ehsan on December 18, 2002, 10:47:17 PM

Title: Automated Random Image Names
Post by: ehsan on December 18, 2002, 10:47:17 PM
Hi all, :wink:

Is there any chance to rename or define random automated names for images, just for security reasons!
i mean when u upload a photo, it will rename it automaticly and save it with a random name (like a code)
in this way, no body can find ur images' files.

thanx for any help and support, 8)
Title: Nope
Post by: Chris on December 19, 2002, 05:05:53 AM
That won't work.  Even if the file is renamed, all I would have to do is "View Source" and find the <img> HTML tag that is displays the renamed image.  That tag will have "src=" and will tell me the image directory and file name.
Title: Automated Random Image Names
Post by: ehsan on December 19, 2002, 06:00:15 AM
Quote


That won't work. Even if the file is renamed, all I would have to do is "View Source" and find the <img> HTML tag that is displays the renamed image. That tag will have "src=" and will tell me the image directory and file name.



maybe i said in a wrong way, but in this way the user will only find the browsing file name and as the other names are random, he/she will never find the other one,
for example in the source code has written:

<img src="http://....../14fs832jkfsd.jpg">

how can you or the user guess the other file names or files in private folders, cuz az i know the folder names are starting from 1 and are just a simple number. so finding private files are not that much difficult,

I dunno if I can password protect the /data/media/ folder with a .htaccess or not ?! will u write the correct form of password protection in .htaccess file?!

thanx  :wink:
Title: Still no
Post by: Chris on December 19, 2002, 03:36:29 PM
Quote from: ehsan
Quote
maybe i said in a wrong way, but in this way the user will only find the browsing file name and as the other names are random, he/she will never find the other one,
for example in the source code has written:

<img src="http://....../14fs832jkfsd.jpg">

But that means the web browser can't find the file either and so it won't be able to display the jpg.
Title: Automated Random Image Names
Post by: V@no on December 29, 2002, 05:14:17 AM
u can rename with random/encrypted name when u upload as user or admin.
here is what u need to do:
1. Open /includes/upload.php file (thx ehsan for correction)
1.1. Find:
Code: [Select]
   case 3: // do nothing if exists, highest protection
    default:
      if (file_exists($this->upload_path[$this->image_type]."/".$this->file_name)) {
       $this->set_error($this->lang['file_already_exists']);
       $ok = 0;
      }
      else {
        $ok = move_uploaded_file($this->upload_file, $this->upload_path[$this->image_type]."/".$this->file_name);
      }
      break;
Add after:
Code: [Select]
   case 4: // random rename
      $rand_numb = md5(uniqid(microtime())); //generate random name u can change this to rand(1,99999); if u want make shorter name
      while (file_exists($this->upload_path[$this->image_type]."/".$rand_numb.".".$this->extension)) { //checking if this file already exist
      $rand_numb = md5(uniqid(microtime())); //wow! same name exist! let's try again.
      }
      $this->file_name = $rand_numb.".".$this->extension;
      $ok = move_uploaded_file($this->upload_file, $this->upload_path[$this->image_type]."/".$this->file_name);
      break;

2. Open /lang/yourlang/admin.php file (" yourlang " - is your language folder ex. english)
2.1. Find:
Code: [Select]
$upload_mode_optionlist = array(
  "1" => "Replace files",
  "2" => "Save files with new name",
  "3" => "No file upload"
);
Change to:
Code: [Select]
$upload_mode_optionlist = array(
  "1" => "Replace files",
  "2" => "Save files with new name",
  "3" => "No file upload",
  "4" => "Random filename"
);


Now u need go to admin settings and change how u want handle uploaded images.
Uploaded files will be renamed to encrypted/randomely generated names.
But it wont work if u do "check image" or "batch import", only if uploaded one-by-one.
Title: Automated Random Image Names
Post by: ehsan on January 01, 2003, 11:28:23 PM
Hi V@no,

Happy new year! 8)

thanx for ur Random Image hack,
(the first file is /include/upload.php not /admin/upload.php)
It's working realy great, but I didn't get ur last sentence, cuz it works properly for multiple uploads, so ??
I checked ur website and its hackes and mods are perfect, especialy the Larg Size Photo, but i realy liked the thumb preview for non members,
anyways, would u plz post the code changes for thumb preview for non-members, as u used in ur site,
of course if it is possible...
thanx !  :wink:
Title: Automated Random Image Names
Post by: V@no on January 02, 2003, 01:27:10 AM
Thanks ehsan for the correction.
well, what I ment by my last sentence, that if u upload pictures directly into ( /data/media/x ) your category and then do 'check image' it wont rename those files and will add them with normal names, because the "check new image" script doesnt even execute the script that renames files. Same thing happens when u have "Batch Import" mod installed and use it.

and if u asked me about the popup message when non-member click on a thumbnail for the category witch settings for "view pictures" set to "registered users only", then u can find the code here:
http://www.4homepages.de/forum/viewtopic.php?t=3304
 :D
Happy New Year everyone!
Title: Re: Automated Random Image Names
Post by: TIMT on September 21, 2005, 07:01:35 PM
Hi V@no

Is it possible instead of renaming the file with a random features to rename the file with a prefix?

There are 4 different prefixes:
32q_ (width-to-height ratio 3:2, landscape format)
32h_ (width-to-height ratio 3:2, panel format)
43q_ (width-to-height ratio 4:3, landscape format)
43h_ (width-to-height ratio 4:3, panel format)

While uploading a picture there should be done the following checks:
1.   Has the picture the required width-to-height ratio of 3:2 or 4:3? When not, the picture has to be rejected. A limit of tolerance should be definable.
2.   which is the format of the picture? Landscape format (1) or panel format (2).  The format should be stored in the database (value 1 or 2)
3.   assign the prefix according width-to-height ratio and format

A picture with the original name “house.jpg”, and a width-to-height ratio 3:2, and landscape format should get the filename “32q_house.jpg”. The new name is stored in the database.

In the database, in the table “4images_images”, there is a filed “image_format” (defined by me).
When a picture has a width-to-height ratio of 3:2, the value „11.5 x 16 cm“ should be stored.
When a picture has a width-to-height ratio of 4:3, the value „12 x 16 cm “ should be stored.

Is that a big issue?

Thanks for helping me.

TIMT
Title: Re: Automated Random Image Names
Post by: kief24 on October 29, 2005, 10:44:28 AM
is it possible to rename your .jpg files manually ?
i would like to rename all my jpg files from dutch to english
ex. : dobberen.jpg should become floating.jpg

Title: Re: Automated Random Image Names
Post by: V@no on October 29, 2005, 12:49:22 PM
not after they were added to your gallery... :?
Title: Re: Automated Random Image Names
Post by: kief24 on October 29, 2005, 01:45:23 PM
ok, thx

so i'll have to delete them, rename them, and upload them again

 :? :(