|
2026 01,17 07:25 |
|
|
× [PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。 |
|
|
2011 02,17 08:44 |
|
|
3連続貫徹・・・ひさびさに本気でキレながらの貫徹なので、余計にエネルギーを使う・・・・
そんな貫徹の作業で、運がよく見つかったサイト(ブログ)があったので、 感謝と尊敬を込めて JavaScriptにはescapeという(PHPでいうurlencode)関数があって、 ただ、このescape関数。 理由はブラウザによって動作が異なること、 <?php
/**
* Function converts an Javascript escaped string back into a string with specified charset (default is UTF-8).
* Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
*
* @param string $source escaped with Javascript's escape() function
* @param string $iconv_to destination character set will be used as second paramether in the iconv function. Default is UTF-8.
* @return string
*/
function unescape($source, $iconv_to = 'UTF-8') {
$decodedStr = '';
$pos = 0;
$len = strlen ($source);
while ($pos < $len) {
$charAt = substr ($source, $pos, 1);
if ($charAt == '%') {
$pos++;
$charAt = substr ($source, $pos, 1);
if ($charAt == 'u') {
// we got a unicode character
$pos++;
$unicodeHexVal = substr ($source, $pos, 4);
$unicode = hexdec ($unicodeHexVal);
$decodedStr .= code2utf($unicode);
$pos += 4;
}
else {
// we have an escaped ascii character
$hexVal = substr ($source, $pos, 2);
$decodedStr .= chr (hexdec ($hexVal));
$pos += 2;
}
}
else {
$decodedStr .= $charAt;
$pos++;
}
}
if ($iconv_to != "UTF-8") {
$decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
}
return $decodedStr;
}
/**
* Function coverts number of utf char into that character.
* Function taken from: http://sk2.php.net/manual/en/function.utf8-encode.php#49336
*
* @param int $num
* @return utf8char
*/
function code2utf($num){
if($num<128)return chr($num);
if($num<2048)return chr(($num>>6)+192).chr(($num&63)+128);
if($num<65536)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
if($num<2097152)return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
return '';
}
?>
日本語も問題なく出来ました!
ホントに感謝です
http://dozo.matrix.jp/pear/index.php?PEAR%2FHTML_AJAX%2FunescapePR |
|
|
2010 11,09 02:48 |
|
|
結構簡単に見えて、意外と難しいmod_rewrite
案の定ハマりました やりたいことは、王道中の王道 「user.example.com で example.com/user/ にアクセスさせる」 色々参考にいろんなサイトを見た結果、以下の設定できた httpd.conf に以下の設定を記述 RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9_-]+)\.example\.com$ RewriteRule ^/(.*)$ /~%1/$1 [PT] でも、これだとindex.html が表示されなかったので、 RewriteRule ^/(.*)$ /~%1/$1 とした しかも、バーチャルマシーンで、サブドメインを切ってある設定の上に、 この設定をしている意味が、少し分からん・・・ まっ、いいか 要望は叶えた |
|
|
2010 11,02 05:28 |
|
|
先ほどの日記の経験をいかし、メンテナンスページを表示する方法をちゃんと学ぼうと思いました。 <IfModule mod_rewrite.c> <IfModule mod_headers.c> 192.168.0.4や192.168.0.5の部分には、管理者のIPアドレスを書きます。管理者IPアドレスがさらにある場合は行をコピーして増やせばOKですし、わからない場合は必要ない場合は行を削除してしまいましょう。 Sun, 14 Jun 2009 06:00:00 GMTの部分には、メンテ終了予定時刻を指定します(メンテ終了までの秒数でも出せますが、終了時刻をRFC1123形式で示すほうが楽でしょう、GMTにする必要がありますが)。ただし、ここに指定する値は人間のユーザーには基本的に示されませんし、あくまでも参考データです。 とのことです。 ためになりますねぇ~ http://web-tan.forum.impressrd.jp/e/2009/06/16/5880 |
|
|
2010 11,02 05:25 |
|
|
無料HPにIPをチェックするスクリプトを置いていたのだが、その無料HPが11/1をもってサービス終了・・・ |
|
|
2010 10,26 01:59 |
|
| 忍者ブログ [PR] |





