Use adler32 hash for app avatars (php74 compat)

This commit is contained in:
celestora 2022-08-20 21:35:30 +03:00
parent 59cb20628f
commit b328254285

View file

@ -74,14 +74,14 @@ class Application extends RowModel
case "basic": case "basic":
return "$serverUrl/blob_" . substr($hash, 0, 2) . "/$hash" . "_app_avatar.png"; return "$serverUrl/blob_" . substr($hash, 0, 2) . "/$hash" . "_app_avatar.png";
case "accelerated": case "accelerated":
return "$serverUrl/openvk-datastore/$hash.app_avatar.png"; return "$serverUrl/openvk-datastore/$hash" . "_app_avatar.png";
case "server": case "server":
$settings = (object) OPENVK_ROOT_CONF["openvk"]["preferences"]["uploads"]["server"]; $settings = (object) OPENVK_ROOT_CONF["openvk"]["preferences"]["uploads"]["server"];
return ( return (
$settings->protocol ?? ovk_scheme() . $settings->protocol ?? ovk_scheme() .
"://" . $settings->host . "://" . $settings->host .
$settings->path . $settings->path .
substr($hash, 0, 2) . "/$hash.app_avatar.png" substr($hash, 0, 2) . "/$hash" . "_app_avatar.png"
); );
} }
} }
@ -205,7 +205,7 @@ class Application extends RowModel
return -2; return -2;
} }
$hash = hash_file("murmur3a", $file["tmp_name"]); $hash = hash_file("adler32", $file["tmp_name"]);
if(!is_dir($this->getAvatarsDir() . substr($hash, 0, 2))) if(!is_dir($this->getAvatarsDir() . substr($hash, 0, 2)))
if(!mkdir($this->getAvatarsDir() . substr($hash, 0, 2))) if(!mkdir($this->getAvatarsDir() . substr($hash, 0, 2)))
return -3; return -3;