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

This commit is contained in:
2025-12-22 23:04:08 +09:00
parent 3b96986a85
commit 05f02e74d5
6 changed files with 110 additions and 78 deletions

View File

@@ -1,9 +1,12 @@
<?php
if (!CURL_ENABLED) define('ACTIVITYPUB_ENABLED', false);
enum LogType {
case ActivityPub;
case Auth;
case Csv;
case Mailer;
case MySQL;
case Csv;
}
class Result {
@@ -112,13 +115,35 @@ function base58btc_encode(string $bin): string {
function logger(LogType $section, mixed $arg): void {
if (LOGGING_ENABLED) {
$success = false;
$logfile = ROOT.'/log/';
if ($section == LogType::ActivityPub) $logfile .= 'ap_log.txt';
else if ($section == LogType::Mailer) $logfile .= 'mail_log.txt';
else if ($section == LogType::MySQL) $logfile .= 'mysql_log.txt';
else if ($section == LogType::Csv) $logfile .= 'csv_log.txt';
file_put_contents($logfile, $arg."\n", FILE_APPEND);
switch ($section) {
case LogType::ActivityPub:
$logfile .= 'ap_log.text';
$success = true;
break;
case LogType::Auth:
$logfile .= 'auth_log.text';
$success = true;
break;
case LogType::Csv:
$logfile .= 'csv_log.text';
$success = true;
break;
case LogType::Mailer:
$logfile .= 'mail_log.text';
$success = true;
break;
case LogType::MySQL:
$logfile .= 'mysql_log.text';
$success = true;
break;
default:
break;
}
if ($success) file_put_contents($logfile, $arg."\n", FILE_APPEND);
}
}