ゆう's Blog
PHPMailer

<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\SMTP; require 'path/to/PHPMailer/src/Exception.php'; require 'path/to/PHPMailer/src/PHPMailer.php'; require 'path/to/PHPMailer/src/SMTP.php'; function sendMail($to, $toname, $subject, $body) { // 文字エンコードを指定 mb_language('uni'); mb_internal_encoding('UTF-8'); $mail = new PHPMailer(true); try { //Enable SMTP debugging //SMTP::DEBUG_OFF = off (for production use) //SMTP::DEBUG_CLIENT = client messages //SMTP::DEBUG_SERVER = client and server messages $mail->SMTPDebug = SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->Host = SMTP_SERVER; $mail->SMTPAuth = true; $mail->Username = SMTP_USER; $mail->Password = SMTP_PASS; $mail->SMTPSecure = 'tls'; $mail->Port = SMTP_PORT; $mail->CharSet = "utf-8"; $mail->setFrom(FROM_MAIL, SITE_NAME); $mail->addAddress($to, $toname); //$mail->addReplyTo('info@example.com', 'Information'); //$mail->addCC('cc@example.com'); //$mail->addBCC('bcc@example.com'); //Attachments //$mail->addAttachment('/var/tmp/file.tar.gz'); //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $body; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } ?>


Fatal error: Uncaught Error: Class "SMTP" not found

use PHPMailer\PHPMailer\SMTP;
SMTPプロトコルを使用してメールを送信することができ、メッセージの配信可能性が向上します。また、SMTPクラスを使用することで、エラーハンドリングやデバッグ機能も利用できるようになり、問題が発生した際の原因特定が容易になります。

食宅便の定期便でポイントを使う。

Web上だと送料が一回注文時のものとなるので、電話で依頼する。

fedora41にdnf5-plugin-automaticをインストールする

# dnf install dnf5-plugin-automatic Updating and loading repositories: Repositories loaded. Failed to resolve the transaction: Problem: conflicting requests - package dnf5-plugin-automatic-5.2.6.2-1.fc41.x86_64 from fedora requires libcurl-full(x86-64), but none of the providers can be installed - package dnf5-plugin-automatic-5.2.7.0-1.fc41.x86_64 from updates requires libcurl-full(x86-64), but none of the providers can be installed - problem with installed package - installed package libcurl-minimal-8.9.1-2.fc41.x86_64 conflicts with libcurl(x86-64) provided by libcurl-8.9.1-2.fc41.x86_64 from fedora - package libcurl-minimal-8.9.1-2.fc41.x86_64 from fedora conflicts with libcurl(x86-64) provided by libcurl-8.9.1-2.fc41.x86_64 from fedora You can try to add to command line: --allowerasing to allow erasing of installed packages to resolve problems --skip-broken to skip uninstallable packages

インストール中に依存関係の問題が発生した場合、特にlibcurlに関連する競合が報告されています。その場合は、次のコマンドで競合するパッケージを交換できます:

# dnf swap libcurl-minimal libcurl


インストール後、設定ファイルを作成します:

# cp /usr/share/dnf5/dnf5-plugins/automatic.conf /etc/dnf/dnf5-plugins/automatic.conf

設定ファイルを編集して自動アップデートを設定します。例えば:

# vi /etc/dnf/dnf5-plugins/automatic.conf

[commands] # Whether updates should be applied when they are available, by # dnf5 automatic. apply_updates = yes

dnf5-automatic.service の ExecStart に --installupdates を追加。

# vi /usr/lib/systemd/system/dnf5-automatic.service

ExecStart=/usr/bin/dnf5 automatic --timer --installupdates

最後に、自動アップデート機能を有効化します:

# systemctl enable --now dnf5-automatic.timer


マジ?

相互依存性:
apply_updatesがyesでも、タイマーが無効なら自動更新は実行されません。
タイマーが有効でも、apply_updatesがnoなら更新は適用されません。

自動インストールを行うためには、download_updates = yes の設定に加えて、dnf-automatic-install.timer を有効にする必要があります。これにより、ダウンロードされた更新パッケージが自動的にインストールされます。

身分証明書

日本では、マイナンバーカードや運転免許証のどちらか一方を持っていれば、身分証明書として認められます。ただし、どちらの証明書を持っているかによって、利用できるサービスや場面が異なる場合があります。

マイナンバーカードは無料で発行されます。申請手続きや発行自体には費用がかかりませんが、もしカードを紛失したり再発行が必要な場合には、再発行手数料がかかることがあります。

マイナンバーカードには有効期限があります。具体的には、20歳以上の方は10年間の有効期限があり、20歳未満の方は5年間の有効期限です。期限が切れる前に更新手続きを行う必要がありますが、カード自体の更新手数料は基本的には無料です。

.htaccess ファイルは、アクセス拒否などをしておかないと見れてしまうものなのでしょうか?

Apacheのデフォルト設定により、.htaccessファイルへのアクセスはデフォルトで拒否されるように設定されている場合があります。具体的には、Apacheの設定ファイル(通常はhttpd.confやapache2.conf)に以下のようなディレクティブが含まれていることが多いです:

<Files ".ht*"> Require all denied </Files>

この設定により、ファイル名が「.ht」で始まるファイル(例:.htaccessや.htpasswd)へのアクセスが全て拒否されるようになっています。これにより、これらのファイルがウェブ経由で閲覧されることを防ぎ、セキュリティを強化しています。

ブラウザが「Edge」かどうかを判定

function isEdge() { return /Edge/.test(navigator.userAgent); } if (isEdge()) { console.log("This is Edge browser."); } else { console.log("This is not Edge browser."); }

文字列シャッフル

shuffledString = string.split('').sort(() => .5 - Math.random()).join('');

「audacity-freeworld」と「audacity」は両方インストールする必要がありますか?

いいえ、両方をインストールする必要はありません。**「audacity-freeworld」と「audacity」**は同じソフトウェアですが、異なる機能を持っています。

「audacity」: 標準バージョンで、特定のライセンスや特許に関連する機能(例えば、MP3のインポート/エクスポート)が含まれていない場合があります。
「audacity-freeworld」: 追加のライブラリ(LameやFFmpegなど)をサポートしており、MP3や他のファイル形式のインポート/エクスポートが可能です。

したがって、MP3ファイルの編集や他の追加機能が必要な場合は、「audacity-freeworld」をインストールすることをお勧めします。どちらか一方を選んでインストールすれば十分です。

$ sudo dnf install audacity-freeworld

font

次の値を含めなければなりません。
<font-size>
<font-family>
次の値は任意で含めることができます。
<font-style>
<font-variant>
<font-weight>
<font-stretch>
<line-height>
font-style, font-variant, font-weight は font-size よりも前になければなりません。
font-variant は CSS 2.1 で定義された値、つまり normal および small-caps のみ指定できます。
font-stretch は単一のキーワード値のみを指定することができます。
line-height は font-size の直後に、 "/" で区切って、 "16px/3" のように指定します。
font-family は指定される最後の値である必要があります。

font: <font-style> <font-weight> <font-size> <font-family>;

font-styleプロパティ
normal,italic,oblique

汎用フォント・ファミリー名
serif:明朝体
sans-serif:ゴシック体
cursive:筆記体
fantasy:ファンタジー
monospace:等幅

Basic認証を特定のファイルに対して設定する

<Files "example.txt"> AuthType Basic AuthName "Restricted Area" AuthUserFile /path/to/.htpasswd Require valid-user </Files>

<Files>
特定のファイルに対して設定を適用します。
<FilesMatch>
正規表現を使用して、複数のファイルや特定のパターンに一致するファイルに対して設定を適用します。

<Directory>
ファイルシステム上のディレクトリに基づいて設定を適用します。

<Location>
URLパスに基づいて設定を適用します。(ディレクトリ,ファイルとも)