【PHP】入力文字のエンコーディング検査

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

文字エンコーディングの検査にはmb_check_encoding関数を利用する。

書式:
bool mb_check_encoding( string $var, string $encoding)

$var → チェック対象の文字列
$string → 比較する文字エンコーディング(省略した場合は、PHPの内部文字エンコーディングとなる)

比較して一致したならば、Trueを返し、一致しない場合はFalseを返す。

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
PHP, Security , Leave a comment

【メモ】HTMLのDOCTYPE文

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

・HTML4.01 Transitional DTD URI無し(互換モード)

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html lang=”ja”>

・HTML4.01 Transitional DTD URI有り(標準モード)

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html lang=”ja”>

・ HTML4.01 Strict DTD URI無し( 標準モード)

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”>
<html lang=”ja”>

・HTML4.01 Strict DTD URI有り(標準モード)

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html lang=”ja”>

・HTML4.01 Frameset DTD URI無し

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN”>
<html lang=”ja”>

・HTML4.01 Frameset DTD URI有り

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
<html lang=”ja”>

・XHTML1.0 Transitional DTD

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”ja” lang=”ja”>

・XHTML1.0 Strict DTD

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”ja” lang=”ja”>

・XHTML1.0 Frameset DTD

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”ja” lang=”ja”>

・XHTML1.1 Strict DTD

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”ja”>

・HTML5

<!DOCTYPE html>
<html lang=”ja”>

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
雑記 Leave a comment

キーボードが壊れた…

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

PCのキーボードの調子が悪いです。
いくつかのキーが反応しません。
左ALTキーが使えないのも、効率が非常に悪いです。
というわけで、FILCOの黒軸をポチりました。
メカニカルキーボードの打鍵が好きなのです。

あれ、このキーボード、今日発売の新製品ですね。
今から届くのが楽しみです。

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
雑記 Leave a comment

【Windows】右クリックメニュに「暗号化」を追加する

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

Windowsで右クリックメニュに暗号化(EFS)を追加する手順です。

1.  レジストリエディタを起動する。
「ファイル名を指定して実行」に「regedit」と入力し、実行する。

2. レジストリエディタより、以下のキーまで移動する。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced

3.  キーを追加する。
右ペインで「新規」-「DWORD値」を追加する。
追加した項目の名前を「EncryptionContextMenu」に変更する。
「EncryptionContextMenu」を右クリックし、修正を選択。
値を「1」に設定する。

 

4. 以上の操作でファイルやフォルダを右クリックした際に「暗号化」が表示されるようになるはずです。
暗号化済みのファイルの場合は「暗号化解除」が表示されます。

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
Tips, Windows , , Leave a comment

【メモ】TeraTermが日本語表示にならない

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

TeraTermをインストール時に日本語設定しているのにもかかわらず、
メニュが英語表示になっている場合に修正する方法です。

メニュが日本語になっていません

インストールフォルダの中にある「TERATERM.INI」ファイルを確認してみると、
「UILanguageFile=」の箇所が=以降、何も記載されていません。

以下のようにファイルを編集し、保存します。
「UILanguageFile=lang\Japanese.lng」
※インストールフォルダ内にあるlangフォルダ内のファイルを指定します。

「TERATERM.INI」ファイルを保存後、TeraTermを再起動すると、
メニュが日本語で表示されています。

VN:F [1.9.17_1161]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.17_1161]
Rating: 0 (from 2 votes)
Tips, Windows , Leave a comment

【Windows】Winodwsで tailコマンドを使用する

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

LinuxやUnixではおなじみのtailコマンド。
リアルタイムにファイルに書き込まれた内容を表示するコマンドです。
故障解析や運用モニタリングで非常に役に立つコマンドです。
実はこのコマンド、Windows 2003のリソースキットに含まれています。

Windows 2003 Resorce kit

リソースキットをインストールすると、tailコマンドがインストールされます。
Windows 7でも問題なく動作しました。

VN:F [1.9.17_1161]
Rating: 6.0/10 (2 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
Windows, Windows 7 , , Leave a comment

【PHP】メモ:ファイルの更新時刻からの経過時間を表示する

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

phpでファイルの更新時刻からの経過時間を表示する例。

<html>
<head>
<title>ファイルの更新時刻からの経過時間を表示する</title>
</head>
<body>
<?php

$fileName = "test.php";
setlocale(LC_TIME, "ja");

if (file_exists($fileName)) {

    $string1 = strtotime(date("Y/m/d H:i:s", filemtime($fileName)));
    echo "<p>最終更新時刻:".date("Y/m/d H:i:s", $string1);

    $string2 = strtotime(date("Y/m/d H:i:s"));
    echo "<p>現在の時刻:".date("Y/m/d H:i:s", $string2);

    $string = ($string2 - $string1) / 60;
    echo "<p>現在の時刻との差は".$string."分です";

} else {

    echo "ファイルが見つかりません";

}

?>
VN:F [1.9.17_1161]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
PHP Leave a comment

【PHP】セキュリティ対策(Script Insertion)

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

PHPのセキュリティ対策例

・Script Insertion(スクリプト挿入)

————————————————————
$string = htmlspecialchars($post_data, ENT_QUOTES, ‘UTF-8′);
————————————————————

・$post_data はブラウザ等で入力されたデータが格納されている。

・htmlspecialcharsの第二引数は指定しない場合は”(ダブルクォート)でエスケープされる。
ダブルクォートでは変数が展開されるため、ENT_QUOTES ( ‘ ) シングルクォートを指定する。

・第三引数は文字コードなので、環境に応じ変更する。

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
PHP, Security , Leave a comment

【Cisco】Ciscoルータでフレッツ回線に接続するConfig例

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

 今日はルータの設定。
ダイアルアップは久々にやると設定が曖昧になってました。
と、いうわけでメモメモ。

——————————
3/31 追記

NTT西日本によると、Bフレッツ・フレッツADSL・フレッツ光ネクストのMTUは1454だが、
フレッツ光プレミアムのMTUは1438になるとのこと。
なんで東西で違いが…

http://www.nttwest-fc.com/faq/faqdet.php?faq_code=1511

——————————

LAN払い出し型(IOS12.4以上)
——————————
service timestamps debug datetime localtime msec
service timestamps log datetime localtime msec
clock timezone JST 9
!
logging buffered 512000 debugging
!
hostname 1812J_LAN
!
ip subnet-zero
!
ip cef
!
interface FastEthernet0
no ip address
duplex auto
speed auto
pppoe enable
pppoe-client dial-pool-number 1
!
interface FastEthernet2
!
interface Vlan1
ip address xxx.xxx.xxx.xxx 255.255.255.240
ip tcp adjust-mss 1414
!
interface Dialer1
ip unnumbered Vlan1
encapsulation ppp
dialer pool 1
dialer-group 1
ip mtu 1454
ppp authentication chap callin
ppp chap hostname user@cisco.com
ppp chap password 0 password
!
ip classless
ip route 0.0.0.0 0.0.0.0 Dialer1
!
dialer-list 1 protocol ip permit
!
end

————————————————————
端末払い出し型(IOS12.4以上)

——————————
service timestamps debug datetime localtime msec
service timestamps log datetime localtime msec
clock timezone JST 9
!
logging buffered 512000 debugging
!
hostname 1812J_Host
!
ip subnet-zero
!
ip cef
!
interface FastEthernet0
no ip address
duplex auto
speed auto
pppoe enable
pppoe-client dial-pool-number 1
!
interface FastEthernet2
!
interface Vlan1
ip address 192.168.0.1 255.255.255.0
ip nat inside
ip tcp adjust-mss 1414
!
interface Dialer1
ip address negotiated
ip mtu 1454
ip nat outside
encapsulation ppp
dialer pool 1
dialer-group 1
ppp authentication chap callin
ppp chap hostname user@cisco.com
ppp chap password 0 password
!
ip classless
ip route 0.0.0.0 0.0.0.0 Dialer1
!
ip nat inside source list 1 interface Dialer1 overload
!
access-list 1 permit 192.168.0.0 0.0.0.255
dialer-list 1 protocol ip permit
!
end

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
cisco, Network , Leave a comment

【メモ】TeraTermでTelnetを標準にする

このエントリーをはてなブックマークに追加
Bookmark this on Livedoor Clip

TeraTermはインストール直後、接続先を入力する画面でデフォルトでSSHが選択されます。

ツールバーの設定ではなぜかtelnetに変更できないため、TeraTerm.iniを直接編集して直す。

■変更箇所
============================================================
[TTSSH]
; SSH enabled flag (1=enabled 0=disabled)
Enabled=1
============================================================

Enabled=1 を 0に変更する

■変更前

■変更後

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
Tips , Leave a comment