/
auth_schtag.pl
93 lines (68 loc) · 1.99 KB
/
auth_schtag.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main;
#-----------------------------------------------------------
# SNSタグ
#-----------------------------------------------------------
sub auth_schtag{
# 局所化
my($type,$file,$maxtag,$max_comment) = @_;
my($tagline,$i,$line,$hit);
# 検索実行
if($in{'word'} ne ""){ ($line) = &search_action($in{'word'}); }
# CSS定義
$css_text .= qq(
.google_link{font-size:150%;}
);
# タイトル定義
$sub_title = "タグ検索 - $title";
$head_link3 = " > タグ検索 ";
# タグ検索フォームを取得
&get_schform();
# ログイン中の場合
my($navilink);
if($idcheck){ $navilink .= qq(<a href="./$pmfile/tag-view">→タグを登録する</a> - ); }
$navilink .= qq(<a href="./tag-new.html">新着タグをチェックする</a>);
# HTML
my $print = qq(
$footer_link
<h1>タグ検索</h1>
$navilink
$schform
$line
$footer_link2
);
Mebius::Template::gzip_and_print_all({},$print);
exit;
}
use Mebius::Tag;
#-----------------------------------------------------------
# 検索実行
#-----------------------------------------------------------
sub search_action{
# 局所化
my($tag) = @_;
my($i,$enc_word,$line);
my($auth_log_directory) = Mebius::SNS::all_log_directory_path() || die;
$enc_word = Mebius::Encode("",$tag);
# キーワード整形
($tag) = Mebius::Tag::FixTag(undef,$tag);
# 全タグファイルを開く
open(ALLTAG_IN,"<","${auth_log_directory}alltag.cgi");
while(<ALLTAG_IN>){
$i++;
chomp;
if($_ =~ /\Q$tag\E/i){
$hit++;
my $enc_tag = $_;
$enc_tag =~ s/([^\w])/'%' . unpack('H2' , $1)/eg;
$enc_tag =~ tr/ /+/;
$line .= qq(<li><a href="./tag-word-$enc_tag.html">$_</a>);
}
}
close(ALLTAG_IN);
# 整形
my $google_link = qq(<a href="http://www.google.co.jp/search?q=$enc_word&sitesearch=mb2.jp&ie=Shift_JIS&oe=Shift_JIS&hl=ja&domains=mb2.jp" class="google_link" rel="nofollow">→”$in{'word'}”をGoogle検索してみる</a>);
if($line eq ""){ $line = qq(<h2>検索結果</h2>ヒットしませんでした。キーワードを変えて試してください。<br><br>$google_link); }
else{ $line = qq(<h2>検索結果 ($hit件)</h2><ul>$line</ul><br>$google_link); }
return($line);
}
1;