How to decode Image IDs in URLs?

rmallory

Network license
License owner
Joined
Jul 6, 2015
Messages
16
Likes
4
Points
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-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
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.
 

shmoopic

New Member
Joined
Jul 15, 2015
Messages
1
Likes
0
Points
1
#3
Hi Rodolfo,

Interesting.... thank you.

In that case, I'm wondering if it would be possible to decode the Image IDs if I had a list of URLs with encoded IDs?

So if I had a CSV with:
http://example.com/image/R
http://example.com/image/H
http://example.com/image/B
... etc

Is there a way to decode the alphanumeric representation and end up with the original image IDs?

Cheers,

RDM
 

Rodolfo

Chevereto Guru-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
rodolfoberrios.com
#4
In that case you need to parse the list as an array using explode(), then with a loop you can do those changes.
 

rmallory

Network license
License owner
Joined
Jul 6, 2015
Messages
16
Likes
4
Points
53
#5
Thanks Rodolfo!

I realized that I don't need to decode the IDs after all... (I found a simpler workaround) but I appreciate your help.
 

CMedia_de

Founder license
Beta tester
Joined
Oct 11, 2011
Messages
41
Likes
6
Points
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-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
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
Beta tester
Joined
Oct 11, 2011
Messages
41
Likes
6
Points
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-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
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
Beta tester
Joined
Oct 11, 2011
Messages
41
Likes
6
Points
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-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
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
Beta tester
Joined
Oct 11, 2011
Messages
41
Likes
6
Points
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-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
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
Beta tester
Joined
Oct 11, 2011
Messages
41
Likes
6
Points
58
#14
why? i only changed one value - and if i don't delete the picture with the high id everything should work fine or?
 

Rodolfo

Chevereto Guru-Guru
Staff member
Joined
Oct 7, 2008
Messages
15,993
Likes
4,187
Points
237
Location
Chevereto HQ
Website
rodolfoberrios.com
#15
Is the same thing, you created a gap altering the image_id of the last record, is almost the same thing as change the table AUTO_INCREMENT value.
 

CMedia_de

Founder license
Beta tester
Joined
Oct 11, 2011
Messages
41
Likes
6
Points
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 :)
 

diogio9888

Network license
License owner
Joined
Nov 6, 2015
Messages
6
Likes
0
Points
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.