2006年06月30日

ウィンドウズでgrep見たいな事

カレントディレクトリ以下のサブディレクトリのPHPの中から、"var_dump"という文字列を見つけたいとき。

findstr /s "var_dump" *.php
helpは findstr -?
posted by ミラクルさん at 17:33| Comment(1) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年06月22日

FC2BLOGのコメント欄にh抜きurlを貼り付けてリンクが張られる件

http://shizurus.blog63.fc2.com/blog-entry-38.html#comment333

たとえば下記のようなurlに勝手にリンクが貼られてしまう。
ttp://www.example.com/
これが、表示時に以下のように変換される
<a href="ttp://www.example.com/">ttp://www.example.com/</a>
このときに正しくは以下のようにhref属性値の頭にhが補完されなければならない。a要素の値として表示される部分については補完される必要は無い。
<a href="http://www.example.com/">ttp://www.example.com/</a>
これならばおかしい仕様でもなんでもない。現に多くの2chブラウザで実装されている仕様だ。
だからFC2の仕様策定者がこのような機能の実装を求めることは別に不思議ではない。
処理の手順としては、
コメントで表示するべき文字列を引っ張り出す。

urlと思しき文字列を検出する。

検出したurlと思しき文字列をa要素に変換する。

表示。
という流れだろう。
(おそらく平のhtmlに打ち出しを行っていると思うが)

実際の検出方法についてはmbereg_replace()でurlをa要素にですでに述べた。

さて、仕様策定者が
「2chでよくあるじゃん。ttp:で始まるやつ。あれにもリンクをつくようにしてよ」
と求めたので、正規表現を少しいじってttp://で始まる文字列にもマッチするよう修正した。ここまではいい。
ならば、なぜ試験をしないのか。試験をすれば不具合のあることと原因はすぐにわかるはずだ。
このような、ユーザが触って百発百中で出てしまう不具合をいつまでも残しておくのは技術者として恥ではないのか。
仕様策定者も自分で求めた仕様ならば完成報告を受けたらなぜ自分で試してみないのか。どこに仕様管理が存在するのか。言いっぱなしなのか。

FC2の企業としての見識を疑います。
posted by ミラクルさん at 17:53| Comment(4) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

HTML_Template_Flexy_Elementメモ

基本的にsetValue()とsetOptions()の使い方を覚えておけば十分かなと思います。

$elements['COMMENT'] = new HTML_Template_Flexy_Element();
$elements['COMMENT']->setValue($req->getValue("COMMENT"));
// <input type="text" name="COMMENT">のvalue属性に値をセット

$elements['PREF'] = new HTML_Template_Flexy_Element();
$elements['PREF']->setOptions($GLOBALS['pref']);
// <select name="PREF">のoption要素をセット(key=value)

気をつけなければいけないのがRadioのみはid属性で一意に指定するので、HTML_Template_Flexy_Elementオブジェクトの要素名はid属性になるということ。(他はname属性)
HTML_Template_Flexy_Elementオブジェクトの第2引数で属性値をkey=value形式で指定できる。そのほかにもsetAttributes()メソッドで動的に指定できます。onClickなどイベントハンドラ系の属性指定に威力を発揮しそう。
今までvalue属性値やchecked,selected属性などの指定はhtml部分に書き込む形が必要でしたが、今後はロジック部分のみに統合させ、制御構文などがhtml(テンプレート)に極力もぐりこまない形がとれそうです。

関連
PEAR::HTML_Template_Flexyメモ
posted by ミラクルさん at 15:47| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年06月19日

今さっき忘れてすごい悩んでいたこと

もう二度と忘れないようにメモ。

mb_send_mailを実行する前に
mb_language("Japanese");
mb_internal_encoding("SJIS");//使用しているスクリプトの文字コード
を忘れないようにする。

はあ、おいらの馬鹿。
posted by ミラクルさん at 17:32| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年06月13日

Web2.0だってよ

PHPとDHTMLを使用したWeb 2.0アプリケーションの開発 第1回: 自分で試してみよう
のっけから
2006年の流行語大賞はWeb 2.0で決まりです。

と飛ばしています。さすがIBMですw
まあ、まだまだブラウザの互換性に関する問題は残っているんですけれどもね。DHTMLは。Internet Explorerでのサポートがちょっと立ち遅れているのは事実ですね。昔のネスケほどではありませんが。
ここには様々な例が載っていますので、いろいろ試してみようとは思いますが、Webユーザの皆様にはここでFirefoxを使おうと声を大にしていいたいです。
posted by ミラクルさん at 10:07| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年06月07日

Flexyの問題なのか?

input要素のname属性に特定の単語で?同じ名前を複数指定するとパーサがエラーを起こす。
action
ACTION
validateで確認。

type属性も関係するのかどうか。
原因がわからない。

とりあえず、名前を変えたり、getを用いたりして対処。
posted by ミラクルさん at 14:39| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年06月06日

mbereg_replace()でurlをa要素に

$html = mbereg_replace(
'https?://'.
'(([a-zA-Z0-9]+\.){1,}[a-zA-Z]+|(\d+.){3}\d+)'. // host
'(:\d+)?'. // port
'(/[-.!~*\d\w;/?:@&=+$,%#]+)?',
'\0',$txt);

正規表現を正確に書くと
\b(?:https?|shttp)://(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f
][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)
*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\.
[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f]
[0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-
Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f
])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)
*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])
*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*
)?
となりますが、ここまでは求めないケースがほとんどでしょう。

posted by ミラクルさん at 23:19| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年05月25日

PHPDOM

DOMによるXMLアクセスは何かと便利ですが、残念ながらPHP4ではPECL拡張モジュールでのサポートとなっています。
XXXI. DOM XML 関数

これではいろいろと不都合なので、探して歩いた結果
こんなのを見つけました。
連想配列でアプローチできないのがちょっとあれですが(過去のVer.ではできたようですが)、なかなか使い心地はよさそうです。
ExcelのXMLスプレッドシートなどの連携をいろいろ試してみようと思います。
うまくすれば、ビジネスの各所で既存のOffice文書とWebアプリケーションの連携がしやすくなるんじゃないかな。

posted by ミラクルさん at 14:40| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年05月23日

PEAR::Mail_Mimeでお困りの方に

−Webメーラー−

PEAR::Mail_Mimeはかなり便利なのですが、ほぼ唯一の欠点は添付ファイル名に日本語をつけると正常にファイル名が受信できない点なのですが、これを解決しているのが、このソースです。

業務要件でどうしても日本語ファイル名を排除できないときに非常に有益かと思います。
個人的にはファイル名に日本語を使う人間はいなくなってほしいと思いますが、仕方のないことですので。

レッツPHPのネタです。
posted by ミラクルさん at 16:39| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年05月19日

Excel2003との連携

Excel2003からXMLファイル・フォーマットが追加されましたが、これによって何ができるかと言いますとこんなことができるようです。
PHPでExcelデータを読み書きする
こいつはちょっと画期的かもしれない。
今までPEARのSpreadsheet_Excel_Writerなどを使用してもぞもぞやっていたのがXMLですっきり読み書き可能になるのはありがたい。

しかしながら問題は実際の現場でどのくらいExcel2003が使用されているかどうかだ。
posted by ミラクルさん at 18:05| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年04月28日

チェックシート

Cheat Sheet Roundup - Over 30 Cheatsheets for developers

PHPをはじめとしてJavaScript、MySQL、HTML、CSS、UNIX、Windows、Vimなど通常使うツールの「覚えてはおけないけれども、本当は覚えておきたい」コマンドやコマンドオプションなどを集めたリンク集。

PHPでいえばdateのオプションとか、fopenのオプションとか、
Vimだったらバッファコントロールとか、UNIXのアーカイバ関連とか本当に助かることしか書いてない。

そのくらい覚えろという突っ込みは却下。
posted by ミラクルさん at 10:07| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年04月20日

駅探路線図情報提供実験

駅探路線図情報提供実験とは

ぐりぐり路線図がちょっと使いづらい。
駅をクリックしても反応しないことが多い。
(都営三田線春日駅のみ正常動作を確認)

所要時間も見やすいんだけど、メインマップの縮尺を調節できないと、
20〜30分以上がほとんど表示できないので意味がないかな。

まあ、実験段階なんで、もっと洗練されることを期待しましょう。
posted by ミラクルさん at 10:45| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年04月17日

電話番号正規表現とメールアドレス正規表現

すぐに忘れるのでメモ
本当は両方ともすごく複雑なので簡易的に

if(!preg_match("/0[346]\-\d{4}\-\d{4}|0[1-9]{2}\-\d{3}\-\d{4}|0[1-9]{2}\d\-\d{2}\-\d{4}|0[1-9]{2}\d{2}\-\d\-\d{4}|0[1-9]{2}\d{7}|0[5789]0\-\d{4}\-\d{4}|0[5789]0\d{8}/", $tel)){
print("電話番号が不正です。");
}

if(!preg_match( '/^[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i' , $mail)){
print("メールアドレスの入力が不正です");
}

posted by ミラクルさん at 21:12| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年04月12日

JavaScript-lint

JavaScript Lintというものがあるらしいので使ってみた。
1:ダウンロードする
2:解凍したファイルの中のjsl-test.jsをチェックしたいJavaScriptに書き換える。
3:jsl-sample.batを実行

いままでJavaScriptではまると時間かかったけど、これのおかげですごい楽になりそう。
おすすめ。

PHPじゃないけど。ね。
posted by ミラクルさん at 17:09| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年04月06日

PEAR::HTML_Template_Flexyメモ

// Flexyオブジェクト作成
$flexy = new HTML_Template_Flexy($options);

// テンプレートをコンパイル
$flexy->compile("schedule.tpl");

// ダミークラスに値を代入
$obj =& new StdClass;
$obj->sch = $req;
$obj->title = $Title;

// 標準出力に表示
$flexy->outputObject($obj);

// HTMLを文字列として取得
$html = $flexy->bufferedOutputObject($obj);

// オプション
$options = array(
'templateDir' => '/home/www/html/test/',
'compileDir' => '/home/www/html/test/',
'forceCompile' => 0,
'debug' => 0,
'compiler' => 'Standard',
'globalfunctions' => true
);

テンプレートは単純なテンプレートでSmartyのようにテンプレート内部でカウンタを持たせたりはできない。
条件分岐と配列ループしかできないと考えたほうがよい。

フォーム要素の操作をコントロールできるが、試していない。
http://pear.php.net/manual/ja/package.html.html-template-flexy.php
posted by ミラクルさん at 12:28| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年03月24日

ImageMagick

PHPでImageMagicを使ってみたメモ


$srcname = "test.jpg";
$size = getimagesize($srcname);
$x_size = 80;
$ritu = $size[0] / $x_size;
$y_size = round ($size[1] / $ritu);

$dstnames = "000490201_S.jpg";
$w = "/usr/local/bin/convert -geometry ".$x_size."x".$y_size." $srcname $dstnames";
exec($w,$parray,$rtnsts);
$dstnames = "000490201_E.jpg";
$w = "/usr/local/bin/convert -geometry ".$x_size."x".$y_size." -equalize $srcname $dstnames";
exec($w,$parray,$rtnsts);
$dstnames = "000490201_N.jpg";
$w = "/usr/local/bin/convert -geometry ".$x_size."x".$y_size." -normalize $srcname $dstnames";
exec($w,$parray,$rtnsts);
$dstnames = "000490201_SH.jpg";
$w = "/usr/local/bin/convert -geometry ".$x_size."x".$y_size." -sharpen 0.5x0.5 $srcname $dstnames";
exec($w,$parray,$rtnsts);
$dstnames = "000490201_SH70.jpg";
$w = "/usr/local/bin/convert -geometry ".$x_size."x".$y_size." -sharpen 100x100 $srcname $dstnames";
exec($w,$parray,$rtnsts);
$dstnames = "000490201_SH50.jpg";
$w = "/usr/local/bin/convert -geometry ".$x_size."x".$y_size." -sharpen 1x1 $srcname $dstnames";
exec($w,$parray,$rtnsts);


表示はお好みで

option一覧
geometryは100x100のように表記


Where options include:
-adjoin join images into a single multi-image file
-affine matrix affine transform matrix
-annotate geometry text
annotate the image with text
-antialias remove pixel-aliasing
-append append an image sequence
-authenticate value decrypt image with this password
-average average an image sequence
-background color background color
-bias value add bias when convolving an image
-black-threshold value
forces all pixels below the threshold into black
-blue-primary point chromaticity blue primary point
-blur geometry blur the image
-border geometry surround image with a border of color
-bordercolor color border color
-channel type apply option to select image channels
-charcoal radius simulate a charcoal drawing
-chop geometry remove pixels from the image interior
-clip clip along the first path from the 8BIM profile
-clip-path id clip along a named path from the 8BIM profile
-clone index clone an image
-coalesce merge a sequence of images
-colorize value colorize the image with the fill color
-colors value preferred number of colors in the image
-colorspace type alternate image colorspace
-combine combine a sequence of images
-comment string annotate image with comment
-compose operator set image composite operator
-composite composite image
-compress type type of pixel compression when writing the image
-contrast enhance or reduce the image contrast
-contrast-stretch geometry
improve the contrast in an image by `stretching' the range of intensity values
-convolve coefficients
apply a convolution kernel to the image
-crop geometry cut out a rectangular region of the image
-cycle amount cycle the image colormap
-debug events display copious debugging information
-define format:option
define one or more image format options
-deconstruct break down an image sequence into constituent parts
-delay value display the next image after pausing
-delete index delete the image from the image sequence
-density geometry horizontal and vertical density of the image
-depth value image depth
-despeckle reduce the speckles within an image
-display server get image or font from this X server
-dispose method GIF disposal method
-dither apply Floyd/Steinberg error diffusion to image
-draw string annotate the image with a graphic primitive
-edge radius apply a filter to detect edges in the image
-emboss radius emboss an image
-encoding type text encoding type
-endian type endianness (MSB or LSB) of the image
-enhance apply a digital filter to enhance a noisy image
-equalize perform histogram equalization to an image
-evaluate operator value
evaluate an arithmetic, relational, or logical expression
-extent geometry set the image size
-extract geometry extract area from image
-family name render text with this font family
-fill color color to use when filling a graphic primitive
-filter type use this filter when resizing an image
-flatten flatten a sequence of images
-flip flip image in the vertical direction
-floodfill geometry color
floodfill the image with color
-flop flop image in the horizontal direction
-font name render text with this font
-format "string" output formatted image characteristics
-frame geometry surround image with an ornamental border
-fuzz distance colors within this distance are considered equal
-fx expression apply mathematical expression to an image channel(s)
-gamma value level of gamma correction
-gaussian geometry gaussian blur an image
-geometry geometry perferred size or location of the image
-green-primary point chromaticity green primary point
-gravity type horizontal and vertical text placement
-help print program options
-identify identify the format and characteristics of the image
-implode amount implode image pixels about the center
-insert index insert last image into the image sequence
-intent type type of rendering intent when managing the image color
-interlace type type of image interlacing scheme
-label name assign a label to an image
-lat geometry local adaptive thresholding
-layers method optimize or compare image layers
-level value adjust the level of image contrast
-limit type value pixel cache resource limit
-log format format of debugging information
-loop iterations add Netscape loop extension to your GIF animation
-map filename transform image colors to match this set of colors
-mask filename set the image clip mask
-matte store matte channel if the image has one
-mattecolor color frame color
-median radius apply a median filter to the image
-modulate value vary the brightness, saturation, and hue
-monitor monitor progress
-monochrome transform image to black and white
-morph value morph an image sequence
-mosaic create a mosaic from an image sequence
-motion-blur geometry
simulate motion blur
-negate replace every pixel with its complementary color
-noise radius add or reduce noise in an image
-normalize transform image to span the full range of colors
-opaque color change this color to the fill color
-ordered-dither NxN
ordered dither the image
-orient type image orientation
-page geometry size and location of an image canvas (setting)
-paint radius simulate an oil painting
-ping efficiently determine image attributes
-pointsize value font point size
-posterize levels reduce the image to a limited number of color levels
-preview type image preview type
-profile filename add, delete, or apply an image profile
-quality value JPEG/MIFF/PNG compression level
-quiet suppress all error or warning messages
-radial-blur angle radial blur the image
-raise value lighten/darken image edges to create a 3-D effect
-random-threshold low,high
random threshold the image
-red-primary point chromaticity red primary point
-region geometry apply options to a portion of the image
-render render vector graphics
-repage geometry size and location of an image canvas
-resample geometry change the resolution of an image
-resize geometry resize the image
-roll geometry roll an image vertically or horizontally
-rotate degrees apply Paeth rotation to the image
-sample geometry scale image with pixel sampling
-sampling-factor geometry
horizontal and vertical sampling factor
-scale geometry scale the image
-scene value image scene number
-seed value pseudo-random number generator seed value
-segment values segment an image
-separate separate an image channel into a grayscale image
-sepia-tone threshold
simulate a sepia-toned photo
-set attribute value set an image attribute
-shade degrees shade the image using a distant light source
-shadow geometry simulate an image shadow
-sharpen geometry sharpen the image
-shave geometry shave pixels from the image edges
-shear geometry slide one edge of the image along the X or Y axis
-sigmodial-contrast geometry
lightness rescaling using sigmoidal contrast enhancement
-size geometry width and height of image
-solarize threshold negate all pixels above the threshold level
-splice geometry splice the background color into the image
-spread amount displace image pixels by a random amount
-strip strip image of all profiles and comments
-stroke color graphic primitive stroke color
-strokewidth value graphic primitive stroke width
-stretch type render text with this font stretch
-style type render text with this font style
-support factor resize support: > 1.0 is blurry, < 1.0 is sharp
-swap indexes swap two images in the image sequence
-swirl degrees swirl image pixels about the center
-texture filename name of texture to tile onto the image background
-threshold value threshold the image
-thumbnail geometry create a thumbnail of the image
-tile filename tile image when filling a graphic primitive
-tint value tint the image with the fill color
-transform affine transform image
-transparent color make this color transparent within the image
-treedepth value color tree depth
-trim trim image edges
-type type image type
-undercolor color annotation bounding box color
-units type the units of image resolution
-unsharp geometry sharpen the image
-verbose print detailed information about the image
-version print version information
-view FlashPix viewing transforms
-vignette geometry soften the edges of the image in vignette style
-virtual-pixel method
virtual pixel access method
-wave geometry alter an image along a sine wave
-weight type render text with this font weight
-white-point point chromaticity white point
-white-threshold value
forces all pixels above the threshold into white
-write filename write images to this file
posted by ミラクルさん at 16:30| Comment(0) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

2006年03月18日

画像圧縮

「PHPで画像圧縮ツールってなんかないの?」という指令を受けたのですが、
正直ツールがなくてもできるようです。
自分用メモ

PHPのGDライブラリを使ってサムネイルの作成

このページスクリプトのサンプルもあるので、結構楽にできると思いますが、
共通関数作らないといけないなと。
めんどくせえな。
posted by ミラクルさん at 17:55| Comment(1) | TrackBack(0) | PHP | このブログの読者になる | 更新情報をチェックする

広告


この広告は60日以上更新がないブログに表示がされております。

以下のいずれかの方法で非表示にすることが可能です。

・記事の投稿、編集をおこなう
・マイブログの【設定】 > 【広告設定】 より、「60日間更新が無い場合」 の 「広告を表示しない」にチェックを入れて保存する。


×

この広告は90日以上新しい記事の投稿がないブログに表示されております。