請求の確認
諏訪子 <suwako@076.moe>、2026-05-04 14:15
コミット fc777da399f914b4b91fc833319869d2a639761f
・親 2570955
・ファイルを見る
17個のファイル、+394 -386
変更
.gitignore
| @@ -8,3 +8,4 @@ | ||
| 8 | 8 | !public/static/user/.kara |
| 9 | 9 | config/config.php |
| 10 | 10 | public/static/*.pem |
| 11 | +.vscode |
変更
route.php
| @@ -96,6 +96,9 @@ | ||
| 96 | 96 | |
| 97 | 97 | if (OPENPROVIDER_ENABLED) { |
| 98 | 98 | $routes[] = Route::add('GET', 'openprovider', Op::class.'@index'); |
| 99 | + $routes[] = Route::add('GET', 'openprovider/listinvoices', Op::class.'@opListInvoices'); | |
| 100 | + $routes[] = Route::add('GET', 'openprovider/listpayments', Op::class.'@opListPayments'); | |
| 101 | + $routes[] = Route::add('GET', 'openprovider/listtransactions', Op::class.'@opListTransactions'); | |
| 99 | 102 | $routes[] = Route::add('GET', 'openprovider/listcustomers', Op::class.'@opListCustomers'); |
| 100 | 103 | $routes[] = Route::add('GET', 'openprovider/createcustomer', Op::class.'@opCreateCustomer'); |
| 101 | 104 | $routes[] = Route::add('GET', 'openprovider/deletecustomer/{handle}', Op::class.'@opDeleteCustomer'); |
| @@ -37,6 +37,8 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | namespace Site\Controller; |
| 39 | 39 | |
| 40 | +use Roles; | |
| 41 | + | |
| 40 | 42 | class BlogPost { |
| 41 | 43 | /** |
| 42 | 44 | * ブログ投稿を取得する |
| @@ -46,9 +48,9 @@ | ||
| 46 | 48 | public function getPosts(string $section, ?\stdClass $user = null): array { |
| 47 | 49 | $path = ROOT.$section; |
| 48 | 50 | $posts = []; |
| 49 | - $isMember = $user !== NULL && $user->role !== \Roles::BANNED; | |
| 50 | - $isPaywall = $user !== NULL && $user->role >= \Roles::SUBSCRIBER; | |
| 51 | - $isStaff = $user !== NULL && $user->role & (\Roles::ADMIN | \Roles::STAFF); | |
| 51 | + $isMember = $user !== NULL && $user->role !== Roles::BANNED; | |
| 52 | + $isPaywall = $user !== NULL && $user->role >= Roles::SUBSCRIBER; | |
| 53 | + $isStaff = $user !== NULL && $user->role & (Roles::ADMIN | Roles::STAFF); | |
| 52 | 54 | |
| 53 | 55 | if (!is_dir($path)) return $posts; |
| 54 | 56 | $files = glob($path.'/*.md'); |
| @@ -40,6 +40,7 @@ | ||
| 40 | 40 | use Site\Controller\BlogPost; |
| 41 | 41 | use Site\Controller\Mods; |
| 42 | 42 | use Std\Lib\Activitypub; |
| 43 | +use LogType; | |
| 43 | 44 | |
| 44 | 45 | class Fediverse extends BlogPost { |
| 45 | 46 | use Mods; |
| @@ -98,7 +99,7 @@ | ||
| 98 | 99 | exit; |
| 99 | 100 | } |
| 100 | 101 | |
| 101 | - logger(\LogType::ActivityPub, "受付に入れた:".json_encode($activity)); | |
| 102 | + logger(LogType::ActivityPub, "受付に入れた:".json_encode($activity)); | |
| 102 | 103 | |
| 103 | 104 | try { |
| 104 | 105 | header('Content-Type: application/activity+json'); |
| @@ -43,6 +43,7 @@ | ||
| 43 | 43 | use Std\Lib\Auth; |
| 44 | 44 | use Std\Lib\Markdown; |
| 45 | 45 | use Std\Lib\Template; |
| 46 | +use Roles; | |
| 46 | 47 | |
| 47 | 48 | class Home extends BlogPost { |
| 48 | 49 | use Mods; |
| @@ -149,9 +150,9 @@ | ||
| 149 | 150 | // ユーザー |
| 150 | 151 | $auth = new Auth(); |
| 151 | 152 | $user = $auth->getLoggedInUser(); |
| 152 | - $isMember = $user !== NULL && $user->role !== \Roles::BANNED; | |
| 153 | - $isPaywall = $user !== NULL && $user->role >= \Roles::SUBSCRIBER; | |
| 154 | - $isStaff = $user !== NULL && $user->role & (\Roles::ADMIN | \Roles::STAFF); | |
| 153 | + $isMember = $user !== NULL && $user->role !== Roles::BANNED; | |
| 154 | + $isPaywall = $user !== NULL && $user->role >= Roles::SUBSCRIBER; | |
| 155 | + $isStaff = $user !== NULL && $user->role & (Roles::ADMIN | Roles::STAFF); | |
| 155 | 156 | $tmpl->assign('user', $user); |
| 156 | 157 | |
| 157 | 158 | $tmpl->assign('pagetit', $pagetit); |
| @@ -46,70 +46,119 @@ | ||
| 46 | 46 | class Op { |
| 47 | 47 | use Mods; |
| 48 | 48 | |
| 49 | + private Template $tmpl; | |
| 50 | + private Auth $auth; | |
| 51 | + private Openprovider $op; | |
| 52 | + private string $pagetit = 'OpenProvider管理 - '; | |
| 53 | + private string $description = ''; | |
| 54 | + private ?\stdClass $user; | |
| 55 | + | |
| 56 | + public function __construct() { | |
| 57 | + $this->tmpl = new Template('/openprovider/'); | |
| 58 | + | |
| 59 | + $this->auth = new Auth(); | |
| 60 | + $this->user = $this->auth->getLoggedInUser(); | |
| 61 | + if ($this->user && $this->user->role & (Roles::ADMIN)) { | |
| 62 | + $this->op = new Openprovider(); | |
| 63 | + $this->op->login(); | |
| 64 | + } | |
| 65 | + | |
| 66 | + $this->tmpl->assign('user', $this->user); | |
| 67 | + $this->tmpl->assign('curPage', 'openprovider'); | |
| 68 | + $this->tmpl->assign('custCss', false); | |
| 69 | + $this->tmpl->assign('menu', $this->getMenu()); | |
| 70 | + $this->tmpl->assign('description', $this->description); | |
| 71 | + $this->tmpl->addCss('openprovider'); | |
| 72 | + $this->tmpl->addCss('table'); | |
| 73 | + } | |
| 74 | + | |
| 49 | 75 | public function index(array $params): void { |
| 50 | 76 | try { |
| 51 | - $tmpl = new Template('/openprovider/'); | |
| 52 | - $pagetit = 'OpenProvider管理 - ホーム'; | |
| 53 | - $description = ''; | |
| 77 | + $this->pagetit .= 'ホーム'; | |
| 78 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 54 | 79 | |
| 55 | - // ユーザー | |
| 56 | - $auth = new Auth(); | |
| 57 | - $user = $auth->getLoggedInUser(); | |
| 58 | - $tmpl->assign('user', $user); | |
| 80 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 81 | + $this->tmpl->render('index'); | |
| 82 | + exit(); | |
| 59 | 83 | |
| 60 | - $tmpl->assign('pagetit', $pagetit); | |
| 61 | - $tmpl->assign('curPage', 'openprovider'); | |
| 62 | - $tmpl->assign('custCss', false); | |
| 63 | - $tmpl->assign('menu', $this->getMenu()); | |
| 64 | - $tmpl->assign('description', $description); | |
| 84 | + noaccess: | |
| 85 | + $this->tmpl->render('nopermission'); | |
| 86 | + } catch (\Exception $e) { | |
| 87 | + throw new \Exception($e->getMessage()); | |
| 88 | + } | |
| 89 | + } | |
| 65 | 90 | |
| 66 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 67 | - $tmpl->addCss('table'); | |
| 68 | - $tmpl->render('index'); | |
| 91 | + public function opListInvoices(array $params): void { | |
| 92 | + try { | |
| 93 | + $this->pagetit .= '請求書一覧'; | |
| 94 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 95 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 96 | + $data = $this->op->listInvoices(); | |
| 97 | + $this->tmpl->assign('data', $data->data); | |
| 98 | + $this->tmpl->render('listinvoices'); | |
| 69 | 99 | exit(); |
| 70 | 100 | |
| 71 | 101 | noaccess: |
| 72 | - $tmpl->render('nopermission'); | |
| 102 | + $this->tmpl->render('nopermission'); | |
| 73 | 103 | } catch (\Exception $e) { |
| 74 | 104 | throw new \Exception($e->getMessage()); |
| 75 | 105 | } |
| 76 | 106 | } |
| 77 | 107 | |
| 78 | - public function opListCustomers(array $params): void { | |
| 108 | + public function opListPayments(array $params): void { | |
| 79 | 109 | try { |
| 80 | - $tmpl = new Template('/openprovider/'); | |
| 81 | - $pagetit = 'OpenProvider管理 - 顧客様検索'; | |
| 82 | - $description = ''; | |
| 110 | + $this->pagetit .= '請求書一覧'; | |
| 111 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 83 | 112 | |
| 84 | - // ユーザー | |
| 85 | - $auth = new Auth(); | |
| 86 | - $user = $auth->getLoggedInUser(); | |
| 87 | - $tmpl->assign('user', $user); | |
| 113 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 114 | + $data = $this->op->listPayments(); | |
| 115 | + $this->tmpl->assign('data', $data->data); | |
| 116 | + $this->tmpl->render('listpayments'); | |
| 117 | + exit(); | |
| 88 | 118 | |
| 89 | - $tmpl->assign('pagetit', $pagetit); | |
| 90 | - $tmpl->assign('curPage', 'openprovider'); | |
| 91 | - $tmpl->assign('custCss', true); | |
| 92 | - $tmpl->assign('menu', $this->getMenu()); | |
| 93 | - $tmpl->assign('description', $description); | |
| 119 | + noaccess: | |
| 120 | + $this->tmpl->render('nopermission'); | |
| 121 | + } catch (\Exception $e) { | |
| 122 | + throw new \Exception($e->getMessage()); | |
| 123 | + } | |
| 124 | + } | |
| 94 | 125 | |
| 95 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 96 | - $op = new Openprovider(); | |
| 97 | - $op->login(); | |
| 98 | - $data = $op->listCustomers(); | |
| 99 | - $tmpl->assign('data', $data->data); | |
| 126 | + public function opListTransactions(array $params): void { | |
| 127 | + try { | |
| 128 | + $this->pagetit .= '請求書一覧'; | |
| 129 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 100 | 130 | |
| 101 | - $tmpl->addCss('table'); | |
| 102 | - $tmpl->addCss('openprovider'); | |
| 103 | - $tmpl->render('listcustomers'); | |
| 131 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 132 | + $data = $this->op->listTransactions(); | |
| 133 | + $this->tmpl->assign('data', $data->data); | |
| 134 | + $this->tmpl->render('listtransactions'); | |
| 104 | 135 | exit(); |
| 105 | 136 | |
| 106 | 137 | noaccess: |
| 107 | - $tmpl->render('nopermission'); | |
| 138 | + $this->tmpl->render('nopermission'); | |
| 108 | 139 | } catch (\Exception $e) { |
| 109 | 140 | throw new \Exception($e->getMessage()); |
| 110 | 141 | } |
| 111 | 142 | } |
| 112 | 143 | |
| 144 | + public function opListCustomers(array $params): void { | |
| 145 | + try { | |
| 146 | + $this->pagetit .= '顧客様検索'; | |
| 147 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 148 | + | |
| 149 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 150 | + $data = $this->op->listCustomers(); | |
| 151 | + $this->tmpl->assign('data', $data->data); | |
| 152 | + $this->tmpl->render('listcustomers'); | |
| 153 | + exit(); | |
| 154 | + | |
| 155 | + noaccess: | |
| 156 | + $this->tmpl->render('nopermission'); | |
| 157 | + } catch (\Exception $e) { | |
| 158 | + throw new \Exception($e->getMessage()); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 113 | 162 | public function opCreateCustomer(array $params): void { |
| 114 | 163 | try { |
| 115 | 164 | $payload = [ |
| @@ -159,24 +208,12 @@ | ||
| 159 | 208 | 'subscriber_number' => $_POST['phone_subscriber_number'] ?? '', |
| 160 | 209 | ], |
| 161 | 210 | ]; |
| 162 | - $tmpl = new Template('/openprovider/'); | |
| 163 | - $pagetit = "OpenProvider管理 - 顧客様の新規作成"; | |
| 164 | - $description = ''; | |
| 211 | + $this->pagetit .= '顧客様の新規作成'; | |
| 212 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 165 | 213 | |
| 166 | - // ユーザー | |
| 167 | - $auth = new Auth(); | |
| 168 | - $user = $auth->getLoggedInUser(); | |
| 169 | - $tmpl->assign('user', $user); | |
| 170 | - | |
| 171 | - $tmpl->assign('pagetit', $pagetit); | |
| 172 | - $tmpl->assign('curPage', 'openprovider'); | |
| 173 | - $tmpl->assign('custCss', true); | |
| 174 | - $tmpl->assign('menu', $this->getMenu()); | |
| 175 | - $tmpl->assign('description', $description); | |
| 176 | - | |
| 177 | 214 | $err = []; |
| 178 | 215 | |
| 179 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 216 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 180 | 217 | |
| 181 | 218 | if (!empty($_POST)) { |
| 182 | 219 | if (NULL === $_POST['last_name'] || $_POST['last_name'] === '' |
| @@ -199,23 +236,20 @@ | ||
| 199 | 236 | if (($_POST['fax_area_code'] !== '' || $_POST['fax_subscriber_number'] !== '') && (!filter_var($_POST['fax_area_code'], FILTER_VALIDATE_INT) || !filter_var($_POST['fax_subscriber_number'], FILTER_VALIDATE_INT))) $err[] = 'FAXは数字をご入力下さい。'; |
| 200 | 237 | if (!empty($err)) goto render; |
| 201 | 238 | |
| 202 | - $op = new Openprovider(); | |
| 203 | - $op->login(); | |
| 204 | - $data = $op->createCustomer($payload, true); | |
| 239 | + $data = $this->op->createCustomer($payload, true); | |
| 205 | 240 | header("Location: /openprovider/getcustomer/{$data->data['data']['handle']}"); |
| 206 | 241 | exit(); |
| 207 | 242 | } |
| 208 | 243 | |
| 209 | 244 | render: |
| 210 | - $tmpl->assign('err', $err); | |
| 211 | - $tmpl->assign('data', $payload); | |
| 212 | - $tmpl->addCss('openprovider'); | |
| 213 | - $tmpl->render('createcustomer'); | |
| 245 | + $this->tmpl->assign('err', $err); | |
| 246 | + $this->tmpl->assign('data', $payload); | |
| 247 | + $this->tmpl->render('createcustomer'); | |
| 214 | 248 | |
| 215 | 249 | exit(); |
| 216 | 250 | |
| 217 | 251 | noaccess: |
| 218 | - $tmpl->render('nopermission'); | |
| 252 | + $this->tmpl->render('nopermission'); | |
| 219 | 253 | } catch (\Exception $e) { |
| 220 | 254 | throw new \Exception($e->getMessage()); |
| 221 | 255 | } |
| @@ -229,34 +263,17 @@ | ||
| 229 | 263 | header('Location: /openprovider/listcustomers'); |
| 230 | 264 | exit(); |
| 231 | 265 | } |
| 232 | - $tmpl = new Template('/openprovider/'); | |
| 233 | - $pagetit = "OpenProvider管理 - 顧客様「{$handle}」の表示"; | |
| 234 | - $description = ''; | |
| 266 | + $this->pagetit .= "顧客様「{$handle}」の表示"; | |
| 267 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 235 | 268 | |
| 236 | - // ユーザー | |
| 237 | - $auth = new Auth(); | |
| 238 | - $user = $auth->getLoggedInUser(); | |
| 239 | - $tmpl->assign('user', $user); | |
| 240 | - | |
| 241 | - $tmpl->assign('pagetit', $pagetit); | |
| 242 | - $tmpl->assign('curPage', 'openprovider'); | |
| 243 | - $tmpl->assign('custCss', true); | |
| 244 | - $tmpl->assign('menu', $this->getMenu()); | |
| 245 | - $tmpl->assign('description', $description); | |
| 246 | - | |
| 247 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 248 | - $op = new Openprovider(); | |
| 249 | - $op->login(); | |
| 250 | - $data = $op->getCustomer($handle, true); | |
| 251 | - $tmpl->assign('data', $data->data); | |
| 252 | - | |
| 253 | - $tmpl->addCss('table'); | |
| 254 | - $tmpl->addCss('openprovider'); | |
| 255 | - $tmpl->render('getcustomer'); | |
| 269 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 270 | + $data = $this->op->getCustomer($handle, true); | |
| 271 | + $this->tmpl->assign('data', $data->data); | |
| 272 | + $this->tmpl->render('getcustomer'); | |
| 256 | 273 | exit(); |
| 257 | 274 | |
| 258 | 275 | noaccess: |
| 259 | - $tmpl->render('nopermission'); | |
| 276 | + $this->tmpl->render('nopermission'); | |
| 260 | 277 | } catch (\Exception $e) { |
| 261 | 278 | throw new \Exception($e->getMessage()); |
| 262 | 279 | } |
| @@ -271,44 +288,29 @@ | ||
| 271 | 288 | exit(); |
| 272 | 289 | } |
| 273 | 290 | assert_not_null($handle); |
| 274 | - $tmpl = new Template('/openprovider/'); | |
| 275 | - $pagetit = "OpenProvider管理 - 顧客様「{$handle}」の表示"; | |
| 276 | - $description = ''; | |
| 291 | + $this->pagetit .= "顧客様「{$handle}」の表示"; | |
| 292 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 277 | 293 | |
| 278 | - // ユーザー | |
| 279 | - $auth = new Auth(); | |
| 280 | - $user = $auth->getLoggedInUser(); | |
| 281 | - $tmpl->assign('user', $user); | |
| 282 | - | |
| 283 | - $tmpl->assign('pagetit', $pagetit); | |
| 284 | - $tmpl->assign('curPage', 'openprovider'); | |
| 285 | - $tmpl->assign('custCss', true); | |
| 286 | - $tmpl->assign('menu', $this->getMenu()); | |
| 287 | - $tmpl->assign('description', $description); | |
| 288 | - | |
| 289 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 294 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 290 | 295 | if (empty($_POST)) goto render_confirm; |
| 291 | 296 | |
| 292 | 297 | if (isset($_POST['delete_reject'])) { |
| 293 | 298 | header("Location: /openprovider/getcustomer/{$handle}"); |
| 294 | 299 | exit(); |
| 295 | 300 | } else if (isset($_POST['delete_confirm'])) { |
| 296 | - $op = new Openprovider(); | |
| 297 | - $op->login(); | |
| 298 | - $op->deleteCustomer($handle); | |
| 301 | + $this->op->deleteCustomer($handle); | |
| 299 | 302 | } |
| 300 | 303 | |
| 301 | 304 | header('Location: /openprovider/listcustomers'); |
| 302 | 305 | exit(); |
| 303 | 306 | |
| 304 | 307 | render_confirm: |
| 305 | - $tmpl->assign('handle', $handle); | |
| 306 | - $tmpl->addCss('openprovider'); | |
| 307 | - $tmpl->render('deletecustomer'); | |
| 308 | + $this->tmpl->assign('handle', $handle); | |
| 309 | + $this->tmpl->render('deletecustomer'); | |
| 308 | 310 | exit(); |
| 309 | 311 | |
| 310 | 312 | noaccess: |
| 311 | - $tmpl->render('nopermission'); | |
| 313 | + $this->tmpl->render('nopermission'); | |
| 312 | 314 | } catch (\Exception $e) { |
| 313 | 315 | throw new \Exception($e->getMessage()); |
| 314 | 316 | } |
| @@ -316,33 +318,17 @@ | ||
| 316 | 318 | |
| 317 | 319 | public function opListTlds(array $params): void { |
| 318 | 320 | try { |
| 319 | - $tmpl = new Template('/openprovider/'); | |
| 320 | - $pagetit = 'OpenProvider管理 - TLD一覧'; | |
| 321 | - $description = ''; | |
| 321 | + $this->pagetit .= 'TLD一覧'; | |
| 322 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 322 | 323 | |
| 323 | - // ユーザー | |
| 324 | - $auth = new Auth(); | |
| 325 | - $user = $auth->getLoggedInUser(); | |
| 326 | - $tmpl->assign('user', $user); | |
| 327 | - | |
| 328 | - $tmpl->assign('pagetit', $pagetit); | |
| 329 | - $tmpl->assign('curPage', 'openprovider'); | |
| 330 | - $tmpl->assign('custCss', false); | |
| 331 | - $tmpl->assign('menu', $this->getMenu()); | |
| 332 | - $tmpl->assign('description', $description); | |
| 333 | - | |
| 334 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 335 | - $op = new Openprovider(); | |
| 336 | - $op->login(); | |
| 337 | - $data = $op->listTlds(); | |
| 338 | - $tmpl->assign('data', $data->data); | |
| 339 | - | |
| 340 | - $tmpl->addCss('table'); | |
| 341 | - $tmpl->render('listtlds'); | |
| 324 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 325 | + $data = $this->op->listTlds(); | |
| 326 | + $this->tmpl->assign('data', $data->data); | |
| 327 | + $this->tmpl->render('listtlds'); | |
| 342 | 328 | exit(); |
| 343 | 329 | |
| 344 | 330 | noaccess: |
| 345 | - $tmpl->render('nopermission'); | |
| 331 | + $this->tmpl->render('nopermission'); | |
| 346 | 332 | } catch (\Exception $e) { |
| 347 | 333 | throw new \Exception($e->getMessage()); |
| 348 | 334 | } |
| @@ -356,33 +342,17 @@ | ||
| 356 | 342 | header('Location: /'); |
| 357 | 343 | exit(); |
| 358 | 344 | } |
| 359 | - $tmpl = new Template('/openprovider/'); | |
| 360 | - $pagetit = "OpenProvider管理 - .{$tld}の表示"; | |
| 361 | - $description = ''; | |
| 345 | + $this->pagetit .= "{$tld}の表示"; | |
| 346 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 362 | 347 | |
| 363 | - // ユーザー | |
| 364 | - $auth = new Auth(); | |
| 365 | - $user = $auth->getLoggedInUser(); | |
| 366 | - $tmpl->assign('user', $user); | |
| 367 | - | |
| 368 | - $tmpl->assign('pagetit', $pagetit); | |
| 369 | - $tmpl->assign('curPage', 'openprovider'); | |
| 370 | - $tmpl->assign('custCss', false); | |
| 371 | - $tmpl->assign('menu', $this->getMenu()); | |
| 372 | - $tmpl->assign('description', $description); | |
| 373 | - | |
| 374 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 375 | - $op = new Openprovider(); | |
| 376 | - $op->login(); | |
| 377 | - $data = $op->getTld($tld); | |
| 378 | - $tmpl->assign('data', $data->data); | |
| 379 | - | |
| 380 | - $tmpl->addCss('table'); | |
| 381 | - $tmpl->render('gettld'); | |
| 348 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 349 | + $data = $this->op->getTld($tld); | |
| 350 | + $this->tmpl->assign('data', $data->data); | |
| 351 | + $this->tmpl->render('gettld'); | |
| 382 | 352 | exit(); |
| 383 | 353 | |
| 384 | 354 | noaccess: |
| 385 | - $tmpl->render('nopermission'); | |
| 355 | + $this->tmpl->render('nopermission'); | |
| 386 | 356 | } catch (\Exception $e) { |
| 387 | 357 | throw new \Exception($e->getMessage()); |
| 388 | 358 | } |
| @@ -390,36 +360,17 @@ | ||
| 390 | 360 | |
| 391 | 361 | public function opListDomains(array $params): void { |
| 392 | 362 | try { |
| 393 | - $tmpl = new Template('/openprovider/'); | |
| 394 | - $pagetit = 'OpenProvider管理 - ドメイン確認'; | |
| 395 | - $description = ''; | |
| 363 | + $this->pagetit .= 'ドメイン確認'; | |
| 364 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 396 | 365 | |
| 397 | - // ユーザー | |
| 398 | - $auth = new Auth(); | |
| 399 | - $user = $auth->getLoggedInUser(); | |
| 400 | - $tmpl->assign('user', $user); | |
| 401 | - | |
| 402 | - $tmpl->assign('pagetit', $pagetit); | |
| 403 | - $tmpl->assign('curPage', 'openprovider'); | |
| 404 | - $tmpl->assign('custCss', false); | |
| 405 | - $tmpl->assign('menu', $this->getMenu()); | |
| 406 | - $tmpl->assign('description', $description); | |
| 407 | - | |
| 408 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 409 | - $op = new Openprovider(); | |
| 410 | - $op->login(); | |
| 411 | - $data = $op->listDomains($domains, true); | |
| 412 | - $tmpl->assign('data', $data->data); | |
| 413 | - | |
| 414 | - $tmpl->assign('saved', $saved); | |
| 415 | - | |
| 416 | - $tmpl->addCss('table'); | |
| 417 | - $tmpl->addCss('openprovider'); | |
| 418 | - $tmpl->render('checkdomain'); | |
| 366 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 367 | + $data = $this->op->listDomains($domains, true); | |
| 368 | + $this->tmpl->assign('data', $data->data); | |
| 369 | + $this->tmpl->render('checkdomain'); | |
| 419 | 370 | exit(); |
| 420 | 371 | |
| 421 | 372 | noaccess: |
| 422 | - $tmpl->render('nopermission'); | |
| 373 | + $this->tmpl->render('nopermission'); | |
| 423 | 374 | } catch (\Exception $e) { |
| 424 | 375 | throw new \Exception($e->getMessage()); |
| 425 | 376 | } |
| @@ -429,40 +380,22 @@ | ||
| 429 | 380 | try { |
| 430 | 381 | $domains = isset($_GET['domains']) ? explode("\n", $_GET['domains']) : []; |
| 431 | 382 | $saved = ''; |
| 383 | + $this->pagetit .= 'ドメイン確認'; | |
| 384 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 432 | 385 | |
| 433 | - $tmpl = new Template('/openprovider/'); | |
| 434 | - $pagetit = 'OpenProvider管理 - ドメイン確認'; | |
| 435 | - $description = ''; | |
| 436 | - | |
| 437 | - // ユーザー | |
| 438 | - $auth = new Auth(); | |
| 439 | - $user = $auth->getLoggedInUser(); | |
| 440 | - $tmpl->assign('user', $user); | |
| 441 | - | |
| 442 | - $tmpl->assign('pagetit', $pagetit); | |
| 443 | - $tmpl->assign('curPage', 'openprovider'); | |
| 444 | - $tmpl->assign('custCss', false); | |
| 445 | - $tmpl->assign('menu', $this->getMenu()); | |
| 446 | - $tmpl->assign('description', $description); | |
| 447 | - | |
| 448 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 449 | - $op = new Openprovider(); | |
| 450 | - $op->login(); | |
| 386 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 451 | 387 | if (!empty($domains)) { |
| 452 | - $data = $op->checkDomainAvailable($domains, true); | |
| 453 | - $tmpl->assign('data', $data->data); | |
| 388 | + $data = $this->op->checkDomainAvailable($domains, true); | |
| 389 | + $this->tmpl->assign('data', $data->data); | |
| 454 | 390 | $saved = $_GET['domains']; |
| 455 | 391 | } |
| 456 | 392 | |
| 457 | - $tmpl->assign('saved', $saved); | |
| 458 | - | |
| 459 | - $tmpl->addCss('table'); | |
| 460 | - $tmpl->addCss('openprovider'); | |
| 461 | - $tmpl->render('checkdomain'); | |
| 393 | + $this->tmpl->assign('saved', $saved); | |
| 394 | + $this->tmpl->render('checkdomain'); | |
| 462 | 395 | exit(); |
| 463 | 396 | |
| 464 | 397 | noaccess: |
| 465 | - $tmpl->render('nopermission'); | |
| 398 | + $this->tmpl->render('nopermission'); | |
| 466 | 399 | } catch (\Exception $e) { |
| 467 | 400 | throw new \Exception($e->getMessage()); |
| 468 | 401 | } |
| @@ -472,34 +405,17 @@ | ||
| 472 | 405 | try { |
| 473 | 406 | $domainname = $_GET['domain_name'] ?? ''; |
| 474 | 407 | $domainext = $_GET['domain_extension'] ?? ''; |
| 408 | + $this->pagetit .= 'ドメイン値段一覧'; | |
| 409 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 475 | 410 | |
| 476 | - $tmpl = new Template('/openprovider/'); | |
| 477 | - $pagetit = 'OpenProvider管理 - ドメイン値段一覧'; | |
| 478 | - $description = ''; | |
| 479 | - | |
| 480 | - // ユーザー | |
| 481 | - $auth = new Auth(); | |
| 482 | - $user = $auth->getLoggedInUser(); | |
| 483 | - $tmpl->assign('user', $user); | |
| 484 | - | |
| 485 | - $tmpl->assign('pagetit', $pagetit); | |
| 486 | - $tmpl->assign('curPage', 'openprovider'); | |
| 487 | - $tmpl->assign('custCss', false); | |
| 488 | - $tmpl->assign('menu', $this->getMenu()); | |
| 489 | - $tmpl->assign('description', $description); | |
| 490 | - | |
| 491 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 492 | - $op = new Openprovider(); | |
| 493 | - $op->login(); | |
| 494 | - $data = $op->getDomainPrices(['domain.name' => $domainname, 'domain.extension' => $domainext]); | |
| 495 | - $tmpl->assign('data', $data->data); | |
| 496 | - | |
| 497 | - $tmpl->addCss('table'); | |
| 498 | - $tmpl->render('getdomainprices'); | |
| 411 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 412 | + $data = $this->op->getDomainPrices(['domain.name' => $domainname, 'domain.extension' => $domainext]); | |
| 413 | + $this->tmpl->assign('data', $data->data); | |
| 414 | + $this->tmpl->render('getdomainprices'); | |
| 499 | 415 | exit(); |
| 500 | 416 | |
| 501 | 417 | noaccess: |
| 502 | - $tmpl->render('nopermission'); | |
| 418 | + $this->tmpl->render('nopermission'); | |
| 503 | 419 | } catch (\Exception $e) { |
| 504 | 420 | throw new \Exception($e->getMessage()); |
| 505 | 421 | } |
| @@ -507,34 +423,17 @@ | ||
| 507 | 423 | |
| 508 | 424 | public function opListDns(array $params): void { |
| 509 | 425 | try { |
| 510 | - $tmpl = new Template('/openprovider/'); | |
| 511 | - $pagetit = "OpenProvider管理 - DNS一覧"; | |
| 512 | - $description = ''; | |
| 426 | + $this->pagetit .= 'DNS一覧'; | |
| 427 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 513 | 428 | |
| 514 | - // ユーザー | |
| 515 | - $auth = new Auth(); | |
| 516 | - $user = $auth->getLoggedInUser(); | |
| 517 | - $tmpl->assign('user', $user); | |
| 518 | - | |
| 519 | - $tmpl->assign('pagetit', $pagetit); | |
| 520 | - $tmpl->assign('curPage', 'openprovider'); | |
| 521 | - $tmpl->assign('custCss', true); | |
| 522 | - $tmpl->assign('menu', $this->getMenu()); | |
| 523 | - $tmpl->assign('description', $description); | |
| 524 | - | |
| 525 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 526 | - $op = new Openprovider(); | |
| 527 | - $op->login(); | |
| 528 | - $data = $op->listDnsZones(); | |
| 529 | - $tmpl->assign('data', $data->data); | |
| 530 | - | |
| 531 | - $tmpl->addCss('table'); | |
| 532 | - if ($user && $user->role & (Roles::ADMIN)) $tmpl->render('listdnszones'); | |
| 533 | - else goto noaccess; | |
| 429 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 430 | + $data = $this->op->listDnsZones(); | |
| 431 | + $this->tmpl->assign('data', $data->data); | |
| 432 | + $this->tmpl->render('listdnszones'); | |
| 534 | 433 | exit(); |
| 535 | 434 | |
| 536 | 435 | noaccess: |
| 537 | - $tmpl->render('nopermission'); | |
| 436 | + $this->tmpl->render('nopermission'); | |
| 538 | 437 | } catch (\Exception $e) { |
| 539 | 438 | throw new \Exception($e->getMessage()); |
| 540 | 439 | } |
| @@ -548,33 +447,17 @@ | ||
| 548 | 447 | header('Location: /'); |
| 549 | 448 | exit(); |
| 550 | 449 | } |
| 551 | - $tmpl = new Template('/openprovider/'); | |
| 552 | - $pagetit = "OpenProvider管理 - {$domain}のDNS管理"; | |
| 553 | - $description = ''; | |
| 450 | + $this->pagetit .= "{$domain}のDNS管理"; | |
| 451 | + $this->tmpl->assign('pagetit', $this->pagetit); | |
| 554 | 452 | |
| 555 | - // ユーザー | |
| 556 | - $auth = new Auth(); | |
| 557 | - $user = $auth->getLoggedInUser(); | |
| 558 | - $tmpl->assign('user', $user); | |
| 559 | - | |
| 560 | - $tmpl->assign('pagetit', $pagetit); | |
| 561 | - $tmpl->assign('curPage', 'openprovider'); | |
| 562 | - $tmpl->assign('custCss', false); | |
| 563 | - $tmpl->assign('menu', $this->getMenu()); | |
| 564 | - $tmpl->assign('description', $description); | |
| 565 | - | |
| 566 | - if (!$user || $user->role !== Roles::ADMIN) goto noaccess; | |
| 567 | - $op = new Openprovider(); | |
| 568 | - $op->login(); | |
| 569 | - $data = ['rec' => $op->listZoneRecords($domain), 'zone' => $op->getDnsZone($domain)]; | |
| 570 | - $tmpl->assign('data', $data->data); | |
| 571 | - | |
| 572 | - $tmpl->addCss('table'); | |
| 573 | - $tmpl->render('getdns'); | |
| 453 | + if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess; | |
| 454 | + $data = ['rec' => $this->op->listZoneRecords($domain), 'zone' => $this->op->getDnsZone($domain)]; | |
| 455 | + $this->tmpl->assign('data', $data->data); | |
| 456 | + $this->tmpl->render('getdns'); | |
| 574 | 457 | exit(); |
| 575 | 458 | |
| 576 | 459 | noaccess: |
| 577 | - $tmpl->render('nopermission'); | |
| 460 | + $this->tmpl->render('nopermission'); | |
| 578 | 461 | } catch (\Exception $e) { |
| 579 | 462 | throw new \Exception($e->getMessage()); |
| 580 | 463 | } |
| @@ -40,6 +40,7 @@ | ||
| 40 | 40 | use Site\Controller\Mods; |
| 41 | 41 | use Std\Lib\Auth; |
| 42 | 42 | use Std\Lib\Template; |
| 43 | +use Roles; | |
| 43 | 44 | |
| 44 | 45 | class Page { |
| 45 | 46 | use Mods; |
| @@ -132,7 +133,7 @@ | ||
| 132 | 133 | $tmpl->assign('menu', $this->getMenu()); |
| 133 | 134 | $tmpl->assign('description', $description); |
| 134 | 135 | |
| 135 | - if ($user && $user->role !== \Roles::BANNED) $tmpl->render('memberonly'); | |
| 136 | + if ($user && $user->role !== Roles::BANNED) $tmpl->render('memberonly'); | |
| 136 | 137 | else $tmpl->render('nopermission'); |
| 137 | 138 | } catch (\Exception $e) { |
| 138 | 139 | throw new \Exception($e->getMessage()); |
| @@ -156,7 +157,7 @@ | ||
| 156 | 157 | $tmpl->assign('menu', $this->getMenu()); |
| 157 | 158 | $tmpl->assign('description', $description); |
| 158 | 159 | |
| 159 | - if ($user && $user->role & (\Roles::ADMIN | \Roles::STAFF)) $tmpl->render('staffonly'); | |
| 160 | + if ($user && $user->role & (Roles::ADMIN | Roles::STAFF)) $tmpl->render('staffonly'); | |
| 160 | 161 | else $tmpl->render('nopermission'); |
| 161 | 162 | } catch (\Exception $e) { |
| 162 | 163 | throw new \Exception($e->getMessage()); |
| @@ -38,6 +38,7 @@ | ||
| 38 | 38 | namespace Std\Lib; |
| 39 | 39 | |
| 40 | 40 | use Std\Lib\Curl; |
| 41 | +use LogType; | |
| 41 | 42 | |
| 42 | 43 | /** |
| 43 | 44 | * ActivityPubプロトコルの実装クラス |
| @@ -434,7 +435,7 @@ | ||
| 434 | 435 | $privFile = FEDIINFO['privkey']; |
| 435 | 436 | $priv = file_get_contents($privFile); |
| 436 | 437 | if ($priv === false) { |
| 437 | - logger(\LogType::ActivityPub, "エラー:秘密鍵「{$privFile}」の読込に失敗"); | |
| 438 | + logger(LogType::ActivityPub, "エラー:秘密鍵「{$privFile}」の読込に失敗"); | |
| 438 | 439 | header('HTTP/1.1 500 Internal Server Error'); |
| 439 | 440 | header('Content-Type: application/activity+json'); |
| 440 | 441 | echo json_encode(['error' => '秘密鍵の読込に失敗']); |
| @@ -454,11 +455,11 @@ | ||
| 454 | 455 | ]; |
| 455 | 456 | |
| 456 | 457 | $stringToSign = "host: {$headers['Host']}\n"."date: {$headers['Date']}\n"."digest: {$headers['Digest']}"; |
| 457 | - logger(\LogType::ActivityPub, "署名対象: {$stringToSign}"); | |
| 458 | + logger(LogType::ActivityPub, "署名対象: {$stringToSign}"); | |
| 458 | 459 | |
| 459 | 460 | if (!openssl_sign($stringToSign, $signature, $priv, OPENSSL_ALGO_SHA256)) { |
| 460 | 461 | $error = openssl_error_string(); |
| 461 | - logger(\LogType::ActivityPub, "エラー:署名に失敗: {$error}"); | |
| 462 | + logger(LogType::ActivityPub, "エラー:署名に失敗: {$error}"); | |
| 462 | 463 | header('HTTP/1.1 500 Internal Server Error'); |
| 463 | 464 | header('Content-Type: application/activity+json'); |
| 464 | 465 | echo json_encode(['error' => '署名に失敗']); |
| @@ -470,7 +471,7 @@ | ||
| 470 | 471 | $headers['Signature'] .= 'algorithm="rsa-sha256",'; |
| 471 | 472 | $headers['Signature'] .= 'headers="host date digest",'; |
| 472 | 473 | $headers['Signature'] .= 'signature="'.$sigValue.'"'; |
| 473 | - logger(\LogType::ActivityPub, "署名: {$headers['Signature']}\n送信データ: {$body}"); | |
| 474 | + logger(LogType::ActivityPub, "署名: {$headers['Signature']}\n送信データ: {$body}"); | |
| 474 | 475 | |
| 475 | 476 | $curl = new Curl($inboxUrl); |
| 476 | 477 | $curl->setMethod('POST') |
| @@ -486,9 +487,9 @@ | ||
| 486 | 487 | $err = $curl->getError(); |
| 487 | 488 | |
| 488 | 489 | var_dump(print_r($res)); |
| 489 | - logger(\LogType::ActivityPub, "アクティビティは「{$inboxUrl}」に送信しました: HTTP {$code}"); | |
| 490 | - logger(\LogType::ActivityPub, "エラー: {$err}"); | |
| 491 | - logger(\LogType::ActivityPub, "レスポンス: {$res}"); | |
| 490 | + logger(LogType::ActivityPub, "アクティビティは「{$inboxUrl}」に送信しました: HTTP {$code}"); | |
| 491 | + logger(LogType::ActivityPub, "エラー: {$err}"); | |
| 492 | + logger(LogType::ActivityPub, "レスポンス: {$res}"); | |
| 492 | 493 | } |
| 493 | 494 | |
| 494 | 495 | /** |
| @@ -571,10 +572,10 @@ | ||
| 571 | 572 | ->setMaxRedirects(5) |
| 572 | 573 | ->setCaInfo('/etc/ssl/cert.pem'); |
| 573 | 574 | |
| 574 | - logger(\LogType::ActivityPub, "アクターURLにリクエスト: {$actor}"); | |
| 575 | + logger(LogType::ActivityPub, "アクターURLにリクエスト: {$actor}"); | |
| 575 | 576 | $success = $curl->execute(); |
| 576 | 577 | if (!$success) { |
| 577 | - logger(\LogType::ActivityPub, "アクターリクエストに失敗: ".$curl->getError()); | |
| 578 | + logger(LogType::ActivityPub, "アクターリクエストに失敗: ".$curl->getError()); | |
| 578 | 579 | return null; |
| 579 | 580 | } |
| 580 | 581 | |
| @@ -583,7 +584,7 @@ | ||
| 583 | 584 | $err = $curl->getError(); |
| 584 | 585 | |
| 585 | 586 | if ($code !== 200) { |
| 586 | - logger(\LogType::ActivityPub, "アクター取得に失敗: HTTP {$code}, エラー: {$err}"); | |
| 587 | + logger(LogType::ActivityPub, "アクター取得に失敗: HTTP {$code}, エラー: {$err}"); | |
| 587 | 588 | return null; |
| 588 | 589 | } |
| 589 | 590 |
| @@ -37,6 +37,11 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | namespace Std\Lib; |
| 39 | 39 | |
| 40 | +use Gender; | |
| 41 | +use LogType; | |
| 42 | +use Result; | |
| 43 | +use Roles; | |
| 44 | + | |
| 40 | 45 | class Auth { |
| 41 | 46 | private int $id; |
| 42 | 47 | |
| @@ -72,22 +77,22 @@ | ||
| 72 | 77 | unset($user->password); |
| 73 | 78 | unset($user->tokens); |
| 74 | 79 | $myself = $this->getUserData(); |
| 75 | - if (!$myself || ($myself->id != $user->id && $myself->role < \Roles::STAFF)) $user->email = '(秘密)'; | |
| 80 | + if (!$myself || ($myself->id != $user->id && $myself->role < Roles::STAFF)) $user->email = '(秘密)'; | |
| 76 | 81 | $user->name = namecolor($user); |
| 77 | 82 | $user->regDate = date('Y年m月d日', $user->regDate); |
| 78 | - $user->gender = $user->gender === \Gender::MALE ? '男' : ($user->gender === \Gender::FEMALE ? '女' : '不明'); | |
| 83 | + $user->gender = $user->gender === Gender::MALE ? '男' : ($user->gender === Gender::FEMALE ? '女' : '不明'); | |
| 79 | 84 | |
| 80 | 85 | switch (true) { |
| 81 | - case ($user->role & \Roles::ADMIN): | |
| 86 | + case ($user->role & Roles::ADMIN): | |
| 82 | 87 | $user->role = '管理者'; |
| 83 | 88 | break; |
| 84 | - case ($user->role & \Roles::STAFF): | |
| 89 | + case ($user->role & Roles::STAFF): | |
| 85 | 90 | $user->role = '076スタジオの会社員'; |
| 86 | 91 | break; |
| 87 | - case ($user->role & (\Roles::FSUBSCRIBER | \Roles::PSUBSCRIBER | \Roles::NSUBSCRIBER | \Roles::SUBSCRIBER)): | |
| 92 | + case ($user->role & (Roles::FSUBSCRIBER | Roles::PSUBSCRIBER | Roles::NSUBSCRIBER | Roles::SUBSCRIBER)): | |
| 88 | 93 | $user->role = '支援者♡'; |
| 89 | 94 | break; |
| 90 | - case ($user->role & \Roles::BANNED): | |
| 95 | + case ($user->role & Roles::BANNED): | |
| 91 | 96 | $user->role = 'BANされた'; |
| 92 | 97 | break; |
| 93 | 98 | default: |
| @@ -103,14 +108,14 @@ | ||
| 103 | 108 | return $user; |
| 104 | 109 | } |
| 105 | 110 | |
| 106 | - public function setToken(string $username, #[SensitiveParameter] string $password): \Result { | |
| 107 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 111 | + public function setToken(string $username, #[SensitiveParameter] string $password): Result { | |
| 112 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 108 | 113 | $userData = $this->getUserData(); |
| 109 | 114 | if (!isset($userData->tokens) || !is_array($userData->tokens)) $userData->tokens = []; |
| 110 | 115 | |
| 111 | 116 | $verify = $this->verifyLogin($username, $password); |
| 112 | 117 | if (!$verify->isSuccess) { |
| 113 | - return \Result::error($verify->message); | |
| 118 | + return Result::error($verify->message); | |
| 114 | 119 | } |
| 115 | 120 | |
| 116 | 121 | $ip = $_SERVER['REMOTE_ADDR']; |
| @@ -119,7 +124,9 @@ | ||
| 119 | 124 | $ip = trim($ipList[0]); |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - $userData = $this->purgeOldTokens($userData); | |
| 127 | + $res = $this->purgeOldTokens($userData); | |
| 128 | + if (!$res->isSuccess) return Result::Error($res->message); | |
| 129 | + $userData = $res->data; | |
| 123 | 130 | $token = bin2hex(random_bytes(64)); |
| 124 | 131 | $expire = time() + $this->tokenDuration; |
| 125 | 132 | $newToken = [ |
| @@ -137,8 +144,8 @@ | ||
| 137 | 144 | $json = json_encode($userData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 138 | 145 | |
| 139 | 146 | if (file_put_contents($path, $json) === false) { |
| 140 | - logger(\LogType::Auth, '【setToken】JSONファイルにユーザーデータを保存出来なかった。パス:'.$path); | |
| 141 | - return \Result::error('エラー:ユーザーデータの保存に失敗。'); | |
| 147 | + logger(LogType::Auth, '【setToken】JSONファイルにユーザーデータを保存出来なかった。パス:'.$path); | |
| 148 | + return Result::error('エラー:ユーザーデータの保存に失敗。'); | |
| 142 | 149 | } |
| 143 | 150 | |
| 144 | 151 | if (!setcookie('kerozen', $token, [ |
| @@ -149,22 +156,24 @@ | ||
| 149 | 156 | 'httponly' => true, |
| 150 | 157 | 'samesite' => 'Strict' |
| 151 | 158 | ])) { |
| 152 | - logger(\LogType::Auth, '【setToken】クッキーを設定出来なかった。トークン:'.$token); | |
| 153 | - return \Result::error('エラー:クッキーを設定に失敗。'); | |
| 159 | + logger(LogType::Auth, '【setToken】クッキーを設定出来なかった。トークン:'.$token); | |
| 160 | + return Result::error('エラー:クッキーを設定に失敗。'); | |
| 154 | 161 | } |
| 155 | 162 | |
| 156 | - return \Result::success('ログイン成功'); | |
| 163 | + return Result::success('ログイン成功'); | |
| 157 | 164 | } |
| 158 | 165 | |
| 159 | - public function getToken(): string { | |
| 166 | + public function getToken(): ?string { | |
| 160 | 167 | if (!AUTH_ENABLED) return ''; |
| 161 | 168 | $userData = $this->getUserData(); |
| 162 | 169 | if (!isset($userData->tokens) || !is_array($userData->tokens)) $userData->tokens = []; |
| 163 | - $userData = $this->purgeOldTokens($userData); | |
| 170 | + $res = $this->purgeOldTokens($userData); | |
| 171 | + if (!$res->isSuccess) return null; | |
| 172 | + $userData = $res->data; | |
| 164 | 173 | } |
| 165 | 174 | |
| 166 | - public function logout(?string $token = null): \Result { | |
| 167 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 175 | + public function logout(?string $token = null): Result { | |
| 176 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 168 | 177 | $userData = $this->getUserData(); |
| 169 | 178 | |
| 170 | 179 | if (!$token) { |
| @@ -182,27 +191,27 @@ | ||
| 182 | 191 | 'samesite' => 'Strict' |
| 183 | 192 | ]); |
| 184 | 193 | |
| 185 | - return \Result::success(); | |
| 194 | + return Result::success(); | |
| 186 | 195 | } |
| 187 | 196 | |
| 188 | - public function isUserExist(?string $username = null): \Result { | |
| 189 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 190 | - if (null === $username) return \Result::Error('エラー:ユーザー名をご入力下さい。'); | |
| 197 | + public function isUserExist(?string $username = null): Result { | |
| 198 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 199 | + if (null === $username) return Result::Error('エラー:ユーザー名をご入力下さい。'); | |
| 191 | 200 | $userList = scandir($this->dataDir); |
| 192 | 201 | |
| 193 | 202 | foreach ($userList as $list) { |
| 194 | 203 | if ($list === '.kara' || $list === '.' || $list === '..') continue; |
| 195 | 204 | $file = str_replace('.json', '', $list); |
| 196 | 205 | $user = explode('.', $file)[1]; |
| 197 | - if ($username === $user) return \Result::Success("ユーザー「{$username}」は既に存在します。"); | |
| 206 | + if ($username === $user) return Result::Success("ユーザー「{$username}」は既に存在します。"); | |
| 198 | 207 | } |
| 199 | 208 | |
| 200 | - return \Result::Error(''); | |
| 209 | + return Result::Error(''); | |
| 201 | 210 | } |
| 202 | 211 | |
| 203 | - public function mkUser(?string $username = null, #[SensitiveParameter] ?string $password = null, ?string $passwordVerify = null, ?string $email = null): \Result { | |
| 204 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 205 | - if (!AUTH_REGISTER_ENABLED) return \Result::Error('ユーザー登録は無効です。'); | |
| 212 | + public function mkUser(?string $username = null, #[SensitiveParameter] ?string $password = null, ?string $passwordVerify = null, ?string $email = null): Result { | |
| 213 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 214 | + if (!AUTH_REGISTER_ENABLED) return Result::Error('ユーザー登録は無効です。'); | |
| 206 | 215 | $resUsr = $this->verifyUsername($username); |
| 207 | 216 | $resPwd = $this->verifyPassword($password, $passwordVerify); |
| 208 | 217 | $resEml = $this->verifyEmail($email); |
| @@ -213,12 +222,12 @@ | ||
| 213 | 222 | if (!$resPwd->isSuccess) $err .= $resPwd->message."<br />"; |
| 214 | 223 | if (!$resEml->isSuccess) $err .= $resEml->message."<br />"; |
| 215 | 224 | |
| 216 | - if ($err != '') return \Result::Error($err); | |
| 225 | + if ($err != '') return Result::Error($err); | |
| 217 | 226 | $err = ''; |
| 218 | 227 | |
| 219 | 228 | if (!mkdir($this->assDir.$username, 0755)) { |
| 220 | - logger(\LogType::Auth, '【mkUser】アセットディレクトリを作成出来なかった。chownをご確認下さい。パス:'.$this->assDir.$username); | |
| 221 | - return \Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。'); | |
| 229 | + logger(LogType::Auth, '【mkUser】アセットディレクトリを作成出来なかった。chownをご確認下さい。パス:'.$this->assDir.$username); | |
| 230 | + return Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。'); | |
| 222 | 231 | } |
| 223 | 232 | |
| 224 | 233 | $file = scandir($this->dataDir); |
| @@ -246,29 +255,29 @@ | ||
| 246 | 255 | $user->regDate = time(); |
| 247 | 256 | $user->namecolor = ''; |
| 248 | 257 | $user->displayname = ''; |
| 249 | - $user->gender = \Gender::UNKNOWN; | |
| 250 | - $user->role = \Roles::MEMBER; | |
| 258 | + $user->gender = Gender::UNKNOWN; | |
| 259 | + $user->role = Roles::MEMBER; | |
| 251 | 260 | $user->tokens = []; |
| 252 | 261 | |
| 253 | 262 | $path = "{$this->dataDir}{$lastId}.{$username}.json"; |
| 254 | 263 | $json = json_encode($user, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 255 | 264 | |
| 256 | 265 | if (file_put_contents($path, $json) === false) { |
| 257 | - logger(\LogType::Auth, '【mkUser】JSONファイルを作成出来なかった。パス:'.$path); | |
| 266 | + logger(LogType::Auth, '【mkUser】JSONファイルを作成出来なかった。パス:'.$path); | |
| 258 | 267 | rmdir($this->assDir.$username); |
| 259 | - return \Result::Error('エラー:ユーザーデータの保存に失敗。'); | |
| 268 | + return Result::Error('エラー:ユーザーデータの保存に失敗。'); | |
| 260 | 269 | } |
| 261 | 270 | |
| 262 | - return \Result::Success(); | |
| 271 | + return Result::Success(); | |
| 263 | 272 | } |
| 264 | 273 | |
| 265 | 274 | //////////////////// |
| 266 | 275 | |
| 267 | - private function verifyLogin(string $username, #[SensitiveParameter] string $password): \Result { | |
| 268 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 276 | + private function verifyLogin(string $username, #[SensitiveParameter] string $password): Result { | |
| 277 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 269 | 278 | $userData = $this->getUserData(); |
| 270 | 279 | if ($username !== $userData->username || !password_verify($password, $userData->password)) { |
| 271 | - return \Result::Error('エラー:ユーザー名又はパスワードが一致していません。'); | |
| 280 | + return Result::Error('エラー:ユーザー名又はパスワードが一致していません。'); | |
| 272 | 281 | } |
| 273 | 282 | |
| 274 | 283 | if (password_needs_rehash($userData->password, $this->algo)) { |
| @@ -277,31 +286,31 @@ | ||
| 277 | 286 | $json = json_encode($userData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 278 | 287 | |
| 279 | 288 | if (file_put_contents($path, $json) === false) { |
| 280 | - logger(\LogType::Auth, '【verifyLogin】JSONファイルを変更出来なかった。chownをご確認下さい。パス:'.$path); | |
| 281 | - return \Result::Error('エラー:ユーザーデータの保存に失敗。'); | |
| 289 | + logger(LogType::Auth, '【verifyLogin】JSONファイルを変更出来なかった。chownをご確認下さい。パス:'.$path); | |
| 290 | + return Result::Error('エラー:ユーザーデータの保存に失敗。'); | |
| 282 | 291 | } |
| 283 | 292 | } |
| 284 | 293 | |
| 285 | - return \Result::Success(); | |
| 294 | + return Result::Success(); | |
| 286 | 295 | } |
| 287 | 296 | |
| 288 | - private function purgeOldTokens(\stdClass $userData): \stdClass|\Result { | |
| 289 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 297 | + private function purgeOldTokens(\stdClass $userData): Result { | |
| 298 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 290 | 299 | // 有効期限切れたトークンの削除 |
| 291 | 300 | $out = $userData; |
| 292 | 301 | $out->tokens = array_filter($userData->tokens, function($t): bool { |
| 293 | - return ($t->expDate ?? 0) > time(); | |
| 302 | + return Result::Success('', ($t->expDate ?? 0) > time()); | |
| 294 | 303 | }); |
| 295 | 304 | |
| 296 | 305 | $path = $this->dataDir.$userData->id.'.'.$userData->username.'.json'; |
| 297 | 306 | $json = json_encode($userData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 298 | 307 | |
| 299 | 308 | if (file_put_contents($path, $json) === false) { |
| 300 | - logger(\LogType::Auth, '【purgeOldTokens】JSONファイルを変更出来なかった。chownをご確認下さい。パス:'.$path); | |
| 301 | - return \Result::Error('エラー:ユーザーデータの保存に失敗。'); | |
| 309 | + logger(LogType::Auth, '【purgeOldTokens】JSONファイルを変更出来なかった。chownをご確認下さい。パス:'.$path); | |
| 310 | + return Result::Error('エラー:ユーザーデータの保存に失敗。'); | |
| 302 | 311 | } |
| 303 | 312 | |
| 304 | - return $out; | |
| 313 | + return Result::Success('', $out); | |
| 305 | 314 | } |
| 306 | 315 | |
| 307 | 316 | private function getUserId(?string $username = null, ?string $token = null): int { |
| @@ -396,8 +405,8 @@ | ||
| 396 | 405 | return json_decode($lines); |
| 397 | 406 | } |
| 398 | 407 | |
| 399 | - private function isEmailExist(?string $email = null): \Result { | |
| 400 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 408 | + private function isEmailExist(?string $email = null): Result { | |
| 409 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 401 | 410 | $userList = scandir($this->dataDir); |
| 402 | 411 | $matches = []; |
| 403 | 412 | |
| @@ -410,67 +419,67 @@ | ||
| 410 | 419 | if (str_contains($content, '"email": "'.$email.'",')) { |
| 411 | 420 | $matches[] = $email; |
| 412 | 421 | } |
| 413 | - if (count($matches) > 0) return \Result::Error("ユーザー「{$email}」は既に存在します。"); | |
| 422 | + if (count($matches) > 0) return Result::Error("ユーザー「{$email}」は既に存在します。"); | |
| 414 | 423 | } |
| 415 | 424 | |
| 416 | - return \Result::Success('エラー:メールアドレスが存在しません。'); | |
| 425 | + return Result::Success('エラー:メールアドレスが存在しません。'); | |
| 417 | 426 | } |
| 418 | 427 | |
| 419 | - private function verifyEmail(?string $email = null): \Result { | |
| 420 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 421 | - if (null === $email || '' === $email) return \Result::Error('エラー:メールアドレスをご入力下さい。'); | |
| 422 | - if (strpos($email, '@') === false) return \Result::Error('エラー:メールアドレスは不正です。'); | |
| 428 | + private function verifyEmail(?string $email = null): Result { | |
| 429 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 430 | + if (null === $email || '' === $email) return Result::Error('エラー:メールアドレスをご入力下さい。'); | |
| 431 | + if (strpos($email, '@') === false) return Result::Error('エラー:メールアドレスは不正です。'); | |
| 423 | 432 | |
| 424 | 433 | $domain = explode('@', $email)[1]; |
| 425 | 434 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 426 | - return \Result::Error('エラー:メールアドレスは不正です。'); | |
| 435 | + return Result::Error('エラー:メールアドレスは不正です。'); | |
| 427 | 436 | } |
| 428 | 437 | |
| 429 | 438 | if (!checkdnsrr($domain, 'MX')) { |
| 430 | - return \Result::Error('エラー:メールアドレスは不正です。'); | |
| 439 | + return Result::Error('エラー:メールアドレスは不正です。'); | |
| 431 | 440 | } |
| 432 | 441 | |
| 433 | 442 | $res = $this->isEmailExist($email); |
| 434 | - if (!$res->isSuccess) return \Result::Error($res->message); | |
| 443 | + if (!$res->isSuccess) return Result::Error($res->message); | |
| 435 | 444 | |
| 436 | - return \Result::Success(); | |
| 445 | + return Result::Success(); | |
| 437 | 446 | } |
| 438 | 447 | |
| 439 | - private function verifyUsername(?string $username): \Result { | |
| 440 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 441 | - if (null === $username || '' === $username) return \Result::Error('エラー:ユーザー名をご入力下さい。'); | |
| 442 | - if (strlen($username) < 6) return \Result::Error('エラー:ユーザー名は6文字以上をご入力下さい。'); | |
| 448 | + private function verifyUsername(?string $username): Result { | |
| 449 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 450 | + if (null === $username || '' === $username) return Result::Error('エラー:ユーザー名をご入力下さい。'); | |
| 451 | + if (strlen($username) < 6) return Result::Error('エラー:ユーザー名は6文字以上をご入力下さい。'); | |
| 443 | 452 | |
| 444 | 453 | $res = $this->isUserExist($username); |
| 445 | - if ($res->isSuccess) return \Result::Error($res->message); | |
| 454 | + if ($res->isSuccess) return Result::Error($res->message); | |
| 446 | 455 | |
| 447 | 456 | $accepted = 'A-Za-z0-9'; |
| 448 | 457 | if (preg_match("/[^{$accepted}]/", $username)) { |
| 449 | - return \Result::Error('エラー:ユーザー名に不正な文字が含みます。'); | |
| 458 | + return Result::Error('エラー:ユーザー名に不正な文字が含みます。'); | |
| 450 | 459 | } |
| 451 | 460 | |
| 452 | - return \Result::Success(); | |
| 461 | + return Result::Success(); | |
| 453 | 462 | } |
| 454 | 463 | |
| 455 | - private function verifyPassword(#[SensitiveParameter] ?string $password = null, #[SensitiveParameter] ?string $passwordVerify = null): \Result { | |
| 456 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 457 | - if (null === $password || '' === $password) return \Result::Error('エラー:パスワードをご入力下さい。'); | |
| 458 | - if ($password !== $passwordVerify) return \Result::Error('エラー:パスワードは一致していません。'); | |
| 464 | + private function verifyPassword(#[SensitiveParameter] ?string $password = null, #[SensitiveParameter] ?string $passwordVerify = null): Result { | |
| 465 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 466 | + if (null === $password || '' === $password) return Result::Error('エラー:パスワードをご入力下さい。'); | |
| 467 | + if ($password !== $passwordVerify) return Result::Error('エラー:パスワードは一致していません。'); | |
| 459 | 468 | |
| 460 | 469 | $res = $this->checkPasswordStandards($password); |
| 461 | 470 | if (!$res->isSuccess) { |
| 462 | - return \Result::Error($res->message); | |
| 471 | + return Result::Error($res->message); | |
| 463 | 472 | } |
| 464 | 473 | |
| 465 | - return \Result::Success(); | |
| 474 | + return Result::Success(); | |
| 466 | 475 | } |
| 467 | 476 | |
| 468 | - private function checkPasswordStandards(#[SensitiveParameter] ?string $password = null): \Result { | |
| 469 | - if (!AUTH_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 470 | - if (strlen($password) < $this->minPassLen) return \Result::Error("エラー:パスワードは{$this->minPassLen}以上をご入力下さい。"); | |
| 477 | + private function checkPasswordStandards(#[SensitiveParameter] ?string $password = null): Result { | |
| 478 | + if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 479 | + if (strlen($password) < $this->minPassLen) return Result::Error("エラー:パスワードは{$this->minPassLen}以上をご入力下さい。"); | |
| 471 | 480 | |
| 472 | 481 | if (!\countmatch($password)) { |
| 473 | - return \Result::Error('エラー:パスワードに不正な文字が含みます。'); | |
| 482 | + return Result::Error('エラー:パスワードに不正な文字が含みます。'); | |
| 474 | 483 | } |
| 475 | 484 | |
| 476 | 485 | $countUpper = preg_match_all('/[A-Z]/', $password) < 2; |
| @@ -479,9 +488,9 @@ | ||
| 479 | 488 | $countSymbol = \count_special_chars($password) < 2; |
| 480 | 489 | |
| 481 | 490 | if ($countUpper || $countLower || $countDigit || $countSymbol) { |
| 482 | - return \Result::Error('エラー:パスワードは2つ以上の大文字、2つ以上の小文字、2つ以上の数字、及び2つ以上の特別文字を含む事が必須です。'); | |
| 491 | + return Result::Error('エラー:パスワードは2つ以上の大文字、2つ以上の小文字、2つ以上の数字、及び2つ以上の特別文字を含む事が必須です。'); | |
| 483 | 492 | } |
| 484 | 493 | |
| 485 | - return \Result::Success(); | |
| 494 | + return Result::Success(); | |
| 486 | 495 | } |
| 487 | 496 | }; |
| @@ -37,6 +37,8 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | namespace Std\Lib; |
| 39 | 39 | |
| 40 | +use Result; | |
| 41 | + | |
| 40 | 42 | /** |
| 41 | 43 | * php_curlへの依存を排除するための独自のCURL実装 |
| 42 | 44 | */ |
| @@ -317,11 +319,11 @@ | ||
| 317 | 319 | * |
| 318 | 320 | * @return Result 成功または失敗 |
| 319 | 321 | */ |
| 320 | - public function execute(): \Result { | |
| 321 | - if (!CURL_ENABLED) return \Result::Error('エラー:認証システムは無効です。'); | |
| 322 | + public function execute(): Result { | |
| 323 | + if (!CURL_ENABLED) return Result::Error('エラー:認証システムは無効です。'); | |
| 322 | 324 | if (empty($this->url)) { |
| 323 | 325 | $this->responseError = 'URLがありません'; |
| 324 | - return \Result::Error($this->responseError); | |
| 326 | + return Result::Error($this->responseError); | |
| 325 | 327 | } |
| 326 | 328 | |
| 327 | 329 | // レスポンスデータのリセット |
| @@ -355,7 +357,7 @@ | ||
| 355 | 357 | $parsed = parse_url($currentUrl); |
| 356 | 358 | if (!$parsed) { |
| 357 | 359 | $this->responseError = "無効なURL: {$currentUrl}"; |
| 358 | - return \Result::Error($this->responseError); | |
| 360 | + return Result::Error($this->responseError); | |
| 359 | 361 | } |
| 360 | 362 | |
| 361 | 363 | $scheme = isset($parsed['scheme']) ? strtolower($parsed['scheme']) : 'http'; |
| @@ -476,7 +478,7 @@ | ||
| 476 | 478 | if ($this->verbose && $this->stderr) { |
| 477 | 479 | fwrite($this->stderr, "* エラー: {$this->responseError}\n"); |
| 478 | 480 | } |
| 479 | - return \Result::Error($this->responseError); | |
| 481 | + return Result::Error($this->responseError); | |
| 480 | 482 | } |
| 481 | 483 | |
| 482 | 484 | // タイムアウトを設定 |
| @@ -497,7 +499,7 @@ | ||
| 497 | 499 | |
| 498 | 500 | if ($rawResponse === '') { |
| 499 | 501 | $this->responseError = 'リスポンスエラー'; |
| 500 | - return \Result::Error($this->responseError); | |
| 502 | + return Result::Error($this->responseError); | |
| 501 | 503 | } |
| 502 | 504 | |
| 503 | 505 | list($headerLines, $body) = $this->parseResponse($rawResponse); |
| @@ -559,7 +561,7 @@ | ||
| 559 | 561 | $this->method = $originalMethod; |
| 560 | 562 | $this->info['total_time'] = microtime(true) - $startTime; |
| 561 | 563 | |
| 562 | - return \Result::Success(); | |
| 564 | + return Result::Success(); | |
| 563 | 565 | } |
| 564 | 566 | |
| 565 | 567 | /** |
| @@ -38,6 +38,7 @@ | ||
| 38 | 38 | namespace Std\Lib\Image; |
| 39 | 39 | |
| 40 | 40 | use Std\Lib\Image\ImageInterface; |
| 41 | +use LogType; | |
| 41 | 42 | |
| 42 | 43 | class Png implements ImageInterface { |
| 43 | 44 | public \stdClass $IHDR; // 画像ヘッダー |
| @@ -629,7 +630,7 @@ | ||
| 629 | 630 | fclose($fp); |
| 630 | 631 | $err = '不明なチャンク:'.$nextChunk.'、HEX:'.bin2hex($nextChunk); |
| 631 | 632 | kys($err); |
| 632 | - logger(\LogType::Image, '【PNG】'.$err); | |
| 633 | + logger(LogType::Image, '【PNG】'.$err); | |
| 633 | 634 | return $png; |
| 634 | 635 | } |
| 635 | 636 |
| @@ -37,6 +37,8 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | namespace Std\Lib; |
| 39 | 39 | |
| 40 | +use LogType; | |
| 41 | + | |
| 40 | 42 | class Mailer { |
| 41 | 43 | private $socket; |
| 42 | 44 | private string $host; |
| @@ -70,7 +72,7 @@ | ||
| 70 | 72 | $this->socket = fsockopen($this->host, $this->port, $errno, $err, 30); |
| 71 | 73 | if (!$this->socket) { |
| 72 | 74 | $msg = "接続に失敗: {$err} ({$errno})"; |
| 73 | - logger(\LogType::Mailer, $msg); | |
| 75 | + logger(LogType::Mailer, $msg); | |
| 74 | 76 | throw new \Exception($msg); |
| 75 | 77 | } |
| 76 | 78 | |
| @@ -104,7 +106,7 @@ | ||
| 104 | 106 | if (!stream_socket_enable_crypto( |
| 105 | 107 | $this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
| 106 | 108 | $msg = "TLSハンドシェイクに失敗"; |
| 107 | - logger(\LogType::Mailer, $msg); | |
| 109 | + logger(LogType::Mailer, $msg); | |
| 108 | 110 | throw new \Exception($msg); |
| 109 | 111 | } |
| 110 | 112 | |
| @@ -198,7 +200,7 @@ | ||
| 198 | 200 | $response = $this->readResponse(); |
| 199 | 201 | if (substr($response, 0, 3) != '250') { |
| 200 | 202 | $msg = "メール送信に失敗: {$response}"; |
| 201 | - logger(\LogType::Mailer, $msg); | |
| 203 | + logger(LogType::Mailer, $msg); | |
| 202 | 204 | throw new \Exception($msg); |
| 203 | 205 | } |
| 204 | 206 | } |
| @@ -235,7 +237,7 @@ | ||
| 235 | 237 | $res = $this->readResponse(); |
| 236 | 238 | if (substr($res, 0, 3) != $retcode) { |
| 237 | 239 | $msg = "「{$command}」に対する予期しないレスポンス: {$res}"; |
| 238 | - logger(\LogType::Mailer, $msg); | |
| 240 | + logger(LogType::Mailer, $msg); | |
| 239 | 241 | throw new \Exception($msg); |
| 240 | 242 | } |
| 241 | 243 |
変更
util.php
| @@ -434,6 +434,44 @@ | ||
| 434 | 434 | return $img; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | +function align(int $val): int { | |
| 438 | + if ($val <= 0) return 1; | |
| 439 | + if ($val === 1) return 1; | |
| 440 | + | |
| 441 | + $res = 0; | |
| 442 | + $lower = 1; | |
| 443 | + | |
| 444 | + while ($lower * 2 <= $val) $lower *= 2; | |
| 445 | + $upper = $lower * 2; | |
| 446 | + | |
| 447 | + if (($val - $lower) <= ($upper - $val)) return $lower; | |
| 448 | + return $upper; | |
| 449 | +} | |
| 450 | + | |
| 451 | +function align_up(int $val): int { | |
| 452 | + if ($val <= 0) return 1; | |
| 453 | + if ($val === 1) return 1; | |
| 454 | + | |
| 455 | + $res = 0; | |
| 456 | + $lower = 1; | |
| 457 | + | |
| 458 | + while ($lower * 2 <= $val) $lower *= 2; | |
| 459 | + $upper = $lower * 2; | |
| 460 | + | |
| 461 | + return $upper; | |
| 462 | +} | |
| 463 | + | |
| 464 | +function align_down(int $val): int { | |
| 465 | + if ($val <= 0) return 1; | |
| 466 | + if ($val === 1) return 1; | |
| 467 | + | |
| 468 | + $res = 0; | |
| 469 | + $lower = 1; | |
| 470 | + | |
| 471 | + while ($lower * 2 <= $val) $lower *= 2; | |
| 472 | + return $lower; | |
| 473 | +} | |
| 474 | + | |
| 437 | 475 | // PHP 8.3と8.4の場合 |
| 438 | 476 | if (!function_exists('array_last')) { |
| 439 | 477 | function array_last(array $array): mixed { |
| @@ -1,6 +1,12 @@ | ||
| 1 | 1 | {@ include(common/header) @} |
| 2 | 2 | <h1>{{ $description }}</h1> |
| 3 | 3 | <ul> |
| 4 | + <li>請求</li> | |
| 5 | + <ul> | |
| 6 | + <li><a href="/openprovider/listinvoices">請求書一覧</a></li> | |
| 7 | + <li><a href="/openprovider/listpayments">支払一覧</a></li> | |
| 8 | + <li><a href="/openprovider/listtransactions">トランザクション一覧</a></li> | |
| 9 | + </ul> | |
| 4 | 10 | <li>顧客様</li> |
| 5 | 11 | <ul> |
| 6 | 12 | <li><a href="/openprovider/listcustomers">顧客様検索</a></li> |
| @@ -0,0 +1,9 @@ | ||
| 1 | +{@ include(common/header) @} | |
| 2 | + <h1>請求書一覧</h1> | |
| 3 | + {@ kys($data) @} | |
| 4 | + 検索バー<br /> | |
| 5 | +{@ if (isset($data['data']['results'])) @} | |
| 6 | +{@ else @} | |
| 7 | + <p>何も見つけられませんでした。</p> | |
| 8 | +{@ endif @} | |
| 9 | +{@ include(common/footer) @} |
| @@ -0,0 +1,9 @@ | ||
| 1 | +{@ include(common/header) @} | |
| 2 | + <h1>支払一覧</h1> | |
| 3 | + {@ kys($data) @} | |
| 4 | + 検索バー<br /> | |
| 5 | +{@ if (isset($data['data']['results'])) @} | |
| 6 | +{@ else @} | |
| 7 | + <p>何も見つけられませんでした。</p> | |
| 8 | +{@ endif @} | |
| 9 | +{@ include(common/footer) @} |
| @@ -0,0 +1,39 @@ | ||
| 1 | +{@ include(common/header) @} | |
| 2 | + <h1>トランザクション一覧</h1> | |
| 3 | + 検索バー<br /> | |
| 4 | +{@ if (isset($data['data']['results'])) @} | |
| 5 | + <table> | |
| 6 | + <thead> | |
| 7 | + <tr> | |
| 8 | + <th>日時</th> | |
| 9 | + <th>状況</th> | |
| 10 | + <th>ドメイン名・商品</th> | |
| 11 | + <th>数</th> | |
| 12 | + <th>値段</th> | |
| 13 | + <th>デビット</th> | |
| 14 | + <th>クレジット</th> | |
| 15 | + </tr> | |
| 16 | + </thead> | |
| 17 | + <tbody> | |
| 18 | +{@ foreach ($data['data']['results'] as $d) @} | |
| 19 | +{$ $pp = $d['price']['product'] $} | |
| 20 | +{$ $pr = $d['price']['reseller'] $} | |
| 21 | +{$ $tp = $d['total']['product'] $} | |
| 22 | +{$ $tr = $d['total']['reseller'] $} | |
| 23 | + <tr> | |
| 24 | + <td>{{ $d['creation_date'] }}</td> | |
| 25 | + <td>{{ $d['action'] }}</td> | |
| 26 | + <td>{{ $d['subject'] }}</td> | |
| 27 | + <td>{{ $d['quantity'] }}</td> | |
| 28 | + <td>{{ $pp['price'].' '.$pp['currency'] }}<br /><span style="color: #777777;">({{ $pr['price'].' '.$pr['currency'] }})</span></td> | |
| 29 | + <td><span style="color: #ee5040;">{{ $tr['price'].' '.$tr['currency'] }}</span></td> | |
| 30 | + <td><span style="color: #14c014;"></span></td> | |
| 31 | + </tr> | |
| 32 | +{@ endforeach @} | |
| 33 | + </tbody> | |
| 34 | + </table> | |
| 35 | + <p>結果数:{{ $data['data']['total'] }}</p> | |
| 36 | +{@ else @} | |
| 37 | + <p>何も見つけられませんでした。</p> | |
| 38 | +{@ endif @} | |
| 39 | +{@ include(common/footer) @} |