スキップしてメイン コンテンツに移動

投稿

エスケープしろよ

頭きた。 いい加減、 何をどうしなけりゃいけないか覚えろ。 基本はこれ。 ■HTMLの一部として出力するとき htmlspecialchars()、htmlentities()のどちらかを通す。 ■MySQL用のSQL文を生成するとき mysql_real_escape_string()を通す。 ■PostgreSQL用のSQL文を生成するとき PHP 5.4.4より前のバージョン:pg_escape_string() PHP 5.4.4以上のバージョン:pg_escape_literal() あと、 過去資産は全て使えないから。

jQueryで連番のid属性を持つ要素に対してまとめて処理する

例えば、何かのマスタデータを一覧形式で修正できるようなインターフェイスがあったとしよう。 <input id="mstcd001" name="mstcode[]" type="text" value="mstcd001" /> <input id="mstcd002" name="mstcode[]" type="text" value="mstcd002" /> <input id="mstcd003" name="mstcode[]" type="text" value="mstcd003" /> <input id="mstcd201" name="mstcode[]" type="text" value="mstcd201" /> <input id="mstcd351" name="mstcode[]" type="text" value="mstcd351" /> クリックしたときやフォーカス取得時に、テキスト全選択したいときは、こんな感じで設定するといい。 <script> <!-- $(document).ready(function() { $('input').filter(function(){ return this.id.match(/^mstcode([0-9])+$/i); }) .focus(function(){ $(this).select(); }) .mouseup(function(e){ e.preventDefault(); }); }); //--> </sc...

CentOS 6.3 最小構成からのスタート
(6)MySQLの起動

インストール直後は、自動起動しない。 # chkconfig auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off # なので、自動起動するようにする。 ...

CentOS 6.3 最小構成からのスタート
(5)apacheの起動

インストール直後は、自動起動しない。 # chkconfig auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off # なので、自動起動するようにする。 ...

CentOS 6.3 最小構成からのスタート
(4)LAMPインストール

# yum install httpd php php-mbstring php-mysql mysql-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.nara.wide.ad.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-15.el6.centos.1 will be installed --> Processing Dependency: httpd-tools = 2.2.15-15.el6.centos.1 for package: httpd-2.2.15-15.el6.centos.1.x86_64 --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-15.el6.centos.1.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-15.el6.centos.1.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64 ---> Package mysql-server.x86_64 0:5.1.66-1.el6_3 will be installed --> Processing Dependency: mysql =...

htmlspecialchars()とhtmlentities()の第4引数はfalseで

文字エンコーディングに UTF-8 を使っているときは気にしなかったが、 EUC-JP や Shift_JIS を使わなければならなかったとき、ハマッた。 EUC-JP や Shift_JIS (両方とも、Windows標準キャラクタセットが扱える CP51932、SJIS-win を含む)の場合、これらの文字セットに存在しない ⓒ などをPOSTすると、数値文字参照形式でPOSTされる。 なので、POSTされた値を htmlspecialchars() や htmlentities() を通して echo htmlspecialchars(POST値, ENT_QUOTES, 文字エンコーディング); echo htmlentities(POST値, ENT_QUOTES, 文字エンコーディング); とすると、数値文字参照の「&」が「&amp;」に変換され、数値文字参照の値がそのまま表示される。 これは、両関数の第4引数「double_encode」のデフォルトが「true」のため。 ■PHPマニュアル htmlspecialchars() http://www.php.net/manual/ja/function.htmlspecialchars.php ■PHPマニュアル htmlentities() http://www.php.net/manual/ja/function.htmlentities.php 回避策は、この第4引数「double_encode」を「false」にしてやればいい。 こんな感じ。 echo htmlspecialchars(POST値, ENT_QUOTES, 文字エンコーディング, false); echo htmlentities(POST値, ENT_QUOTES, 文字エンコーディング, false);

ただのメモ兼ブックマーク

PHP型の比較表 http://www.php.net/manual/ja/types.comparisons.php MySQLのNULLは、 ・is_null() で true。 ・ == '' で true。 phpMyAdminでtext型フィールドの値を表示する http://www.zelazny.mydns.jp/archives/002723.php InsertしたレコードのAUTO_INCREMENT値を取得する http://blog.tofu-kun.org/071206185929.php CentOS6.2 へ OpenVZ を入れる http://www.mogumagu.com/wp/wordpress/?p=729 iPhone4 のデフォルト文字数など 横幅:ひらがな19文字 縦幅:14行 htmlspecialchars(),htmlentities()の第3引数は、IANAに登録されているMIME名を使う UTF-8 Shift_JIS EUC-JP PHPでシングルトン http://d.hatena.ne.jp/Yudoufu/20090811/1250021010 topコマンドで表示される値の意味 http://www.uetyi.mydns.jp/wordpress/command/entry-124.html topコマンドで表示されるVIRTの意味 http://okwave.jp/qa/q5812588.html findで検索していろいろ http://uguisu.skr.jp/Windows/find_xargs.html OpenSSLの脆弱性 ・libcrypto ・libssl 2014/4と2014/6の脆弱性はこっちのライブラリ