【スポンサーリンク】
レンタルサーバーでメンテナンス後に「Internal Server Error」エラーが表示されサロンの自作の予約システムが使えなくなってしまいました。
ネットで調べてみると「jcode.pl」に問題があるようです。
jcode.plとは、日本語の文字符号化方式であるShift_JIS、EUC-JP、ISO-2022-JP(俗にJISもしくはJISコードとも称する)で記述された、日本語符号による文字列の相互変換を行うPerl記述のライブラリ |
そこでコパイロットに質問しながらプログラムの修正をしてみる事にしました。
目次
CGIのエラーをブラウザに表示
【Copilotの回答】次のコードを追加すると、エラーが発生した際にブラウザ上で確認できます。
perl
use CGI::Carp qw(fatalsToBrowser);
この行をスクリプトの先頭部分に追加すると、500エラーが出た際に、どんな問題が発生したのかブラウザにメッセージが表示されます。
さっそく試してみるとこのようなメッセージがでました。
Software error: Can’t use ‘defined(%hash)’ (Maybe you should just omit the defined()?) at ../lib/jcode.pl line 641. For help, please send mail to the webmaster (webmaster@gmoserver.jp), giving this error message and the time and date of the error. Software error: [Thu Apr 24 13:42:01 2025] yoyaku1_carender.cgi: Can’t use ‘defined(%hash)’ (Maybe you should just omit the defined()?) at ../lib/jcode.pl line 641. Compilation failed in require at yoyaku1_carender.cgi line 14. For help, please send mail to the webmaster (webmaster@gmoserver.jp), giving this error message and the time and date of the error. |
【翻訳】 ソフトウェアエラー: ../lib/jcode.pl の 641 行目では、’defined(%hash)’ を使用できません (defined() を省略した方が良いかもしれません)。 サポートが必要な場合は、ウェブマスター (webmaster@gmoserver.jp) までメールをお送りください。メールには、このエラーメッセージとエラー発生日時をご記入ください。ソフトウェアエラー: [Thu Apr 24 13:42:01 2025] yoyaku1_carender.cgi: ../lib/jcode.pl の 641 行目では、’defined(%hash)’ を使用できません (defined() を省略した方が良いかもしれません)。 yoyaku1_carender.cgi の 14 行目では、require でコンパイルに失敗しました。 サポートが必要な場合は、ウェブマスター (webmaster@gmoserver.jp) までメールをお送りください。メールには、このエラーメッセージとエラー発生日時をご記入ください。 |
【Copilotの回答】
このエラーの原因は、Perl の新しいバージョンでは
このエラーの原因は、Perl の新しいバージョンでは
defined(%hash)
のような書き方が非推奨になっているためです。最近の Perl では defined(%hash)
のようなコードはエラーになります。修正するための方法をいくつか提案します。sub z2h_euc { local(*_, $n) = @_; &init_z2h_euc unless defined %z2h_euc; s/($re_euc_c|$re_euc_kana)/$z2h_euc{$1} ? ($n++, $z2h_euc{$1}) : $1/geo; $n; } |
【私からの質問】このように書かれていますが、どう修正したらいいですか?
&init_z2h_euc unless keys %z2h_euc; |
これに修正したらまた下記のようなエラーメッセージが表示されました。内容は、先ほどと同じだったので同じ修正を加えました。
Can’t use ‘defined(%hash)’ (Maybe you should just omit the defined()?) at ../lib/jcode.pl line 648. For help, please send mail to the webmaster (webmaster@gmoserver.jp), giving this error message and the time and date of the error.Software error: [Thu Apr 24 13:55:29 2025] yoyaku1_carender.cgi: Can’t use ‘defined(%hash)’ (Maybe you should just omit the defined()?) at ../lib/jcode.pl line 648. Compilation failed in require at yoyaku1_carender.cgi line 14. For help, please send mail to the webmaster (webmaster@gmoserver.jp), giving this error message and the time and date of the error.
|
ソフトウェアエラー: ../lib/jcode.pl の 648 行目では、’defined(%hash)’ を使用できません (defined() を省略した方が良いかもしれません)。 サポートが必要な場合は、ウェブマスター (webmaster@gmoserver.jp) までメールでお問い合わせください。エラーメッセージとエラー発生日時をお知らせください。ソフトウェアエラー: [Thu Apr 24 13:55:29 2025] yoyaku1_carender.cgi: ../lib/jcode.pl の 648 行目では、’defined(%hash)’ を使用できません (defined() を省略した方が良いかもしれません)。 yoyaku1_carender.cgi の 14 行目では、require でコンパイルに失敗しました。 サポートが必要な場合は、ウェブマスター (webmaster@gmoserver.jp) までメールでお問い合わせください。エラーメッセージとエラー発生日時をお知らせください。 |
これを修正したらサロン側の予約管理システムは、復旧できました。
あとは、お客様用の予約システムです。
ログインしようとしたら下記のようなエラーメッセージが表示されます。
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator at webmaster@gmoserver.jp to inform them of the time this error occurred, and the actions you performed just before this error.More information about this error may be available in the server error log. |
内部サーバーエラー サーバーで内部エラーまたは設定ミスが発生したため、リクエストを完了できませんでした。サーバー管理者(webmaster@gmoserver.jp)に、エラーの発生時刻と、エラー発生直前の操作内容をお知らせください。このエラーに関する詳細は、サーバーエラーログに記載されている可能性があります。 |
レンタルサーバーに問い合わせるとフォームに対してのGoogle reCAPTCHA(リキャプチャ)設置などのセキュリティ対策をお願いしますという事でした。