• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space

Random Filenames

  • Thread starter Thread starter Wacky
  • Start date Start date
Status
Not open for further replies.
W

Wacky

Guest
Hi guys

I love this script, can't wait for more features, is there a way of the script generating a random filename once the image has been uploaded instead of using the exact filename.

I uploaded logo.png for example and the link provided had http://www.sitename/logo.png

Is there a way of doing this like TinyPic.com

Thanks
 
Look up in engine.php this:
PHP:
// Limpiemos el nombre
			// --> Tambien me quedo "super rico".
			$lower = strtolower($tmp_name); // Solo minusculas
			$alnum = ereg_replace("[^[:alnum:]]","",$lower); // Solo alfanumericos
			if ($exten==peg) { unset($exten); $exten = 'jpg'; }
			$clear = substr_replace($alnum, '', -3); // sin extension ni punto
			// Cortemos el nombre (si hace falta)
			$conteo = strlen($clear);
			
			// Random
			$ch_1 = chr(rand(ord("a"), ord("z")));
			$ch_2 = chr(rand(ord("z"), ord("a")));
			
			if ($conteo>$max_name) {
				$renombre = substr("$clear", 0, $max_name);
			} else {
				if (empty($clear)) {
					$renombre = $ch_1.$ch_2.$ch_1;
				} else {
					$renombre = $clear;
				}
			}
				
			// Si existe el nombre, renombramos el que estamos subiendo.
        	if (file_exists(DIR_IM.$renombre.'.'.$exten)) {
				if ($conteo>$totalchars) { 
					// Si el nombre es muy largo, corta
					$renombra = substr("$renombre", 0, $max_name-4); // 4 -> El remplazo de mas abajo			
				} else { 
					$renombra = $renombre;	
				}
				// Vamos a darle caracteres aleatorios.			
				$name = $renombra.$ch_1.$ch_2.$ch_1.'.'.$exten;
			} else { 
				$name = $renombre.'.'.$exten;
			}

That is all the "name thing". If you want some changes you must take care of:
- What happens if the file already exists?
- What kind of rename should i use?

So, try to make your way trhought that code, is not too hard.
 
Rodolfo said:
Look up in engine.php this:
PHP:
// Limpiemos el nombre
			// --> Tambien me quedo "super rico".
			$lower = strtolower($tmp_name); // Solo minusculas
			$alnum = ereg_replace("[^[:alnum:]]","",$lower); // Solo alfanumericos
			if ($exten==peg) { unset($exten); $exten = 'jpg'; }
			$clear = substr_replace($alnum, '', -3); // sin extension ni punto
			// Cortemos el nombre (si hace falta)
			$conteo = strlen($clear);
			
			// Random
			$ch_1 = chr(rand(ord("a"), ord("z")));
			$ch_2 = chr(rand(ord("z"), ord("a")));
			
			if ($conteo>$max_name) {
				$renombre = substr("$clear", 0, $max_name);
			} else {
				if (empty($clear)) {
					$renombre = $ch_1.$ch_2.$ch_1;
				} else {
					$renombre = $clear;
				}
			}
				
			// Si existe el nombre, renombramos el que estamos subiendo.
        	if (file_exists(DIR_IM.$renombre.'.'.$exten)) {
				if ($conteo>$totalchars) { 
					// Si el nombre es muy largo, corta
					$renombra = substr("$renombre", 0, $max_name-4); // 4 -> El remplazo de mas abajo			
				} else { 
					$renombra = $renombre;	
				}
				// Vamos a darle caracteres aleatorios.			
				$name = $renombra.$ch_1.$ch_2.$ch_1.'.'.$exten;
			} else { 
				$name = $renombre.'.'.$exten;
			}

That is all the "name thing". If you want some changes you must take care of:
- What happens if the file already exists?
- What kind of rename should i use?

So, try to make your way trhought that code, is not too hard.
I would but I don't speak Spanish!!!
 
Wacky said:
Rodolfo said:
So, try to make your way trhought that code, is not too hard.
I would but I don't speak Spanish!!!

Then learn, is the most beautiful language.
ALSO.. you can check the functions and see what they do. belive me, is not hard and you could learn some basic php thing that you can use in several ways!.
 
Status
Not open for further replies.
Back
Top