Skip to content

Commit

Permalink
add niconico
Browse files Browse the repository at this point in the history
  • Loading branch information
maoutokagura committed Jan 3, 2012
1 parent fb04e70 commit e29eaa0
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions log_script.cgi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/perl

use strict;

my $buffer = $ENV{'QUERY_STRING'};
my ($channel,$date,$enc) = split(/&/,$buffer);

my $i;
my @nick;
my @colors = ('aqua','yellow','lime','fuchsia','orange','Teal','red','Purple','Maroon','Green');
my $logdir = "/home/2TB/irclog/";
my $logDir = "/home/2TB/irclog/";
my $script_name = "log_script.cgi";

print "Content-type: text/html", "\n\n";
Expand All @@ -17,7 +18,7 @@ print <<EOM;
</head>\n <body>\n<div id="main">
EOM

chdir("$logdir");
chdir("$logDir");
my @follist= glob "*/";

if ($buffer == undef){
Expand All @@ -32,14 +33,16 @@ print <<EOM;
EOM

sub getlog{
my $line;
my $folname = $follist[$channel - 1];
print "$folname<br>\n";
chdir("$logdir$folname");
chdir("$logDir$folname");
open(IN, $date);
while ( $line = <IN>) {
# my $line;
# while ( $line = <IN>) {
# print &rewrite($line);
# }
foreach my $line (<IN>){
print &rewrite($line);
$i++;
}
print @nick;
close(IN);
Expand All @@ -49,7 +52,7 @@ sub getfiles{
my $req = $channel;
my $folname = $follist[$req - 1];
print "$folname<br>\n aa\n";
chdir("$logdir$folname");
chdir("$logDir$folname");
my @filelist= glob "*.txt";
foreach my $file (sort @filelist){
next if( $file =~ /^\.{1,2}$/ );
Expand All @@ -75,29 +78,32 @@ sub href {

sub rewrite{
my $string = @_[0];
my $tennpo;
my $tmp;
my $nick_color;


if($string =~ m/^(\d\d:\d\d)\s\W(\S+?:)/){
$tennpo = $2 . "<br>";
if (!grep(/$tennpo/,@nick)){
push(@nick,$tennpo);
$tmp = $2 . "<br>";
if (!grep(/$tmp/,@nick)){
push(@nick,$tmp);
}
}
$nick_color = @colors[(&nick_search($tennpo,@nick) % scalar(@colors))];
$nick_color = @colors[(&nick_search($tmp,@nick) % scalar(@colors))];
$string =~ s/</\&lt\;/g;
$string =~ s/^(\d\d:\d\d)\s\W(\S+?:)/<span style="color:blue;">\1<\/span><span style="color:$nick_color ;"> \2<\/span>/;
if ($string =~ m/.*(http.*?)\s/o){
$tennpo = $1;
$tmp = $1;
$string =~ s/(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/<a href=\"$1\" target="_blank" >$1 <\/a>/gi;
if($tennpo =~ /(jpg)|(png)|(gif)$/){
return "<img height=200 src=\"$tennpo \"><br>" . $string . "<br>\n";
}
elsif($tennpo =~ /http:\/\/www\.youtube\.com\/.*v=([^&]+).*/){
if($tmp =~ /(jpg)|(png)|(gif)$/){
return "<img height=200 src=\"$tmp \"><br>" . $string . "<br>\n";
}elsif($tmp =~ /http:\/\/www\.youtube\.com\/.*v=([^&]+).*/){
return "<img height=200 src=\"http\:\/\/i.ytimg\.com\/vi\/$1/default.jpg \"><br>" . $string . "<br>\n";
}elsif($tmp =~ /http:\/\/www\.nicovideo\.jp\/watch\/.*sm([^&]+).*/){
return "<img height=200 src=http://tn-skr2.smilevideo.jp/smile?i=$1 \"><br>" . $string . "<br>\n";
}elsif($tmp =~ /http:\/\/shindanmaker.com\/([^&]+).*/){
return $string ."<br>\n";
}else{
return "<img src=\"http\:\/\/capture.heartrails.com\/\?$tennpo \"><br>" . $string . "<br>\n";
return "<img src=\"http\:\/\/capture.heartrails.com\/\?$tmp \"><br>" . $string . "<br>\n";
}
return $string ."<br>\n";
}else{
Expand Down

0 comments on commit e29eaa0

Please sign in to comment.