How to decode Image IDs in URLs?

  • Notice: New feature requests and suggestions won't be considered for Chevereto development at this time. Learn more.

rmallory

Network license
Jul 6, 2015
16
4
53
#1
Hello Again,

I have a new question. I'm wondering if there is a way to use the actual image and album IDs (the integers) in a URL rather than the encoded IDs.

So I'm wanting to change this:
http://example.com/image/R
to this:
http://example.com/image/2
(assuming the image ID is 2)

Does anyone know if this is possible, and if so are there any performance or security concerns with this setup?

I'm asking because I need a way to associate user created URLs back to the user that created them. So that if I had a list of all URLs, I could associate any user created URLs to their publishing user. Maybe there is a better way?

Please let me know if you have any ideas.

Best,
RDM
 

Rodolfo

Chevereto Guru
Staff member
Oct 7, 2008
15,542
3,870
237
Chevereto HQ
rodolfoberrios.com
#2
Sure is possible but is not wise to do it. The point of using an alphanumeric representation is to avoid enumeration and the system uses the same method that you can see in YouTube.

If you want to use the real id you will need to lookup for the calls of the encodeID() and decodeID() functions. That will give you an insight on where the ids are decoded/encoded in the source code.

Hope it helps.
 

CMedia_de

Founder license
Oct 11, 2011
39
6
58
#6
Hello @rmallory, could you share your work or is there a way to make longer more unique image id's? i have got the problem that some link-grabbing scripts visit my sites and they index letter for letter - that' is not so cool -.-
 

Rodolfo

Chevereto Guru
Staff member
Oct 7, 2008
15,542
3,870
237
Chevereto HQ
rodolfoberrios.com
#7
Hello @rmallory, could you share your work or is there a way to make longer more unique image id's? i have got the problem that some link-grabbing scripts visit my sites and they index letter for letter - that' is not so cool -.-
Chevereto now has id padding (key id_padding), which allows to add a fake upscaled ID, check it at chv_settings table.
 

CMedia_de

Founder license
Oct 11, 2011
39
6
58
#8
the padding only works if you use a new galery , couse every link is rewritten by that.. :(
but nice feature - for next website i will use it :)
 

Rodolfo

Chevereto Guru
Staff member
Oct 7, 2008
15,542
3,870
237
Chevereto HQ
rodolfoberrios.com
#9
the padding only works if you use a new galery , couse every link is rewritten by that.. :(
but nice feature - for next website i will use it :)
Padding works only for new installations, old installations have untouched that otherwise dozens of links will be lost. You can hack the system and add a forced id padding, just look for "padding" in the chv_settings table.
 

CMedia_de

Founder license
Oct 11, 2011
39
6
58
#10
Solution: Upload a new picture, go to PhpmyAdmin > Table: chv_images > order by image_id > take the last one > multiplicate the id with a factor you want and save > what next comes is magic :)
 

Rodolfo

Chevereto Guru
Staff member
Oct 7, 2008
15,542
3,870
237
Chevereto HQ
rodolfoberrios.com
#11
Solution: Upload a new picture, go to PhpmyAdmin > Table: chv_images > order by image_id > take the last one > multiplicate the id with a factor you want and save > what next comes is magic :)
That's not the way to do it and I will like to not encourage that method. The way to deal with this is simply go to chv_settings and locate this setting_name = id_padding and set the setting_value to any large number you want.
 

CMedia_de

Founder license
Oct 11, 2011
39
6
58
#12
hola rodolfo, it's not possible without loosing the links to your old images. you have written on post above - my solution is only for experienced users .. and I'm happy with it.. by now ...
 

Rodolfo

Chevereto Guru
Staff member
Oct 7, 2008
15,542
3,870
237
Chevereto HQ
rodolfoberrios.com
#13
hola rodolfo, it's not possible without loosing the links to your old images. you have written on post above - my solution is only for experienced users .. and I'm happy with it.. by now ...
In that case you need to alter the table and increase the auto_increment value.
 

CMedia_de

Founder license
Oct 11, 2011
39
6
58
#16
sure you are the best rodolfo - here the sql code:
Code:
ALTER TABLE 'chv_images' AUTO_INCREMENT = 1000000000;
URL's now looks like: chvereto.url/image/XXxxxx < exactly what i wanted :)
 
Nov 6, 2015
5
0
51
#18
Hi, Is there any simple way to find from image Id to image url ? I need to do that because the search function can't find image name like "xr2017-1216-4". I can find it from phpmyadmin in chv_images table but I still could not find the image url ? I need to find them then I can delete it from user interface not from mysql.