mirror of
https://github.com/openvk/openvk
synced 2025-04-23 00:23:01 +03:00
Compare commits
6 commits
fcbd42e1ac
...
9bdf523f76
Author | SHA1 | Date | |
---|---|---|---|
|
9bdf523f76 | ||
|
a12c77083b | ||
|
4815186b79 | ||
|
9ef7d2d7c4 | ||
|
3fec1b57a4 | ||
|
ca8b6a83fb |
8 changed files with 27 additions and 11 deletions
|
@ -187,7 +187,7 @@ class Photo extends Media
|
|||
foreach ($sizes as $id => $meta) {
|
||||
if (isset($meta[3]) && !$meta[3]) {
|
||||
$res[$id] = (object) [
|
||||
"url" => ovk_scheme(true) . $_SERVER["HTTP_HOST"] . "/photos/thumbnails/" . $this->getId() . "_$id.jpeg",
|
||||
"url" => ovk_scheme(true) . $_SERVER["HTTP_HOST"] . "/photos/thumbnails/" . $this->getRecord()->hash . "_$id.jpeg",
|
||||
"width" => null,
|
||||
"height" => null,
|
||||
"crop" => null,
|
||||
|
|
|
@ -41,11 +41,11 @@ trait TRichText
|
|||
return preg_replace_callback(
|
||||
"%(([A-z]++):\/\/(\S*?\.\S*?))([\s)\[\]{},\"\'<]|\.\s|$)%",
|
||||
(function (array $matches): string {
|
||||
$href = str_replace("#", "#", $matches[1]);
|
||||
$href = rawurlencode(str_replace(";", ";", $href));
|
||||
$link = str_replace("#", "#", $matches[3]);
|
||||
$href = rawurlencode($matches[1]);
|
||||
$href = str_replace("%26amp%3B", "%26", $href);
|
||||
$link = $matches[3];
|
||||
# this string breaks ampersands
|
||||
$link = str_replace(";", ";", $link);
|
||||
# $link = str_replace(";", ";", $link);
|
||||
$rel = $this->isAd() ? "sponsored" : "ugc";
|
||||
|
||||
/*$server_domain = str_replace(':' . $_SERVER['SERVER_PORT'], '', $_SERVER['HTTP_HOST']);
|
||||
|
|
|
@ -524,7 +524,10 @@ class User extends RowModel
|
|||
|
||||
public function getAge(): ?int
|
||||
{
|
||||
return (int) floor((time() - $this->getBirthday()->timestamp()) / YEAR);
|
||||
$birthday = new \DateTime();
|
||||
$birthday->setTimestamp($this->getBirthday()->timestamp());
|
||||
$today = new \DateTime();
|
||||
return (int) $today->diff($birthday)->y;
|
||||
}
|
||||
|
||||
public function get2faSecret(): ?string
|
||||
|
|
|
@ -28,6 +28,17 @@ class Photos
|
|||
return new Photo($photo);
|
||||
}
|
||||
|
||||
public function getByHash(string $hash): ?Photo
|
||||
{
|
||||
$photo = $this->photos->where("hash", $hash)->fetch();
|
||||
|
||||
if (!$photo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Photo($photo);
|
||||
}
|
||||
|
||||
public function getByOwnerAndVID(int $owner, int $vId): ?Photo
|
||||
{
|
||||
$photo = $this->photos->where([
|
||||
|
|
|
@ -157,7 +157,7 @@ class Users
|
|||
{
|
||||
return (object) [
|
||||
"all" => (clone $this->users)->count('*'),
|
||||
"active" => (clone $this->users)->where("online > 0")->count('*'),
|
||||
"active" => (clone $this->users)->where("online >= ?", time() - MONTH)->count('*'),
|
||||
"online" => (clone $this->users)->where("online >= ?", time() - 900)->count('*'),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ final class AwayPresenter extends OpenVKPresenter
|
|||
|
||||
header("HTTP/1.0 302 Found");
|
||||
header("X-Robots-Tag: noindex, nofollow, noarchive");
|
||||
header("Location: " . $this->queryParam("to"));
|
||||
header("Location: " . rawurldecode($this->queryParam("to")));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,9 +229,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
$this->renderPhoto($photo->getOwner(true)->getId(), $photo->getVirtualId());
|
||||
}
|
||||
|
||||
public function renderThumbnail($id, $size): void
|
||||
public function renderThumbnail($hash, $size): void
|
||||
{
|
||||
$photo = $this->photos->get($id);
|
||||
$photo = $this->photos->getByHash((string) $hash);
|
||||
if (!$photo || $photo->isDeleted()) {
|
||||
$this->notFound();
|
||||
}
|
||||
|
|
|
@ -173,8 +173,10 @@ routes:
|
|||
handler: "Photos->photo"
|
||||
- url: "/photo{num}_{num}/like"
|
||||
handler: "Photos->like"
|
||||
- url: "/photos/thumbnails/{num}_{text}.jpeg"
|
||||
- url: "/photos/thumbnails/{?hash}_{text}.jpeg"
|
||||
handler: "Photos->thumbnail"
|
||||
placeholders:
|
||||
hash: "[A-z0-9\\-_\\/]{15,}"
|
||||
- url: "/photos/{text}"
|
||||
handler: "Photos->absolutePhoto"
|
||||
- url: "/photo{num}_{num}/edit"
|
||||
|
|
Loading…
Reference in a new issue