Updated Index and switched to Carbon for date handling.
This commit is contained in:
parent
e2ee567711
commit
e708f99fee
47 changed files with 801 additions and 283 deletions
public-legacy
|
@ -3,9 +3,10 @@ namespace Misuzu;
|
|||
|
||||
use stdClass;
|
||||
use RuntimeException;
|
||||
use Index\DateTime;
|
||||
use Misuzu\Forum\ForumTopicInfo;
|
||||
use Misuzu\Parsers\Parser;
|
||||
use Index\XDateTime;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
$authInfo = $msz->getAuthInfo();
|
||||
if(!$authInfo->isLoggedIn())
|
||||
|
@ -152,11 +153,11 @@ if(!empty($_POST)) {
|
|||
if($mode === 'create') {
|
||||
$postTimeout = $cfg->getInteger('forum.posting.timeout', 5);
|
||||
if($postTimeout > 0) {
|
||||
$postTimeoutThreshold = DateTime::now()->modify(sprintf('-%d seconds', $postTimeout));
|
||||
$postTimeoutThreshold = new CarbonImmutable(sprintf('-%d seconds', $postTimeout));
|
||||
$lastPostCreatedAt = $forumPosts->getUserLastPostCreatedAt($currentUser);
|
||||
|
||||
if($lastPostCreatedAt->isMoreThan($postTimeoutThreshold)) {
|
||||
$waitSeconds = $postTimeout + ($lastPostCreatedAt->getUnixTimeSeconds() - time());
|
||||
if(XDateTime::compare($lastPostCreatedAt, $postTimeoutThreshold) > 0) {
|
||||
$waitSeconds = $postTimeout + ((int)$lastPostCreatedAt->format('U') - time());
|
||||
|
||||
$notices[] = sprintf("You're posting too quickly! Please wait %s seconds before posting again.", number_format($waitSeconds));
|
||||
$notices[] = "It's possible that your post went through successfully and you pressed the submit button twice by accident.";
|
||||
|
|
|
@ -3,9 +3,9 @@ namespace Misuzu;
|
|||
|
||||
use DateTimeInterface;
|
||||
use RuntimeException;
|
||||
use Index\DateTime;
|
||||
use Index\XArray;
|
||||
use Misuzu\Changelog\Changelog;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Index\{XArray,XDateTime};
|
||||
|
||||
$authInfo = $msz->getAuthInfo();
|
||||
if(!$authInfo->getPerms('global')->check(Perm::G_CL_CHANGES_MANAGE))
|
||||
|
@ -58,8 +58,8 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
if(empty($createdAt))
|
||||
$createdAt = null;
|
||||
else {
|
||||
$createdAt = DateTime::createFromFormat(DateTimeInterface::ATOM, $createdAt . ':00Z');
|
||||
if($createdAt->getUnixTimeSeconds() < 0)
|
||||
$createdAt = CarbonImmutable::createFromFormat(DateTimeInterface::ATOM, $createdAt . ':00Z');
|
||||
if((int)$createdAt->format('U') < 0)
|
||||
$createdAt = null;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
$summary = null;
|
||||
if($body === $changeInfo->getBody())
|
||||
$body = null;
|
||||
if($createdAt !== null && $createdAt->equals($changeInfo->getCreatedAt()))
|
||||
if($createdAt !== null && XDateTime::compare($createdAt, $changeInfo->getCreatedAt()) === 0)
|
||||
$createdAt = null;
|
||||
$updateUserInfo = $userId !== $changeInfo->getUserId();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace Misuzu;
|
|||
|
||||
use DateTimeInterface;
|
||||
use RuntimeException;
|
||||
use Index\DateTime;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
$authInfo = $msz->getAuthInfo();
|
||||
if(!$authInfo->getPerms('user')->check(Perm::U_BANS_MANAGE))
|
||||
|
@ -56,7 +56,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
if($expires === -1) {
|
||||
$expires = null;
|
||||
} elseif($expires === -2) {
|
||||
$expires = DateTime::createFromFormat(DateTimeInterface::ATOM, $expiresCustom . ':00Z');
|
||||
$expires = CarbonImmutable::createFromFormat(DateTimeInterface::ATOM, $expiresCustom . ':00Z');
|
||||
} else {
|
||||
echo 'Invalid duration specified.';
|
||||
break;
|
||||
|
|
|
@ -5,7 +5,6 @@ use stdClass;
|
|||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\ByteFormat;
|
||||
use Index\DateTime;
|
||||
use Misuzu\Parsers\Parser;
|
||||
use Misuzu\Users\User;
|
||||
use Misuzu\Users\Assets\UserAvatarAsset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue