#!C:\perl\bin\perl.exe # jun hirabayashi 2006/03/11 use strict; use WWW::Mechanize; use Crypt::SSLeay; use CGI ':standard'; use Jcode; if ( param() ) { #....................................................... my $pass = 'hoge'; my $user = 'hoge'; my $mail_adress = 'hoge@hoge'; #....................................................... my $lat = param('lat'); my $lon = param('lon'); $lat =~ s/\+//; $lon =~ s/\+//; my $str = param('cond'); $str = jcode( UrlDecode( $str ) )->euc; $str = 'マンガ喫茶'; $str = jcode( $str )->utf8; $str = UrlEncode( $str ); #-------- Get Position and Write info ------------------ my $uri = '"http://local.google.co.jp/local?f=l&hl=en&sll='.$lat.','.$lon.'&q=' . $str . '&near=' . '' . '"'; my $file = makeFile( $uri, 1600, 1600 ); postFileToNetprint( $user, $pass, $mail_adress, $file ); #....................................................... printHTML2( $lat, $lon, jcode( UrlDecode( $str ) )->euc ); } else { printHTML1(); } #===============URLから画像を作成する========================== sub makeFile { my ( $uri, $w, $h ) = @_; my $apl = 'url2bmp.exe'; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); $year += 1900; $mon += 1; my $file = sprintf "%04d%02d%02d%02d%02d", $year, $mon, $mday, $hour ,$min; system( "$apl -url $uri -format jpeg -file $file -wx $w -wy $h -bx $w -by $h -maximize -wait 6 -notinteractive"); return "$file.jpg"; } #===============ネットプリントにファイル登録========================== sub postFileToNetprint { my ( $user, $pass, $mail_adress, $file ) = @_; my $net_print_url = 'https://www.printing.ne.jp/cgi-bin/mn.cgi'; $net_print_url = "$net_print_url?i=$user&p=$pass"; my $mech = WWW::Mechanize->new(); my $response = $mech->get( $net_print_url ); # ネットプリントへ $mech->follow_link( url_regex => qr/&c=0&m=1/i );# ファイル登録ページへ $mech->submit_form( # ファイル送信フォーム form_name => 'uploadform', fields => { file1 => $file, color => '1', # プリント時にカラー/白黒 選択 number => '1', # 数字のみ番号に設定 secretcodesw =>'0', # 暗証番号は設定しない secretcode => '', mailsw => '1', # 登録結果を通知する mailaddr => $mail_adress, }, ); $mech->submit_form( form_name => 'm1form', # サイズ指定 fields => { papersize => 'A4',}, # A4, A3, B5, B4 ); return 1; } #===============HTML表示========================== sub printHTML2 { my ( $lat, $lon, $cond ) = @_; my $head = << 'END_OF_HTML'; Content-Type: text/x-hdml END_OF_HTML my $contents = jcode('[[ この辺りの地図を出力しました ]]

')->sjis . jcode(' ●条件: ')->sjis . jcode($cond)->sjis . '
' . jcode(' ●緯度: ')->sjis . $lat . '
' . jcode( ' ●経度: ')->sjis . $lon . '
'; my $end = << 'END_OF_HTML';
END_OF_HTML print $head, $contents, $end; } #===============HTML表示========================== sub printHTML1 { my $head = << 'END_OF_HTML'; Content-Type: text/html Map Printer
END_OF_HTML my $contents = ''; my $end = << 'END_OF_HTML'; END_OF_HTML print $head, $contents, $end; } #...........URLエンコード.......................... sub UrlEncode { my($str) = @_; $str =~ s/([^ 0-9a-zA-Z\-@\*\._])/sprintf("%%%02X", ord($1))/eg; $str =~ s/ /+/g; return $str; } #...........URLデコード............................ sub UrlDecode { my($str) = @_; $str =~ s/\+/ /g; $str =~ s/%([0-9A-Fa-f]{2})/pack("C", hex($1))/eg; return $str; }