yadenisenko
Chevereto Member
Hello Please tell me how to do that would be short image url and Viewer kept on one character and example jhsdgfbsd
Sorry for my English, I'm from Russia
Sorry for my English, I'm from Russia
Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.
Please keep in mind:
Just in the beginning, when the length of links 2 letters, it is easy to access the link, by sorting characters
function chevereto_id($var, $action='encode') {
$base_chars = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // DON'T REPEAT A SINGLE CHAR!
for ($n = 0; $n<strlen($base_chars); $n++) {
$i[] = substr( $base_chars,$n ,1);
}
$passhash = hash('sha256',__CHV_CRYPT_SALT__);
$passhash = (strlen($passhash) < strlen($base_chars)) ? hash('sha512',__CHV_CRYPT_SALT__) : $passhash;
for ($n=0; $n < strlen($base_chars); $n++) {
$p[] = substr($passhash, $n ,1);
}
array_multisort($p, SORT_DESC, $i);
$base_chars = implode($i);
switch($action) {
case 'encode':
$string = '';
$len = strlen($base_chars);
while($var >= $len) {
$mod = bcmod($var, $len);
$var = bcdiv($var, $len);
$string = $base_chars[$mod].$string;
}
return $base_chars[$var] . $string;
break;
case 'decode':
$integer = 0;
$var = strrev($var );
$baselen = strlen( $base_chars );
$inputlen = strlen( $var );
for ($i = 0; $i < $inputlen; $i++) {
$index = strpos($base_chars, $var[$i] );
$integer = bcadd($integer, bcmul($index, bcpow($baselen, $i)));
}
return $integer;
break;
}
I made: $base_chars = "qpwoieurytALSKDJFHGQPWOEIRUTYzmxncbvalskdjfhg0192837465"; but chevereto_id is too light and is not protected from brute force
Hello.
See, well, this is too short url, anyone can see the brute force http://llln.ru/J if he was such http://llln.ru/JKdn3 then it would be difficult to find
file_html =
'<div class="'+list_item.replace(".", "")+'" id="'+value.image_id+'">\
<a class="title link" href="'+value.image_shorturl+'" target="_blank">'+image_name+'</a><span class="'+checkbox_class+'"></span>\
<div class="thumb">\
<img src="'+value.image_thumb_url+'" alt="" width="'+th_width+'" height="'+th_height+'" />\
<span class="attr">'+value.image_width+'x'+value.image_height+'</span>\
<span class="size">'+value.image_size+'</span>\
</div>\
<div class="date">'+value.image_date+'</div>\
</div>';
file_html =
'<div class="'+list_item.replace(".", "")+'" id="'+value.image_id+'">\
<a class="title link" href="'+value.image_url+'" target="_blank"><b>'+image_name+'</b></a><span class="'+checkbox_class+'"></span>\
<div class="thumb">\
<img src="'+value.image_thumb_url+'" alt="" width="'+th_width+'" height="'+th_height+'" />\
<span class="attr">'+value.image_width+'x'+value.image_height+'</span>\
<span class="size">'+value.image_size+'</span>\
</div>\
<div class="date">'+value.image_date+'</div>\
</div>';