動いている
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Site\Controller;
|
|||||||
use Site\Controller\BlogPost;
|
use Site\Controller\BlogPost;
|
||||||
use Site\Controller\Mods;
|
use Site\Controller\Mods;
|
||||||
use Site\Lib\Activitypub;
|
use Site\Lib\Activitypub;
|
||||||
|
use Site\Lib\Auth;
|
||||||
use Site\Lib\Markdown;
|
use Site\Lib\Markdown;
|
||||||
use Site\Lib\Template;
|
use Site\Lib\Template;
|
||||||
|
|
||||||
@@ -56,6 +57,11 @@ class Home extends BlogPost {
|
|||||||
$postsPerPage
|
$postsPerPage
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ユーザー
|
||||||
|
$auth = new Auth();
|
||||||
|
$user = $auth->getLoggedInUser();
|
||||||
|
$tmpl->assign('user', $user);
|
||||||
|
|
||||||
$tmpl->assign('currentPage', $page);
|
$tmpl->assign('currentPage', $page);
|
||||||
$tmpl->assign('totalPages', $totalPages);
|
$tmpl->assign('totalPages', $totalPages);
|
||||||
$tmpl->assign('posts', $currentPosts);
|
$tmpl->assign('posts', $currentPosts);
|
||||||
@@ -104,6 +110,11 @@ class Home extends BlogPost {
|
|||||||
$meta->title = $this->highlightTextContent($meta->title, $keywords);
|
$meta->title = $this->highlightTextContent($meta->title, $keywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ユーザー
|
||||||
|
$auth = new Auth();
|
||||||
|
$user = $auth->getLoggedInUser();
|
||||||
|
$tmpl->assign('user', $user);
|
||||||
|
|
||||||
$tmpl->assign('pagetit', $pagetit);
|
$tmpl->assign('pagetit', $pagetit);
|
||||||
$tmpl->assign('curPage', 'blog');
|
$tmpl->assign('curPage', 'blog');
|
||||||
$tmpl->assign('custCss', false);
|
$tmpl->assign('custCss', false);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace Site\Controller;
|
namespace Site\Controller;
|
||||||
|
|
||||||
use Site\Controller\Mods;
|
use Site\Controller\Mods;
|
||||||
|
use Site\Lib\Auth;
|
||||||
use Site\Lib\Template;
|
use Site\Lib\Template;
|
||||||
|
|
||||||
class Page {
|
class Page {
|
||||||
@@ -13,6 +14,11 @@ class Page {
|
|||||||
$pagetit = '新ページ';
|
$pagetit = '新ページ';
|
||||||
$description = 'PHPフレームワークについて';
|
$description = 'PHPフレームワークについて';
|
||||||
|
|
||||||
|
// ユーザー
|
||||||
|
$auth = new Auth();
|
||||||
|
$user = $auth->getLoggedInUser();
|
||||||
|
$tmpl->assign('user', $user);
|
||||||
|
|
||||||
$tmpl->assign('pagetit', $pagetit);
|
$tmpl->assign('pagetit', $pagetit);
|
||||||
$tmpl->assign('curPage', 'about');
|
$tmpl->assign('curPage', 'about');
|
||||||
$tmpl->assign('custCss', false);
|
$tmpl->assign('custCss', false);
|
||||||
@@ -31,6 +37,11 @@ class Page {
|
|||||||
$pagetit = 'モネロ(XMR)で支援♡';
|
$pagetit = 'モネロ(XMR)で支援♡';
|
||||||
$description = 'テクニカル諏訪子ちゃんをモネロで支援♡';
|
$description = 'テクニカル諏訪子ちゃんをモネロで支援♡';
|
||||||
|
|
||||||
|
// ユーザー
|
||||||
|
$auth = new Auth();
|
||||||
|
$user = $auth->getLoggedInUser();
|
||||||
|
$tmpl->assign('user', $user);
|
||||||
|
|
||||||
$tmpl->assign('pagetit', $pagetit);
|
$tmpl->assign('pagetit', $pagetit);
|
||||||
$tmpl->assign('curPage', 'support');
|
$tmpl->assign('curPage', 'support');
|
||||||
$tmpl->assign('custCss', true);
|
$tmpl->assign('custCss', true);
|
||||||
@@ -50,6 +61,11 @@ class Page {
|
|||||||
$pagetit = '秘密のページ';
|
$pagetit = '秘密のページ';
|
||||||
$description = 'ケロ';
|
$description = 'ケロ';
|
||||||
|
|
||||||
|
// ユーザー
|
||||||
|
$auth = new Auth();
|
||||||
|
$user = $auth->getLoggedInUser();
|
||||||
|
$tmpl->assign('user', $user);
|
||||||
|
|
||||||
$tmpl->assign('pagetit', $pagetit);
|
$tmpl->assign('pagetit', $pagetit);
|
||||||
$tmpl->assign('curPage', 'support');
|
$tmpl->assign('curPage', 'support');
|
||||||
$tmpl->assign('custCss', false);
|
$tmpl->assign('custCss', false);
|
||||||
@@ -61,4 +77,4 @@ class Page {
|
|||||||
throw new \Exception($e->getMessage());
|
throw new \Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,4 +72,4 @@ class User {
|
|||||||
throw new \Exception($e->getMessage());
|
throw new \Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class Auth {
|
|||||||
$token = bin2hex(random_bytes(64));
|
$token = bin2hex(random_bytes(64));
|
||||||
$expire = time() + $this->tokenDuration;
|
$expire = time() + $this->tokenDuration;
|
||||||
$newToken = [
|
$newToken = [
|
||||||
'token' => password_hash($token, $algo),
|
'token' => $token,
|
||||||
'ip' => $ip,
|
'ip' => $ip,
|
||||||
'createDate' => time(),
|
'createDate' => time(),
|
||||||
'expDate' => $expire,
|
'expDate' => $expire,
|
||||||
@@ -151,7 +151,7 @@ class Auth {
|
|||||||
return \Result::success();
|
return \Result::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isUserExist(?string $username): \Result {
|
public function isUserExist(?string $username = null): \Result {
|
||||||
if (null === $username) return \Result::Error('エラー:ユーザー名をご入力下さい。');
|
if (null === $username) return \Result::Error('エラー:ユーザー名をご入力下さい。');
|
||||||
$userList = scandir($this->dataDir);
|
$userList = scandir($this->dataDir);
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ class Auth {
|
|||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
|
|
||||||
private function purgeOldTokens(\stdClass $userData): \stdClass {
|
private function purgeOldTokens(\stdClass $userData): \stdClass|\Result {
|
||||||
// 有効期限切れたトークンの削除
|
// 有効期限切れたトークンの削除
|
||||||
$out = $userData;
|
$out = $userData;
|
||||||
$out->tokens = array_filter($userData->tokens, function($t): bool {
|
$out->tokens = array_filter($userData->tokens, function($t): bool {
|
||||||
@@ -196,8 +196,12 @@ class Auth {
|
|||||||
$path = "{$this->dataDir}{$f}";
|
$path = "{$this->dataDir}{$f}";
|
||||||
if (!is_file($path)) continue;
|
if (!is_file($path)) continue;
|
||||||
$content = file_get_contents($path);
|
$content = file_get_contents($path);
|
||||||
if (str_contains($content, $token)) {
|
if ($token && str_contains($content, $token)) {
|
||||||
$matches[] = $path;
|
$matches[] = $path;
|
||||||
|
break;
|
||||||
|
} else if (!$token && str_contains($content, '"username": "'.$username.'",')) {
|
||||||
|
$matches[] = $path;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$id = (int)preg_replace('/^(.*?)\.(.*?)$/', "$1", str_replace($this->dataDir, '', $matches[0]));
|
$id = (int)preg_replace('/^(.*?)\.(.*?)$/', "$1", str_replace($this->dataDir, '', $matches[0]));
|
||||||
@@ -277,4 +281,4 @@ class Auth {
|
|||||||
|
|
||||||
return \Result::Success();
|
return \Result::Success();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user