mirror of
https://github.com/openvk/openvk
synced 2024-11-14 19:19:14 +03:00
AJAX: Fix compatibility with PHP 8.2
This commit is contained in:
parent
d9412b2df8
commit
195cf9807e
9 changed files with 32 additions and 27 deletions
|
@ -48,11 +48,11 @@ class APIToken extends RowModel
|
||||||
$this->delete();
|
$this->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(): void
|
function save(?bool $log = false): void
|
||||||
{
|
{
|
||||||
if(is_null($this->getRecord()))
|
if(is_null($this->getRecord()))
|
||||||
$this->stateChanges("secret", bin2hex(openssl_random_pseudo_bytes(36)));
|
$this->stateChanges("secret", bin2hex(openssl_random_pseudo_bytes(36)));
|
||||||
|
|
||||||
parent::save();
|
parent::save($log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,11 +105,11 @@ class IP extends RowModel
|
||||||
$this->stateChanges("ip", $ip);
|
$this->stateChanges("ip", $ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(): void
|
function save(?bool $log = false): void
|
||||||
{
|
{
|
||||||
if(is_null($this->getRecord()))
|
if(is_null($this->getRecord()))
|
||||||
$this->stateChanges("first_seen", time());
|
$this->stateChanges("first_seen", time());
|
||||||
|
|
||||||
parent::save();
|
parent::save($log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,14 +121,14 @@ abstract class Media extends Postable
|
||||||
$this->stateChanges("hash", $hash);
|
$this->stateChanges("hash", $hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(): void
|
function save(?bool $log = false): void
|
||||||
{
|
{
|
||||||
if(!is_null($this->processingPlaceholder) && is_null($this->getRecord())) {
|
if(!is_null($this->processingPlaceholder) && is_null($this->getRecord())) {
|
||||||
$this->stateChanges("processed", 0);
|
$this->stateChanges("processed", 0);
|
||||||
$this->stateChanges("last_checked", time());
|
$this->stateChanges("last_checked", time());
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::save();
|
parent::save($log);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete(bool $softly = true): void
|
function delete(bool $softly = true): void
|
||||||
|
|
|
@ -54,11 +54,11 @@ class PasswordReset extends RowModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(): void
|
function save(?bool $log = false): void
|
||||||
{
|
{
|
||||||
$this->stateChanges("key", base64_encode(openssl_random_pseudo_bytes(46)));
|
$this->stateChanges("key", base64_encode(openssl_random_pseudo_bytes(46)));
|
||||||
$this->stateChanges("timestamp", time());
|
$this->stateChanges("timestamp", time());
|
||||||
|
|
||||||
parent::save();
|
parent::save($log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,12 +279,12 @@ class Poll extends Attachable
|
||||||
return $poll;
|
return $poll;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(): void
|
function save(?bool $log = false): void
|
||||||
{
|
{
|
||||||
if(empty($this->choicesToPersist))
|
if(empty($this->choicesToPersist))
|
||||||
throw new InvalidStateException;
|
throw new InvalidStateException;
|
||||||
|
|
||||||
parent::save();
|
parent::save($log);
|
||||||
foreach($this->choicesToPersist as $option) {
|
foreach($this->choicesToPersist as $option) {
|
||||||
DatabaseConnection::i()->getContext()->table("poll_options")->insert([
|
DatabaseConnection::i()->getContext()->table("poll_options")->insert([
|
||||||
"poll" => $this->getId(),
|
"poll" => $this->getId(),
|
||||||
|
|
|
@ -151,7 +151,7 @@ abstract class Postable extends Attachable
|
||||||
throw new ISE("Setting virtual id manually is forbidden");
|
throw new ISE("Setting virtual id manually is forbidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(): void
|
function save(?bool $log = false): void
|
||||||
{
|
{
|
||||||
$vref = $this->upperNodeReferenceColumnName;
|
$vref = $this->upperNodeReferenceColumnName;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ abstract class Postable extends Attachable
|
||||||
$this->stateChanges("edited", time());
|
$this->stateChanges("edited", time());
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::save();
|
parent::save($log);
|
||||||
}
|
}
|
||||||
|
|
||||||
use Traits\TAttachmentHost;
|
use Traits\TAttachmentHost;
|
||||||
|
|
|
@ -197,19 +197,23 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
{
|
{
|
||||||
$user = Authenticator::i()->getUser();
|
$user = Authenticator::i()->getUser();
|
||||||
|
|
||||||
$this->template->isXmas = intval(date('d')) >= 1 && date('m') == 12 || intval(date('d')) <= 15 && date('m') == 1 ? true : false;
|
if(!is_null($this->template)) {
|
||||||
$this->template->isTimezoned = Session::i()->get("_timezoneOffset");
|
$this->template->isXmas = intval(date('d')) >= 1 && date('m') == 12 || intval(date('d')) <= 15 && date('m') == 1 ? true : false;
|
||||||
|
$this->template->isTimezoned = Session::i()->get("_timezoneOffset");
|
||||||
|
}
|
||||||
|
|
||||||
$userValidated = 0;
|
$userValidated = 0;
|
||||||
$cacheTime = OPENVK_ROOT_CONF["openvk"]["preferences"]["nginxCacheTime"] ?? 0;
|
$cacheTime = OPENVK_ROOT_CONF["openvk"]["preferences"]["nginxCacheTime"] ?? 0;
|
||||||
|
|
||||||
if(!is_null($user)) {
|
if(!is_null($user)) {
|
||||||
$this->user = (object) [];
|
$this->user = (object) [];
|
||||||
$this->user->raw = $user;
|
$this->user->raw = $user;
|
||||||
$this->user->identity = (new Users)->getByChandlerUser($user);
|
$this->user->identity = (new Users)->getByChandlerUser($user);
|
||||||
$this->user->id = $this->user->identity->getId();
|
$this->user->id = $this->user->identity->getId();
|
||||||
$this->template->thisUser = $this->user->identity;
|
if(!is_null($this->template)) {
|
||||||
$this->template->userTainted = $user->isTainted();
|
$this->template->thisUser = $this->user->identity;
|
||||||
|
$this->template->userTainted = $user->isTainted();
|
||||||
|
}
|
||||||
|
|
||||||
if($this->user->identity->isDeleted() && !$this->deactivationTolerant) {
|
if($this->user->identity->isDeleted() && !$this->deactivationTolerant) {
|
||||||
if($this->user->identity->isDeactivated()) {
|
if($this->user->identity->isDeactivated()) {
|
||||||
|
@ -227,7 +231,7 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->user->identity->isBanned() && !$this->banTolerant) {
|
if($this->user->identity->isBanned() && !$this->banTolerant) {
|
||||||
header("HTTP/1.1 403 Forbidden");
|
header("HTTP/1.1 403 Forbidden");
|
||||||
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@banned.xml", [
|
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@banned.xml", [
|
||||||
|
@ -237,7 +241,7 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
]);
|
]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ето для емейл уже надо (и по хорошему надо бы избавится от повторяющегося кода мда)
|
# ето для емейл уже надо (и по хорошему надо бы избавится от повторяющегося кода мда)
|
||||||
if(!$this->user->identity->isActivated() && !$this->activationTolerant) {
|
if(!$this->user->identity->isActivated() && !$this->activationTolerant) {
|
||||||
header("HTTP/1.1 403 Forbidden");
|
header("HTTP/1.1 403 Forbidden");
|
||||||
|
@ -248,7 +252,7 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
]);
|
]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userValidated = 1;
|
$userValidated = 1;
|
||||||
$cacheTime = 0; # Force no cache
|
$cacheTime = 0; # Force no cache
|
||||||
if($this->user->identity->onlineStatus() == 0 && !($this->user->identity->isDeleted() || $this->user->identity->isBanned())) {
|
if($this->user->identity->onlineStatus() == 0 && !($this->user->identity->isDeleted() || $this->user->identity->isBanned())) {
|
||||||
|
@ -256,9 +260,10 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
$this->user->identity->setClient_name(NULL);
|
$this->user->identity->setClient_name(NULL);
|
||||||
$this->user->identity->save();
|
$this->user->identity->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->ticketAnsweredCount = (new Tickets)->getTicketsCountByUserId($this->user->id, 1);
|
if(!is_null($this->template))
|
||||||
if($user->can("write")->model("openvk\Web\Models\Entities\TicketReply")->whichBelongsTo(0))
|
$this->template->ticketAnsweredCount = (new Tickets)->getTicketsCountByUserId($this->user->id, 1);
|
||||||
|
if(!is_null($this->template) && $user->can("write")->model("openvk\Web\Models\Entities\TicketReply")->whichBelongsTo(0))
|
||||||
$this->template->helpdeskTicketNotAnsweredCount = (new Tickets)->getTicketCount(0);
|
$this->template->helpdeskTicketNotAnsweredCount = (new Tickets)->getTicketCount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,8 +280,8 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
$this->redirect("/maintenances/");
|
$this->redirect("/maintenances/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!is_null($this->template))
|
||||||
$this->template->__isAjax= $this->requestParam("al");
|
$this->template->__isAjax= $this->requestParam("al");
|
||||||
parent::onStartup();
|
parent::onStartup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$this->template->paginatorConf = (object) [
|
$this->template->paginatorConf = (object) [
|
||||||
"count" => $count,
|
"count" => $count,
|
||||||
"page" => (int) ($_GET["p"] ?? 1),
|
"page" => (int) ($_GET["p"] ?? 1),
|
||||||
"amount" => sizeof($posts),
|
"amount" => sizeof((array) $posts),
|
||||||
"perPage" => $pPage,
|
"perPage" => $pPage,
|
||||||
];
|
];
|
||||||
foreach($posts as $post)
|
foreach($posts as $post)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
style="position: absolute; top: 40%; left: 50%; background: #4C4C4C; padding: 20px 30px; border-radius: 3px; opacity: 0.8;"/>
|
style="position: absolute; top: 40%; left: 50%; background: #4C4C4C; padding: 20px 30px; border-radius: 3px; opacity: 0.8;"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" id="__current_url" value="{=$_SERVER[REQUEST_URI]}" />
|
<input type="hidden" id="__current_url" value="{=$_SERVER['REQUEST_URI']}" />
|
||||||
<div id="sudo-banner" n:if="isset($thisUser) && $userTainted">
|
<div id="sudo-banner" n:if="isset($thisUser) && $userTainted">
|
||||||
<p>
|
<p>
|
||||||
Вы вошли как <b>{$thisUser->getCanonicalName()}</b>. Пожалуйста, уважайте
|
Вы вошли как <b>{$thisUser->getCanonicalName()}</b>. Пожалуйста, уважайте
|
||||||
|
|
Loading…
Reference in a new issue