#!/usr/bin/perl
require '/home/rexi-jp/public_html/tg/lib/lib.pl';
#require '/home/rexi-jp/public_html/lib/mobile.pl';
$mid = $uid;
$uid = '';
$mycgi = 'index.cgi';
#大聖堂
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$ip = $ENV{'REMOTE_ADDR'};
$host = gethostbyaddr(pack("C4", split(/\./, $ip)), 2);
$host ||= $ENV{'REMOTE_HOST'};
$host ||= $ip;
$referer=$ENV{'HTTP_REFERER'};
$script=$ENV{'SCRIPT_NAME'};
$query = CGI->new;
my @params = $query->param();#全てのパラメータ名を取得 なのでこれを$inにしてしまえば$inで使用可能
foreach my $param (@params) {
$in{$param} = $query->param($param);
}
$uid = &get_usr_cookie;
$pcid = &get_pcid_cookie;
my $imode = &CHECK_UA;
if($imode eq "26"){
$dbh = &connectDB($mainDB);
$sql = "select name from character where pcid = '$pcid' and admission = 1 and state = 0;";
$ref = $dbh->selectrow_arrayref($sql) or &html_out("エラーが発生しました。");
$pcname = @$ref->[0];
if ($uid eq 2){$out{'pcname'} = 'DB' . $pcname;}
&disconDB($dbh);
}else{
$out{'pcname'} = &get_pcname_cookie . '(' . $pcid . ')';
}
$dbh = &connectDB($mainDB);
&in_enc;
$st_cnt = 0;
#$sql = "select a.crid,a.pdname,a.crname,a.file_name,substr(a.reg_date,1,10),b.pcid,b.name,a.plural_pcid,a.url,a.pdid from stars_data a,character b where a.state = 0 and a.pcid = b.pcid order by a.reg_date desc limit 12;";
$sql = "select a.crid,a.pdname,a.crname,a.file_name,substr(a.reg_date,1,10),b.pcid,b.name,a.plural_pcid,a.url,a.pdid from stars_data a,character b where a.hidden = 0 and a.state = 0 and a.crid != 'rexi' and a.pcid = b.pcid order by a.reg_date desc limit 16;";
$ref = $dbh->selectall_arrayref($sql) or $err=1;
foreach(@$ref) {
($crid,$pdname,$crname,$file_name,$reg_date,$gpcid,$pcname,$plural_pcid,$furl,$pdid)=@{$_};
$st_cnt++;
$mem = '';
$mem2 = '';
$member = '';
my ($ex) = ($file_name =~ m|(\.[^./\\]+)$|);
$v_flg = 0;
if(($ex eq '.MP3') or ($ex eq '.mp3') or ($ex eq '.Mp3')){$v_flg = 1;}
if (substr($furl,0,26) eq 'http://rexi.jp/stars/data/'){$furl =~ s/rexi\.jp/rexis\.jp/g;}
if ($plural_pcid ne ''){
@mem_pcid = split(/\,/,$plural_pcid);
@mem_pcid = sort @mem_pcid;
foreach (@mem_pcid){
$mpcid = $_;
$sql = "select name from character where pcid = '$mpcid';";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("CODE:S-03
エラーが発生しました。");
($m_name)=@{$ref->[0]};
$mem .= ",$mpcid $m_name";
$mem2 .=<<"EOT";
$mpcid $m_name
EOT
}
if ($mem2 ne ''){$mem2 = substr($mem2,0,-2);}
}
$date2 = substr($reg_date,0,10);
if (-e "/home/rexi-jp/public_html/stars/data/tg/$file_name" && substr($pdid,0,1) ne 'V'){
($format,$width,$height) = &GetImageSize("/home/rexi-jp/public_html/stars/data/tg/$file_name");
}
else{
}
if($v_flg eq 0){
if ($pdid ne 'C02'){
$out{'obj' . $st_cnt} =<<"EOT";
EOT
}
else{
$out{'obj' . $st_cnt} =<<"EOT";
EOT
}
}
else{
$out{'obj' . $st_cnt} =<<"EOT";
EOT
}
$out{'crname' . $st_cnt} =<<"EOT";
$crname
EOT
$out{'pdname' . $st_cnt} =<<"EOT";
$pdname
EOT
$out{'n_date' . $st_cnt} =<<"EOT";
$date2
EOT
$out{'n_pcid' . $st_cnt} =<<"EOT";
$gpcid
EOT
$len = length $pcname;
if ($len > 18){
$pcname = "$pcname";
}
$out{'n_pcname' . $st_cnt} =<<"EOT";
$pcname
EOT
}
&disconDB($dbh);
&out_enc;
#if($flg_smartphone eq 1){$html_file = 'index_sp.html';}
#else{$html_file = 'index_pc.html';}
$html_file = 'index_.html';
&html_out($html_file);
exit;