Compare commits

...

2 commits

Author SHA1 Message Date
celestora
3db545f91a Fix bugs in photos.getUploadServer and photos.save 2023-07-12 20:49:55 +03:00
Dmitry Tretyakov
79ae72f15a VKAPI: Add NSFW boolean key in Wall.get/Newsfeed.get/Newsfeed.getGlobal 2023-07-12 22:38:01 +07:00
3 changed files with 8 additions and 5 deletions

View file

@ -61,7 +61,7 @@ final class Photos extends VKAPIRequestHandler
}
return (object) [
"upload_url" => $this->getPhotoUploadUrl("photo", isset($club) ? 0 : $club->getId()),
"upload_url" => $this->getPhotoUploadUrl("photo", !isset($club) ? 0 : $club->getId()),
];
}

View file

@ -125,6 +125,7 @@ final class Wall extends VKAPIRequestHandler
"can_archive" => false, # TODO MAYBE
"is_archived" => false,
"is_pinned" => $post->isPinned(),
"is_explicit" => $post->isExplicit(),
"attachments" => $attachments,
"post_source" => $post_source,
"comments" => (object)[
@ -299,6 +300,7 @@ final class Wall extends VKAPIRequestHandler
"can_archive" => false, # TODO MAYBE
"is_archived" => false,
"is_pinned" => $post->isPinned(),
"is_explicit" => $post->isExplicit(),
"post_source" => $post_source,
"attachments" => $attachments,
"comments" => (object)[

View file

@ -99,20 +99,21 @@ final class VKAPIPresenter extends OpenVKPresenter
function renderPhotoUpload(string $signature): void
{
$secret = CHANDLER_ROOT_CONF["security"]["secret"];
$computedSignature = hash_hmac("sha3-224", $_SERVER["QUERY_STRING"], $secret);
$secret = CHANDLER_ROOT_CONF["security"]["secret"];
$queryString = rawurldecode($_SERVER["QUERY_STRING"]);
$computedSignature = hash_hmac("sha3-224", $queryString, $secret);
if(!(strlen($signature) == 56 && sodium_memcmp($signature, $computedSignature) == 0)) {
header("HTTP/1.1 422 Unprocessable Entity");
exit("Try harder <3");
}
$data = unpack("vDOMAIN/Z10FIELD/vMF/vMP/PTIME/PUSER/PGROUP", base64_decode($_SERVER["QUERY_STRING"]));
$data = unpack("vDOMAIN/Z10FIELD/vMF/vMP/PTIME/PUSER/PGROUP", base64_decode($queryString));
if((time() - $data["TIME"]) > 600) {
header("HTTP/1.1 422 Unprocessable Entity");
exit("Expired");
}
$folder = __DIR__ . "../../tmp/api-storage/photos";
$folder = __DIR__ . "/../../tmp/api-storage/photos";
$maxSize = OPENVK_ROOT_CONF["openvk"]["preferences"]["uploads"]["api"]["maxFileSize"];
$maxFiles = OPENVK_ROOT_CONF["openvk"]["preferences"]["uploads"]["api"]["maxFilesPerDomain"];
$usrFiles = sizeof(glob("$folder/$data[USER]_*.oct"));