Index: trunk/install/perl/foltialib.pl =================================================================== --- trunk/install/perl/foltialib.pl (リビジョン 83) +++ trunk/install/perl/foltialib.pl (リビジョン 94) @@ -4,5 +4,5 @@ $path = $0; $path =~ s/foltialib.pl$//i; -if ($pwd ne "./"){ +if ($path ne "./"){ push( @INC, "$path"); } @@ -13,10 +13,8 @@ use DBI; use DBD::Pg; - - - $DBDriv=$main::DBDriv; - $DBHost=$main::DBHost; - $DBPort=$main::DBPort; - $DBName=$main::DBName; +use DBD::SQLite; +use POSIX qw(strftime); + +$DSN=$main::DSN; $DBUser=$main::DBUser; $DBPass=""; @@ -47,5 +45,5 @@ sub writelog{ my $messages = $_[0]; -my $timestump = `date +%Y/%m/%d_%H:%M:%S`; + my $timestump = strftime("%Y/%m/%d_%H:%M:%S", localtime); chomp($timestump); if ($debugmode == 1){ @@ -146,9 +144,8 @@ my $stationname = $_[0] ; my $stationid ; -my $DBQuery = "SELECT count(*) FROM foltia_station WHERE stationname = '$item{ChName}'"; my $sth; - $sth = $dbh->prepare($DBQuery); - $sth->execute(); + $sth = $dbh->prepare($stmt{'foltialib.getstationid.1'}); + $sth->execute($item{'ChName'}); my @stationcount; @stationcount= $sth->fetchrow_array; @@ -156,7 +153,6 @@ if ($stationcount[0] == 1){ #チャンネルID取得 -$DBQuery = "SELECT stationid,stationname FROM foltia_station WHERE stationname = '$item{ChName}'"; - $sth = $dbh->prepare($DBQuery); - $sth->execute(); + $sth = $dbh->prepare($stmt{'foltialib.getstationid.2'}); + $sth->execute($item{'ChName'}); @stationinfo= $sth->fetchrow_array; #局ID @@ -166,6 +162,5 @@ }elsif($stationcount[0] == 0){ #新規登録 -$DBQuery = "SELECT max(stationid) FROM foltia_station"; - $sth = $dbh->prepare($DBQuery); + $sth = $dbh->prepare($stmt{'foltialib.getstationid.3'}); $sth->execute(); @stationinfo= $sth->fetchrow_array; @@ -174,10 +169,8 @@ ##$DBQuery = "insert into foltia_station values ('$stationid' ,'$item{ChName}','0','','','','','','')"; #新規局追加時は非受信局をデフォルトに -$DBQuery = "insert into foltia_station (stationid , stationname ,stationrecch ) values ('$stationid' ,'$item{ChName}','-10')"; - - $sth = $dbh->prepare($DBQuery); - $sth->execute(); + $sth = $dbh->prepare($stmt{'foltialib.getstationid.4'}); + $sth->execute($stationid, $item{'ChName'}, -10); #print "Add station;$DBQuery\n"; -&writelog("foltialib Add station;$DBQuery"); + &writelog("foltialib Add station;$stmt{'foltialib.getstationid.4'}"); }else{ @@ -287,9 +280,8 @@ } -my $DBQuery = "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$m2pfilename' LIMIT 1 "; my $sth; -$sth = $dbh->prepare($DBQuery); -$sth->execute(); -#print "$DBQuery\n"; + $sth = $dbh->prepare($stmt{'foltialib.getpidbympegfilename.1'}); + $sth->execute($m2pfilename); +#print "$stmt{'foltialib.getpidbympegfilename.1'}\n"; my @pidinfo = $sth->fetchrow_array; my $pid = $pidinfo[0]; @@ -312,8 +304,7 @@ if ($updatestatus > 0 ){ -my $DBQuery = "UPDATE foltia_subtitle SET filestatus = $updatestatus , lastupdate = now() WHERE pid = $pid "; my $sth; -$sth = $dbh->prepare($DBQuery); -$sth->execute(); + $sth = $dbh->prepare($stmt{'foltialib.changefilestatus.1'}); + $sth->execute($updatestatus, $pid); return 1; }else{ @@ -351,8 +342,7 @@ } -my $DBQuery = "SELECT filestatus FROM foltia_subtitle WHERE pid = $pid "; my $sth; -$sth = $dbh->prepare($DBQuery); -$sth->execute(); + $sth = $dbh->prepare($stmt{'foltialib.getfilestatus.1'}); + $sth->execute($pid); my @statusinfo = $sth->fetchrow_array;