ActivityPubユニットテストの追加、CURLの変更、認証にログの追加

諏訪子 <suwako@076.moe>、2025-12-22 23:04
コミット 05f02e74d5a3cb8fa2de057989ea40affbaa51aa ・親 3b96986 ・ファイルを見る

6個のファイル、+110 -78

@@ -16,6 +16,7 @@
1616 private string $desc;
1717 private string $icon;
1818 private array $posts = [];
19+ private string $https;
1920
2021 /**
2122 * コンストラクタ
@@ -23,11 +24,13 @@
2324 * @param array $posts 投稿データの配列
2425 */
2526 public function __construct(array $posts = []) {
26- $this->domain = $_SERVER['SERVER_NAME'];
27+ if (!ACTIVITYPUB_ENABLED) return;
28+ $this->https = 'http'.((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 's' : '').'://';
29+ $this->domain = $this->https.($_SERVER['SERVER_NAME'] ?? '127.0.0.1:8000');
2730 $this->actor = FEDIINFO['actor'];
2831 $this->actorNick = FEDIINFO['actorNick'];
2932 $this->desc = FEDIINFO['desc'];
30- $this->icon = "https://{$this->domain}".FEDIINFO['icon'];
33+ $this->icon = "{$this->domain}".FEDIINFO['icon'];
3134 $this->posts = $posts;
3235 }
3336
@@ -38,6 +41,7 @@
3841 * @throws \Exception 公開鍵の読み込みに失敗した場合
3942 */
4043 public function getActor(): string {
44+ if (!ACTIVITYPUB_ENABLED) return '';
4145 $pubkey = file_get_contents(FEDIINFO['pubkey']);
4246 if ($pubkey === false) {
4347 throw new \Exception('公開鍵の受取に失敗。パス:'.FEDIINFO['pubkey']);
@@ -48,7 +52,7 @@
4852 'https://www.w3.org/ns/activitystreams',
4953 'https://w3id.org/security/v1',
5054 ],
51- 'id' => "https://{$this->domain}/ap/actor",
55+ 'id' => "{$this->domain}/ap/actor",
5256 'name' => $this->actorNick,
5357 'summary' => $this->desc,
5458 'manuallyApprovesFollowers' => false,
@@ -59,22 +63,21 @@
5963 ],
6064 'image' => [
6165 'type' => 'Image',
62- 'url' =>
63- "https://{$this->domain}/static/article/o_53803618dc1691.28179609.jpg",
66+ 'url' => "{$this->domain}/static/article/o_53803618dc1691.28179609.jpg",
6467 'mediaType' => 'image/jpeg',
6568 ],
6669 'type' => 'Person',
67- 'url' => "https://{$this->domain}",
70+ 'url' => "{$this->domain}",
6871 'preferredUsername' => $this->actor,
69- 'inbox' => "https://{$this->domain}/ap/inbox",
70- 'outbox' => "https://{$this->domain}/ap/outbox",
71- 'followers' => "https://{$this->domain}/ap/followers",
72- 'following' => "https://{$this->domain}/ap/following",
72+ 'inbox' => "{$this->domain}/ap/inbox",
73+ 'outbox' => "{$this->domain}/ap/outbox",
74+ 'followers' => "{$this->domain}/ap/followers",
75+ 'following' => "{$this->domain}/ap/following",
7376 'published' => '2025-03-28T18:00:00Z',
7477 'updated' => gmdate('c'),
7578 'publicKey' => [
76- 'id' => "https://{$this->domain}/ap/actor#main-key",
77- 'owner' => "https://{$this->domain}/ap/actor",
79+ 'id' => "{$this->domain}/ap/actor#main-key",
80+ 'owner' => "{$this->domain}/ap/actor",
7881 'publicKeyPem' => $pubkey,
7982 ],
8083 ];
@@ -89,6 +92,7 @@
8992 * @return string JSONエンコードされたアクティビティデータ
9093 */
9194 public function getActivity(string $uuid): string {
95+ if (!ACTIVITYPUB_ENABLED) return '';
9296 $items = [];
9397
9498 foreach ($this->posts as $post) {
@@ -107,28 +111,27 @@
107111 'toot' => 'http://joinmastodon.org/ns#',
108112 ],
109113 ],
110- 'id' => "https://{$this->domain}/ap/activities/create/{$post['uuid']}",
114+ 'id' => "{$this->domain}/ap/activities/create/{$post['uuid']}",
111115 'type' => 'Create',
112- 'actor' => "https://{$this->domain}/ap/actor",
116+ 'actor' => "{$this->domain}/ap/actor",
113117 'cc' => [
114- "https://{$this->domain}/ap/followers",
118+ "{$this->domain}/ap/followers",
115119 ],
116120 'published' => date("Y-m-d\TH:i:s.u\Z", strtotime($post['date'])),
117121 'to' => ['https://www.w3.org/ns/activitystreams#Public'],
118122 'object' => [
119- 'id' => "https://{$this->domain}/ap/objects/{$post['uuid']}",
123+ 'id' => "{$this->domain}/ap/objects/{$post['uuid']}",
120124 'type' => 'Note',
121125 'name' => $post['title'],
122- 'attributedTo' => "https://{$this->domain}/ap/actor",
126+ 'attributedTo' => "{$this->domain}/ap/actor",
123127 'cc' => [
124- "https://{$this->domain}/ap/followers",
128+ "{$this->domain}/ap/followers",
125129 ],
126130 'to' => ['https://www.w3.org/ns/activitystreams#Public'],
127- 'content' =>
128- $post['preview']."<br /><br /><a href=\"https://{$this->domain}/blog/{$post['slug']}\">読み続き</a>",
129- 'url' => "https://{$this->domain}/blog/{$post['slug']}",
131+ 'content' => $post['preview']."<br /><br /><a href=\"{$this->domain}/blog/{$post['slug']}\">読み続き</a>",
132+ 'url' => "{$this->domain}/blog/{$post['slug']}",
130133 'published' => date("Y-m-d\TH:i:s.u\Z", strtotime($post['date'])),
131- 'replies' => "https://{$this->domain}/ap/objects/{$uuid}/replies",
134+ 'replies' => "{$this->domain}/ap/objects/{$uuid}/replies",
132135 'sensitive' => false,
133136 ],
134137 ];
@@ -141,7 +144,7 @@
141144 }
142145
143146 if (isset($post['thumbnail']) && $post['thumbnail'] != '') {
144- $imgurl = "https://technicalsuwako.moe/static/article/{$post['thumbnail']}";
147+ $imgurl = "{$this->domain}/static/article/{$post['thumbnail']}";
145148 $imgpath = ROOT."/public/static/article/{$post['thumbnail']}";
146149 $imgraw = file_get_contents($imgpath);
147150
@@ -167,6 +170,7 @@
167170 * @return string JSONエンコードされたアウトボックスデータ
168171 */
169172 public function getOutbox(): string {
173+ if (!ACTIVITYPUB_ENABLED) return '';
170174 $items = [];
171175 $counter = 0;
172176
@@ -186,28 +190,27 @@
186190 'toot' => 'http://joinmastodon.org/ns#',
187191 ],
188192 ],
189- 'id' => "https://{$this->domain}/ap/activities/create/{$uid}",
193+ 'id' => "{$this->domain}/ap/activities/create/{$uid}",
190194 'type' => 'Create',
191- 'actor' => "https://{$this->domain}/ap/actor",
195+ 'actor' => "{$this->domain}/ap/actor",
192196 'cc' => [
193- "https://{$this->domain}/ap/followers",
197+ "{$this->domain}/ap/followers",
194198 ],
195199 'published' => date("Y-m-d\TH:i:s.u\Z", strtotime($post['date'])),
196200 'to' => ['https://www.w3.org/ns/activitystreams#Public'],
197201 'object' => [
198- 'id' => "https://{$this->domain}/ap/objects/{$uid}",
202+ 'id' => "{$this->domain}/ap/objects/{$uid}",
199203 'type' => 'Note',
200204 'name' => $post['title'],
201- 'attributedTo' => "https://{$this->domain}/ap/actor",
205+ 'attributedTo' => "{$this->domain}/ap/actor",
202206 'cc' => [
203- "https://{$this->domain}/ap/followers",
207+ "{$this->domain}/ap/followers",
204208 ],
205209 'to' => ['https://www.w3.org/ns/activitystreams#Public'],
206- 'content' =>
207- $post['preview']."<br /><br /><a href=\"https://{$this->domain}/blog/{$post['slug']}\">読み続き</a>",
208- 'url' => "https://{$this->domain}/blog/{$post['slug']}",
210+ 'content' => $post['preview']."<br /><br /><a href=\"{$this->domain}/blog/{$post['slug']}\">読み続き</a>",
211+ 'url' => "{$this->domain}/blog/{$post['slug']}",
209212 'published' => date("Y-m-d\TH:i:s.u\Z", strtotime($post['date'])),
210- 'replies' => "https://{$this->domain}/ap/objects/{$uid}/replies",
213+ 'replies' => "{$this->domain}/ap/objects/{$uid}/replies",
211214 'sensitive' => false,
212215 ],
213216 ];
@@ -220,7 +223,7 @@
220223 }
221224
222225 if (isset($post['thumbnail']) && $post['thumbnail'] != '') {
223- $imgurl = "https://technicalsuwako.moe/static/article/{$post['thumbnail']}";
226+ $imgurl = "{$this->domain}/static/article/{$post['thumbnail']}";
224227 $imgpath = ROOT."/public/static/article/{$post['thumbnail']}";
225228 $imgraw = file_get_contents($imgpath);
226229
@@ -242,7 +245,7 @@
242245 'https://www.w3.org/ns/activitystreams',
243246 'https://w3id.org/security/v1',
244247 ],
245- 'id' => "https://{$this->domain}/ap/outbox",
248+ 'id' => "{$this->domain}/ap/outbox",
246249 'type' => 'OrderedCollection',
247250 'totalItems' => count($items),
248251 'orderedItems' => $items,
@@ -257,13 +260,14 @@
257260 * @return string JSONエンコードされたWebFingerデータ
258261 */
259262 public function getWebfinger(): string {
263+ if (!ACTIVITYPUB_ENABLED) return '';
260264 $webfinger = [
261265 'subject' => "acct:{$this->actor}@{$this->domain}",
262266 'links' => [
263267 [
264268 'rel' => 'self',
265269 'type' => 'application/activity+json',
266- 'href' => "https://{$this->domain}/ap/actor",
270+ 'href' => "{$this->domain}/ap/actor",
267271 ],
268272 ],
269273 ];
@@ -277,6 +281,7 @@
277281 * @return string JSONエンコードされたフォロワーのリスト
278282 */
279283 public function getFollowers(): string {
284+ if (!ACTIVITYPUB_ENABLED) return '';
280285 $f = array_filter(explode("\n", file_get_contents(ROOT.'/data/followers.txt')));
281286
282287 $followers = [
@@ -284,7 +289,7 @@
284289 'https://www.w3.org/ns/activitystreams',
285290 'https://w3id.org/security/v1',
286291 ],
287- 'id' => "https://{$this->domain}/ap/followers",
292+ 'id' => "{$this->domain}/ap/followers",
288293 'type' => 'OrderredCollection',
289294 'totalItems' => count($f),
290295 'orderedItems' => $f,
@@ -299,6 +304,7 @@
299304 * @return string JSONエンコードされたフォローリスト
300305 */
301306 public function getFollowing(): string {
307+ if (!ACTIVITYPUB_ENABLED) return '';
302308 $f = array_filter(explode("\n", file_get_contents(ROOT.'/data/following.txt')));
303309
304310 $following = [
@@ -306,7 +312,7 @@
306312 'https://www.w3.org/ns/activitystreams',
307313 'https://w3id.org/security/v1',
308314 ],
309- 'id' => "https://{$this->domain}/ap/following",
315+ 'id' => "{$this->domain}/ap/following",
310316 'type' => 'OrderredCollection',
311317 'totalItems' => count($f),
312318 'orderedItems' => $f,
@@ -322,6 +328,7 @@
322328 * @return void
323329 */
324330 public function postInbox(array $activity): void {
331+ if (!ACTIVITYPUB_ENABLED) return;
325332 switch ($activity['type']) {
326333 case 'Follow':
327334 $this->acceptFollower($activity);
@@ -329,8 +336,7 @@
329336 default:
330337 header('HTTP/1.1 501 Not Implemented');
331338 header('Content-Type: application/activity+json');
332- echo json_encode(['error' =>
333- '未対応なアクティビティタイプ: '.$activity['type']]);
339+ echo json_encode(['error' => '未対応なアクティビティタイプ: '.$activity['type']]);
334340 exit;
335341 }
336342
@@ -346,14 +352,15 @@
346352 * @return string JSONエンコードされた更新アクティビティ
347353 */
348354 public function update(): string {
355+ if (!ACTIVITYPUB_ENABLED) return '';
349356 $update = [
350357 '@context' => [
351358 'https://www.w3.org/ns/activitystreams',
352359 'https://w3id.org/security/v1',
353360 ],
354- 'id' => "https://{$this->domain}/ap/activities/update/".uuid(),
361+ 'id' => "{$this->domain}/ap/activities/update/".uuid(),
355362 'type' => 'Update',
356- 'actor' => "https://{$this->domain}/ap/actor",
363+ 'actor' => "{$this->domain}/ap/actor",
357364 'to' => ['https://www.w3.org/ns/activitystreams#Public'],
358365 'object' => json_decode($this->getActor(), true),
359366 ];
@@ -368,14 +375,13 @@
368375 * @return void
369376 */
370377 public function sendActorUpdate(array $params): void {
378+ if (!ACTIVITYPUB_ENABLED) return;
371379 $f = array_filter(explode("\n", file_get_contents(ROOT.'/data/followers.txt')));
372380 $ap = new Activitypub();
373381 $inboxes = implode("\n", $f);
374382 $update = json_decode($ap->update(), true);
375383
376- foreach ($f as $inbox) {
377- $this->sendActivity($inbox, $update);
378- }
384+ foreach ($f as $inbox) $this->sendActivity($inbox, $update);
379385 }
380386
381387 // 機能性メソッド
@@ -410,9 +416,7 @@
410416 'Digest' => "SHA-256=$digest",
411417 ];
412418
413- $stringToSign = "host: {$headers['Host']}\n"
414- ."date: {$headers['Date']}\n"
415- ."digest: {$headers['Digest']}";
419+ $stringToSign = "host: {$headers['Host']}\n"."date: {$headers['Date']}\n"."digest: {$headers['Digest']}";
416420 logger(\LogType::ActivityPub, "署名対象: {$stringToSign}");
417421
418422 if (!openssl_sign($stringToSign, $signature, $priv, OPENSSL_ALGO_SHA256)) {
@@ -425,18 +429,16 @@
425429 }
426430
427431 $sigValue = base64_encode($signature);
428- $headers['Signature'] = "keyId=\"https://{$this->domain}/ap/actor#main-key\",";
432+ $headers['Signature'] = "keyId=\"{$this->domain}/ap/actor#main-key\",";
429433 $headers['Signature'] .= 'algorithm="rsa-sha256",';
430434 $headers['Signature'] .= 'headers="host date digest",';
431435 $headers['Signature'] .= 'signature="'.$sigValue.'"';
432- logger(\LogType::ActivityPub,
433- "署名: {$headers['Signature']}\n送信データ: {$body}");
436+ logger(\LogType::ActivityPub, "署名: {$headers['Signature']}\n送信データ: {$body}");
434437
435438 $curl = new Curl($inboxUrl);
436439 $curl->setMethod('POST')
437440 ->setPostRaw($body)
438- ->setHeaders(array_map(fn($k, $v) => "$k: $v",
439- array_keys($headers), $headers))
441+ ->setHeaders(array_map(fn($k, $v) => "$k: $v", array_keys($headers), $headers))
440442 ->setCaInfo('/etc/ssl/cert.pem')
441443 ->setVerbose(true)
442444 ->setStderr(fopen(ROOT.'/log/ap_log.txt', 'a'));
@@ -447,8 +449,7 @@
447449 $err = $curl->getError();
448450
449451 var_dump(print_r($res));
450- logger(\LogType::ActivityPub,
451- "アクティビティは「{$inboxUrl}」に送信しました: HTTP {$code}");
452+ logger(\LogType::ActivityPub, "アクティビティは「{$inboxUrl}」に送信しました: HTTP {$code}");
452453 logger(\LogType::ActivityPub, "エラー: {$err}");
453454 logger(\LogType::ActivityPub, "レスポンス: {$res}");
454455 }
@@ -483,9 +484,9 @@
483484 'https://www.w3.org/ns/activitystreams',
484485 'https://w3id.org/security/v1',
485486 ],
486- 'id' => "https://{$this->domain}/ap/activities/".uniqid(),
487+ 'id' => "{$this->domain}/ap/activities/".uniqid(),
487488 'type' => 'Accept',
488- 'actor' => "https://{$this->domain}/ap/actor",
489+ 'actor' => "{$this->domain}/ap/actor",
489490 'object' => $activity,
490491 ];
491492
@@ -506,9 +507,7 @@
506507 }
507508
508509 $followers = $this->getFollowersList();
509- if (!in_array($followerActor, $followers)) {
510- file_put_contents($file, "$followerActor\n", FILE_APPEND);
511- }
510+ if (!in_array($followerActor, $followers)) file_put_contents($file, "$followerActor\n", FILE_APPEND);
512511 }
513512
514513 /**
@@ -519,8 +518,7 @@
519518 private function getFollowersList(): array {
520519 $file = ROOT.'/data/followers.txt';
521520 $f = array_filter(explode("\n", file_get_contents($file)));
522- return file_exists($file)
523- ? array_filter(explode("\n", file_get_contents($file))) : [];
521+ return file_exists($file) ? array_filter(explode("\n", file_get_contents($file))) : [];
524522 }
525523
526524 /**
@@ -89,6 +89,7 @@
8989 $json = json_encode($userData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
9090
9191 if (file_put_contents($path, $json) === false) {
92+ logger(\LogType::Auth, '【setToken】JSONファイルにユーザーデータを保存出来なかった。パス:'.$path);
9293 return \Result::error('エラー:ユーザーデータの保存に失敗。');
9394 }
9495
@@ -100,6 +101,7 @@
100101 'httponly' => true,
101102 'samesite' => 'Strict'
102103 ])) {
104+ logger(\LogType::Auth, '【setToken】クッキーを設定出来なかった。トークン:'.$token);
103105 return \Result::error('エラー:クッキーを設定に失敗。');
104106 }
105107
@@ -147,7 +149,7 @@
147149 if ($username === $user) return \Result::Success("ユーザー「{$username}」は既に存在します。");
148150 }
149151
150- return \Result::Error("エラー:ユーザー「{$username}」は存在しません。");
152+ return \Result::Error('');
151153 }
152154
153155 public function mkUser(?string $username = null, #[SensitiveParameter] ?string $password = null, ?string $passwordVerify = null, ?string $email = null): \Result {
@@ -167,6 +169,7 @@
167169 $err = '';
168170
169171 if (!mkdir($this->assDir.$username, 0755)) {
172+ logger(\LogType::Auth, '【mkUser】アセットディレクトリを作成出来なかった。chownをご確認下さい。パス:'.$this->assDir.$username);
170173 return \Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。');
171174 }
172175
@@ -203,6 +206,7 @@
203206 $json = json_encode($user, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
204207
205208 if (file_put_contents($path, $json) === false) {
209+ logger(\LogType::Auth, '【mkUser】JSONファイルを作成出来なかった。パス:'.$path);
206210 rmdir($this->assDir.$username);
207211 return \Result::Error('エラー:ユーザーデータの保存に失敗。');
208212 }
@@ -225,6 +229,7 @@
225229 $json = json_encode($userData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
226230
227231 if (file_put_contents($path, $json) === false) {
232+ logger(\LogType::Auth, '【verifyLogin】JSONファイルを変更出来なかった。chownをご確認下さい。パス:'.$path);
228233 return \Result::Error('エラー:ユーザーデータの保存に失敗。');
229234 }
230235 }
@@ -244,6 +249,7 @@
244249 $json = json_encode($userData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
245250
246251 if (file_put_contents($path, $json) === false) {
252+ logger(\LogType::Auth, '【purgeOldTokens】JSONファイルを変更出来なかった。chownをご確認下さい。パス:'.$path);
247253 return \Result::Error('エラー:ユーザーデータの保存に失敗。');
248254 }
249255
@@ -37,6 +37,7 @@
3737 * @param string|null $url リクエスト先のURL
3838 */
3939 public function __construct(?string $url = null) {
40+ if (!CURL_ENABLED) return;
4041 if ($url !== null) {
4142 $this->url = $url;
4243 }
@@ -247,12 +248,13 @@
247248 /**
248249 * リクエストを実行する
249250 *
250- * @return bool 成功または失敗
251+ * @return Result 成功または失敗
251252 */
252- public function execute(): bool {
253+ public function execute(): \Result {
254+ if (!CURL_ENABLED) return \Result::Error('エラー:認証システムは無効です。');
253255 if (empty($this->url)) {
254256 $this->responseError = 'URLがありません';
255- return false;
257+ return \Result::Error($this->responseError);
256258 }
257259
258260 // レスポンスデータのリセット
@@ -286,7 +288,7 @@
286288 $parsed = parse_url($currentUrl);
287289 if (!$parsed) {
288290 $this->responseError = "無効なURL: {$currentUrl}";
289- return false;
291+ return \Result::Error($this->responseError);
290292 }
291293
292294 $scheme = isset($parsed['scheme']) ? strtolower($parsed['scheme']) : 'http';
@@ -403,7 +405,7 @@
403405 if ($this->verbose && $this->stderr) {
404406 fwrite($this->stderr, "* エラー: {$this->responseError}\n");
405407 }
406- return false;
408+ return \Result::Error($this->responseError);
407409 }
408410
409411 // タイムアウトを設定
@@ -523,7 +525,7 @@
523525 $this->method = $originalMethod;
524526 $this->info['total_time'] = microtime(true) - $startTime;
525527
526- return true;
528+ return \Result::Success();
527529 }
528530
529531 /**
@@ -65,7 +65,7 @@
6565 $curl = new Curl('https://076.moe');
6666 $result = $curl->execute();
6767
68- $test->assertTrue($result);
68+ $test->assertTrue($result->isSuccess);
6969 $test->assertEquals(200, $curl->getResponseCode());
7070 $test->assertNotNull($curl->getResponseBody());
7171 $test->assertStringContains('<html', $curl->getResponseBody());
@@ -81,7 +81,7 @@
8181 ]);
8282
8383 $result = $curl->execute();
84- $test->assertTrue($result);
84+ $test->assertTrue($result->isSuccess);
8585 $test->assertEquals(200, $curl->getResponseCode());
8686
8787 $responseBody = $curl->getResponseBody();
変更 tester.php
@@ -1,8 +1,9 @@
11 <?php
22 require_once __DIR__.DIRECTORY_SEPARATOR.'/autoload.php';
33 define('ROOT', realpath(__DIR__));
4-require_once ROOT.'/util.php';
54 require_once ROOT.'/config/config.php';
5+require_once ROOT.'/util.php';
6+if (!CURL_ENABLED) define('ACTIVITYPUB_ENABLED', false);
67
78 mb_internal_encoding('UTF-8');
89 header('Content-Type: text/plain; charset=UTF-8');
変更 util.php
@@ -1,9 +1,12 @@
11 <?php
2+if (!CURL_ENABLED) define('ACTIVITYPUB_ENABLED', false);
3+
24 enum LogType {
35 case ActivityPub;
6+ case Auth;
7+ case Csv;
48 case Mailer;
59 case MySQL;
6- case Csv;
710 }
811
912 class Result {
@@ -112,13 +115,35 @@
112115
113116 function logger(LogType $section, mixed $arg): void {
114117 if (LOGGING_ENABLED) {
118+ $success = false;
115119 $logfile = ROOT.'/log/';
116- if ($section == LogType::ActivityPub) $logfile .= 'ap_log.txt';
117- else if ($section == LogType::Mailer) $logfile .= 'mail_log.txt';
118- else if ($section == LogType::MySQL) $logfile .= 'mysql_log.txt';
119- else if ($section == LogType::Csv) $logfile .= 'csv_log.txt';
120120
121- file_put_contents($logfile, $arg."\n", FILE_APPEND);
121+ switch ($section) {
122+ case LogType::ActivityPub:
123+ $logfile .= 'ap_log.text';
124+ $success = true;
125+ break;
126+ case LogType::Auth:
127+ $logfile .= 'auth_log.text';
128+ $success = true;
129+ break;
130+ case LogType::Csv:
131+ $logfile .= 'csv_log.text';
132+ $success = true;
133+ break;
134+ case LogType::Mailer:
135+ $logfile .= 'mail_log.text';
136+ $success = true;
137+ break;
138+ case LogType::MySQL:
139+ $logfile .= 'mysql_log.text';
140+ $success = true;
141+ break;
142+ default:
143+ break;
144+ }
145+
146+ if ($success) file_put_contents($logfile, $arg."\n", FILE_APPEND);
122147 }
123148 }
124149